7#if defined(_WIN32) && !defined(_WIN64)
8#define dec_directives_win32
32#ifdef dec_directives_win32
46 INTEGER,
Dimension(:),
Pointer :: cntvect
100#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
101 coi_error = max( coi_error,
coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
104 If ( coi_error .ne. 0 )
THEN
106 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
108 call flog(
"Skipping Solve due to setup errors", 1 )
116 write(*,*)
'End of QP example 4. Return code=',coi_error
118 If ( coi_error /= 0 )
then
119 call flog(
"Errors encountered during solution", 1 )
121 call flog(
"Status or Solution routine was not called", 1 )
123 call flog(
"Solver and Model Status was not as expected (1,2)", 1 )
126 if (
coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
128 call flog(
"Successful Solve", 0 )
135Integer Function qp_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
136 colsta, rowno, value, nlflag, n, m, nz, &
138#ifdef dec_directives_win32
143 integer,
intent (in) :: n
144 integer,
intent (in) :: m
145 integer,
intent (in) :: nz
146 real*8,
intent (in out),
dimension(n) :: lower
147 real*8,
intent (in out),
dimension(n) :: curr
148 real*8,
intent (in out),
dimension(n) :: upper
149 integer,
intent (in out),
dimension(n) :: vsta
151 integer,
intent (out),
dimension(m) ::
type
152 integer,
intent (in out),
dimension(m) :: esta
154 real*8,
intent (in out),
dimension(m) :: rhs
155 integer,
intent (in out),
dimension(n+1) :: colsta
156 integer,
intent (out),
dimension(nz) :: rowno
157 integer,
intent (in out),
dimension(nz) :: nlflag
158 real*8,
intent (in out),
dimension(nz) ::
value
223Integer Function qp_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
224 n, nz, thread, usrmem )
225#ifdef dec_directives_win32
230 integer,
intent (in) :: n
231 integer,
intent (in) :: rowno
232 integer,
intent (in) :: nz
233 real*8,
intent (in),
dimension(n) :: x
234 real*8,
intent (in out) :: g
235 real*8,
intent (in out),
dimension(n) :: jac
236 integer,
intent (in),
dimension(nz) :: jcnm
238 integer,
intent (in) :: mode
240 integer,
intent (in) :: ignerr
242 integer,
intent (in out) :: errcnt
244 integer,
intent (in) :: thread
251 if ( rowno .eq. 1 )
then
255 if ( mode .eq. 1 .or. mode .eq. 3 )
then
271 if ( mode .eq. 2 .or. mode .eq. 3 )
then
281 jac(i) = jac(i) +
q(k) * (x(j)-
target(j))
282 jac(j) = jac(j) +
q(k) * (x(i)-
target(i))
297Integer Function qp_2ddir( X, DX, D2G, ROWNO, JCNM, NODRV, N, NJ, THREAD, USRMEM )
298#ifdef dec_directives_win32
303 INTEGER,
Intent(IN) :: rowno, n,
nj, thread
304 INTEGER,
Intent(IN OUT) :: nodrv
305 INTEGER,
Dimension(NJ),
Intent(IN) :: jcnm
306 real*8,
Dimension(N),
Intent(IN) :: x
307 real*8,
Dimension(N),
Intent(IN) :: dx
308 real*8,
Dimension(N),
Intent(OUT) :: d2g
309 real*8,
Intent(IN OUT) :: usrmem(*)
315 if ( rowno .eq. 1 )
then
323 d2g(i) = d2g(i) +
q(k) * dx(i)
325 d2g(i) = d2g(i) +
q(k) * dx(j)
326 d2g(j) = d2g(j) +
q(k) * dx(i)
339Integer Function qp_2dlagrstr( ROWNO, COLNO, NODRV, N, M, NHESS, USRMEM )
340#ifdef dec_directives_win32
345 INTEGER n, m, nhess, nodrv
347 INTEGER rowno(nhess), colno(nhess)
362Integer Function qp_2dlagrval( X, U, ROWNO, COLNO, VALUE, NODRV, N, M, NHESS, USRMEM )
363#ifdef dec_directives_win32
368 INTEGER n, m, nhess, nodrv
369 real*8 x(n), u(m), value(nhess), usrmem(*)
370 INTEGER rowno(nhess), colno(nhess)
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_2ddir(cntvect, coi_2ddir)
define callback routine for computing the second derivative for a constraint in a direction.
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_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)
real(8), dimension(nn, nn) q
program qp
Main program. A simple setup and call of CONOPT for a QP model.
integer function qp_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function qp_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
integer function qp_2ddir(x, dx, d2g, rowno, jcnm, nodrv, n, nj, thread, usrmem)
Computes the second derivative of a constraint in a direction.
integer function qp_2dlagrval(x, u, rowno, colno, value, nodrv, n, m, nhess, usrmem)
Compute the Lagrangian of the Hessian.
integer function qp_2dlagrstr(rowno, colno, nodrv, n, m, nhess, usrmem)
Specify the structure of the Lagrangian of the Hessian.