8#if defined(_WIN32) && !defined(_WIN64)
9#define dec_directives_win32
31#ifdef dec_directives_win32
44 INTEGER,
Dimension(:),
Pointer :: cntvect
63 coi_error = max( coi_error,
coidef_optfile( cntvect,
'tutorial2.opt' ) )
76#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
77 coi_error = max( coi_error,
coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_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 )
116Integer Function tut_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
117 colsta, rowno, value, nlflag, n, m, nz, &
119#ifdef dec_directives_win32
123 integer,
intent (in) :: n
124 integer,
intent (in) :: m
125 integer,
intent (in) :: nz
126 real*8,
intent (in out),
dimension(n) :: lower
127 real*8,
intent (in out),
dimension(n) :: curr
128 real*8,
intent (in out),
dimension(n) :: upper
129 integer,
intent (in out),
dimension(n) :: vsta
131 integer,
intent (out),
dimension(m) ::
type
132 integer,
intent (in out),
dimension(m) :: esta
134 real*8,
intent (in out),
dimension(m) :: rhs
135 integer,
intent (in out),
dimension(n+1) :: colsta
136 integer,
intent (out),
dimension(nz) :: rowno
137 integer,
intent (in out),
dimension(nz) :: nlflag
138 real*8,
intent (in out),
dimension(nz) ::
value
253Integer Function tut_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
254 n, nz, thread, usrmem )
255#ifdef dec_directives_win32
259 integer,
intent (in) :: n
260 integer,
intent (in) :: rowno
261 integer,
intent (in) :: nz
262 real*8,
intent (in),
dimension(n) :: x
263 real*8,
intent (in out) :: g
264 real*8,
intent (in out),
dimension(n) :: jac
265 integer,
intent (in),
dimension(nz) :: jcnm
267 integer,
intent (in) :: mode
269 integer,
intent (in) :: ignerr
271 integer,
intent (in out) :: errcnt
273 integer,
intent (in) :: thread
279 real*8 :: l, inp, out, p
283 real*8,
parameter :: w = 1.0d0
284 real*8,
parameter :: l0 = 0.1d0
285 real*8,
parameter :: pinp = 1.0d0
286 real*8,
parameter :: al = 0.16d0
287 real*8,
parameter :: ak = 2.0d0
288 real*8,
parameter :: ainp = 0.16d0
289 real*8,
parameter :: rho = 1.0d0
290 real*8,
parameter :: k = 4.0d0
291 real*8 :: hold1, hold2, hold3
305 if ( rowno .eq. 1 )
then
309 if ( mode .eq. 1 .or. mode .eq. 3 )
then
315 if ( mode .eq. 2 .or. mode .eq. 3 )
then
322 elseif ( rowno .eq. 2 )
then
326 hold1 = (al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho))
327 hold2 = hold1 ** ( -1.d0/rho )
331 if ( mode .eq. 1 .or. mode .eq. 3 )
then
337 if ( mode .eq. 2 .or. mode .eq. 3 )
then
338 hold3 = hold2 / hold1
339 jac(1) = hold3 * al * l ** (-rho-1.d0)
340 jac(2) = hold3 * ainp * inp ** (-rho-1.d0)
353Integer Function tut_2dlagrstr( HSRW, HSCL, NODRV, N, M, NHESS, UsrMem )
354#ifdef dec_directives_win32
359 Integer,
Intent (IN) :: n, m, nhess
360 Integer,
Intent (IN OUT) :: nodrv
361 Integer,
Dimension(Nhess),
Intent(Out) :: hsrw, hscl
362 real*8,
Intent(IN OUT) :: usrmem(*)
408 hsrw(1) = 1; hscl(1) = 1
409 hsrw(2) = 2; hscl(2) = 1
410 hsrw(3) = 2; hscl(3) = 2
411 hsrw(4) = 4; hscl(4) = 3
420Integer Function tut_2dlagrval( X, U, HSRW, HSCL, HSVL, NODRV, N, M, NHESS, UsrMem )
421#ifdef dec_directives_win32
426 Integer,
Intent (IN) :: n, m, nhess
427 Integer,
Intent (IN OUT) :: nodrv
428 real*8,
Dimension(N),
Intent (IN) :: x
429 real*8,
Dimension(M),
Intent (IN) :: u
430 Integer,
Dimension(Nhess),
Intent (In) :: hsrw, hscl
431 real*8,
Dimension(Nhess),
Intent (Out) :: hsvl
432 real*8,
Intent(IN OUT) :: usrmem(*)
437 real*8 :: l, inp, out, p
441 real*8,
parameter :: w = 1.0d0
442 real*8,
parameter :: l0 = 0.1d0
443 real*8,
parameter :: pinp = 1.0d0
444 real*8,
parameter :: al = 0.16d0
445 real*8,
parameter :: ak = 2.0d0
446 real*8,
parameter :: ainp = 0.16d0
447 real*8,
parameter :: rho = 1.0d0
448 real*8,
parameter :: k = 4.0d0
449 real*8 :: hold1, hold2, hold3, hold4
497 if ( u(2) .ne. 0.d0 )
Then
502 hold1 = (al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho))
503 hold2 = hold1 ** ( -1.d0/rho )
504 hold3 = hold2 / hold1
511 hold4 = hold3 / hold1 * (-1.d0/rho-1.d0)
519 hsvl(1) = hold4 * (-rho) * (al*l**(-rho-1.d0))**2 + &
520 hold3 * al * (-rho-1.d0)*l**(-rho-2.d0)
521 hsvl(2) = hold4 * (-rho) * (al*l**(-rho-1.d0)) * &
522 (ainp*inp**(-rho-1.d0))
523 hsvl(3) = hold4 * (-rho) * (ainp*inp**(-rho-1.d0))**2 + &
524 hold3 * ainp * (-rho-1.d0)*inp**(-rho-2.d0)
529 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(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_2dlagrstr(cntvect, coi_2dlagrstr)
define callback routine for providing the structure of the second derivatives of the Lagrangian.
integer(c_int) function coidef_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer(c_int) function coidef_2dlagrval(cntvect, coi_2dlagrval)
define callback routine for computing the values of the second derivatives of the Lagrangian.
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
integer(c_int) function coidef_debug2d(cntvect, debug2d)
turn debugging of 2nd derivatives on and off.
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_numhess(cntvect, numhess)
defines the Number of Hessian Nonzeros.
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.
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.