42 INTEGER :: numcallback
43 INTEGER,
Dimension(:),
Pointer :: cntvect
48 INTEGER :: major, minor, patch
55 Allocate( cntvect(numcallback) )
61 write(*,
"('Solving Pindyck Model using CONOPT version ',i2,'.',i2,'.',i2)") major, minor, patch
75 coi_error = max( coi_error,
coidef_numcon( cntvect, 1 + 6 * t ) )
81 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 * t + 4 * (t-1) ) )
117#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
118 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
121 If ( coi_error .ne. 0 )
THEN
123 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
125 call flog(
"Skipping Solve due to setup errors", 1 )
137 write(*,*)
'End of FVboth2 Model. Return code=',coi_error
139 If ( coi_error /= 0 )
then
140 call flog(
"Errors encountered during solution", 1 )
142 call flog(
"Status or Solution routine was not called", 1 )
144 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
145 elseif ( abs(
obj-1170.4863d0 ) > 0.0001d0 )
then
146 call flog(
"Incorrect objective returned", 1 )
151 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
153 call flog(
"Successful Solve", 0 )
165 colsta, rowno, value, nlflag, n, m, nz, usrmem )
171 integer,
intent (in) :: n
172 integer,
intent (in) :: m
173 integer,
intent (in) :: nz
174 real*8,
intent (in out),
dimension(n) :: lower
175 real*8,
intent (in out),
dimension(n) :: curr
176 real*8,
intent (in out),
dimension(n) :: upper
177 integer,
intent (in out),
dimension(n) :: vsta
179 integer,
intent (out),
dimension(m) ::
type
180 integer,
intent (in out),
dimension(m) :: esta
182 real*8,
intent (in out),
dimension(m) :: rhs
183 integer,
intent (in out),
dimension(n+1) :: colsta
184 integer,
intent (out),
dimension(nz) :: rowno
185 integer,
intent (in out),
dimension(nz) :: nlflag
186 real*8,
intent (in out),
dimension(nz) ::
value
189 Integer :: it, is, i, icol, iz
216 curr(is+4) = curr(is+1) - curr(is+3)
217 if ( it .gt. 1 )
then
218 curr(is+5) = curr(is+5-7) - curr(is+4)
220 curr(is+5) = 500.d0 - curr(is+4)
248 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
253 rhs(2) = rhs(2) + 0.87d0*18.d0
257 rhs(3) = 0.75d0*6.5d0
312 if ( it .lt. t )
then
330 if ( it .lt. t )
then
353 if ( it .lt. t )
then
387 if ( it .lt. t )
then
414 value(iz) = 1.05d0**(1-it)
435Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
436 n, nz, thread, usrmem )
442 integer,
intent (in) :: n
443 integer,
intent (in) :: rowno
444 integer,
intent (in) :: nz
445 real*8,
intent (in),
dimension(n) :: x
446 real*8,
intent (in out) :: g
447 real*8,
intent (in out),
dimension(n) :: jac
448 integer,
intent (in),
dimension(nz) :: jcnm
450 integer,
intent (in) :: mode
452 integer,
intent (in) :: ignerr
454 integer,
intent (in out) :: errcnt
456 integer,
intent (in) :: thread
467 if ( rowno == 1 )
then
472 if ( mode == 1 .or. mode == 3 )
then
476 g = g + x(is+7) * 1.05d0**(1-it)
479 if ( mode == 2 .or. mode == 3 )
then
482 jac(is+7) = 1.05d0**(1-it)
485 else if ( rowno == (it-1)*6+2 )
then
489 if ( mode == 1 .or. mode == 3 )
then
490 g = x(is+1) + 0.13d0*x(is+6)
491 if ( it > 1 ) g = g - 0.87d0*x(is+1-7)
493 if ( mode == 2 .or. mode == 3 )
then
496 if ( it > 1 ) jac(is+1-7) = -0.87d0
498 else if ( rowno == (it-1)*6+3 )
then
502 h1 = (1.1d0+0.1d0*x(is+6))
503 h2 = 1.02d0**(-x(is+2)/7.d0)
504 if ( mode == 1 .or. mode == 3 )
then
506 if ( it > 1 ) g = g - 0.75d0*x(is+3-7)
508 if ( mode == 2 .or. mode == 3 )
then
509 jac(is+2) = h1*h2*log(1.02d0)/7.d0
510 jac(is+6) = -h2*0.1d0
512 if ( it > 1 ) jac(is+3-7) = -0.75d0
514 else if ( rowno == (it-1)*6+4 )
then
518 if ( mode == 1 .or. mode == 3 )
then
519 g = x(is+2) - x(is+3)
520 if ( it > 1 ) g = g - x(is+2-7)
522 if ( mode == 2 .or. mode == 3 )
then
525 if ( it > 1 ) jac(is+2-7) = -1.0d0
527 else if ( rowno == (it-1)*6+5 )
then
531 if ( mode == 1 .or. mode == 3 )
then
532 g = -x(is+1) + x(is+3) + x(is+4)
534 if ( mode == 2 .or. mode == 3 )
then
539 else if ( rowno == (it-1)*6+6 )
then
543 if ( mode == 1 .or. mode == 3 )
then
544 g = x(is+4) + x(is+5)
545 if ( it > 1 ) g = g - x(is+5-7)
547 if ( mode == 2 .or. mode == 3 )
then
550 if ( it > 1 ) jac(is+5-7) = -1.0d0
552 elseif ( rowno == (it-1)*6+7 )
then
556 if ( mode == 1 .or. mode == 3 )
then
557 g = x(is+7) -x(is+4)*(x(is+6)-250.d0/x(is+5))
559 if ( mode == 2 .or. mode == 3 )
then
560 jac(is+4) = -(x(is+6)-250.d0/x(is+5))
561 jac(is+5) = -x(is+4)*250d0/x(is+5)**2
574Integer Function pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
584 INTEGER,
Intent(IN) :: n, m
585 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
586 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
587 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
588 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
589 real*8,
Intent(IN OUT) :: usrmem(*)
590 character*6,
parameter,
dimension(7) :: vname = (/
'td ',
'cs ',
's ',
'd ',
'r ',
'p ',
'rev '/)
591 character*6,
parameter,
dimension(6) :: ename = (/
'tddef ',
'sdef ',
'csdef ',
'ddef ',
'rdef ',
'revdef'/)
594 CHARACTER*5,
Parameter,
Dimension(4) :: stat = (/
'Lower',
'Upper',
'Basic',
'Super' /)
596 WRITE(10,
"(/' Variable Solution value Reduced cost B-stat'/)")
601 WRITE(10,
"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
605 WRITE(10,
"(/' Constrnt Activity level Marginal cost B-stat'/)")
607 WRITE(10,
"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
611 WRITE(10,
"(1x,A6,i2,1P,E20.6,E16.6,4X,A5 )") ename(i1),it, yval(i), ymar(i), stat(1+ybas(i))
integer function std_status(modsta, solsta, iter, objval, usrmem)
subroutine checkdual(case, minmax)
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
integer function std_errmsg(rowno, colno, posno, msglen, usrmem, msg)
program fvboth2
Main program. A simple setup and call of CONOPT.
integer function pin_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
integer function pin_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function pin_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
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_debugfv(cntvect, debugfv)
turn Debugging of FDEval on and off.
integer function coidef_fvinclin(cntvect, fvinclin)
include the linear terms in function evaluations.
integer function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
integer function coidef_fvforall(cntvect, fvforall)
call the FDEval for all constraints, including linear constraints.
integer function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
integer function coidef_objcon(cntvect, objcon)
defines the Objective Constraint.
integer function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
integer function coidef_optdir(cntvect, optdir)
defines the Optimization Direction.
integer function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear Nonzeros.
integer function coidef_numcon(cntvect, numcon)
defines the number of constraints in the model.
integer function coidef_size()
returns the size the Control Vector must have, measured in standard Integer units.
integer function coidef_inifort(cntvect)
initialisation method for Fortran applications.
subroutine coiget_version(major, minor, patch)
returns the version number. It can be used to ensure that the modeler is linked to the correct versio...
integer function coi_solve(cntvect)
method for starting the solving process of CONOPT.
subroutine flog(msg, code)
integer, parameter maximize