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