17 integer,
Parameter ::
vpp = 7
18 integer,
Parameter ::
epp = 6
19 Integer,
Parameter ::
hpp = 5
20 real*8,
Dimension(Tmax*Vpp) :: xkeep
21 Integer,
Dimension(Tmax*Vpp) ::
xstas
22 Integer,
Dimension(Tmax*Epp) ::
estat
57 INTEGER :: numcallback
58 INTEGER,
Dimension(:),
Pointer :: cntvect
66 Allocate( cntvect(numcallback) )
87 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 *
t + 4 * (
t-1) ) )
111 coi_error = max( coi_error,
coidef_optfile( cntvect,
'test.opt' ) )
124#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
125 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
128 If ( coi_error .ne. 0 )
THEN
130 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
132 call flog(
"Skipping First Solve due to setup errors", 1 )
138 If ( coi_error .ne. 0 )
THEN
140 write(*,*)
'**** Fatal Error while Solving first model.'
142 call flog(
"Errors encountered during first Solve.", 1 )
144 call flog(
"Status or Solution routine was not called during first Solve", 1 )
146 call flog(
"Incorrect Model or Solver Status during first solve", 1 )
155 coi_error = max( coi_error,
coidef_numnz( cntvect, 17 *
t + 4 * (
t-1) ) )
167 If ( coi_error .ne. 0 )
THEN
169 write(*,*)
'**** Fatal Error while revising CONOPT Sizes.'
171 call flog(
"Skipping Later Solve due to setup errors", 1 )
174 If ( coi_error .ne. 0 )
THEN
176 write(*,*)
'**** Fatal Error while Solving for T=',
t
178 call flog(
"Errors encountered during later Solve.", 1 )
180 call flog(
"Status or Solution routine was not called during later Solve", 1 )
182 call flog(
"Incorrect Model or Solver Status during later solve", 1 )
186 write(*,*)
'End of Pinadd2 Model. Return code=',coi_error
188 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
190 call flog(
"Successful Solve", 0 )
202 colsta, rowno, value, nlflag, n, m, nz, usrmem )
208 integer,
intent (in) :: n
209 integer,
intent (in) :: m
210 integer,
intent (in) :: nz
211 real*8,
intent (in out),
dimension(n) :: lower
212 real*8,
intent (in out),
dimension(n) :: curr
213 real*8,
intent (in out),
dimension(n) :: upper
214 integer,
intent (in out),
dimension(n) :: vsta
216 integer,
intent (out),
dimension(m) ::
type
217 integer,
intent (in out),
dimension(m) :: esta
219 real*8,
intent (in out),
dimension(m) :: rhs
220 integer,
intent (in out),
dimension(n+1) :: colsta
221 integer,
intent (out),
dimension(nz) :: rowno
222 integer,
intent (in out),
dimension(nz) :: nlflag
223 real*8,
intent (in out),
dimension(nz) ::
value
226 Integer :: it, is, i, icol, iz, iold
253 curr(is+4) = curr(is+1) - curr(is+3)
254 if ( it .gt. 1 )
then
255 curr(is+5) = curr(is+5-
vpp) - curr(is+4)
257 curr(is+5) = 500.d0 - curr(is+4)
268 curr(1:iold) = xkeep(1:iold)
270 curr(iold+i) = curr(iold+i-
vpp) + (curr(iold+i-
vpp)-curr(iold+i-2*
vpp))
277 vsta(1:iold) =
xstas(1:iold)
282 esta(1:iold) =
estat(1:iold)
311 rhs(is+1) = 1.d0+2.3d0*1.015d0**(it-1)
316 rhs(2) = rhs(2) + 0.87d0*18.d0
320 rhs(3) = 0.75d0*6.5d0
375 if ( it .lt.
t )
then
393 if ( it .lt.
t )
then
416 if ( it .lt.
t )
then
450 if ( it .lt.
t )
then
477 value(iz) = 1.05d0**(1-it)
498Integer Function pin_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
499 n, nz, thread, usrmem )
505 integer,
intent (in) :: n
506 integer,
intent (in) :: rowno
507 integer,
intent (in) :: nz
508 real*8,
intent (in),
dimension(n) :: x
509 real*8,
intent (in out) :: g
510 real*8,
intent (in out),
dimension(n) :: jac
511 integer,
intent (in),
dimension(nz) :: jcnm
513 integer,
intent (in) :: mode
515 integer,
intent (in) :: ignerr
517 integer,
intent (in out) :: errcnt
519 integer,
intent (in) :: thread
529 if ( rowno == (it-1)*
epp+3 )
then
533 h1 = (1.1d0+0.1d0*x(is+6))
534 h2 = 1.02d0**(-x(is+2)/7.d0)
535 if ( mode == 1 .or. mode == 3 )
then
538 if ( mode == 2 .or. mode == 3 )
then
539 jac(is+2) = h1*h2*log(1.02d0)/7.d0
540 jac(is+6) = -h2*0.1d0
542 elseif ( rowno == (it-1)*
epp+7 )
then
546 if ( mode == 1 .or. mode == 3 )
then
547 g = -x(is+4)*(x(is+6)-250.d0/x(is+5))
549 if ( mode == 2 .or. mode == 3 )
then
550 jac(is+4) = -(x(is+6)-250.d0/x(is+5))
551 jac(is+5) = -x(is+4)*250d0/x(is+5)**2
559 write(*,*)
'Error. FDEval called with rowno=',rowno
568Integer Function pin_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
576 INTEGER,
Intent(IN) :: n, m
577 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
578 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
579 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
580 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
581 real*8,
Intent(IN OUT) :: usrmem(*)
582 character*6,
parameter,
dimension(7) :: vname = (/
'td ',
'cs ',
's ',
'd ',
'r ',
'p ',
'rev '/)
583 character*6,
parameter,
dimension(6) :: ename = (/
'tddef ',
'sdef ',
'csdef ',
'ddef ',
'rdef ',
'revdef'/)
586 CHARACTER*5,
Parameter,
Dimension(4) :: stat = (/
'Lower',
'Upper',
'Basic',
'Super' /)
590 Write(*,
"(A,i3)")
'Saving primal solution and status information for T =',
t
591 xkeep(1:n) = xval(1:n)
592 xstas(1:n) = xbas(1:n)
593 estat(1:m) = ybas(1:m)
598 WRITE(10,
"(/' Variable Solution value Reduced cost B-stat'/)")
603 WRITE(10,
"(1X,A6,i2,1p,E20.6,E16.6,4X,A5 )") vname(i1), it, xval(i), xmar(i), stat(1+xbas(i))
607 WRITE(10,
"(/' Constrnt Activity level Marginal cost B-stat'/)")
609 WRITE(10,
"(1x,'Objective',1P,E19.6,E16.6,4X,A5 )") yval(i), ymar(i), stat(1+ybas(i))
613 WRITE(10,
"(1x,A6,i2,1P,E20.6,E16.6,4X,A5 )") ename(i1),it, yval(i), ymar(i), stat(1+ybas(i))
632 Integer,
Intent (IN) :: n, m, nhess
633 Integer,
Intent (IN OUT) :: nodrv
634 Integer,
Dimension(NHess),
Intent (Out) :: hsrw, hscl
635 real*8,
Intent(IN OUT) :: usrmem(*)
637 Integer :: it, is, ic
677 if ( n /=
vpp*
t )
then
678 write(*,*)
'Struct: Number of variables should be=',
vpp*
t,
' but CONOPT uses',n
679 write(*,*)
'Number of periods=',
t
683 if ( m /=
epp*
t+1 )
then
684 write(*,*)
'Struct: Number of equations should be=',
epp*
t+1,
' but CONOPT uses',m
685 write(*,*)
'Number of periods=',
t
691 hscl(is+1) = ic+2; hsrw(is+1) = ic+2
692 hscl(is+2) = ic+2; hsrw(is+2) = ic+6
693 hscl(is+3) = ic+4; hsrw(is+3) = ic+5
694 hscl(is+4) = ic+4; hsrw(is+4) = ic+6
695 hscl(is+5) = ic+5; hsrw(is+5) = ic+5
706Integer Function pin_2dlagrval( X, U, HSRW, HSCL, HSVL, NODRV, N, M, NHESS, UsrMem )
713 Integer,
Intent (IN) :: n, m, nhess
714 Integer,
Intent (IN OUT) :: nodrv
715 real*8,
Dimension(N),
Intent (IN) :: x
716 real*8,
Dimension(M),
Intent (IN) :: u
717 Integer,
Dimension(Nhess),
Intent (IN) :: hsrw, hscl
718 real*8,
Dimension(NHess),
Intent (Out) :: hsvl
719 real*8,
Intent(IN OUT) :: usrmem(*)
721 Integer :: it, is, ic, ie
722 real*8 :: cs, d, r, p
763 if ( n /=
vpp*
t )
then
764 write(*,*)
'Eval: Number of variables should be=',
vpp*
t,
' but CONOPT uses',n
765 write(*,*)
'Number of periods=',
t
768 if ( m /=
epp*
t+1 )
then
769 write(*,*)
'Eval: Number of equations should be=',
epp*
t+1,
' but CONOPT uses',m
770 write(*,*)
'Number of periods=',
t
782 h2 = 1.02d0**(-cs/7.d0)
783 hsvl(is+1) = -h1*h2*(log(1.02)/7.d0)**2 * u(ie+2)
784 hsvl(is+2) = 0.1d0*h2*(log(1.02)/7.d0) * u(ie+2)
785 hsvl(is+3) = -250.d0/r**2 * u(ie+6)
786 hsvl(is+4) = -1.d0 * u(ie+6)
787 hsvl(is+5) = 500.d0*d/ r**3 * u(ie+6)
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_2dlagrstr(cntvect, coi_2dlagrstr)
define callback routine for providing the structure of the second derivatives of the Lagrangian.
integer function coidef_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer function coidef_2dlagrval(cntvect, coi_2dlagrval)
define callback routine for computing the values of the second derivatives of the Lagrangian.
integer function coidef_inistat(cntvect, inistat)
handling of the initial status values.
integer function coidef_debug2d(cntvect, debug2d)
turn debugging of 2nd derivatives on and off.
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_numhess(cntvect, numhess)
defines the Number of Hessian 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 pinadd2
Main program. A simple setup and call of CONOPT.
integer function pin_2dlagrstr(hsrw, hscl, nodrv, n, m, nhess, usrmem)
Specify the structure of the Lagrangian of the Hessian.
integer function pin_2dlagrval(x, u, hsrw, hscl, hsvl, nodrv, n, m, nhess, usrmem)
Compute the Lagrangian of the Hessian.