14#if defined(_WIN32) && !defined(_WIN64)
15#define dec_directives_win32
20 integer,
Parameter :: Tmin = 16,
tmax = 20
21 integer,
Parameter ::
vpp = 7
22 integer,
Parameter ::
epp = 6
24 real*8,
Dimension(Tmax*Vpp) :: xkeep
25 Integer,
Dimension(Tmax*Vpp) ::
xstas
26 Integer,
Dimension(Tmax*Epp) ::
estat
46#ifdef dec_directives_win32
57 INTEGER,
Dimension(:),
Pointer :: cntvect
84 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 *
t + 4 * (
t-1) ) )
100 coi_error = max( coi_error,
coidef_optfile( cntvect,
'test.opt' ) )
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) )
115 If ( coi_error .ne. 0 )
THEN
117 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
119 call flog(
"Skipping First Solve due to setup errors", 1 )
126 If ( coi_error .ne. 0 )
THEN
128 write(*,*)
'**** Fatal Error while Solving first model.'
130 call flog(
"Errors encountered during first Solve.", 1 )
132 call flog(
"Status or Solution routine was not called during first solve", 1 )
134 call flog(
"Solver and Model Status in first solve was not as expected (1,2)", 1 )
144 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 *
t + 4 * (
t-1) ) )
152 If ( coi_error .ne. 0 )
THEN
154 write(*,*)
'**** Fatal Error while revising CONOPT Sizes.'
156 call flog(
"Skipping second solve due to setup errors", 1 )
160 If ( coi_error .ne. 400 )
THEN
162 write(*,*)
'**** Second solve did not return error 400 as expected. COI_Error=',coi_error
164 call flog(
"Incorrect COI_Error from second solve.", 1 )
173 If ( coi_error .ne. 0 )
THEN
175 write(*,*)
'**** Fatal Error while revising CONOPT Sizes.'
177 call flog(
"Skipping third solve due to setup errors", 1 )
181 If ( coi_error .ne. 400 )
THEN
183 write(*,*)
'**** Third solve did not return error 400 as expected. COI_Error=',coi_error
185 call flog(
"Incorrect COI_Error from third solve.", 1 )
193 If ( coi_error .ne. 0 )
THEN
195 write(*,*)
'**** Fatal Error while revising CONOPT Sizes.'
197 call flog(
"Skipping third solve due to setup errors", 1 )
201 If ( coi_error .ne. 0 )
THEN
203 write(*,*)
'**** Fourth solve did not return error 0 as expected. COI_Error=',coi_error
205 call flog(
"Incorrect COI_Error from fourth solve.", 1 )
207 call flog(
"Status or Solution routine was not called during fourth solve", 1 )
209 call flog(
"Solver and Model Status in fourth solve was not as expected (1,2)", 1 )
213 write(*,*)
'End of PinStatErr Model. Return code=',coi_error
215 if (
coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
217 call flog(
"Successful Solve", 0 )
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
235 integer,
intent (in) :: n
236 integer,
intent (in) :: m
237 integer,
intent (in) :: nz
238 real*8,
intent (in out),
dimension(n) :: lower
239 real*8,
intent (in out),
dimension(n) :: curr
240 real*8,
intent (in out),
dimension(n) :: upper
241 integer,
intent (in out),
dimension(n) :: vsta
243 integer,
intent (out),
dimension(m) ::
type
244 integer,
intent (in out),
dimension(m) :: esta
246 real*8,
intent (in out),
dimension(m) :: rhs
247 integer,
intent (in out),
dimension(n+1) :: colsta
248 integer,
intent (out),
dimension(nz) :: rowno
249 integer,
intent (in out),
dimension(nz) :: nlflag
250 real*8,
intent (in out),
dimension(nz) ::
value
253 Integer :: it, is, i, icol, iz, iold
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)
284 curr(is+5) = 500.d0 - curr(is+4)
295 curr(1:iold) = xkeep(1:iold)
297 curr(iold+i) = curr(iold+i-
vpp) + (curr(iold+i-
vpp)-curr(iold+i-2*
vpp))
306 vsta(1:iold) =
xstas(1:iold)
313 esta(1:iold) =
estat(1:iold)
348 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
353 rhs(2) = rhs(2) + 0.87d0*18.d0
357 rhs(3) = 0.75d0*6.5d0
412 if ( it .lt.
t )
then
430 if ( it .lt.
t )
then
453 if ( it .lt.
t )
then
487 if ( it .lt.
t )
then
514 value(iz) = 1.05d0**(1-it)
535Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
536 n, nz, thread, usrmem )
537#ifdef dec_directives_win32
542 integer,
intent (in) :: n
543 integer,
intent (in) :: rowno
544 integer,
intent (in) :: nz
545 real*8,
intent (in),
dimension(n) :: x
546 real*8,
intent (in out) :: g
547 real*8,
intent (in out),
dimension(n) :: jac
548 integer,
intent (in),
dimension(nz) :: jcnm
550 integer,
intent (in) :: mode
552 integer,
intent (in) :: ignerr
554 integer,
intent (in out) :: errcnt
556 integer,
intent (in) :: thread
566 if ( rowno == (it-1)*
epp+3 )
then
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
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
579 elseif ( rowno == (it-1)*
epp+7 )
then
583 if ( mode == 1 .or. mode == 3 )
then
584 g = -x(is+4)*(x(is+6)-250.d0/x(is+5))
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
596 write(*,*)
'Error. FDEval called with rowno=',rowno
605INTEGER FUNCTION pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
606#ifdef dec_directives_win32
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'/)
623 CHARACTER*5,
Parameter,
Dimension(4) :: stat = (/
'Lower',
'Upper',
'Basic',
'Super' /)
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)
635 WRITE(10,
"(/' Variable Solution value Reduced cost B-stat'/)")
640 WRITE(10,
"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
644 WRITE(10,
"(/' Constrnt Activity level Marginal cost B-stat'/)")
646 WRITE(10,
"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
650 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)
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
integer function std_errmsg(rowno, colno, posno, msglen, usrmem, msg)
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_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer(c_int) function coidef_inistat(cntvect, inistat)
handling of the initial status values.
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
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.
integer(c_int) function coi_solve(cntvect)
method for starting the solving process of CONOPT.
integer, dimension(tmax *vpp) xstas
integer, dimension(tmax *epp) estat
subroutine flog(msg, code)
program pinadd
Main program. A simple setup and call of CONOPT.