17#if defined(_WIN32) && !defined(_WIN64)
18#define dec_directives_win32
40#ifdef dec_directives_win32
53 INTEGER,
Dimension(:),
Pointer :: cntvect
66 coi_error = max( coi_error,
coidef_numnz( cntvect, 11 ) )
73 coi_error = max( coi_error,
coidef_optfile( cntvect,
'tutorial.opt' ) )
86#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
87 coi_error = max( coi_error,
coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
90 If ( coi_error .ne. 0 )
THEN
92 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
94 call flog(
"Skipping Solve due to setup errors", 1 )
102 write(*,*)
'End of Tutorial2r example. Return code=',coi_error
104 If ( coi_error /= 0 )
then
105 call flog(
"Errors encountered during solution", 1 )
107 call flog(
"Status or Solution routine was not called", 1 )
109 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
110 elseif ( abs(
obj-0.572943d0 ) > 0.000001d0 )
then
111 call flog(
"Incorrect objective returned", 1 )
114 if (
coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
116 call flog(
"Successful Solve", 0 )
123Integer Function tut_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
124 colsta, rowno, value, nlflag, n, m, nz, &
126#ifdef dec_directives_win32
130 integer,
intent (in) :: n
131 integer,
intent (in) :: m
132 integer,
intent (in) :: nz
133 real*8,
intent (in out),
dimension(n) :: lower
134 real*8,
intent (in out),
dimension(n) :: curr
135 real*8,
intent (in out),
dimension(n) :: upper
136 integer,
intent (in out),
dimension(n) :: vsta
138 integer,
intent (out),
dimension(m) ::
type
139 integer,
intent (in out),
dimension(m) :: esta
141 real*8,
intent (in out),
dimension(m) :: rhs
142 integer,
intent (in out),
dimension(n+1) :: colsta
143 integer,
intent (out),
dimension(nz) :: rowno
144 integer,
intent (in out),
dimension(nz) :: nlflag
145 real*8,
intent (in out),
dimension(nz) ::
value
151 real*8,
parameter :: al = 0.16d0
152 real*8,
parameter :: ak = 2.0d0
153 real*8,
parameter :: ainp = 0.16d0
154 real*8,
parameter :: rho = 1.0d0
155 real*8,
parameter :: k = 4.0d0
182 curr(5) = (al*curr(1)**(-rho) + ak*k**(-rho) + ainp*curr(2)**(-rho))
292Integer Function tut_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
293 n, nz, thread, usrmem )
294#ifdef dec_directives_win32
298 integer,
intent (in) :: n
299 integer,
intent (in) :: rowno
300 integer,
intent (in) :: nz
301 real*8,
intent (in),
dimension(n) :: x
302 real*8,
intent (in out) :: g
303 real*8,
intent (in out),
dimension(n) :: jac
304 integer,
intent (in),
dimension(nz) :: jcnm
306 integer,
intent (in) :: mode
308 integer,
intent (in) :: ignerr
310 integer,
intent (in out) :: errcnt
312 integer,
intent (in) :: thread
318 real*8 :: l, inp, out, p, int
322 real*8,
parameter :: w = 1.0d0
323 real*8,
parameter :: l0 = 0.1d0
324 real*8,
parameter :: pinp = 1.0d0
325 real*8,
parameter :: al = 0.16d0
326 real*8,
parameter :: ak = 2.0d0
327 real*8,
parameter :: ainp = 0.16d0
328 real*8,
parameter :: rho = 1.0d0
329 real*8,
parameter :: k = 4.0d0
344 if ( rowno .eq. 1 )
then
348 if ( mode .eq. 1 .or. mode .eq. 3 )
then
354 if ( mode .eq. 2 .or. mode .eq. 3 )
then
362 elseif ( rowno .eq. 2 )
then
366 if ( mode .eq. 1 .or. mode .eq. 3 )
then
367 g = al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho)
372 if ( mode .eq. 2 .or. mode .eq. 3 )
then
373 jac(1) = -rho * al * l ** (-rho-1.d0)
374 jac(2) = -rho * ainp * inp ** (-rho-1.d0)
379 elseif ( rowno .eq. 4 )
then
380 if ( mode .eq. 1 .or. mode .eq. 3 )
then
383 if ( mode .eq. 2 .or. mode .eq. 3 )
then
384 jac(5) = (-1.d0/rho)*int**(-1.d0/rho-1.d0)
395Integer Function tut_2dlagrstr( HSRW, HSCL, NODRV, N, M, NHESS, UsrMem )
396#ifdef dec_directives_win32
401 Integer,
Intent (IN) :: n, m, nhess
402 Integer,
Intent (IN OUT) :: nodrv
403 Integer,
Dimension(Nhess),
Intent (Out) :: hsrw, hscl
404 real*8,
Intent(IN OUT) :: usrmem(*)
460 hsrw(1) = 1; hscl(1) = 1
461 hsrw(2) = 2; hscl(2) = 2
462 hsrw(3) = 4; hscl(3) = 3
463 hsrw(4) = 5; hscl(4) = 5
472Integer Function tut_2dlagrval( X, U, HSRW, HSCL, HSVL, NODRV, N, M, NHESS, UsrMem )
473#ifdef dec_directives_win32
478 Integer,
Intent (IN) :: n, m, nhess
479 Integer,
Intent (IN OUT) :: nodrv
480 real*8,
Dimension(N),
Intent (IN) :: x
481 real*8,
Dimension(M),
Intent (IN) :: u
482 Integer,
Dimension(NHess),
Intent (IN) :: hsrw, hscl
483 real*8,
Dimension(NHess),
Intent (Out) :: hsvl
484 real*8,
Intent(IN OUT) :: usrmem(*)
493 real*8,
parameter :: w = 1.0d0
494 real*8,
parameter :: l0 = 0.1d0
495 real*8,
parameter :: pinp = 1.0d0
496 real*8,
parameter :: al = 0.16d0
497 real*8,
parameter :: ak = 2.0d0
498 real*8,
parameter :: ainp = 0.16d0
499 real*8,
parameter :: rho = 1.0d0
500 real*8,
parameter :: k = 4.0d0
557 if ( u(2) .ne. 0.d0 )
Then
560 hsvl(1) = (-rho) * (-rho-1.d0) * al * l**(-rho-2.d0) * u(2)
561 hsvl(2) = (-rho) * (-rho-1.d0) * ainp * inp**(-rho-2.d0) * u(2)
563 if ( u(4) .ne. 0.d0 )
then
564 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(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_debugfv(cntvect, debugfv)
turn Debugging of FDEval on and off.
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.
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.