14#if defined(_WIN32) && !defined(_WIN64)
15#define dec_directives_win32
35#ifdef dec_directives_win32
46 INTEGER,
Dimension(:),
Pointer :: cntvect
51 INTEGER :: major, minor, patch
62 write(*,
"('Solving Pindyck Model using CONOPT version ',i2,'.',i2,'.',i2)") major, minor, patch
76 coi_error = max( coi_error,
coidef_numcon( cntvect, 1 + 6 * t ) )
82 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 * t + 4 * (t-1) ) )
118#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
119 coi_error = max( coi_error,
coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
122 If ( coi_error .ne. 0 )
THEN
124 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
126 call flog(
"Skipping Solve due to setup errors", 1 )
138 write(*,*)
'End of FVboth2 Model. Return code=',coi_error
140 If ( coi_error /= 0 )
then
141 call flog(
"Errors encountered during solution", 1 )
143 call flog(
"Status or Solution routine was not called", 1 )
145 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
146 elseif ( abs(
obj-1170.4863d0 ) > 0.0001d0 )
then
147 call flog(
"Incorrect objective returned", 1 )
152 if (
coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
154 call flog(
"Successful Solve", 0 )
165Integer Function pin_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
166 colsta, rowno, value, nlflag, n, m, nz, usrmem )
167#ifdef dec_directives_win32
172 integer,
intent (in) :: n
173 integer,
intent (in) :: m
174 integer,
intent (in) :: nz
175 real*8,
intent (in out),
dimension(n) :: lower
176 real*8,
intent (in out),
dimension(n) :: curr
177 real*8,
intent (in out),
dimension(n) :: upper
178 integer,
intent (in out),
dimension(n) :: vsta
180 integer,
intent (out),
dimension(m) ::
type
181 integer,
intent (in out),
dimension(m) :: esta
183 real*8,
intent (in out),
dimension(m) :: rhs
184 integer,
intent (in out),
dimension(n+1) :: colsta
185 integer,
intent (out),
dimension(nz) :: rowno
186 integer,
intent (in out),
dimension(nz) :: nlflag
187 real*8,
intent (in out),
dimension(nz) ::
value
190 Integer :: it, is, i, icol, iz
217 curr(is+4) = curr(is+1) - curr(is+3)
218 if ( it .gt. 1 )
then
219 curr(is+5) = curr(is+5-7) - curr(is+4)
221 curr(is+5) = 500.d0 - curr(is+4)
249 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
254 rhs(2) = rhs(2) + 0.87d0*18.d0
258 rhs(3) = 0.75d0*6.5d0
313 if ( it .lt. t )
then
331 if ( it .lt. t )
then
354 if ( it .lt. t )
then
388 if ( it .lt. t )
then
415 value(iz) = 1.05d0**(1-it)
436Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
437 n, nz, thread, usrmem )
438#ifdef dec_directives_win32
443 integer,
intent (in) :: n
444 integer,
intent (in) :: rowno
445 integer,
intent (in) :: nz
446 real*8,
intent (in),
dimension(n) :: x
447 real*8,
intent (in out) :: g
448 real*8,
intent (in out),
dimension(n) :: jac
449 integer,
intent (in),
dimension(nz) :: jcnm
451 integer,
intent (in) :: mode
453 integer,
intent (in) :: ignerr
455 integer,
intent (in out) :: errcnt
457 integer,
intent (in) :: thread
468 if ( rowno == 1 )
then
473 if ( mode == 1 .or. mode == 3 )
then
477 g = g + x(is+7) * 1.05d0**(1-it)
480 if ( mode == 2 .or. mode == 3 )
then
483 jac(is+7) = 1.05d0**(1-it)
486 else if ( rowno == (it-1)*6+2 )
then
490 if ( mode == 1 .or. mode == 3 )
then
491 g = x(is+1) + 0.13d0*x(is+6)
492 if ( it > 1 ) g = g - 0.87d0*x(is+1-7)
494 if ( mode == 2 .or. mode == 3 )
then
497 if ( it > 1 ) jac(is+1-7) = -0.87d0
499 else if ( rowno == (it-1)*6+3 )
then
503 h1 = (1.1d0+0.1d0*x(is+6))
504 h2 = 1.02d0**(-x(is+2)/7.d0)
505 if ( mode == 1 .or. mode == 3 )
then
507 if ( it > 1 ) g = g - 0.75d0*x(is+3-7)
509 if ( mode == 2 .or. mode == 3 )
then
510 jac(is+2) = h1*h2*log(1.02d0)/7.d0
511 jac(is+6) = -h2*0.1d0
513 if ( it > 1 ) jac(is+3-7) = -0.75d0
515 else if ( rowno == (it-1)*6+4 )
then
519 if ( mode == 1 .or. mode == 3 )
then
520 g = x(is+2) - x(is+3)
521 if ( it > 1 ) g = g - x(is+2-7)
523 if ( mode == 2 .or. mode == 3 )
then
526 if ( it > 1 ) jac(is+2-7) = -1.0d0
528 else if ( rowno == (it-1)*6+5 )
then
532 if ( mode == 1 .or. mode == 3 )
then
533 g = -x(is+1) + x(is+3) + x(is+4)
535 if ( mode == 2 .or. mode == 3 )
then
540 else if ( rowno == (it-1)*6+6 )
then
544 if ( mode == 1 .or. mode == 3 )
then
545 g = x(is+4) + x(is+5)
546 if ( it > 1 ) g = g - x(is+5-7)
548 if ( mode == 2 .or. mode == 3 )
then
551 if ( it > 1 ) jac(is+5-7) = -1.0d0
553 elseif ( rowno == (it-1)*6+7 )
then
557 if ( mode == 1 .or. mode == 3 )
then
558 g = x(is+7) -x(is+4)*(x(is+6)-250.d0/x(is+5))
560 if ( mode == 2 .or. mode == 3 )
then
561 jac(is+4) = -(x(is+6)-250.d0/x(is+5))
562 jac(is+5) = -x(is+4)*250d0/x(is+5)**2
575Integer Function pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
576#ifdef dec_directives_win32
585 INTEGER,
Intent(IN) :: n, m
586 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
587 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
588 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
589 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
590 real*8,
Intent(IN OUT) :: usrmem(*)
591 character*6,
parameter,
dimension(7) :: vname = (/
'td ',
'cs ',
's ',
'd ',
'r ',
'p ',
'rev '/)
592 character*6,
parameter,
dimension(6) :: ename = (/
'tddef ',
'sdef ',
'csdef ',
'ddef ',
'rdef ',
'revdef'/)
595 CHARACTER*5,
Parameter,
Dimension(4) :: stat = (/
'Lower',
'Upper',
'Basic',
'Super' /)
597 WRITE(10,
"(/' Variable Solution value Reduced cost B-stat'/)")
602 WRITE(10,
"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
606 WRITE(10,
"(/' Constrnt Activity level Marginal cost B-stat'/)")
608 WRITE(10,
"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
612 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(c_int) function coidef_message(cntvect, coi_message)
define callback routine for handling messages returned during the solution process.
integer(c_int) function coidef_solution(cntvect, coi_solution)
define callback routine for returning the final solution values.
integer(c_int) function coidef_status(cntvect, coi_status)
define callback routine for returning the completion status.
integer(c_int) function coidef_readmatrix(cntvect, coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
integer(c_int) function coidef_errmsg(cntvect, coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
integer(c_int) function coidef_fdeval(cntvect, coi_fdeval)
define callback routine for performing function and derivative evaluations.
integer(c_int) function coidef_fvforall(cntvect, fvforall)
call the FDEval for all constraints, including linear constraints.
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
integer(c_int) function coidef_debugfv(cntvect, debugfv)
turn Debugging of FDEval on and off.
integer(c_int) function coidef_fvinclin(cntvect, fvinclin)
include the linear terms in function evaluations.
integer(c_int) function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
integer(c_int) function coidef_numcon(cntvect, numcon)
defines the number of constraints in the model.
integer(c_int) function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear Nonzeros.
integer(c_int) function coidef_optdir(cntvect, optdir)
defines the Optimization Direction.
integer(c_int) function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
integer(c_int) function coidef_objcon(cntvect, objcon)
defines the Objective Constraint.
integer(c_int) function coi_create(cntvect)
initializes CONOPT and creates the control vector.
integer(c_int) function coi_free(cntvect)
frees the control vector.
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(c_int) function coi_solve(cntvect)
method for starting the solving process of CONOPT.
subroutine flog(msg, code)
integer, parameter maximize