17 integer,
Parameter ::
vpp = 7
18 integer,
Parameter ::
epp = 6
19 real*8,
Dimension(Tmax*Vpp) :: xkeep
20 Integer,
Dimension(Tmax*Vpp) ::
xstas
21 Integer,
Dimension(Tmax*Epp) ::
estat
52 INTEGER :: numcallback
53 INTEGER,
Dimension(:),
Pointer :: cntvect
61 Allocate( cntvect(numcallback) )
82 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 *
t + 4 * (
t-1) ) )
98 coi_error = max( coi_error,
coidef_optfile( cntvect,
'test.opt' ) )
109#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
110 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
113 If ( coi_error .ne. 0 )
THEN
115 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
117 call flog(
"Skipping First Solve due to setup errors", 1 )
123 If ( coi_error .ne. 0 )
THEN
125 write(*,*)
'**** Fatal Error while Solving first model.'
127 call flog(
"Errors encountered during first Solve.", 1 )
129 call flog(
"Status or Solution routine was not called during first solve", 1 )
131 call flog(
"Solver and Model Status in first solve was not as expected (1,2)", 1 )
140 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 *
t + 4 * (
t-1) ) )
147 If ( coi_error .ne. 0 )
THEN
149 write(*,*)
'**** Fatal Error while revising CONOPT Sizes.'
151 call flog(
"Skipping Later Solve due to setup errors", 1 )
155 If ( coi_error .ne. 0 )
THEN
157 write(*,*)
'**** Fatal Error while Solving for T=',
t
159 call flog(
"Errors encountered during later Solve.", 1 )
161 call flog(
"Status or Solution routine was not called during later solve", 1 )
163 call flog(
"Solver and Model Status in later solve was not as expected (1,2)", 1 )
167 write(*,*)
'End of Pinadd Model. Return code=',coi_error
169 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
171 call flog(
"Successful Solve", 0 )
183 colsta, rowno, value, nlflag, n, m, nz, usrmem )
189 integer,
intent (in) :: n
190 integer,
intent (in) :: m
191 integer,
intent (in) :: nz
192 real*8,
intent (in out),
dimension(n) :: lower
193 real*8,
intent (in out),
dimension(n) :: curr
194 real*8,
intent (in out),
dimension(n) :: upper
195 integer,
intent (in out),
dimension(n) :: vsta
197 integer,
intent (out),
dimension(m) ::
type
198 integer,
intent (in out),
dimension(m) :: esta
200 real*8,
intent (in out),
dimension(m) :: rhs
201 integer,
intent (in out),
dimension(n+1) :: colsta
202 integer,
intent (out),
dimension(nz) :: rowno
203 integer,
intent (in out),
dimension(nz) :: nlflag
204 real*8,
intent (in out),
dimension(nz) ::
value
207 Integer :: it, is, i, icol, iz, iold
234 curr(is+4) = curr(is+1) - curr(is+3)
235 if ( it .gt. 1 )
then
236 curr(is+5) = curr(is+5-
vpp) - curr(is+4)
238 curr(is+5) = 500.d0 - curr(is+4)
249 curr(1:iold) = xkeep(1:iold)
251 curr(iold+i) = curr(iold+i-
vpp) + (curr(iold+i-
vpp)-curr(iold+i-2*
vpp))
258 vsta(1:iold) =
xstas(1:iold)
263 esta(1:iold) =
estat(1:iold)
292 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
297 rhs(2) = rhs(2) + 0.87d0*18.d0
301 rhs(3) = 0.75d0*6.5d0
356 if ( it .lt.
t )
then
374 if ( it .lt.
t )
then
397 if ( it .lt.
t )
then
431 if ( it .lt.
t )
then
458 value(iz) = 1.05d0**(1-it)
479Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
480 n, nz, thread, usrmem )
486 integer,
intent (in) :: n
487 integer,
intent (in) :: rowno
488 integer,
intent (in) :: nz
489 real*8,
intent (in),
dimension(n) :: x
490 real*8,
intent (in out) :: g
491 real*8,
intent (in out),
dimension(n) :: jac
492 integer,
intent (in),
dimension(nz) :: jcnm
494 integer,
intent (in) :: mode
496 integer,
intent (in) :: ignerr
498 integer,
intent (in out) :: errcnt
500 integer,
intent (in) :: thread
510 if ( rowno == (it-1)*
epp+3 )
then
514 h1 = (1.1d0+0.1d0*x(is+6))
515 h2 = 1.02d0**(-x(is+2)/7.d0)
516 if ( mode == 1 .or. mode == 3 )
then
519 if ( mode == 2 .or. mode == 3 )
then
520 jac(is+2) = h1*h2*log(1.02d0)/7.d0
521 jac(is+6) = -h2*0.1d0
523 elseif ( rowno == (it-1)*
epp+7 )
then
527 if ( mode == 1 .or. mode == 3 )
then
528 g = -x(is+4)*(x(is+6)-250.d0/x(is+5))
530 if ( mode == 2 .or. mode == 3 )
then
531 jac(is+4) = -(x(is+6)-250.d0/x(is+5))
532 jac(is+5) = -x(is+4)*250d0/x(is+5)**2
540 write(*,*)
'Error. FDEval called with rowno=',rowno
549INTEGER FUNCTION pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
557 INTEGER,
Intent(IN) :: n, m
558 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
559 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
560 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
561 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
562 real*8,
Intent(IN OUT) :: usrmem(*)
563 character*6,
parameter,
dimension(7) :: vname = (/
'td ',
'cs ',
's ',
'd ',
'r ',
'p ',
'rev '/)
564 character*6,
parameter,
dimension(6) :: ename = (/
'tddef ',
'sdef ',
'csdef ',
'ddef ',
'rdef ',
'revdef'/)
567 CHARACTER*5,
Parameter,
Dimension(4) :: stat = (/
'Lower',
'Upper',
'Basic',
'Super' /)
571 Write(*,
"(A,i3)")
'Saving primal solution and status information for T =',
t
572 xkeep(1:n) = xval(1:n)
573 xstas(1:n) = xbas(1:n)
574 estat(1:m) = ybas(1:m)
579 WRITE(10,
"(/' Variable Solution value Reduced cost B-stat'/)")
584 WRITE(10,
"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
588 WRITE(10,
"(/' Constrnt Activity level Marginal cost B-stat'/)")
590 WRITE(10,
"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
594 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 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_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer function coidef_inistat(cntvect, inistat)
handling of the initial status values.
integer function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
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.
integer 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.