CONOPT
Loading...
Searching...
No Matches
pinstaterr.f90
Go to the documentation of this file.
1!> @file pinstaterr.f90
2!! @ingroup FORT1THREAD_EXAMPLES
3!!
4!!
5!! This is a CONOPT implementation of the Pindyck model from the
6!! GAMS model library. The implementation is similar to the one
7!! in pindyck, but this time we first solve the model for 16
8!! periods and then we gradually increase the number of periods
9!! one at a time up to 20.
10!!
11!!
12!! For more information about the individual callbacks, please have a look at the source code.
13
15 integer :: t
16 integer, Parameter :: tmin = 16, tmax = 20
17 integer, Parameter :: vpp = 7 ! Variables per period
18 integer, Parameter :: epp = 6 ! Equations per period
19 integer :: casenum
20 real*8, Dimension(Tmax*Vpp) :: xkeep ! Store previous solutions
21 Integer, Dimension(Tmax*Vpp) :: xstas ! Store previous status
22 Integer, Dimension(Tmax*Epp) :: estat ! for variables and equations
23End Module pinstaterrdata
24
25!> Main program. A simple setup and call of CONOPT
26!!
27Program pinadd
28 Use proginfo
29 Use coidef
31 Implicit none
32!
33! Declare the user callback routines as Integer, External:
34!
35 Integer, External :: pin_readmatrix ! Mandatory Matrix definition routine defined below
36 Integer, External :: pin_fdeval ! Function and Derivative evaluation routine
37 ! needed a nonlinear model.
38 Integer, External :: std_status ! Standard callback for displaying solution status
39 Integer, External :: pin_solution ! Specialized callback for displaying solution values
40 Integer, External :: std_message ! Standard callback for managing messages
41 Integer, External :: std_errmsg ! Standard callback for managing error messages
42#if defined(itl)
43!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_ReadMatrix
44!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_FDEval
45!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Status
46!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_Solution
47!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Message
48!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_ErrMsg
49#endif
50!
51! Control vector
52!
53 INTEGER :: numcallback
54 INTEGER, Dimension(:), Pointer :: cntvect
55 INTEGER :: coi_error
56
57 call startup
58!
59! Create and initialize a Control Vector
60!
61 numcallback = coidef_size()
62 Allocate( cntvect(numcallback) )
63 coi_error = coidef_inifort( cntvect )
64!
65! Define the number of time periods, T.
66!
67 t = tmin
68!
69! Tell CONOPT about the size of the model by populating the Control Vector:
70!
71! Number of variables (excl. slacks): Vpp per period
72!
73 coi_error = max( coi_error, coidef_numvar( cntvect, vpp * t ) )
74!
75! Number of equations: 1 objective + Epp per period
76!
77 coi_error = max( coi_error, coidef_numcon( cntvect, 1 + epp * t ) )
78!
79! Number of nonzeros in the Jacobian. See the counting in ReadMatrix below:
80! For each period there is 1 in the objective, 16 for unlagged
81! variables and 4 for lagged variables.
82!
83 coi_error = max( coi_error, coidef_numnz( cntvect, 17 * t + 4 * (t-1) ) )
84!
85! Number of nonlinear nonzeros. 5 unlagged for each period.
86!
87 coi_error = max( coi_error, coidef_numnlnz( cntvect, 5 * t ) )
88!
89! Direction: +1 = maximization.
90!
91 coi_error = max( coi_error, coidef_optdir( cntvect, 1 ) )
92!
93! Objective: Constraint no 1
94!
95 coi_error = max( coi_error, coidef_objcon( cntvect, 1 ) ) ! Objective is constraint 1
96!
97! Options file = test.opt
98!
99 coi_error = max( coi_error, coidef_optfile( cntvect, 'test.opt' ) )
100!
101! Tell CONOPT about the callback routines:
102!
103 coi_error = max( coi_error, coidef_readmatrix( cntvect, pin_readmatrix ) )
104 coi_error = max( coi_error, coidef_fdeval( cntvect, pin_fdeval ) )
105 coi_error = max( coi_error, coidef_status( cntvect, std_status ) )
106 coi_error = max( coi_error, coidef_solution( cntvect, pin_solution ) )
107 coi_error = max( coi_error, coidef_message( cntvect, std_message ) )
108 coi_error = max( coi_error, coidef_errmsg( cntvect, std_errmsg ) )
109
110#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
111 coi_error = max( coi_error, coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
112#endif
113
114 If ( coi_error .ne. 0 ) THEN
115 write(*,*)
116 write(*,*) '**** Fatal Error while loading CONOPT Callback routines.'
117 write(*,*)
118 call flog( "Skipping First Solve due to setup errors", 1 )
119 ENDIF
120!
121! Start CONOPT:
122!
123 casenum = 1
124 coi_error = coi_solve( cntvect )
125 If ( coi_error .ne. 0 ) THEN
126 write(*,*)
127 write(*,*) '**** Fatal Error while Solving first model.'
128 write(*,*)
129 call flog( "Errors encountered during first Solve.", 1 )
130 elseif ( stacalls == 0 .or. solcalls == 0 ) then
131 call flog( "Status or Solution routine was not called during first solve", 1 )
132 elseif ( sstat /= 1 .or. mstat /= 2 ) then
133 call flog( "Solver and Model Status in first solve was not as expected (1,2)", 1 )
134 Endif
135!
136! Now increase the time horizon and introduce various status errors.
137! First we define an incorrect status type.
138!
139 t = tmin+1
140 casenum = 2
141 coi_error = max( coi_error, coidef_numvar( cntvect, 7 * t ) )
142 coi_error = max( coi_error, coidef_numcon( cntvect, 1 + 6 * t ) )
143 coi_error = max( coi_error, coidef_numnz( cntvect, 17 * t + 4 * (t-1) ) )
144 coi_error = max( coi_error, coidef_numnlnz( cntvect, 5 * t ) )
145!
146! This time we have status information copied from a previous solve, i.e.
147! IniStat should be defined as 2. To see that values are tested we define IniStat = 1
148! initially.
149!
150 coi_error = max( coi_error, coidef_inistat( cntvect, 1 ) )
151 If ( coi_error .ne. 0 ) THEN
152 write(*,*)
153 write(*,*) '**** Fatal Error while revising CONOPT Sizes.'
154 write(*,*)
155 call flog( "Skipping second solve due to setup errors", 1 )
156 ENDIF
157 stacalls = 0; solcalls = 0; ! reset so we can test them again
158 coi_error = coi_solve( cntvect )
159 If ( coi_error .ne. 400 ) THEN
160 write(*,*)
161 write(*,*) '**** Second solve did not return error 400 as expected. COI_Error=',coi_error
162 write(*,*)
163 call flog( "Incorrect COI_Error from second solve.", 1 )
164 Endif
165!
166! Second we only define status information for some of the variables and
167! equations. The code is in ReadMatrix
168!
169 coi_error = 0
170 casenum = 3
171 coi_error = max( coi_error, coidef_inistat( cntvect, 2 ) )
172 If ( coi_error .ne. 0 ) THEN
173 write(*,*)
174 write(*,*) '**** Fatal Error while revising CONOPT Sizes.'
175 write(*,*)
176 call flog( "Skipping third solve due to setup errors", 1 )
177 ENDIF
178 stacalls = 0; solcalls = 0; ! reset so we can test them again
179 coi_error = coi_solve( cntvect )
180 If ( coi_error .ne. 400 ) THEN
181 write(*,*)
182 write(*,*) '**** Third solve did not return error 400 as expected. COI_Error=',coi_error
183 write(*,*)
184 call flog( "Incorrect COI_Error from third solve.", 1 )
185 Endif
186!
187! Third: we define Inistat = 1 and all status values as 1 = basic. This is not useful but OK
188!
189 coi_error = 0
190 casenum = 4
191 coi_error = max( coi_error, coidef_inistat( cntvect, 1 ) )
192 If ( coi_error .ne. 0 ) THEN
193 write(*,*)
194 write(*,*) '**** Fatal Error while revising CONOPT Sizes.'
195 write(*,*)
196 call flog( "Skipping third solve due to setup errors", 1 )
197 ENDIF
198 stacalls = 0; solcalls = 0; ! reset so we can test them again
199 coi_error = coi_solve( cntvect )
200 If ( coi_error .ne. 0 ) THEN
201 write(*,*)
202 write(*,*) '**** Fourth solve did not return error 0 as expected. COI_Error=',coi_error
203 write(*,*)
204 call flog( "Incorrect COI_Error from fourth solve.", 1 )
205 elseif ( stacalls == 0 .or. solcalls == 0 ) then
206 call flog( "Status or Solution routine was not called during fourth solve", 1 )
207 elseif ( sstat /= 1 .or. mstat /= 2 ) then
208 call flog( "Solver and Model Status in fourth solve was not as expected (1,2)", 1 )
209 Endif
210
211 write(*,*)
212 write(*,*) 'End of PinStatErr Model. Return code=',coi_error
213
214 if ( coi_free(cntvect) /= 0 ) call flog( "Error while freeing control vector",1)
215
216 call flog( "Successful Solve", 0 )
217
218end Program pinadd
219!
220! =====================================================================
221! Define information about the model structure
222!
223
224!> Define information about the model
225!!
226!! @include{doc} readMatrix_params.dox
227Integer Function pin_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
228 colsta, rowno, value, nlflag, n, m, nz, usrmem )
229#if defined(itl)
230!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_ReadMatrix
231#endif
233 implicit none
234 integer, intent (in) :: n ! number of variables
235 integer, intent (in) :: m ! number of constraints
236 integer, intent (in) :: nz ! number of nonzeros
237 real*8, intent (in out), dimension(n) :: lower ! vector of lower bounds
238 real*8, intent (in out), dimension(n) :: curr ! vector of initial values
239 real*8, intent (in out), dimension(n) :: upper ! vector of upper bounds
240 integer, intent (in out), dimension(n) :: vsta ! vector of initial variable status
241 ! Defined during restarts
242 integer, intent (out), dimension(m) :: type ! vector of equation types
243 integer, intent (in out), dimension(m) :: esta ! vector of initial equation status
244 ! Defined during restarts
245 real*8, intent (in out), dimension(m) :: rhs ! vector of right hand sides
246 integer, intent (in out), dimension(n+1) :: colsta ! vector with start of column indices
247 integer, intent (out), dimension(nz) :: rowno ! vector of row numbers
248 integer, intent (in out), dimension(nz) :: nlflag ! vector of nonlinearity flags
249 real*8, intent (in out), dimension(nz) :: value ! vector of matrix values
250 real*8 usrmem(*) ! optional user memory
251
252 Integer :: it, is, i, icol, iz, iold
253!
254! Define the information for the columns.
255!
256! We should not supply status information, vsta.
257!
258! We order the variables as follows:
259! td, cs, s, d, r, p, and rev. All variables for period 1 appears
260! first followed by all variables for period 2 etc.
261!
262! td, cs, s, and d have lower bounds of 0, r and p have lower
263! bounds of 1, and rev has no lower bound.
264! All have infinite upper bounds (default).
265! The initial value of td is 18, s is 7, cs is 7*t, d is td-s,
266! p is 14, and r is r(t-1)-d. No initial value for rev.
267!
268 do it = 1, t
269 is = vpp*(it-1)
270 lower(is+1) = 0.d0
271 lower(is+2) = 0.d0
272 lower(is+3) = 0.d0
273 lower(is+4) = 0.d0
274 lower(is+5) = 1.d0
275 lower(is+6) = 1.d0
276 curr(is+1) = 18.d0
277 curr(is+2) = 7.d0*it
278 curr(is+3) = 7.d0
279 curr(is+4) = curr(is+1) - curr(is+3)
280 if ( it .gt. 1 ) then
281 curr(is+5) = curr(is+5-vpp) - curr(is+4)
282 else
283 curr(is+5) = 500.d0 - curr(is+4)
284 endif
285 curr(is+6) = 14.d0
286 enddo
287 If ( t > tmin ) Then
288!
289! This is a restart: Use the initial values from last solve for
290! the variables in the first periods and extrapolate the last
291! period using a linear extrapolation between the last two
292!
293 iold = vpp*(t-1)
294 curr(1:iold) = xkeep(1:iold)
295 do i = 1, vpp
296 curr(iold+i) = curr(iold+i-vpp) + (curr(iold+i-vpp)-curr(iold+i-2*vpp))
297 enddo
298!
299! The variables from the last solve are given the old status and
300! the variables in the new period are given those in the last
301! pariod. Similarly with the Equation status:
302! When Casenum is 3 we do not initialize the new period, just to test the
303! messages and return code.
304!
305 vsta(1:iold) = xstas(1:iold)
306 if ( casenum /= 3 ) then
307 do i = 1, vpp
308 vsta(iold+i) = xstas(iold+i-vpp)
309 enddo
310 endif
311 iold = epp*(t-1)+1
312 esta(1:iold) = estat(1:iold)
313 if ( casenum /= 3 ) then
314 do i = 1, epp
315 esta(iold+i) = estat(iold+i-epp)
316 enddo
317 endif
318 if ( casenum == 4 ) then
319 vsta(1:vpp*t) = 1
320 esta(1:epp*t) = 1
321 endif
322 endif
323!
324! Define the information for the rows
325!
326! We order the constraints as follows: The objective is first,
327! followed by tddef, sdef, csdef, ddef, rdef, and revdef for
328! the first period, the same for the second period, etc.
329!
330! The objective is a nonbinding constraint:
331!
332 type(1) = 3
333!
334! All others are equalities:
335!
336 do i = 2, m
337 type(i) = 0
338 enddo
339!
340! Right hand sides: In all periods except the first, only tddef
341! has a nonzero right hand side of 1+2.3*1.015**(t-1).
342! In the initial period there are contributions from lagged
343! variables in the constraints that have lagged variables.
344!
345 do it = 1, t
346 is = 1 + 6*(it-1)
347 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
348 enddo
349!
350! tddef: + 0.87*td(0)
351!
352 rhs(2) = rhs(2) + 0.87d0*18.d0
353!
354! sdef: +0.75*s(0)
355!
356 rhs(3) = 0.75d0*6.5d0
357!
358! csdef: +1*cs(0)
359!
360 rhs(4) = 0.d0
361!
362! rdef: +1*r(0)
363!
364 rhs(6) = 500.d0
365!
366! Define the structure and content of the Jacobian:
367! To help define the Jacobian pattern and values it can be useful to
368! make a picture of the Jacobian. We describe the variables for one
369! period and the constraints they are part of:
370!
371! td cs s d r p rev
372! Obj (1+r)**(1-t)
373! Period t:
374! tddef 1.0 0.13
375! sdef NL 1.0 NL
376! csdef 1.0 -1.0
377! ddef -1.0 1.0 1.0
378! rdef 1.0 1.0
379! revdef NL NL NL 1.0
380! Period t+1:
381! tddef -0.87
382! sdef -0.75
383! csdef -1.0
384! ddef
385! rdef -1.0
386! revdef
387!
388! The Jacobian has to be sorted column-wise so we will just define
389! the elements column by column according to the table above:
390!
391 iz = 1
392 icol = 1
393 do it = 1, t
394!
395! is points to the position before the first equation for the period
396!
397 is = 1 + 6*(it-1)
398!
399! Column td:
400!
401 colsta(icol) = iz
402 icol = icol + 1
403 rowno(iz) = is+1
404 value(iz) = +1.d0
405 nlflag(iz) = 0
406 iz = iz + 1
407 rowno(iz) = is+4
408 value(iz) = -1.d0
409 nlflag(iz) = 0
410 iz = iz + 1
411 if ( it .lt. t ) then
412 rowno(iz) = is+7
413 value(iz) = -0.87d0
414 nlflag(iz) = 0
415 iz = iz + 1
416 endif
417!
418! Column cs
419!
420 colsta(icol) = iz
421 icol = icol + 1
422 rowno(iz) = is+2
423 nlflag(iz) = 1
424 iz = iz + 1
425 rowno(iz) = is+3
426 value(iz) = +1.d0
427 nlflag(iz) = 0
428 iz = iz + 1
429 if ( it .lt. t ) then
430 rowno(iz) = is+9
431 value(iz) = -1.d0
432 nlflag(iz) = 0
433 iz = iz + 1
434 endif
435!
436! Column s
437!
438 colsta(icol) = iz
439 icol = icol + 1
440 rowno(iz) = is+2
441 value(iz) = +1.d0
442 nlflag(iz) = 0
443 iz = iz + 1
444 rowno(iz) = is+3
445 value(iz) = -1.d0
446 nlflag(iz) = 0
447 iz = iz + 1
448 rowno(iz) = is+4
449 value(iz) = +1.d0
450 nlflag(iz) = 0
451 iz = iz + 1
452 if ( it .lt. t ) then
453 rowno(iz) = is+8
454 value(iz) = -0.75d0
455 nlflag(iz) = 0
456 iz = iz + 1
457 endif
458!
459! Column d:
460!
461 colsta(icol) = iz
462 icol = icol + 1
463 rowno(iz) = is+4
464 value(iz) = +1.d0
465 nlflag(iz) = 0
466 iz = iz + 1
467 rowno(iz) = is+5
468 value(iz) = +1.d0
469 nlflag(iz) = 0
470 iz = iz + 1
471 rowno(iz) = is+6
472 nlflag(iz) = 1
473 iz = iz + 1
474!
475! Column r:
476!
477 colsta(icol) = iz
478 icol = icol + 1
479 rowno(iz) = is+5
480 value(iz) = +1.d0
481 nlflag(iz) = 0
482 iz = iz + 1
483 rowno(iz) = is+6
484 nlflag(iz) = 1
485 iz = iz + 1
486 if ( it .lt. t ) then
487 rowno(iz) = is+11
488 value(iz) = -1.d0
489 nlflag(iz) = 0
490 iz = iz + 1
491 endif
492!
493! Column p:
494!
495 colsta(icol) = iz
496 icol = icol + 1
497 rowno(iz) = is+1
498 value(iz) = +0.13d0
499 nlflag(iz) = 0
500 iz = iz + 1
501 rowno(iz) = is+2
502 nlflag(iz) = 1
503 iz = iz + 1
504 rowno(iz) = is+6
505 nlflag(iz) = 1
506 iz = iz + 1
507!
508! Column rev:
509!
510 colsta(icol) = iz
511 icol = icol + 1
512 rowno(iz) = +1
513 value(iz) = 1.05d0**(1-it)
514 nlflag(iz) = 0
515 iz = iz + 1
516 rowno(iz) = is+6
517 value(iz) = 1.d0
518 nlflag(iz) = 0
519 iz = iz + 1
520 enddo
521 colsta(icol) = iz
522
524
525end Function pin_readmatrix
526!
527! =====================================================================
528! Compute nonlinear terms and non-constant Jacobian elements
529!
530
531!> Compute nonlinear terms and non-constant Jacobian elements
532!!
533!! @include{doc} fdeval_params.dox
534Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
535 n, nz, thread, usrmem )
536#if defined(itl)
537!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_FDEval
538#endif
540 implicit none
541 integer, intent (in) :: n ! number of variables
542 integer, intent (in) :: rowno ! number of the row to be evaluated
543 integer, intent (in) :: nz ! number of nonzeros in this row
544 real*8, intent (in), dimension(n) :: x ! vector of current solution values
545 real*8, intent (in out) :: g ! constraint value
546 real*8, intent (in out), dimension(n) :: jac ! vector of derivatives for current constraint
547 integer, intent (in), dimension(nz) :: jcnm ! list of variables that appear nonlinearly
548 ! in this row. Ffor information only.
549 integer, intent (in) :: mode ! evaluation mode: 1 = function value
550 ! 2 = derivatives, 3 = both
551 integer, intent (in) :: ignerr ! if 1 then errors can be ignored as long
552 ! as errcnt is incremented
553 integer, intent (in out) :: errcnt ! error counter to be incremented in case
554 ! of function evaluation errors.
555 integer, intent (in) :: thread
556 real*8 usrmem(*) ! optional user memory
557
558 integer it, is
559 real*8 h1, h2
560!
561! Compute the number of the period
562!
563 it = (rowno+4) / epp
564 is = vpp*(it-1)
565 if ( rowno == (it-1)*epp+3 ) then
566!
567! sdef equation. Nonlinear term = -(1.1+0.1*p)*1.02**(-cs/7)
568!
569 h1 = (1.1d0+0.1d0*x(is+6))
570 h2 = 1.02d0**(-x(is+2)/7.d0)
571 if ( mode == 1 .or. mode == 3 ) then
572 g = -h1*h2
573 endif
574 if ( mode == 2 .or. mode == 3 ) then
575 jac(is+2) = h1*h2*log(1.02d0)/7.d0
576 jac(is+6) = -h2*0.1d0
577 endif
578 elseif ( rowno == (it-1)*epp+7 ) then
579!
580! revdef equation. Nonlinear term = -d*(p-250/r)
581!
582 if ( mode == 1 .or. mode == 3 ) then
583 g = -x(is+4)*(x(is+6)-250.d0/x(is+5))
584 endif
585 if ( mode == 2 .or. mode == 3 ) then
586 jac(is+4) = -(x(is+6)-250.d0/x(is+5))
587 jac(is+5) = -x(is+4)*250d0/x(is+5)**2
588 jac(is+6) = -x(is+4)
589 endif
590 else
591!
592! Error - this equation is not nonlinear
593!
594 write(*,*)
595 write(*,*) 'Error. FDEval called with rowno=',rowno
596 write(*,*)
597 pin_fdeval = 1
598 Return
599 endif
600 pin_fdeval = 0
601
602end Function pin_fdeval
603
604INTEGER FUNCTION pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
605#if defined(itl)
606!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_Solution
607#endif
608
610 Use proginfo
611 IMPLICIT NONE
612 INTEGER, Intent(IN) :: n, m
613 INTEGER, Intent(IN), Dimension(N) :: xbas, xsta
614 INTEGER, Intent(IN), Dimension(M) :: ybas, ysta
615 real*8, Intent(IN), Dimension(N) :: xval, xmar
616 real*8, Intent(IN), Dimension(M) :: yval, ymar
617 real*8, Intent(IN OUT) :: usrmem(*)
618 character*6, parameter, dimension(7) :: vname = (/'td ','cs ','s ','d ','r ','p ','rev '/)
619 character*6, parameter, dimension(6) :: ename = (/'tddef ','sdef ','csdef ','ddef ','rdef ','revdef'/)
620
621 INTEGER :: i, it, i1
622 CHARACTER*5, Parameter, Dimension(4) :: stat = (/ 'Lower','Upper','Basic','Super' /)
623
624 solcalls = solcalls + 1
625 If ( t < tmax ) Then
626 Write(*,"(A,i3)") 'Saving primal solution and status information for T =',t
627 xkeep(1:n) = xval(1:n)
628 xstas(1:n) = xbas(1:n)
629 estat(1:m) = ybas(1:m)
630 pin_solution = 0
631 Return
632 Endif
633
634 WRITE(10,"(/' Variable Solution value Reduced cost B-stat'/)")
635 i = 0
636 do it = 1, t
637 DO i1 = 1, vpp
638 i = i + 1
639 WRITE(10,"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
640 ENDDO
641 enddo
642
643 WRITE(10,"(/' Constrnt Activity level Marginal cost B-stat'/)")
644 i = 1
645 WRITE(10,"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
646 do it = 1, t
647 do i1 = 1, epp
648 i = i + 1
649 WRITE(10,"(1x,A6,i2,1P,E20.6,E16.6,4X,A5 )") ename(i1),it, yval(i), ymar(i), stat(1+ybas(i))
650 enddo
651 ENDDO
652 pin_solution = 0
653
654END FUNCTION pin_solution
integer function std_status(modsta, solsta, iter, objval, usrmem)
Definition comdecl.f90:82
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
Definition comdecl.f90:203
integer function std_errmsg(rowno, colno, posno, msglen, usrmem, msg)
Definition comdecl.f90:248
integer function pin_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
Definition fvboth.f90:436
integer function pin_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
Definition fvboth.f90:165
integer function pin_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
Definition fvboth.f90:545
integer function coidef_fdeval(cntvect, coi_fdeval)
define callback routine for performing function and derivative evaluations.
integer function coidef_errmsg(cntvect, coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
integer function coidef_message(cntvect, coi_message)
define callback routine for handling messages returned during the solution process.
integer function coidef_readmatrix(cntvect, coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
integer function coidef_status(cntvect, coi_status)
define callback routine for returning the completion status.
integer function coidef_solution(cntvect, coi_solution)
define callback routine for returning the final solution values.
integer function coidef_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer function coidef_inistat(cntvect, inistat)
handling of the initial status values.
integer function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
Definition coistart.f90:680
integer function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
Definition coistart.f90:358
integer function coidef_objcon(cntvect, objcon)
defines the Objective Constraint.
Definition coistart.f90:629
integer function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
Definition coistart.f90:437
integer function coidef_optdir(cntvect, optdir)
defines the Optimization Direction.
Definition coistart.f90:552
integer function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear Nonzeros.
Definition coistart.f90:476
integer function coidef_numcon(cntvect, numcon)
defines the number of constraints in the model.
Definition coistart.f90:398
integer function coidef_size()
returns the size the Control Vector must have, measured in standard Integer units.
Definition coistart.f90:176
integer function coidef_inifort(cntvect)
initialisation method for Fortran applications.
Definition coistart.f90:314
integer function coi_solve(cntvect)
method for starting the solving process of CONOPT.
Definition coistart.f90:14
integer, parameter epp
integer, dimension(tmax *vpp) xstas
integer, parameter vpp
integer, parameter tmin
integer, parameter tmax
integer, dimension(tmax *epp) estat
integer solcalls
Definition comdecl.f90:9
integer sstat
Definition comdecl.f90:12
integer stacalls
Definition comdecl.f90:8
subroutine flog(msg, code)
Definition comdecl.f90:56
integer mstat
Definition comdecl.f90:11
subroutine startup
Definition comdecl.f90:35
program pinadd
Main program. A simple setup and call of CONOPT.
Definition pinadd.f90:26