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
219end Program pinadd
220!
221! =====================================================================
222! Define information about the model structure
223!
224
225!> Define information about the model
226!!
227!! @include{doc} readMatrix_params.dox
228Integer Function pin_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
229 colsta, rowno, value, nlflag, n, m, nz, usrmem )
230#ifdef dec_directives_win32
231!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_ReadMatrix
232#endif
234 implicit none
235 integer, intent (in) :: n ! number of variables
236 integer, intent (in) :: m ! number of constraints
237 integer, intent (in) :: nz ! number of nonzeros
238 real*8, intent (in out), dimension(n) :: lower ! vector of lower bounds
239 real*8, intent (in out), dimension(n) :: curr ! vector of initial values
240 real*8, intent (in out), dimension(n) :: upper ! vector of upper bounds
241 integer, intent (in out), dimension(n) :: vsta ! vector of initial variable status
242 ! Defined during restarts
243 integer, intent (out), dimension(m) :: type ! vector of equation types
244 integer, intent (in out), dimension(m) :: esta ! vector of initial equation status
245 ! Defined during restarts
246 real*8, intent (in out), dimension(m) :: rhs ! vector of right hand sides
247 integer, intent (in out), dimension(n+1) :: colsta ! vector with start of column indices
248 integer, intent (out), dimension(nz) :: rowno ! vector of row numbers
249 integer, intent (in out), dimension(nz) :: nlflag ! vector of nonlinearity flags
250 real*8, intent (in out), dimension(nz) :: value ! vector of matrix values
251 real*8 usrmem(*) ! optional user memory
252
253 Integer :: it, is, i, icol, iz, iold
254!
255! Define the information for the columns.
256!
257! We should not supply status information, vsta.
258!
259! We order the variables as follows:
260! td, cs, s, d, r, p, and rev. All variables for period 1 appears
261! first followed by all variables for period 2 etc.
262!
263! td, cs, s, and d have lower bounds of 0, r and p have lower
264! bounds of 1, and rev has no lower bound.
265! All have infinite upper bounds (default).
266! The initial value of td is 18, s is 7, cs is 7*t, d is td-s,
267! p is 14, and r is r(t-1)-d. No initial value for rev.
268!
269 do it = 1, t
270 is = vpp*(it-1)
271 lower(is+1) = 0.d0
272 lower(is+2) = 0.d0
273 lower(is+3) = 0.d0
274 lower(is+4) = 0.d0
275 lower(is+5) = 1.d0
276 lower(is+6) = 1.d0
277 curr(is+1) = 18.d0
278 curr(is+2) = 7.d0*it
279 curr(is+3) = 7.d0
280 curr(is+4) = curr(is+1) - curr(is+3)
281 if ( it .gt. 1 ) then
282 curr(is+5) = curr(is+5-vpp) - curr(is+4)
283 else
284 curr(is+5) = 500.d0 - curr(is+4)
285 endif
286 curr(is+6) = 14.d0
287 enddo
288 If ( t > tmin ) Then
289!
290! This is a restart: Use the initial values from last solve for
291! the variables in the first periods and extrapolate the last
292! period using a linear extrapolation between the last two
293!
294 iold = vpp*(t-1)
295 curr(1:iold) = xkeep(1:iold)
296 do i = 1, vpp
297 curr(iold+i) = curr(iold+i-vpp) + (curr(iold+i-vpp)-curr(iold+i-2*vpp))
298 enddo
299!
300! The variables from the last solve are given the old status and
301! the variables in the new period are given those in the last
302! pariod. Similarly with the Equation status:
303! When Casenum is 3 we do not initialize the new period, just to test the
304! messages and return code.
305!
306 vsta(1:iold) = xstas(1:iold)
307 if ( casenum /= 3 ) then
308 do i = 1, vpp
309 vsta(iold+i) = xstas(iold+i-vpp)
310 enddo
311 endif
312 iold = epp*(t-1)+1
313 esta(1:iold) = estat(1:iold)
314 if ( casenum /= 3 ) then
315 do i = 1, epp
316 esta(iold+i) = estat(iold+i-epp)
317 enddo
318 endif
319 if ( casenum == 4 ) then
320 vsta(1:vpp*t) = 1
321 esta(1:epp*t) = 1
322 endif
323 endif
324!
325! Define the information for the rows
326!
327! We order the constraints as follows: The objective is first,
328! followed by tddef, sdef, csdef, ddef, rdef, and revdef for
329! the first period, the same for the second period, etc.
330!
331! The objective is a nonbinding constraint:
332!
333 type(1) = 3
334!
335! All others are equalities:
336!
337 do i = 2, m
338 type(i) = 0
339 enddo
340!
341! Right hand sides: In all periods except the first, only tddef
342! has a nonzero right hand side of 1+2.3*1.015**(t-1).
343! In the initial period there are contributions from lagged
344! variables in the constraints that have lagged variables.
345!
346 do it = 1, t
347 is = 1 + 6*(it-1)
348 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
349 enddo
350!
351! tddef: + 0.87*td(0)
352!
353 rhs(2) = rhs(2) + 0.87d0*18.d0
354!
355! sdef: +0.75*s(0)
356!
357 rhs(3) = 0.75d0*6.5d0
358!
359! csdef: +1*cs(0)
360!
361 rhs(4) = 0.d0
362!
363! rdef: +1*r(0)
364!
365 rhs(6) = 500.d0
366!
367! Define the structure and content of the Jacobian:
368! To help define the Jacobian pattern and values it can be useful to
369! make a picture of the Jacobian. We describe the variables for one
370! period and the constraints they are part of:
371!
372! td cs s d r p rev
373! Obj (1+r)**(1-t)
374! Period t:
375! tddef 1.0 0.13
376! sdef NL 1.0 NL
377! csdef 1.0 -1.0
378! ddef -1.0 1.0 1.0
379! rdef 1.0 1.0
380! revdef NL NL NL 1.0
381! Period t+1:
382! tddef -0.87
383! sdef -0.75
384! csdef -1.0
385! ddef
386! rdef -1.0
387! revdef
388!
389! The Jacobian has to be sorted column-wise so we will just define
390! the elements column by column according to the table above:
391!
392 iz = 1
393 icol = 1
394 do it = 1, t
395!
396! is points to the position before the first equation for the period
397!
398 is = 1 + 6*(it-1)
399!
400! Column td:
401!
402 colsta(icol) = iz
403 icol = icol + 1
404 rowno(iz) = is+1
405 value(iz) = +1.d0
406 nlflag(iz) = 0
407 iz = iz + 1
408 rowno(iz) = is+4
409 value(iz) = -1.d0
410 nlflag(iz) = 0
411 iz = iz + 1
412 if ( it .lt. t ) then
413 rowno(iz) = is+7
414 value(iz) = -0.87d0
415 nlflag(iz) = 0
416 iz = iz + 1
417 endif
418!
419! Column cs
420!
421 colsta(icol) = iz
422 icol = icol + 1
423 rowno(iz) = is+2
424 nlflag(iz) = 1
425 iz = iz + 1
426 rowno(iz) = is+3
427 value(iz) = +1.d0
428 nlflag(iz) = 0
429 iz = iz + 1
430 if ( it .lt. t ) then
431 rowno(iz) = is+9
432 value(iz) = -1.d0
433 nlflag(iz) = 0
434 iz = iz + 1
435 endif
436!
437! Column s
438!
439 colsta(icol) = iz
440 icol = icol + 1
441 rowno(iz) = is+2
442 value(iz) = +1.d0
443 nlflag(iz) = 0
444 iz = iz + 1
445 rowno(iz) = is+3
446 value(iz) = -1.d0
447 nlflag(iz) = 0
448 iz = iz + 1
449 rowno(iz) = is+4
450 value(iz) = +1.d0
451 nlflag(iz) = 0
452 iz = iz + 1
453 if ( it .lt. t ) then
454 rowno(iz) = is+8
455 value(iz) = -0.75d0
456 nlflag(iz) = 0
457 iz = iz + 1
458 endif
459!
460! Column d:
461!
462 colsta(icol) = iz
463 icol = icol + 1
464 rowno(iz) = is+4
465 value(iz) = +1.d0
466 nlflag(iz) = 0
467 iz = iz + 1
468 rowno(iz) = is+5
469 value(iz) = +1.d0
470 nlflag(iz) = 0
471 iz = iz + 1
472 rowno(iz) = is+6
473 nlflag(iz) = 1
474 iz = iz + 1
475!
476! Column r:
477!
478 colsta(icol) = iz
479 icol = icol + 1
480 rowno(iz) = is+5
481 value(iz) = +1.d0
482 nlflag(iz) = 0
483 iz = iz + 1
484 rowno(iz) = is+6
485 nlflag(iz) = 1
486 iz = iz + 1
487 if ( it .lt. t ) then
488 rowno(iz) = is+11
489 value(iz) = -1.d0
490 nlflag(iz) = 0
491 iz = iz + 1
492 endif
493!
494! Column p:
495!
496 colsta(icol) = iz
497 icol = icol + 1
498 rowno(iz) = is+1
499 value(iz) = +0.13d0
500 nlflag(iz) = 0
501 iz = iz + 1
502 rowno(iz) = is+2
503 nlflag(iz) = 1
504 iz = iz + 1
505 rowno(iz) = is+6
506 nlflag(iz) = 1
507 iz = iz + 1
508!
509! Column rev:
510!
511 colsta(icol) = iz
512 icol = icol + 1
513 rowno(iz) = +1
514 value(iz) = 1.05d0**(1-it)
515 nlflag(iz) = 0
516 iz = iz + 1
517 rowno(iz) = is+6
518 value(iz) = 1.d0
519 nlflag(iz) = 0
520 iz = iz + 1
521 enddo
522 colsta(icol) = iz
525
526end Function pin_readmatrix
527!
528! =====================================================================
529! Compute nonlinear terms and non-constant Jacobian elements
530!
531
532!> Compute nonlinear terms and non-constant Jacobian elements
533!!
534!! @include{doc} fdeval_params.dox
535Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
536 n, nz, thread, usrmem )
537#ifdef dec_directives_win32
538!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_FDEval
539#endif
541 implicit none
542 integer, intent (in) :: n ! number of variables
543 integer, intent (in) :: rowno ! number of the row to be evaluated
544 integer, intent (in) :: nz ! number of nonzeros in this row
545 real*8, intent (in), dimension(n) :: x ! vector of current solution values
546 real*8, intent (in out) :: g ! constraint value
547 real*8, intent (in out), dimension(n) :: jac ! vector of derivatives for current constraint
548 integer, intent (in), dimension(nz) :: jcnm ! list of variables that appear nonlinearly
549 ! in this row. Ffor information only.
550 integer, intent (in) :: mode ! evaluation mode: 1 = function value
551 ! 2 = derivatives, 3 = both
552 integer, intent (in) :: ignerr ! if 1 then errors can be ignored as long
553 ! as errcnt is incremented
554 integer, intent (in out) :: errcnt ! error counter to be incremented in case
555 ! of function evaluation errors.
556 integer, intent (in) :: thread
557 real*8 usrmem(*) ! optional user memory
558
559 integer it, is
560 real*8 h1, h2
561!
562! Compute the number of the period
563!
564 it = (rowno+4) / epp
565 is = vpp*(it-1)
566 if ( rowno == (it-1)*epp+3 ) then
567!
568! sdef equation. Nonlinear term = -(1.1+0.1*p)*1.02**(-cs/7)
569!
570 h1 = (1.1d0+0.1d0*x(is+6))
571 h2 = 1.02d0**(-x(is+2)/7.d0)
572 if ( mode == 1 .or. mode == 3 ) then
573 g = -h1*h2
574 endif
575 if ( mode == 2 .or. mode == 3 ) then
576 jac(is+2) = h1*h2*log(1.02d0)/7.d0
577 jac(is+6) = -h2*0.1d0
578 endif
579 elseif ( rowno == (it-1)*epp+7 ) then
580!
581! revdef equation. Nonlinear term = -d*(p-250/r)
582!
583 if ( mode == 1 .or. mode == 3 ) then
584 g = -x(is+4)*(x(is+6)-250.d0/x(is+5))
585 endif
586 if ( mode == 2 .or. mode == 3 ) then
587 jac(is+4) = -(x(is+6)-250.d0/x(is+5))
588 jac(is+5) = -x(is+4)*250d0/x(is+5)**2
589 jac(is+6) = -x(is+4)
590 endif
591 else
592!
593! Error - this equation is not nonlinear
594!
595 write(*,*)
596 write(*,*) 'Error. FDEval called with rowno=',rowno
597 write(*,*)
598 pin_fdeval = 1
599 Return
600 endif
601 pin_fdeval = 0
602
603end Function pin_fdeval
604
605INTEGER FUNCTION pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
606#ifdef dec_directives_win32
607!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Pin_Solution
608#endif
609
611 Use proginfo
612 IMPLICIT NONE
613 INTEGER, Intent(IN) :: n, m
614 INTEGER, Intent(IN), Dimension(N) :: xbas, xsta
615 INTEGER, Intent(IN), Dimension(M) :: ybas, ysta
616 real*8, Intent(IN), Dimension(N) :: xval, xmar
617 real*8, Intent(IN), Dimension(M) :: yval, ymar
618 real*8, Intent(IN OUT) :: usrmem(*)
619 character*6, parameter, dimension(7) :: vname = (/'td ','cs ','s ','d ','r ','p ','rev '/)
620 character*6, parameter, dimension(6) :: ename = (/'tddef ','sdef ','csdef ','ddef ','rdef ','revdef'/)
621
622 INTEGER :: i, it, i1
623 CHARACTER*5, Parameter, Dimension(4) :: stat = (/ 'Lower','Upper','Basic','Super' /)
624
625 solcalls = solcalls + 1
626 If ( t < tmax ) Then
627 Write(*,"(A,i3)") 'Saving primal solution and status information for T =',t
628 xkeep(1:n) = xval(1:n)
629 xstas(1:n) = xbas(1:n)
630 estat(1:m) = ybas(1:m)
631 pin_solution = 0
632 Return
633 Endif
634
635 WRITE(10,"(/' Variable Solution value Reduced cost B-stat'/)")
636 i = 0
637 do it = 1, t
638 DO i1 = 1, vpp
639 i = i + 1
640 WRITE(10,"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
641 ENDDO
642 enddo
643
644 WRITE(10,"(/' Constrnt Activity level Marginal cost B-stat'/)")
645 i = 1
646 WRITE(10,"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
647 do it = 1, t
648 do i1 = 1, epp
649 i = i + 1
650 WRITE(10,"(1x,A6,i2,1P,E20.6,E16.6,4X,A5 )") ename(i1),it, yval(i), ymar(i), stat(1+ybas(i))
651 enddo
652 ENDDO
653 pin_solution = 0
654
655END FUNCTION pin_solution
integer function std_status(modsta, solsta, iter, objval, usrmem)
Definition comdecl.f90:88
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
Definition comdecl.f90:205
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:425
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:157
integer function pin_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
Definition fvboth.f90:531
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
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
program pinadd
Main program. A simple setup and call of CONOPT.
Definition pinadd.f90:32