7#if defined(_WIN32) && !defined(_WIN64)
8#define dec_directives_win32
28#ifdef dec_directives_win32
39 INTEGER,
Dimension(:),
Pointer :: cntvect
56 coi_error = max( coi_error,
coidef_optfile( cntvect,
'tutorial.opt' ) )
67#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
68 coi_error = max( coi_error,
coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
71 If ( coi_error .ne. 0 )
THEN
73 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
75 call flog(
"Skipping Solve due to setup errors", 1 )
87 write(*,*)
'End of Tutorial example. Return code=',coi_error
89 If ( coi_error /= 0 )
then
90 call flog(
"Errors encountered during solution", 1 )
92 call flog(
"Status or Solution routine was not called", 1 )
94 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
95 elseif ( abs(
obj-0.572943d0 ) > 0.000001d0 )
then
96 call flog(
"Incorrect objective returned", 1 )
101 if (
coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
103 call flog(
"Successful Solve", 0 )
110Integer Function tut_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
111 colsta, rowno, value, nlflag, n, m, nz, &
113#ifdef dec_directives_win32
117 integer,
intent (in) :: n
118 integer,
intent (in) :: m
119 integer,
intent (in) :: nz
120 real*8,
intent (in out),
dimension(n) :: lower
121 real*8,
intent (in out),
dimension(n) :: curr
122 real*8,
intent (in out),
dimension(n) :: upper
123 integer,
intent (in out),
dimension(n) :: vsta
125 integer,
intent (out),
dimension(m) ::
type
126 integer,
intent (in out),
dimension(m) :: esta
128 real*8,
intent (in out),
dimension(m) :: rhs
129 integer,
intent (in out),
dimension(n+1) :: colsta
130 integer,
intent (out),
dimension(nz) :: rowno
131 integer,
intent (in out),
dimension(nz) :: nlflag
132 real*8,
intent (in out),
dimension(nz) ::
value
247Integer Function tut_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
248 n, nz, thread, usrmem )
249#ifdef dec_directives_win32
253 integer,
intent (in) :: n
254 integer,
intent (in) :: rowno
255 integer,
intent (in) :: nz
256 real*8,
intent (in),
dimension(n) :: x
257 real*8,
intent (in out) :: g
258 real*8,
intent (in out),
dimension(n) :: jac
259 integer,
intent (in),
dimension(nz) :: jcnm
261 integer,
intent (in) :: mode
263 integer,
intent (in) :: ignerr
265 integer,
intent (in out) :: errcnt
267 integer,
intent (in) :: thread
273 real*8 :: l, inp, out, p
277 real*8,
parameter :: w = 1.0d0
278 real*8,
parameter :: l0 = 0.1d0
279 real*8,
parameter :: pinp = 1.0d0
280 real*8,
parameter :: al = 0.16d0
281 real*8,
parameter :: ak = 2.0d0
282 real*8,
parameter :: ainp = 0.16d0
283 real*8,
parameter :: rho = 1.0d0
284 real*8,
parameter :: k = 4.0d0
285 real*8 :: hold1, hold2, hold3
299 if ( rowno .eq. 1 )
then
303 if ( mode .eq. 1 .or. mode .eq. 3 )
then
309 if ( mode .eq. 2 .or. mode .eq. 3 )
then
316 elseif ( rowno .eq. 2 )
then
320 hold1 = (al*l**(-rho) + ak*k**(-rho) + ainp*inp**(-rho))
321 hold2 = hold1 ** ( -1.d0/rho )
325 if ( mode .eq. 1 .or. mode .eq. 3 )
then
331 if ( mode .eq. 2 .or. mode .eq. 3 )
then
332 hold3 = hold2 / hold1
333 jac(1) = hold3 * al * l ** (-rho-1.d0)
334 jac(2) = hold3 * ainp * inp ** (-rho-1.d0)
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)
subroutine checkdual(case, minmax)
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_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
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_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, parameter maximize
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.