49 INTEGER :: numcallback
50 INTEGER,
Dimension(:),
Pointer :: cntvect
58 Allocate( cntvect(numcallback) )
65 coi_error = max( coi_error,
coidef_numnz( cntvect, 11 ) )
72 coi_error = max( coi_error,
coidef_optfile( cntvect,
'tutorial.opt' ) )
85#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
86 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
89 If ( coi_error .ne. 0 )
THEN
91 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
93 call flog(
"Skipping Solve due to setup errors", 1 )
101 write(*,*)
'End of Tutorial2r example. Return code=',coi_error
103 If ( coi_error /= 0 )
then
104 call flog(
"Errors encountered during solution", 1 )
106 call flog(
"Status or Solution routine was not called", 1 )
108 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
109 elseif ( abs(
obj-0.572943d0 ) > 0.000001d0 )
then
110 call flog(
"Incorrect objective returned", 1 )
113 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
115 call flog(
"Successful Solve", 0 )
123 colsta, rowno, value, nlflag, n, m, nz, &
129 integer,
intent (in) :: n
130 integer,
intent (in) :: m
131 integer,
intent (in) :: nz
132 real*8,
intent (in out),
dimension(n) :: lower
133 real*8,
intent (in out),
dimension(n) :: curr
134 real*8,
intent (in out),
dimension(n) :: upper
135 integer,
intent (in out),
dimension(n) :: vsta
137 integer,
intent (out),
dimension(m) ::
type
138 integer,
intent (in out),
dimension(m) :: esta
140 real*8,
intent (in out),
dimension(m) :: rhs
141 integer,
intent (in out),
dimension(n+1) :: colsta
142 integer,
intent (out),
dimension(nz) :: rowno
143 integer,
intent (in out),
dimension(nz) :: nlflag
144 real*8,
intent (in out),
dimension(nz) ::
value
150 real*8,
parameter :: al = 0.16d0
151 real*8,
parameter :: ak = 2.0d0
152 real*8,
parameter :: ainp = 0.16d0
153 real*8,
parameter :: rho = 1.0d0
154 real*8,
parameter :: k = 4.0d0
181 curr(5) = (al*curr(1)**(-rho) + ak*k**(-rho) + ainp*curr(2)**(-rho))
291Integer Function tut_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
292 n, nz, thread, usrmem )
297 integer,
intent (in) :: n
298 integer,
intent (in) :: rowno
299 integer,
intent (in) :: nz
300 real*8,
intent (in),
dimension(n) :: x
301 real*8,
intent (in out) :: g
302 real*8,
intent (in out),
dimension(n) :: jac
303 integer,
intent (in),
dimension(nz) :: jcnm
305 integer,
intent (in) :: mode
307 integer,
intent (in) :: ignerr
309 integer,
intent (in out) :: errcnt
311 integer,
intent (in) :: thread
317 real*8 :: l, inp, out, p, int
321 real*8,
parameter :: w = 1.0d0
322 real*8,
parameter :: l0 = 0.1d0
323 real*8,
parameter :: pinp = 1.0d0
324 real*8,
parameter :: al = 0.16d0
325 real*8,
parameter :: ak = 2.0d0
326 real*8,
parameter :: ainp = 0.16d0
327 real*8,
parameter :: rho = 1.0d0
328 real*8,
parameter :: k = 4.0d0
343 if ( rowno .eq. 1 )
then
347 if ( mode .eq. 1 .or. mode .eq. 3 )
then
353 if ( mode .eq. 2 .or. mode .eq. 3 )
then
361 elseif ( rowno .eq. 2 )
then
365 if ( mode .eq. 1 .or. mode .eq. 3 )
then
366 g = al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho)
371 if ( mode .eq. 2 .or. mode .eq. 3 )
then
372 jac(1) = -rho * al * l ** (-rho-1.d0)
373 jac(2) = -rho * ainp * inp ** (-rho-1.d0)
378 elseif ( rowno .eq. 4 )
then
379 if ( mode .eq. 1 .or. mode .eq. 3 )
then
382 if ( mode .eq. 2 .or. mode .eq. 3 )
then
383 jac(5) = (-1.d0/rho)*int**(-1.d0/rho-1.d0)
400 Integer,
Intent (IN) :: n, m, nhess
401 Integer,
Intent (IN OUT) :: nodrv
402 Integer,
Dimension(Nhess),
Intent (Out) :: hsrw, hscl
403 real*8,
Intent(IN OUT) :: usrmem(*)
459 hsrw(1) = 1; hscl(1) = 1
460 hsrw(2) = 2; hscl(2) = 2
461 hsrw(3) = 4; hscl(3) = 3
462 hsrw(4) = 5; hscl(4) = 5
471Integer Function tut_2dlagrval( X, U, HSRW, HSCL, HSVL, NODRV, N, M, NHESS, UsrMem )
477 Integer,
Intent (IN) :: n, m, nhess
478 Integer,
Intent (IN OUT) :: nodrv
479 real*8,
Dimension(N),
Intent (IN) :: x
480 real*8,
Dimension(M),
Intent (IN) :: u
481 Integer,
Dimension(NHess),
Intent (IN) :: hsrw, hscl
482 real*8,
Dimension(NHess),
Intent (Out) :: hsvl
483 real*8,
Intent(IN OUT) :: usrmem(*)
492 real*8,
parameter :: w = 1.0d0
493 real*8,
parameter :: l0 = 0.1d0
494 real*8,
parameter :: pinp = 1.0d0
495 real*8,
parameter :: al = 0.16d0
496 real*8,
parameter :: ak = 2.0d0
497 real*8,
parameter :: ainp = 0.16d0
498 real*8,
parameter :: rho = 1.0d0
499 real*8,
parameter :: k = 4.0d0
556 if ( u(2) .ne. 0.d0 )
Then
559 hsvl(1) = (-rho) * (-rho-1.d0) * al * l**(-rho-2.d0) * u(2)
560 hsvl(2) = (-rho) * (-rho-1.d0) * ainp * inp**(-rho-2.d0) * u(2)
562 if ( u(4) .ne. 0.d0 )
then
563 hsvl(4) = (-1.d0/rho)*(-1.d0/rho-1.d0)*x(5)**(-1.d0/rho-2.d0)
integer function std_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
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 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_debugfv(cntvect, debugfv)
turn Debugging of FDEval on and off.
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.
subroutine flog(msg, code)
integer function tut_2dlagrval(x, u, hsrw, hscl, hsvl, nodrv, n, m, nhess, usrmem)
Compute the Lagrangian of the Hessian.
integer function tut_2dlagrstr(hsrw, hscl, nodrv, n, m, nhess, usrmem)
Specify the structure of the Lagrangian of the Hessian.
program tutorial2r
Main program. A simple setup and call of CONOPT.
integer function tut_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function tut_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.