104 INTEGER :: numcallback
105 INTEGER,
Dimension(:),
Pointer :: cntvect
110 real*8 x1, x2, y1, y2, det, tol
112 det = sqrt(1.d0+4000.d0*3992d0)
113 x1 = (1.d0+det)/2000.d0; y1 = 8.d0-x1
114 x2 = (1.d0-det)/2000.d0; y2 = 8.d0-x2
122 Allocate( cntvect(numcallback) )
129 coi_error = max( coi_error,
coidef_numnz( cntvect, 4 ) )
132 coi_error = max( coi_error,
coidef_optfile( cntvect,
'cns02.opt' ) )
143#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
144 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
147 If ( coi_error .ne. 0 )
THEN
149 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
151 call flog(
"Skipping Solve due to setup errors", 1 )
157 write(10,*)
'Solution set 1: x1=',x1,
' y1=',y1
158 write(10,*)
'Solution set 2: x2=',x2,
' y2=',y2
165 If ( coi_error /= 0 )
then
166 call flog(
"Case 1: Errors encountered during solution", 1 )
168 call flog(
"Case 1: Status or Solution routine was not called", 1 )
170 call flog(
"Case 1: Solver and Model Status was not as expected (1,16)", 1 )
172 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol ) .or. &
173 ( abs(
xprim(1)-x2) < tol .and. abs(
xprim(2)-y2) < tol )
175 write(10,*)
'Solution for case 1 was x=',
xprim(1),
' and y=',
xprim(2)
176 call flog(
"Case 1: Solver values were not correct.", 1 )
184 If ( coi_error /= 0 )
then
185 call flog(
"Case 2: Errors encountered during solution", 1 )
187 call flog(
"Case 2: Status or Solution routine was not called", 1 )
189 call flog(
"Case 2: Solver and Model Status was not as expected (1,16)", 1 )
191 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol ) .or. &
192 ( abs(
xprim(1)-x2) < tol .and. abs(
xprim(2)-y2) < tol )
194 write(10,*)
'Solution for case 2 was x=',
xprim(1),
' and y=',
xprim(2)
195 call flog(
"Case 2: Solver values were not correct.", 1 )
202 If ( coi_error /= 0 )
then
203 call flog(
"Case 3: Errors encountered during solution", 1 )
205 call flog(
"Case 3: Status or Solution routine was not called", 1 )
207 call flog(
"Case 3: Solver and Model Status was not as expected (1,16)", 1 )
209 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol )
211 write(10,*)
'Solution for case 3 was x=',
xprim(1),
' and y=',
xprim(2)
212 call flog(
"Case 3: Solver values were not correct.", 1 )
219 If ( coi_error /= 0 )
then
220 call flog(
"Case 4: Errors encountered during solution", 1 )
222 call flog(
"Case 4: Status or Solution routine was not called", 1 )
224 call flog(
"Case 4: Solver and Model Status was not as expected (1,5)", 1 )
226 call flog(
"Case 4: Infeasibility count is zero.", 1 )
230 write(*,*)
'End of Cns02 example. Return code=',coi_error
232 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
234 call flog(
"Successful Solve", 0 )
246 colsta, rowno, value, nlflag, n, m, nz, &
253 integer,
intent (in) :: n
254 integer,
intent (in) :: m
255 integer,
intent (in) :: nz
256 real*8,
intent (in out),
dimension(n) :: lower
257 real*8,
intent (in out),
dimension(n) :: curr
258 real*8,
intent (in out),
dimension(n) :: upper
259 integer,
intent (in out),
dimension(n) :: vsta
261 integer,
intent (out),
dimension(m) ::
type
262 integer,
intent (in out),
dimension(m) :: esta
264 real*8,
intent (in out),
dimension(m) :: rhs
265 integer,
intent (in out),
dimension(n+1) :: colsta
266 integer,
intent (out),
dimension(nz) :: rowno
267 integer,
intent (in out),
dimension(nz) :: nlflag
268 real*8,
intent (in out),
dimension(nz) ::
value
275 if ( casenum == 1 )
then
277 else if ( casenum == 2 )
then
279 else if ( casenum == 3 )
then
283 else if ( casenum == 4 )
then
357Integer Function cns02_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
358 n, nz, thread, usrmem )
363 integer,
intent (in) :: n
364 integer,
intent (in) :: rowno
365 integer,
intent (in) :: nz
366 real*8,
intent (in),
dimension(n) :: x
367 real*8,
intent (in out) :: g
368 real*8,
intent (in out),
dimension(n) :: jac
369 integer,
intent (in),
dimension(nz) :: jcnm
371 integer,
intent (in) :: mode
373 integer,
intent (in) :: ignerr
375 integer,
intent (in out) :: errcnt
377 integer,
intent (in) :: thread
382 if ( rowno .eq. 1 )
then
386 if ( mode .eq. 1 .or. mode .eq. 3 )
then
392 if ( mode .eq. 2 .or. mode .eq. 3 )
then
program cns02
Main program. A simple setup and call of CONOPT.
integer function cns02_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function cns02_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
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_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer function coidef_square(cntvect, square)
square models.
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_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
integer function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear 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)
real *8, dimension(:), pointer xprim