89#if defined(_WIN32) && !defined(_WIN64)
90#define dec_directives_win32
111#ifdef dec_directives_win32
122 INTEGER,
Dimension(:),
Pointer :: cntvect
140 coi_error = max( coi_error,
coidef_numnz( cntvect, 6 ) )
143 coi_error = max( coi_error,
coidef_optfile( cntvect,
'cns12.opt' ) )
154#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
155 coi_error = max( coi_error,
coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
158 If ( coi_error .ne. 0 )
THEN
160 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
162 call flog(
"Skipping Solve due to setup errors", 1 )
171 casenum = 1; scale = 1.d0
174 If ( coi_error /= 0 )
then
175 call flog(
"Case 1: Errors encountered during solution", 1 )
177 call flog(
"Case 1: Status or Solution routine was not called", 1 )
178 elseif (
sstat /= 1 )
then
179 call flog(
"Case 1: Solver Status was not 1 as expected.", 1 )
181 if (
mstat == 16 )
then
184 if ( abs(
uprim(1)-scale)>tol )
then
185 call flog(
"Case 1: Bad e1 level.", 1 )
187 else if ( abs(
uprim(2)-0)>tol )
then
188 call flog(
"Case 1: Bad e2 level.", 1 )
190 else if ( abs(
uprim(3)-0)>tol )
then
191 call flog(
"Case 1: Bad e3 level.", 1 )
193 else if (
mstat /= 5 )
then
194 call flog(
"Case 1: Model Status was not as expected either 5 or 16.", 1 )
196 call flog(
"Case 1: Infeasibility count was zero.", 1 )
200#if defined (notfinished)
204 If ( coi_error /= 0 )
then
205 call flog(
"Case 2: Errors encountered during solution", 1 )
207 call flog(
"Case 2: Status or Solution routine was not called", 1 )
209 call flog(
"Case 2: Solver and Model Status was not as expected (1,16)", 1 )
211 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol ) .or. &
212 ( abs(
xprim(1)-x2) < tol .and. abs(
xprim(2)-y2) < tol )
214 write(10,*)
'Solution for case 2 was x=',
xprim(1),
' and y=',
xprim(2)
215 call flog(
"Case 2: Solver values were not correct.", 1 )
222 If ( coi_error /= 0 )
then
223 call flog(
"Case 3: Errors encountered during solution", 1 )
225 call flog(
"Case 3: Status or Solution routine was not called", 1 )
227 call flog(
"Case 3: Solver and Model Status was not as expected (1,16)", 1 )
229 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol )
231 write(10,*)
'Solution for case 3 was x=',
xprim(1),
' and y=',
xprim(2)
232 call flog(
"Case 3: Solver values were not correct.", 1 )
239 If ( coi_error /= 0 )
then
240 call flog(
"Case 4: Errors encountered during solution", 1 )
242 call flog(
"Case 4: Status or Solution routine was not called", 1 )
244 call flog(
"Case 4: Solver and Model Status was not as expected (1,5)", 1 )
246 call flog(
"Case 4: Infeasibility count is zero.", 1 )
251 write(*,*)
'End of Cns12 example. Return code=',coi_error
253 if (
coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
255 call flog(
"Successful Solve", 0 )
266Integer Function cns12_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
267 colsta, rowno, value, nlflag, n, m, nz, &
269#ifdef dec_directives_win32
274 integer,
intent (in) :: n
275 integer,
intent (in) :: m
276 integer,
intent (in) :: nz
277 real*8,
intent (in out),
dimension(n) :: lower
278 real*8,
intent (in out),
dimension(n) :: curr
279 real*8,
intent (in out),
dimension(n) :: upper
280 integer,
intent (in out),
dimension(n) :: vsta
282 integer,
intent (out),
dimension(m) ::
type
283 integer,
intent (in out),
dimension(m) :: esta
285 real*8,
intent (in out),
dimension(m) :: rhs
286 integer,
intent (in out),
dimension(n+1) :: colsta
287 integer,
intent (out),
dimension(nz) :: rowno
288 integer,
intent (in out),
dimension(nz) :: nlflag
289 real*8,
intent (in out),
dimension(nz) ::
value
296 if ( casenum == 1 )
then
379Integer Function cns12_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
380 n, nz, thread, usrmem )
381#ifdef dec_directives_win32
386 integer,
intent (in) :: n
387 integer,
intent (in) :: rowno
388 integer,
intent (in) :: nz
389 real*8,
intent (in),
dimension(n) :: x
390 real*8,
intent (in out) :: g
391 real*8,
intent (in out),
dimension(n) :: jac
392 integer,
intent (in),
dimension(nz) :: jcnm
394 integer,
intent (in) :: mode
396 integer,
intent (in) :: ignerr
398 integer,
intent (in out) :: errcnt
400 integer,
intent (in) :: thread
405 if ( rowno .eq. 1 )
then
409 if ( mode .eq. 1 .or. mode .eq. 3 )
then
415 if ( mode .eq. 2 .or. mode .eq. 3 )
then
integer function cns12_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
program cns12
Main program. A simple setup and call of CONOPT.
integer function cns12_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
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_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_square(cntvect, square)
square models.
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_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
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(:), pointer xprim
real *8, dimension(:), pointer uprim