41 INTEGER :: numcallback
42 INTEGER,
Dimension(:),
Pointer :: cntvect
50 Allocate( cntvect(numcallback) )
63 coi_error = max( coi_error,
coidef_optfile( cntvect,
'tutorial2.opt' ) )
76#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
77 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
80 If ( coi_error .ne. 0 )
THEN
82 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
84 call flog(
"Skipping Solve due to setup errors", 1 )
92 write(*,*)
'End of Tutorial2 example. Return code=',coi_error
94 If ( coi_error /= 0 )
then
95 call flog(
"Errors encountered during solution", 1 )
97 call flog(
"Status or Solution routine was not called", 1 )
99 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
100 elseif ( abs(
obj-0.572943d0 ) > 0.000001d0 )
then
101 call flog(
"Incorrect objective returned", 1 )
104 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
106 call flog(
"Successful Solve", 0 )
113 colsta, rowno, value, nlflag, n, m, nz, &
119 integer,
intent (in) :: n
120 integer,
intent (in) :: m
121 integer,
intent (in) :: nz
122 real*8,
intent (in out),
dimension(n) :: lower
123 real*8,
intent (in out),
dimension(n) :: curr
124 real*8,
intent (in out),
dimension(n) :: upper
125 integer,
intent (in out),
dimension(n) :: vsta
127 integer,
intent (out),
dimension(m) ::
type
128 integer,
intent (in out),
dimension(m) :: esta
130 real*8,
intent (in out),
dimension(m) :: rhs
131 integer,
intent (in out),
dimension(n+1) :: colsta
132 integer,
intent (out),
dimension(nz) :: rowno
133 integer,
intent (in out),
dimension(nz) :: nlflag
134 real*8,
intent (in out),
dimension(nz) ::
value
249Integer Function tut_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
250 n, nz, thread, usrmem )
255 integer,
intent (in) :: n
256 integer,
intent (in) :: rowno
257 integer,
intent (in) :: nz
258 real*8,
intent (in),
dimension(n) :: x
259 real*8,
intent (in out) :: g
260 real*8,
intent (in out),
dimension(n) :: jac
261 integer,
intent (in),
dimension(nz) :: jcnm
263 integer,
intent (in) :: mode
265 integer,
intent (in) :: ignerr
267 integer,
intent (in out) :: errcnt
269 integer,
intent (in) :: thread
275 real*8 :: l, inp, out, p
279 real*8,
parameter :: w = 1.0d0
280 real*8,
parameter :: l0 = 0.1d0
281 real*8,
parameter :: pinp = 1.0d0
282 real*8,
parameter :: al = 0.16d0
283 real*8,
parameter :: ak = 2.0d0
284 real*8,
parameter :: ainp = 0.16d0
285 real*8,
parameter :: rho = 1.0d0
286 real*8,
parameter :: k = 4.0d0
287 real*8 :: hold1, hold2, hold3
301 if ( rowno .eq. 1 )
then
305 if ( mode .eq. 1 .or. mode .eq. 3 )
then
311 if ( mode .eq. 2 .or. mode .eq. 3 )
then
318 elseif ( rowno .eq. 2 )
then
322 hold1 = (al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho))
323 hold2 = hold1 ** ( -1.d0/rho )
327 if ( mode .eq. 1 .or. mode .eq. 3 )
then
333 if ( mode .eq. 2 .or. mode .eq. 3 )
then
334 hold3 = hold2 / hold1
335 jac(1) = hold3 * al * l ** (-rho-1.d0)
336 jac(2) = hold3 * ainp * inp ** (-rho-1.d0)
355 Integer,
Intent (IN) :: n, m, nhess
356 Integer,
Intent (IN OUT) :: nodrv
357 Integer,
Dimension(Nhess),
Intent(Out) :: hsrw, hscl
358 real*8,
Intent(IN OUT) :: usrmem(*)
404 hsrw(1) = 1; hscl(1) = 1
405 hsrw(2) = 2; hscl(2) = 1
406 hsrw(3) = 2; hscl(3) = 2
407 hsrw(4) = 4; hscl(4) = 3
416Integer Function tut_2dlagrval( X, U, HSRW, HSCL, HSVL, NODRV, N, M, NHESS, UsrMem )
422 Integer,
Intent (IN) :: n, m, nhess
423 Integer,
Intent (IN OUT) :: nodrv
424 real*8,
Dimension(N),
Intent (IN) :: x
425 real*8,
Dimension(M),
Intent (IN) :: u
426 Integer,
Dimension(Nhess),
Intent (In) :: hsrw, hscl
427 real*8,
Dimension(Nhess),
Intent (Out) :: hsvl
428 real*8,
Intent(IN OUT) :: usrmem(*)
433 real*8 :: l, inp, out, p
437 real*8,
parameter :: w = 1.0d0
438 real*8,
parameter :: l0 = 0.1d0
439 real*8,
parameter :: pinp = 1.0d0
440 real*8,
parameter :: al = 0.16d0
441 real*8,
parameter :: ak = 2.0d0
442 real*8,
parameter :: ainp = 0.16d0
443 real*8,
parameter :: rho = 1.0d0
444 real*8,
parameter :: k = 4.0d0
445 real*8 :: hold1, hold2, hold3, hold4
493 if ( u(2) .ne. 0.d0 )
Then
498 hold1 = (al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho))
499 hold2 = hold1 ** ( -1.d0/rho )
500 hold3 = hold2 / hold1
507 hold4 = hold3 / hold1 * (-1.d0/rho-1.d0)
515 hsvl(1) = hold4 * (-rho) * (al*l**(-rho-1.d0))**2 + &
516 hold3 * al * (-rho-1.d0)*l**(-rho-2.d0)
517 hsvl(2) = hold4 * (-rho) * (al*l**(-rho-1.d0)) * &
518 (ainp*inp**(-rho-1.d0))
519 hsvl(3) = hold4 * (-rho) * (ainp*inp**(-rho-1.d0))**2 + &
520 hold3 * ainp * (-rho-1.d0)*inp**(-rho-2.d0)
525 hsvl(i) = hsvl(i) * u(2)
Main program. A simple setup and call of CONOPT.
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_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.
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.