CONOPT
Loading...
Searching...
No Matches
conopt.f90
Go to the documentation of this file.
1! CONOPT Fortran API
2!
3! Copyright (C) 1995-2025 GAMS Software GmbH
4! Copyright (C) 1995-2025 GAMS Development Corporation
5
6!> @file conopt.f90
7!! @ingroup PUBLICAPI_FILES
8!! @brief public Fortran API source file
9
10#if defined(_WIN32) && !defined(_WIN64)
11#define dec_directives_win32
12#endif
13
14module conopt
15!
16! Definition of the interface for the CONOPT4 Library
17!
18!> @cond KEEP_F90_INTERFACE
19 interface
20!> @endcond
21!
22! Routines used for initialization purposes
23!
24 !> @cond UNDOCUMENTED_F90API
25 ! returns the size the Control Vector must have, measured in standard Integer units.
26 function coidef_size( ) bind(c, name = "COIDEF_Size")
27#if defined (dec_directives_win32)
28!DEC$ ATTRIBUTES STDCALL :: COIDEF_Size
29#endif
30 use, intrinsic :: iso_c_binding
31 implicit none
32 integer(c_int) :: COIDEF_Size
33 end function coidef_size
34 !> @endcond
35
36 !> initializes the Control Vector by placing default values in the various positions.
37 !! @attention Either this method or conopt::coi_create() must be called.
38 !!
39 !! There is currently no error checking and this method will always return 0.
40 !!
41 !! If you have multiple models with multiple Control Vectors then you must call either this method
42 !! or conopt::coi_create() to create a control vector for each. If you solve a sequence of different
43 !! models then you can use the same Control Vector provided you don't need to
44 !! reinitialize it. If the control vector must be reinitialized, then it is
45 !! necessary to call conopt::coi_free() followed by conopt::coi_create() between the
46 !! solves.
47 !!
48 !! @param cntvect the control vector
49 !!
50 !! @ingroup THE_CONTROL_VECTOR_F90
51 function coidef_ini( CntVect ) bind(c, name = "COIDEF_Ini")
52#if defined (dec_directives_win32)
53!DEC$ ATTRIBUTES STDCALL :: COIDEF_Ini
54#endif
55 use, intrinsic :: iso_c_binding
56 implicit none
57 integer(c_int), dimension(*), intent(inout) :: cntvect
58 integer(c_int) :: coidef_ini
59 end function coidef_ini
60
61 !> @cond UNDOCUMENTED_F90API
62 !> initialisation method for Fortran applications.
63 !!
64 !! This method will initialise the control vector and set the parameters associated with the base and array indices.
65 !!
66 !! @param cntvect the control vector
67 !!
68 !! @ingroup THE_CONTROL_VECTOR_F90
69 !!
70 function coidef_inifort( CntVect ) bind(c, name = "COIDEF_IniFort")
71#if defined (dec_directives_win32)
72!DEC$ ATTRIBUTES STDCALL :: COIDEF_IniFort
73#endif
74 use, intrinsic :: iso_c_binding
75 implicit none
76 integer(c_int), dimension(*), intent(inout) :: cntvect
77 integer(c_int) :: coidef_inifort
78 end function coidef_inifort
79 !> @endcond
80!
81! Routines used to register sizes
82!
83 !> defines the number of variables in the model.
84 !! @attention Mandatory routine. The number must be positive.
85 !!
86 !! defines the number of variables in the model. The number does not include
87 !! any slack or artificial variables.
88 !!
89 !! @param cntvect the control vector
90 !! @param numvar the number of variables
91 !!
92 !! @ingroup REGISTRATION_OF_SIZES_F90
93 !!
94 function coidef_numvar( CntVect, NumVar ) bind(c, name = "COIDEF_NumVar")
95#if defined (dec_directives_win32)
96!DEC$ ATTRIBUTES STDCALL :: COIDEF_NumVar
97#endif
98 use, intrinsic :: iso_c_binding
99 implicit none
100 integer(c_int), dimension(*), intent(inout) :: cntvect
101 integer(c_int), value :: numvar
102 integer(c_int) :: coidef_numvar
103 end function coidef_numvar
104
105 !> defines the number of constraints in the model.
106 !!
107 !! @attention Mandatory routine. The number must be positive.
108 !!
109 !! defines the number of constraints in the model. The number includes the
110 !! objective function if the objective is defined as an expression (see
111 !! coidef_objcon() and coidef_objvar()).
112 !!
113 !! @param cntvect the control vector
114 !! @param numcon the number of constraints
115 !!
116 !! @ingroup REGISTRATION_OF_SIZES_F90
117 !!
118 function coidef_numcon( CntVect, NumCon ) bind(c, name = "COIDEF_NumCon")
119#if defined (dec_directives_win32)
120!DEC$ ATTRIBUTES STDCALL :: COIDEF_NumCon
121#endif
122 use, intrinsic :: iso_c_binding
123 implicit none
124 integer(c_int), dimension(*), intent(inout) :: cntvect
125 integer(c_int), value :: numcon
126 integer(c_int) :: coidef_numcon
127 end function coidef_numcon
128
129 !> defines the number of nonzero elements in the Jacobian.
130 !!
131 !! @attention Mandatory routine. The number must be positive.
132 !!
133 !! defines the number of nonzero elements in the Jacobian of the model (the
134 !! matrix of first derivatives of all constraints with respect to all variables).
135 !!
136 !! @param cntvect the control vector
137 !! @param numnz the number of nonzero elements
138 !!
139 !! @ingroup REGISTRATION_OF_SIZES_F90
140 !!
141 function coidef_numnz( CntVect, NumNz ) bind(c, name = "COIDEF_NumNz")
142#if defined (dec_directives_win32)
143!DEC$ ATTRIBUTES STDCALL :: COIDEF_NumNz
144#endif
145 use, intrinsic :: iso_c_binding
146 implicit none
147 integer(c_int), dimension(*), intent(inout) :: cntvect
148 integer(c_int), value :: numnz
149 integer(c_int) :: coidef_numnz
150 end function coidef_numnz
151
152 !> defines the Number of Nonlinear Nonzeros.
153 !!
154 !! @attention Mandatory routine.
155 !!
156 !! defines the number of nonlinear nonzeros in the Jacobian. The number is zero
157 !! if the model is linear and positive if the model is nonlinear.
158 !!
159 !! @param cntvect the control vector
160 !! @param numnlnz the number of nonlinear nonzeros
161 !!
162 !! @ingroup REGISTRATION_OF_SIZES_F90
163 !!
164 function coidef_numnlnz( CntVect, NumNlNz ) bind(c, name = "COIDEF_NumNlNz")
165#if defined (dec_directives_win32)
166!DEC$ ATTRIBUTES STDCALL :: COIDEF_NumNlNz
167#endif
168 use, intrinsic :: iso_c_binding
169 implicit none
170 integer(c_int), dimension(*), intent(inout) :: cntvect
171 integer(c_int), value :: numnlnz
172 integer(c_int) :: coidef_numnlnz
173 end function coidef_numnlnz
174
175 !> defines the Number of Hessian Nonzeros.
176 !!
177 !! defines the number of nonzeros in the Hessian. The number is zero
178 !! if the model is linear and positive if the model is nonlinear.
179 !!
180 !! @param cntvect the control vector
181 !! @param numhess the number of nonzeros in Hessian
182 !!
183 !! @ingroup REGISTRATION_OF_SIZES_F90
184 !!
185 function coidef_numhess( CntVect, NumHess ) bind(c, name = "COIDEF_NumHess")
186#if defined (dec_directives_win32)
187!DEC$ ATTRIBUTES STDCALL :: COIDEF_NumHess
188#endif
189 use, intrinsic :: iso_c_binding
190 implicit none
191 integer(c_int), dimension(*), intent(inout) :: cntvect
192 integer(c_int), value :: numhess
193 integer(c_int) :: coidef_numhess
194 end function coidef_numhess
195!
196! Routines used to register the objective
197!
198 !> defines the Optimization Direction.
199 !!
200 !! defines the optimization direction. `OptDir = +1` defines maximization and
201 !! `OptDir = -1` defines minimization. Setting an optimization direction is optional. If
202 !! no optimization direction is set, the CONOPT will search for a feasible solution and
203 !! then stop.
204 !!
205 !! @param cntvect the control vector
206 !! @param optdir the optimization direction
207 !!
208 !! @ingroup REGISTRATION_OF_SIZES_F90
209 !!
210 function coidef_optdir( CntVect, OptDir ) bind(c, name = "COIDEF_OptDir")
211#if defined (dec_directives_win32)
212!DEC$ ATTRIBUTES STDCALL :: COIDEF_OptDir
213#endif
214 use, intrinsic :: iso_c_binding
215 implicit none
216 integer(c_int), dimension(*), intent(inout) :: cntvect
217 integer(c_int), value :: optdir
218 integer(c_int) :: coidef_optdir
219 end function coidef_optdir
220
221 !> defines the Objective Constraint.
222 !!
223 !! \note The constraint must be a Free Row, see argument `TYPE` in
224 !! `ReadMatrix` in section \ref API_READMATRIX_F90 "ReadMatrix".
225 !!
226 !! If both an objective variable and constraint are set, the last one set will
227 !! be used in the optimization. You can turn a previously defined objective off by defining variable
228 !! or constraint 0 as the objective (Fortran notation) or variable or
229 !! constraint -1 (C notation).
230 !!
231 !! @param cntvect the control vector
232 !! @param objcon the index of the objective constraint
233 !!
234 !! @ingroup REGISTRATION_OF_SIZES_F90
235 !!
236 function coidef_objcon( CntVect, ObjCon ) bind(c, name = "COIDEF_ObjCon")
237#if defined (dec_directives_win32)
238!DEC$ ATTRIBUTES STDCALL :: COIDEF_ObjCon
239#endif
240 use, intrinsic :: iso_c_binding
241 implicit none
242 integer(c_int), dimension(*), intent(inout) :: cntvect
243 integer(c_int), value :: objcon
244 integer(c_int) :: coidef_objcon
245 end function coidef_objcon
246
247 !> defines the Objective Variable.
248 !!
249 !! @param cntvect the control vector
250 !! @param objvar the index of the objective variable
251 !!
252 !! @ingroup REGISTRATION_OF_SIZES_F90
253 !!
254 function coidef_objvar( CntVect, ObjVar ) bind(c, name = "COIDEF_ObjVar")
255#if defined (dec_directives_win32)
256!DEC$ ATTRIBUTES STDCALL :: COIDEF_ObjVar
257#endif
258 use, intrinsic :: iso_c_binding
259 implicit none
260 integer(c_int), dimension(*), intent(inout) :: cntvect
261 integer(c_int), value :: objvar
262 integer(c_int) :: coidef_objvar
263 end function coidef_objvar
264!
265! Routines used to register the license information
266!
267 !> @defgroup DEF_COI_LICENSE ""
268 !! define the License Information.
269 !!
270 !! The license consists of three integer codes and a string that defines the user.
271 !! If the license is not defined or if it is incorrect then CONOPT will run in
272 !! small-scale demo mode and it will only be able to solve small models.
273 !!
274 !! \if HIDDEN_DOC
275 !! where the last argument must hold the length of `LicString`, e.g. <i>in the form
276 !! of `strlen(LicString)`.</i> The length is added to conform to Fortran calling
277 !! conventions.
278 !! \endif
279 !!
280 !! @param licint1 the first license integer code
281 !! @param licint2 the second license integer code
282 !! @param licint3 the third license integer code
283 !! @param licstring the license string
284
285 !> @copydoc DEF_COI_LICENSE
286 !! @param cntvect the control vector
287 !!
288 !! @ingroup REGISTRATION_OF_OPTIONS_F90
289 !!
290 function coidef_license( CntVect, LicInt1, LicInt2, LicInt3, Licstring )
291#if defined (dec_directives_win32)
292!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_License
293!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_LICENSE'::COIDEF_License
294#endif
295 use, intrinsic :: iso_c_binding
296 implicit none
297 integer(c_int), dimension(*), intent(inout) :: cntvect
298 character(len=*,kind=c_char), intent(in) :: licstring
299 integer(c_int), intent(in) :: licint1, licint2, licint3
300 integer(c_int) :: coidef_license
301 end function coidef_license
302!
303! Routines used to register various options
304!
305 !> @defgroup DEF_COI_ITLIM ""
306 !! define the Iteration Limit.
307 !!
308 !! By default CONOPT uses an iteration limit of <b>1 million iterations</b>.
309 !! This method can be used to set a new iteration limit.
310 !!
311 !! The call is optional.
312 !!
313 !! @param itlim the iteration limit
314
315 !> @copydoc DEF_COI_ITLIM
316 !! @param cntvect the control vector
317 !!
318 !! @ingroup REGISTRATION_OF_OPTIONS_F90
319 !!
320 function coidef_itlim( CntVect, ItLim ) bind(c, name = "COIDEF_ItLim")
321#if defined (dec_directives_win32)
322!DEC$ ATTRIBUTES STDCALL :: COIDEF_ItLim
323#endif
324 use, intrinsic :: iso_c_binding
325 implicit none
326 integer(c_int), dimension(*), intent(inout) :: cntvect
327 integer(c_int), value :: itlim
328 integer(c_int) :: coidef_itlim
329 end function coidef_itlim
330
331 !> @defgroup DEF_COI_ERRLIM ""
332 !! define the Error Limit.
333 !!
334 !! The nonlinear functions may not be defined in all points, and the user written
335 !! callback routine `FDEval` has an argument for
336 !! telling CONOPT if a point is “bad”. CONOPT may try other points to avoid “bad”
337 !! points up to a defined error limit (as specified by a call to this method). The default error limit is
338 !! <b>zero</b>, i.e. CONOPT will by default stop if a “bad” point is encountered.
339 !!
340 !! The call is optional.
341 !!
342 !! @param errlim the error limit
343
344 !> @copydoc DEF_COI_ERRLIM
345 !! @param cntvect the control vector
346 !!
347 !! @ingroup REGISTRATION_OF_OPTIONS_F90
348 !!
349 function coidef_errlim( CntVect, ErrLim ) bind(c, name = "COIDEF_ErrLim")
350#if defined (dec_directives_win32)
351!DEC$ ATTRIBUTES STDCALL :: COIDEF_ErrLim
352#endif
353 use, intrinsic :: iso_c_binding
354 implicit none
355 integer(c_int), dimension(*), intent(inout) :: cntvect
356 integer(c_int), value :: errlim
357 integer(c_int) :: coidef_errlim
358 end function coidef_errlim
359
360 !> @defgroup DEF_COI_DEBUGFV ""
361 !! turn Debugging of FDEval on and off.
362 !!
363 !! CONOPT has a Function and Derivative Debugger that can check if the function
364 !! values and derivatives computed by `FDEval` seem to be consistent and the
365 !! derivatives are consistent with the sparsity pattern of the Jacobian.
366 !!
367 !! The interpretation of `DebugFV` is:
368 !!
369 !! - <b>0:</b> No debugging (the default value)
370 !! - <b>-1:</b> Perform debugging in the initial point only.
371 !! - <b>+n:</b> Perform debugging every n’th iteration.
372 !!
373 !! The value can also be defined in an options file or options routine be setting
374 !! `LKDEBG`. Error messages and error return codes are described in
375 !! \ref API_ERROR_RETURN_CODES.
376 !!
377 !! @param debugfv the flag to enable debugging of function evaluations
378
379 !> @copydoc DEF_COI_DEBUGFV
380 !! @param cntvect the control vector
381 !!
382 !! @ingroup REGISTRATION_OF_OPTIONS_F90
383 !!
384 function coidef_debugfv( CntVect, DebugFV ) bind(c, name = "COIDEF_DebugFV")
385#if defined (dec_directives_win32)
386!DEC$ ATTRIBUTES STDCALL :: COIDEF_DebugFV
387#endif
388 use, intrinsic :: iso_c_binding
389 implicit none
390 integer(c_int), dimension(*), intent(inout) :: cntvect
391 integer(c_int), value :: debugfv
392 integer(c_int) :: coidef_debugfv
393 end function coidef_debugfv
394
395 !> @defgroup DEF_COI_MAXSUP ""
396 !! limit on superbasics.
397 !!
398 !! CONOPT uses a reduced gradient algorithm and performs its optimization in a
399 !! space of “Superbasic” variables. It needs a square matrix of size the number of
400 !! superbasic variables for estimated second order information. Since this matrix
401 !! can be fairly large, CONOPT places a limit that by default is at least <b>500
402 !! rows and columns</b>. For larger models CONOPT reserves around <b>25% of the
403 !! memory</b> needed for other purposes to this matrix. If you have a model with
404 !! many superbasic variables it may be advantageous to increase this limit.
405 !!
406 !! \note If you provide second order information, through one of the `2DLagr`,
407 !! `2DDir`, or `2DDirLag` routines, then it is usually not worth while to increase
408 !! `MaxSup`.
409 !!
410 !! The limit can also be defined in an options file or options routine by setting
411 !! `LFNSUP`.
412 !!
413 !! @param maxsup the limit on superbasics
414
415 !> @copydoc DEF_COI_MAXSUP
416 !! @param cntvect the control vector
417 !!
418 !! @ingroup REGISTRATION_OF_OPTIONS_F90
419 !!
420 function coidef_maxsup( CntVect, MaxSup ) bind(c, name = "COIDEF_MaxSup")
421#if defined (dec_directives_win32)
422!DEC$ ATTRIBUTES STDCALL :: COIDEF_MaxSup
423#endif
424 use, intrinsic :: iso_c_binding
425 implicit none
426 integer(c_int), dimension(*), intent(inout) :: cntvect
427 integer(c_int), value :: maxsup
428 integer(c_int) :: coidef_maxsup
429 end function coidef_maxsup
430
431 !> @defgroup DEF_COI_SQUARE ""
432 !! square models.
433 !!
434 !! CONOPT has a special routine for solve square sets of equations without an
435 !! objective function.
436 !!
437 !! @param square `Square = 1` informs CONOPT that the model is Square. `Square = 0` is the default used for an ordinary optimization model.
438
439 !> @copydoc DEF_COI_SQUARE
440 !! @param cntvect the control vector
441 !!
442 !! @ingroup REGISTRATION_OF_OPTIONS_F90
443 !!
444 function coidef_square( CntVect, Square ) bind(c, name = "COIDEF_Square")
445#if defined (dec_directives_win32)
446!DEC$ ATTRIBUTES STDCALL :: COIDEF_Square
447#endif
448 use, intrinsic :: iso_c_binding
449 implicit none
450 integer(c_int), dimension(*), intent(inout) :: cntvect
451 integer(c_int), value :: square
452 integer(c_int) :: coidef_square
453 end function coidef_square
454
455 !> @defgroup DEF_COI_EMPTYROW ""
456 !! allow empty rows.
457 !!
458 !! CONOPT performs many tests on the input data and by default it does not allow
459 !! empty rows, i.e. constraints that do not depend on any variables. In some
460 !! modeling systems environments it can be useful to allow empty rows.
461 !!
462 !! @param emptyrow 1 allows empty rows, 0 is the default behavior.
463
464 !> @copydoc DEF_COI_EMPTYROW
465 !! @param cntvect the control vector
466 !!
467 !! @ingroup REGISTRATION_OF_OPTIONS_F90
468 !!
469 function coidef_emptyrow( CntVect, EmptyRow ) bind(c, name = "COIDEF_EmptyRow")
470#if defined (dec_directives_win32)
471!DEC$ ATTRIBUTES STDCALL :: COIDEF_EmptyRow
472#endif
473 use, intrinsic :: iso_c_binding
474 implicit none
475 integer(c_int), dimension(*), intent(inout) :: cntvect
476 integer(c_int), value :: emptyrow
477 integer(c_int) :: coidef_emptyrow
478 end function coidef_emptyrow
479
480 !> @defgroup DEF_COI_EMPTYCOL ""
481 !! allow empty columns.
482 !!
483 !! CONOPT performs many tests on the input data and by default it does not allow
484 !! empty columns, i.e. variables that do not appear in any constraints. In some
485 !! modeling systems environments it can be useful to allow empty columns. To
486 !! bypass the usual tests you must inform CONOPT that empty columns should be
487 !! allowed.
488 !!
489 !! @param emptycol 1 allows empty columns, 0 is the default behaviour.
490
491 !> @copydoc DEF_COI_EMPTYCOL
492 !! @param cntvect the control vector
493 !!
494 !! @ingroup REGISTRATION_OF_OPTIONS_F90
495 !!
496 function coidef_emptycol( CntVect, EmptyCol ) bind(c, name = "COIDEF_EmptyCol")
497#if defined (dec_directives_win32)
498!DEC$ ATTRIBUTES STDCALL :: COIDEF_EmptyCol
499#endif
500 use, intrinsic :: iso_c_binding
501 implicit none
502 integer(c_int), dimension(*), intent(inout) :: cntvect
503 integer(c_int), value :: emptycol
504 integer(c_int) :: coidef_emptycol
505 end function coidef_emptycol
506
507 !> @defgroup DEF_COI_DEBUG2D ""
508 !! turn debugging of 2nd derivatives on and off.
509 !!
510 !! CONOPT has a rudimentary routine for checking if the 2<sup>nd</sup> derivatives
511 !! computed by `2DLagr`, `2DDir`, or `2DDirLag` seem to be consistent with the
512 !! derivatives computed by `FDEval`.
513 !!
514 !! The interpretation of `Debug2D` is:
515 !!
516 !! - <b>0:</b> No debugging (the default value)
517 !! - <b>-1:</b> Perform debugging in the initial point only.
518 !! - <b>+n:</b> Perform debugging every n’th iteration.
519 !!
520 !! The value can also be defined in an options file or options routine be setting
521 !! `LKDEB2`. Error return codes and examples of messages can be found in
522 !! \ref API_ERROR_RETURN_CODES.
523 !!
524 !! @param debug2d the flag to enable the debugging of the second derivative evaulations
525
526 !> @copydoc DEF_COI_DEBUG2D
527 !! @param cntvect the control vector
528 !!
529 !! @ingroup REGISTRATION_OF_OPTIONS_F90
530 !!
531 function coidef_debug2d( CntVect, Debug2D ) bind(c, name = "COIDEF_Debug2D")
532#if defined (dec_directives_win32)
533!DEC$ ATTRIBUTES STDCALL :: COIDEF_Debug2D
534#endif
535 use, intrinsic :: iso_c_binding
536 implicit none
537 integer(c_int), dimension(*), intent(inout) :: cntvect
538 integer(c_int), value :: debug2d
539 integer(c_int) :: coidef_debug2d
540 end function coidef_debug2d
541
542 !> define Optfile / Option order.
543 !!
544 !! By default CONOPT will first process the options defined in a file, see
545 !! coidef_optfile(), and the process the options defined via
546 !! a call-back routine. This method is called to change this order.
547 !!
548 !! The interpretation of `OptOrder` is:
549 !! - <b>0:</b> Process option defined via the option file
550 !! before options defined via the options callback. <i>(default
551 !! value)</i>
552 !! - <b>1:</b> Process option defined via the options callback
553 !! before options defined via options file.
554 !!
555 !! @param cntvect the control vector
556 !! @param optorder Option processing order
557 !!
558 !! @ingroup REGISTRATION_OF_OPTIONS_F90
559 !!
560 function coidef_optorder( CntVect, OptOrder ) bind(c, name = "COIDEF_OptOrder")
561#if defined (dec_directives_win32)
562!DEC$ ATTRIBUTES STDCALL :: COIDEF_OptOrder
563#endif
564 use, intrinsic :: iso_c_binding
565 implicit none
566 integer(c_int), dimension(*), intent(inout) :: cntvect
567 integer(c_int), value :: optorder
568 integer(c_int) :: coidef_optorder
569 end function coidef_optorder
570
571 !> @defgroup DEF_COI_DISCONT ""
572 !! allow discontinuous functions and derivatives.
573 !!
574 !! CONOPT assumes that all functions are smooth with smooth derivatives and that
575 !! these functions and derivatives can be computed with a noise level close to the
576 !! machine precision. CONOPT can also be used on models with non-smooth
577 !! derivatives, e.g. models with `ABS` or `MIN` or `MAX` functions, but the
578 !! algorithm will still work as if all functions and derivatives are smooth. A few
579 !! internal tests may fail for a model with discontinuous derivatives. The call will only
580 !! turn the tests off or on; it will not alter the optimization behavior.
581 !!
582 !! @param discont 1 allows discontinuous functions and derivatives, 0 is the default behaviour.
583
584 !> @copydoc DEF_COI_DISCONT
585 !! @param cntvect the control vector
586 !!
587 !! @ingroup REGISTRATION_OF_OPTIONS_F90
588 !!
589 function coidef_discont( CntVect, DisCont ) bind(c, name = "COIDEF_DisCont")
590#if defined (dec_directives_win32)
591!DEC$ ATTRIBUTES STDCALL :: COIDEF_DisCont
592#endif
593 use, intrinsic :: iso_c_binding
594 implicit none
595 integer(c_int), dimension(*), intent(inout) :: cntvect
596 integer(c_int), value :: discont
597 integer(c_int) :: coidef_discont
598 end function coidef_discont
599
600 !> @defgroup DEF_COI_THREADS ""
601 !! number of threads allowed internally in CONOPT.
602 !!
603 !! As discussed in \ref API_MULTI_THREADING CONOPT can use
604 !! multiple threads using the `OpenMP` standard. The multi-threading capability is
605 !! divided into three areas: <b>(1)</b> Internally in CONOPT, <b>(2)</b> during
606 !! function and derivative calls using the `FDEval` callback routine,
607 !! and <b>(3)</b> during directional 2<sup>nd</sup> derivative
608 !! calls using the 2DDir callback routine.
609 !!
610 !! This method is used to define how many threads can be used internally
611 !! in CONOPT. The argument `ThreadS` is interpreted as follows:
612 !!
613 !! - <b>ThreadS = 0:</b> use `MaxThread` threads, as many as the `OpenMP` system will allocate,
614 !! - <b>ThreadS = 1:</b> use one thread <i>(this is the default)</i>,
615 !! - <b>ThreadS > 1:</b> use `min(ThreadS,MaxThread)` threads.
616 !!
617 !! @param threads the number of threads allowed internally
618
619 !> @copydoc DEF_COI_THREADS
620 !! @param cntvect the control vector
621 !!
622 !! @ingroup REGISTRATION_OF_OPTIONS_F90
623 !!
624 function coidef_threads( CntVect, ThreadS ) bind(c, name = "COIDEF_ThreadS")
625#if defined (dec_directives_win32)
626!DEC$ ATTRIBUTES STDCALL :: COIDEF_ThreadS
627#endif
628 use, intrinsic :: iso_c_binding
629 implicit none
630 integer(c_int), dimension(*), intent(inout) :: cntvect
631 integer(c_int), value :: threads
632 integer(c_int) :: coidef_threads
633 end function coidef_threads
634
635 !> @defgroup DEF_COI_THREADF ""
636 !! number of threads allowed for simultaneous `FDEval` calls.
637 !!
638 !! This method can be used to define how many threads can be used for
639 !! simultaneous `FDEval` calls. The argument `ThreadF` is interpreted as follows:
640 !!
641 !! - <b>ThreadF = 0:</b> use the same number of threads as internally in CONOPT
642 !! <i>(this is the default)</i>,
643 !!
644 !! - <b>ThreadF = 1:</b> use one thread,
645 !!
646 !! - <b>ThreadF > 1:</b> use `min(ThreadS,ThreadF)` threads.
647 !!
648 !! @param threadf the number of threads for simultaneous `FDEval` calls
649
650 !> @copydoc DEF_COI_THREADF
651 !! @param cntvect the control vector
652 !!
653 !! @ingroup REGISTRATION_OF_OPTIONS_F90
654 !!
655 function coidef_threadf( CntVect, ThreadF ) bind(c, name = "COIDEF_ThreadF")
656#if defined (dec_directives_win32)
657!DEC$ ATTRIBUTES STDCALL :: COIDEF_ThreadF
658#endif
659 use, intrinsic :: iso_c_binding
660 implicit none
661 integer(c_int), dimension(*), intent(inout) :: cntvect
662 integer(c_int), value :: threadf
663 integer(c_int) :: coidef_threadf
664 end function coidef_threadf
665
666 !> @defgroup DEF_COI_THREAD2D ""
667 !! number of threads allowed for simultaneous `2DDir` calls.
668 !!
669 !! This method can be used to define how many threads can be used
670 !! for simultaneous `2DDir` calls. The argument `Thread2D` is interpreted as
671 !! follows:
672 !!
673 !! - <b>Thread2D = 0:</b> use the same number of threads as internally in CONOPT
674 !! <i>(this is the default)</i>,
675 !!
676 !! - <b>Thread2D = 1:</b> use one thread,
677 !!
678 !! - <b>Thread2D > 1:</b> use `min(Thread2D,ThreadF)` threads.
679 !!
680 !! @param thread2d the number of threads for simultaneous `2DDir` calls
681
682 !> @copydoc DEF_COI_THREAD2D
683 !! @param cntvect the control vector
684 !!
685 !! @ingroup REGISTRATION_OF_OPTIONS_F90
686 !!
687 function coidef_thread2d( CntVect, Thread2D ) bind(c, name = "COIDEF_Thread2D")
688#if defined (dec_directives_win32)
689!DEC$ ATTRIBUTES STDCALL :: COIDEF_Thread2D
690#endif
691 use, intrinsic :: iso_c_binding
692 implicit none
693 integer(c_int), dimension(*), intent(inout) :: cntvect
694 integer(c_int), value :: thread2d
695 integer(c_int) :: coidef_thread2d
696 end function coidef_thread2d
697
698 !> @defgroup DEF_COI_THREADC ""
699 !! check for thread compatibility.
700 !!
701 !! When using multiple threads, the result of the execution is in most cases
702 !! independent of the number of threads. However, a few operations mostly related
703 !! to summations can create slightly different results depending on the number of
704 !! threads, and therefore the results may depend on the number of threads.
705 !! `ThreadC` can be used to force reproducible results. The execution is done as
706 !! if there were `ThreadC` threads independent of the actual number of `ThreadS`
707 !! <i>(`ThreadS` > `ThreadC`)</i>.
708 !!
709 !! This method can be used to define how many threads CONOPT should simulate.
710 !! The argument `ThreadC` is interpreted as follows:
711 !!
712 !! - <b>ThreadC = 0:</b> let the execution be controlled by `ThreadS` defined above,
713 !! - <b>ThreadC > 1:</b> simulate the use of `ThreadC > ThreadS` threads.
714 !!
715 !! <b>The upper bound on `ThreadC` is currently 8.</b>
716 !!
717 !! @param threadc the number of threads CONOPT should simulate
718
719 !> @copydoc DEF_COI_THREADC
720 !! @param cntvect the control vector
721 !!
722 !! @ingroup REGISTRATION_OF_OPTIONS_F90
723 !!
724 function coidef_threadc( CntVect, ThreadC ) bind(c, name = "COIDEF_ThreadC")
725#if defined (dec_directives_win32)
726!DEC$ ATTRIBUTES STDCALL :: COIDEF_ThreadC
727#endif
728 use, intrinsic :: iso_c_binding
729 implicit none
730 integer(c_int), dimension(*), intent(inout) :: cntvect
731 integer(c_int), value :: threadc
732 integer(c_int) :: coidef_threadc
733 end function coidef_threadc
734
735 !> allow output to StdOut.
736 !!
737 !! CONOPT will by default not write to Standard Output or Fortran Write(*,*) to
738 !! avoid problems in certain Windowing environments. All communication goes via
739 !! callback routines. If there are errors during the initial setup of communication
740 !! it can sometimes be difficult to locate these errors. If you allow output to
741 !! Standard Output then CONOPT may provide some extra debugging information.
742 !!
743 !! @param cntvect the control vector
744 !! @param tostdout 1 to output to Standard Output, 0 to silence the output.
745 !!
746 !! @ingroup REGISTRATION_OF_OPTIONS_F90
747 !!
748 function coidef_stdout( CntVect, ToStdOut ) bind(c, name = "COIDEF_StdOut")
749#if defined (dec_directives_win32)
750!DEC$ ATTRIBUTES STDCALL :: COIDEF_StdOut
751#endif
752 use, intrinsic :: iso_c_binding
753 implicit none
754 integer(c_int), dimension(*), intent(inout) :: cntvect
755 integer(c_int), value :: tostdout
756 integer(c_int) :: coidef_stdout
757 end function coidef_stdout
758
759 !> @defgroup DEF_COI_CLEARM ""
760 !! ClearM
761 !!
762 !! @param clearm
763
764 !> @copydoc DEF_COI_CLEARM
765 !! @param cntvect the control vector
766 !!
767 !! @ingroup REGISTRATION_OF_OPTIONS_F90
768 !!
769 function coidef_clearm( CntVect, ClearM ) bind(c, name = "COIDEF_ClearM")
770#if defined (dec_directives_win32)
771!DEC$ ATTRIBUTES STDCALL :: COIDEF_ClearM
772#endif
773 use, intrinsic :: iso_c_binding
774 implicit none
775 integer(c_int), dimension(*), intent(inout) :: cntvect
776 integer(c_int), value :: clearm
777 integer(c_int) :: coidef_clearm
778 end function coidef_clearm
779
780 !> define zero noise level.
781 !!
782 !! CONOPT has a Function and Derivative Debugger that also tests whether variables that
783 !! should not appear in an equation actually have an influence on the function
784 !! value: the variables that should not appear are all perturbed by random amounts
785 !! and the function is called again. If the function changes by the slightest
786 !! amount, this must have been caused by one of the variables that should not
787 !! influence the equation, and an error has been identified.
788 !!
789 !! However, some implementations may give very small function changes as shown by
790 !! the following example: Equation \f$i\f$ depends on \f$\sum_{j \neq i}X(j)\f$.
791 !! Initially, compute \f$XS = \sum_{i}X(i)\f$ and the compute \f$XS-X(i)\f$ for
792 !! use in `Equation` \f$i\f$. Because of the round-off errors involved in
793 !! computing \f$XS-X(i)\f$, \f$X(i)\f$ may seem to appear in `Equation` \f$i\f$.
794 !! For these rare cases you may need to define a small <i>"zero noise level"</i>
795 !! and all derivatives less that this value will not be considered errors.
796 !! The default value is zero.
797 !!
798 !! @param cntvect the control vector
799 !! @param zeronoise the threshold for zero noise level in function derivatives
800 !!
801 !! @ingroup REGISTRATION_OF_OPTIONS_F90
802 !!
803 function coidef_zeronoise( CntVect, ZeroNoise ) bind(c, name = "COIDEF_ZeroNoise")
804#if defined (dec_directives_win32)
805!DEC$ ATTRIBUTES STDCALL :: COIDEF_ZeroNoise
806#endif
807 use, intrinsic :: iso_c_binding
808 implicit none
809 integer(c_int), dimension(*), intent(inout) :: cntvect
810 integer(c_int), value :: zeronoise
811 integer(c_int) :: coidef_zeronoise
812 end function coidef_zeronoise
813
814 !> @defgroup DEF_COI_RESLIM ""
815 !! define resource limit.
816 !!
817 !! CONOPT will by default allow the optimization to run for <b>1 million
818 !! seconds</b>. A new limit can be set by a call to this method.
819 !!
820 !! \note `ResLim` is a double precision number.
821 !!
822 !! @param reslim the solve time limit in seconds
823
824 !> @copydoc DEF_COI_RESLIM
825 !! @param cntvect the control vector
826 !!
827 !! @ingroup REGISTRATION_OF_OPTIONS_F90
828 !!
829 function coidef_reslim( CntVect, ResLim ) bind(c, name = "COIDEF_ResLim")
830#if defined (dec_directives_win32)
831!DEC$ ATTRIBUTES STDCALL :: COIDEF_ResLim
832#endif
833 use, intrinsic :: iso_c_binding
834 implicit none
835 integer(c_int), dimension(*), intent(inout) :: cntvect
836 real(c_double), value :: reslim
837 integer(c_int) :: coidef_reslim
838 end function coidef_reslim
839
840 !> factor for Hessian density relative to Jacobian density HessFac.
841 !!
842 !! CONOPT will not use the Hessian of the Lagrangian if it is too dense. The limit
843 !! on the number of nonzero Hessian elements (on an below the diagonal) is set to
844 !! `HessFac` times the number of nonlinear Jacobian elements,:vertical resize 120
845 !! and the default value of `HessFac` is 10. The assumption is
846 !! that computations involving a dense Hessian will be too expensive.
847 !!
848 !! The Hessian factor can also be defined by defining the option `RVHESS`.
849 !!
850 !! @param cntvect the control vector
851 !! @param hessfac the threshold factor for Hessian density relative to Jacobian density
852 !!
853 !! @ingroup REGISTRATION_OF_OPTIONS_F90
854 !!
855 function coidef_hessfac( CntVect, HessFac ) bind(c, name = "COIDEF_HessFac")
856#if defined (dec_directives_win32)
857!DEC$ ATTRIBUTES STDCALL :: COIDEF_HessFac
858#endif
859 use, intrinsic :: iso_c_binding
860 implicit none
861 integer(c_int), dimension(*), intent(inout) :: cntvect
862 real(c_double), value :: hessfac
863 integer(c_int) :: coidef_hessfac
864 end function coidef_hessfac
865
866 !> @defgroup DEF_COI_MAXHEAP ""
867 !! define Limit on Heap Memory.
868 !!
869 !! By default CONOPT will allocate the memory it needs from the computers heap
870 !! memory using `Allocate` or `malloc` calls. For very large models CONOPT may try
871 !! to allocate more than the available physical memory and the responsiveness of
872 !! the computer may suffer. This may not be acceptable in certain server
873 !! environments. This method is used to define a limit on the amount of heap
874 !! memory that CONOPT will allocate.
875 !! If CONOPT reaches a point where it needs more memory than allowed it will try
876 !! to continue without extra memory (if this is possible) or it will stop with an
877 !! out of memory message and the sovle will return the value <b>113</b> or
878 !! <b>114</b>.
879 !!
880 !! `MaxHeap` is measured in <b>MegaBytes</b>. A positive `MaxHeap` value indicates
881 !! a limit while `Maxheap = 0.0` indicates that the limit is set by the physical
882 !! memory or the virtual memory system on the machine. After you have solved a
883 !! model you can query the amount of memory actually used with the
884 !! coiget_maxheapused() or COIGET_MaxHeapUsed().
885 !!
886 !! The call is optional.
887 !!
888 !! @param maxheap the limit on heap memory
889
890 !> @copydoc DEF_COI_MAXHEAP ""
891 !! @param cntvect the control vector
892 !!
893 !! @ingroup REGISTRATION_OF_OPTIONS_F90
894 !!
895 function coidef_maxheap( CntVect, MaxHeap ) bind(c, name = "COIDEF_MaxHeap")
896#if defined (dec_directives_win32)
897!DEC$ ATTRIBUTES STDCALL :: COIDEF_MaxHeap
898#endif
899 use, intrinsic :: iso_c_binding
900 implicit none
901 integer(c_int), dimension(*), intent(inout) :: cntvect
902 real(c_double), value :: maxheap
903 integer(c_int) :: coidef_maxheap
904 end function coidef_maxheap
905
906 !> define callback routine for defining an options file.
907 !!
908 !! It is possible to define an options file with user defined values for certain
909 !! options. To define an options file you must write a callback routine that gives
910 !! CONOPT the file name (see \ref API_OPTFILE_F90 "OptFile") and register this optional
911 !! routine with a call to coidef_optfile() before CONOPT is started. The name of
912 !! your version of `OptFile` must be declared as external and given to
913 !! coidef_optfile() as its second argument.
914 !!
915 !! \note By default the options defined via an option file are processed before the
916 !! options defined via the callback routine (see coidef_option()). The order can be changed with a call to coidef_optorder().
917 !!
918 !! For the definition of the `Optfile` callback function, see \ref API_OPTFILE_F90 "Optfile"
919 !!
920 !! @param cntvect the control vector
921 !! @param optfile the pointer to the `OptFile` routine for providing the options file name
922 !!
923 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
924 !!
925 function coidef_optfile( CntVect, Optfile )
926#if defined (dec_directives_win32)
927!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_Optfile
928!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_OPTFILE'::COIDEF_Optfile
929#endif
930 use, intrinsic :: iso_c_binding
931 implicit none
932 integer(c_int), dimension(*), intent(inout) :: cntvect
933 character(len=*,kind=c_char) :: optfile
934 integer(c_int) :: coidef_optfile
935 end function coidef_optfile
936!
937! Routines used to reguster alternative interpretations of the interface
938!
939 !> @cond UNDOCUMENTED_F90API
940 !> define the Base index for vectors.
941 !!
942 !! Some of the vectors that are passed between CONOPT and the callback routines
943 !! point to other vectors. Examples are Row Indices and Start of Column pointers.
944 !! You must define to CONOPT if you use Fortran conventions with 1 as the first
945 !! element or C conventions with 0. The base will also determine how the index
946 !! of the objective is interpreted.
947 !!
948 !! @param cntvect the control vector
949 !! @param base the base index for vectors
950 !!
951 !! @ingroup REGISTRATION_OF_OPTIONS_F90
952 !!
953 function coidef_base( CntVect, Base ) bind(c, name = "COIDEF_Base")
954#if defined (dec_directives_win32)
955!DEC$ ATTRIBUTES STDCALL :: COIDEF_Base
956#endif
957 use, intrinsic :: iso_c_binding
958 implicit none
959 integer(c_int), dimension(*), intent(inout) :: cntvect
960 integer(c_int), value :: base
961 integer(c_int) :: coidef_base
962 end function coidef_base
963
964 !> define Fortran Conventions for Argument Passing.
965 !!
966 !! This is equivalent to calling coidef_base(1) in Fortran
967 !! or COIDEF_Base(1) in C.
968 !!
969 !! @param cntvect the control vector
970 !!
971 !! @ingroup REGISTRATION_OF_OPTIONS_F90
972 !!
973 function coidef_fortran( CntVect ) bind(c, name = "COIDEF_Fortran")
974#if defined (dec_directives_win32)
975!DEC$ ATTRIBUTES STDCALL :: COIDEF_Fortran
976#endif
977 use, intrinsic :: iso_c_binding
978 implicit none
979 integer(c_int), dimension(*), intent(inout) :: cntvect
980 integer(c_int) :: coidef_fortran
981 end function coidef_fortran
982
983 !> define C Conventions for Argument Passing.
984 !!
985 !! This is equivalent to calling coidef_base(0) in Fortran
986 !! or COIDEF_Base(0) in C.
987 !!
988 !! @param cntvect the control vector
989 !!
990 !! @ingroup REGISTRATION_OF_OPTIONS_F90
991 !!
992 function coidef_c( CntVect ) bind(c, name = "COIDEF_C")
993#if defined (dec_directives_win32)
994!DEC$ ATTRIBUTES STDCALL :: COIDEF_C
995#endif
996 use, intrinsic :: iso_c_binding
997 implicit none
998 integer(c_int), dimension(*), intent(inout) :: cntvect
999 integer(c_int) :: coidef_c
1000 end function coidef_c
1001 !> @endcond
1002
1003 !> handling of the initial status values.
1004 !!
1005 !! CONOPT can take advantage of initial ‘Status’ information about the variables
1006 !! and constraints. This is information of the type: Variable number \f$i\f$ is
1007 !! basic, variable \f$j\f$ is superbasic, variable \f$k\f$ is at lower bound
1008 !! etc.
1009 !!
1010 !! \note If you are going to provide Status information when building the model then
1011 !! CONOPT must be informed a call to this method with the second argument
1012 !! equal to 1 or 2 (depending on the definition you choose). You can turn it off
1013 !! again with another call with the value 0 (the default initial value).
1014 !!
1015 !! @param cntvect the control vector
1016 !! @param inistat the initial status
1017 !!
1018 !! @ingroup REGISTRATION_OF_OPTIONS_F90
1019 !!
1020 function coidef_inistat( CntVect, IniStat ) bind(c, name = "COIDEF_IniStat")
1021#if defined (dec_directives_win32)
1022!DEC$ ATTRIBUTES STDCALL :: COIDEF_IniStat
1023#endif
1024 use, intrinsic :: iso_c_binding
1025 implicit none
1026 integer(c_int), dimension(*), intent(inout) :: cntvect
1027 integer(c_int), value :: inistat
1028 integer(c_int) :: coidef_inistat
1029 end function coidef_inistat
1030
1031 !> @defgroup DEF_COI_FVINCLIN ""
1032 !! include the linear terms in function evaluations.
1033 !!
1034 !! CONOPT assumes that the function values returned by the user defined callback
1035 !! routine `FDEval` only include nonlinear terms, i.e. terms that correspond to
1036 !! variables that appear nonlinearly in the particular constraint.
1037 !!
1038 !! If you prefer your `FDEval` routine to return function values as the
1039 !! sum of both linear and nonlinear terms then you must inform CONOPT by calling
1040 !! this method with `FVincLin = 1`. `FVincLin = 0` will return CONOPT to
1041 !! the default behavior.
1042 !!
1043 !! @param fvinclin the linear terms in functions
1044
1045 !> @copydoc DEF_COI_FVINCLIN
1046 !! @param cntvect the control vector
1047 !!
1048 !! @ingroup REGISTRATION_OF_OPTIONS_F90
1049 !!
1050 function coidef_fvinclin( CntVect, FVIncLin ) bind(c, name = "COIDEF_FVincLin")
1051#if defined (dec_directives_win32)
1052!DEC$ ATTRIBUTES STDCALL :: COIDEF_FVincLin
1053#endif
1054 use, intrinsic :: iso_c_binding
1055 implicit none
1056 integer(c_int), dimension(*), intent(inout) :: cntvect
1057 integer(c_int), value :: fvinclin
1058 integer(c_int) :: coidef_fvinclin
1059 end function coidef_fvinclin
1060
1061 !> @defgroup DEF_COI_FVFORALL ""
1062 !! call the FDEval for all constraints, including linear constraints.
1063 !!
1064 !! CONOPT will usually only call the user provided `FDEval` routine for
1065 !! nonlinear constraints. However, some models may have constant terms included
1066 !! in `FDEval` instead of in the right hand side, also for linear constraints.
1067 !!
1068 !! \note If your `FDEval` routine is programmed this way you must tell CONOPT to
1069 !! call `FDEval` for all constraints, linear as well as nonlinear, by calling
1070 !! this method with `FVforAll = 1`. Calling again with `FVforAll = 0` will
1071 !! return CONOPT to its default behavior.
1072 !!
1073 !! @param fvforall the linear constraints in functions
1074
1075 !> @copydoc DEF_COI_FVFORALL
1076 !! @param cntvect the control vector
1077 !!
1078 !! @ingroup REGISTRATION_OF_OPTIONS_F90
1079 !!
1080 function coidef_fvforall( CntVect, FVforAll ) bind(c, name = "COIDEF_FVforAll")
1081#if defined (dec_directives_win32)
1082!DEC$ ATTRIBUTES STDCALL :: COIDEF_FVforAll
1083#endif
1084 use, intrinsic :: iso_c_binding
1085 implicit none
1086 integer(c_int), dimension(*), intent(inout) :: cntvect
1087 integer(c_int), value :: fvforall
1088 integer(c_int) :: coidef_fvforall
1089 end function coidef_fvforall
1090!
1091! Routines used to register the callback so CONOPT can find them:
1092!
1093 !> define callback routine for providing the matrix data to CONOPT.
1094 !!
1095 !! CONOPT gets information about the structure of the model from a user written
1096 !! callback routine referred to as `ReadMatrix`. You must register this routine with a call to
1097 !! this method before CONOPT is started. The name
1098 !! of your version of `ReadMatrix` must be declared as external.
1099 !!
1100 !! \note There is no type checking for the argument list on External functions in
1101 !! Fortran, so you must be very careful.
1102 !!
1103 !! @param cntvect the control vector
1104 !! @param coi_readmatrix the pointer to the user-defined `ReadMatrix` callback routine
1105 !!
1106 !! @ingroup REGISTRATION_OF_MANDATORY_CALLBACK_ROUTINES_F90
1107 !!
1108 function coidef_readmatrix( CntVect, coi_ReadMatrix )
1109#if defined (dec_directives_win32)
1110!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_ReadMatrix
1111!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_READMATRIX'::COIDEF_ReadMatrix
1112#endif
1113 use, intrinsic :: iso_c_binding
1114 implicit none
1115 integer(c_int), dimension(*), intent(inout) :: cntvect
1116 integer(c_int), external :: coi_readmatrix
1117 integer(c_int) :: coidef_readmatrix
1118 end function coidef_readmatrix
1119
1120 !> define callback routine for performing function and derivative evaluations.
1121 !!
1122 !! CONOPT get information about the nonlinearities from a user written callback
1123 !! routine referred to as `FDEval`. You
1124 !! must register this routine with a call to this method before CONOPT is
1125 !! started. The name of your version of `FDEval` must be declared as external.
1126 !!
1127 !! @param cntvect the control vector
1128 !! @param coi_fdeval pointer to the user-defined `FDEval` callback routine
1129 !!
1130 !! @ingroup REGISTRATION_OF_MANDATORY_CALLBACK_ROUTINES_F90
1131 !!
1132 function coidef_fdeval( CntVect, coi_FDEval )
1133#if defined (dec_directives_win32)
1134!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_FDEval
1135!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_FDEVAL'::COIDEF_FDEval
1136#endif
1137 use, intrinsic :: iso_c_binding
1138 implicit none
1139 integer(c_int), dimension(*), intent(inout) :: cntvect
1140 integer(c_int), external :: coi_fdeval
1141 integer(c_int) :: coidef_fdeval
1142 end function coidef_fdeval
1143
1144 !> define callback routine to perform initialization tasks for the function and derivative evaluation.
1145 !!
1146 !! The nonlinear `FDEval` routine is usually called for several constraints in one
1147 !! point before being called for constraints in another point. An optional user
1148 !! provided `FDEvalIni` routine can be used to perform common tasks that are
1149 !! needed in preparation for a new point. You must register this
1150 !! routine with a call to this method before CONOPT is started. The name of
1151 !! your version of `FDEvalIni` must be declared as external.
1152 !!
1153 !! @param cntvect the control vector
1154 !! @param coi_fdevalini the pointer to the `FDEvalIni` routine for initializing data before nonlinear evaluations
1155 !!
1156 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1157 !!
1158 function coidef_fdevalini( CntVect, coi_FDEvalIni )
1159#if defined (dec_directives_win32)
1160!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_FDEvalIni
1161!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_FDEVALINI'::COIDEF_FDEvalIni
1162#endif
1163 use, intrinsic :: iso_c_binding
1164 implicit none
1165 integer(c_int), dimension(*), intent(inout) :: cntvect
1166 integer(c_int), external :: coi_fdevalini
1167 integer(c_int) :: coidef_fdevalini
1168 end function coidef_fdevalini
1169
1170 !> define callback routine for the termination of the function and derivative evaluation.
1171 !!
1172 !! After the nonlinear `FDEval` routine has been called for several constraints in
1173 !! one point an optional user provided `FDEvalEnd` routine can be used to perform
1174 !! common cleanup tasks. If you want to use this possibility you must
1175 !! register this routine with a call to this method before CONOPT is
1176 !! started. The name of your version of `FDEvalEnd` must be declared as external.
1177 !!
1178 !! @param cntvect the control vector
1179 !! @param coi_fdevalend the pointer to the `FDEvalEnd` routine for cleanup after nonlinear evaluations
1180 !!
1181 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1182 !!
1183 function coidef_fdevalend( CntVect, coi_FDEvalEnd )
1184#if defined (dec_directives_win32)
1185!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_FDEvalEnd
1186!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_FDEVALEND'::COIDEF_FDEvalEnd
1187#endif
1188 use, intrinsic :: iso_c_binding
1189 implicit none
1190 integer(c_int), dimension(*), intent(inout) :: cntvect
1191 integer(c_int), external :: coi_fdevalend
1192 integer(c_int) :: coidef_fdevalend
1193 end function coidef_fdevalend
1194
1195 !> define callback routine for returning the completion status.
1196 !!
1197 !! When CONOPT has finished optimizing it informs the modeler about the status of
1198 !! the solution: Optimal, Infeasible, Normal completion, Interrupted by function
1199 !! evaluation errors etc. This is done by a call to a user written callback routine
1200 !! referred to as `Status`. You must
1201 !! register this routine with a call to this method before CONOPT is started.
1202 !! The name of your version of `Status` must be declared as external.
1203 !!
1204 !! @param cntvect the control vector
1205 !! @param coi_status pointer to the user-defined `Status` callback routine
1206 !!
1207 !! @ingroup REGISTRATION_OF_MANDATORY_CALLBACK_ROUTINES_F90
1208 !!
1209 function coidef_status( CntVect, coi_Status )
1210#if defined (dec_directives_win32)
1211!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_Status
1212!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_STATUS'::COIDEF_Status
1213#endif
1214 use, intrinsic :: iso_c_binding
1215 implicit none
1216 integer(c_int), dimension(*), intent(inout) :: cntvect
1217 integer(c_int), external :: coi_status
1218 integer(c_int) :: coidef_status
1219 end function coidef_status
1220
1221 !> define callback routine for returning the final solution values.
1222 !!
1223 !! After the user written callback Status has been called CONOPT will usually
1224 !! (unless the Status indicates some serious error condition) call another user
1225 !! written callback routine called `Solution` to inform the modeler about the
1226 !! actual primal and dual solution values. You must register this routine with a call to
1227 !! this method before CONOPT is started. The name of your version of
1228 !! `Solution` must be declared as external.
1229 !!
1230 !! @param cntvect the control vector
1231 !! @param coi_solution the pointer to the user-defined `Solution` callback routine
1232 !!
1233 !! @ingroup REGISTRATION_OF_MANDATORY_CALLBACK_ROUTINES_F90
1234 !!
1235 function coidef_solution( CntVect, coi_Solution )
1236#if defined (dec_directives_win32)
1237!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_Solution
1238!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_SOLUTION'::COIDEF_Solution
1239#endif
1240 use, intrinsic :: iso_c_binding
1241 implicit none
1242 integer(c_int), dimension(*), intent(inout) :: cntvect
1243 integer(c_int), external :: coi_solution
1244 integer(c_int) :: coidef_solution
1245 end function coidef_solution
1246
1247 !> define callback routine for handling messages returned during the solution process.
1248 !!
1249 !! Apart from the solution itself, CONOPT provides a number of messages about
1250 !! progress and problems during the optimization. Most messages are provided in the
1251 !! form of character strings that are passed as arguments to a user written
1252 !! callback routine called `Message`. It is the modelers responsibility to handle
1253 !! these messages. You must register this routine with a call
1254 !! to this method before CONOPT is started. The name of your version of
1255 !! `Message` must be declared as external.
1256 !!
1257 !! @param cntvect the control vector
1258 !! @param coi_message the pointer to the user-defined `Message` callback routine
1259 !!
1260 !! @ingroup REGISTRATION_OF_MANDATORY_CALLBACK_ROUTINES_F90
1261 !!
1262 function coidef_message( CntVect, coi_Message )
1263#if defined (dec_directives_win32)
1264!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_Message
1265!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_MESSAGE'::COIDEF_Message
1266#endif
1267 use, intrinsic :: iso_c_binding
1268 implicit none
1269 integer(c_int), dimension(*), intent(inout) :: cntvect
1270 integer(c_int), external :: coi_message
1271 integer(c_int) :: coidef_message
1272 end function coidef_message
1273
1274 !> define callback routine for returning error messages for row, column or Jacobian elements.
1275 !!
1276 !! Certain messages, including error messages, refer to a particular variable
1277 !! and/or constraint. The mandatory `ErrMsg` callback routine is used to format and
1278 !! display these messages. If
1279 !! you want to supply it you must register it with a call to this method before
1280 !! CONOPT is started. The name of your version of `ErrMsg` must be declared as
1281 !! external.
1282 !!
1283 !! @param cntvect the control vector
1284 !! @param coi_errmsg pointer to the user-defined `ErrMsg` callback routine
1285 !!
1286 !! @ingroup REGISTRATION_OF_MANDATORY_CALLBACK_ROUTINES_F90
1287 !!
1288 function coidef_errmsg( CntVect, coi_ErrMsg )
1289#if defined (dec_directives_win32)
1290!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_ErrMsg
1291!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_ERRMSG'::COIDEF_ErrMsg
1292#endif
1293 use, intrinsic :: iso_c_binding
1294 implicit none
1295 integer(c_int), dimension(*), intent(inout) :: cntvect
1296 integer(c_int), external :: coi_errmsg
1297 integer(c_int) :: coidef_errmsg
1298 end function coidef_errmsg
1299
1300 !> define callback routine for monitoring the algorithmic progress.
1301 !!
1302 !! If you would like to write your own iteration log then CONOPT can provide the
1303 !! necessary information to a user written callback routine called `Progress`.
1304 !! `Progress` can also be used to communicate a Stop messages back to CONOPT. If you
1305 !! would like CONOPT to call your `Progress` routine you must register it with a
1306 !! call to this method before CONOPT is started. The name of your version of
1307 !! `Progress` must be declared as external.
1308 !!
1309 !! @param cntvect the control vector
1310 !! @param coi_progress the pointer to the `Progress` routine for logging iteration progress or sending stop messages
1311 !!
1312 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1313 !!
1314 function coidef_progress( CntVect, coi_Progress )
1315#if defined (dec_directives_win32)
1316!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_Progress
1317!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_PROGRESS'::COIDEF_Progress
1318#endif
1319 use, intrinsic :: iso_c_binding
1320 implicit none
1321 integer(c_int), dimension(*), intent(inout) :: cntvect
1322 integer(c_int), external :: coi_progress
1323 integer(c_int) :: coidef_progress
1324 end function coidef_progress
1325
1326 !> define callback routine for defining runtime options.
1327 !!
1328 !! An alternative or supplement to an options file is an option callback routine
1329 !! that CONOPT calls repeatedly to get non-default option values. To use this
1330 !! method you must write a callback routine that gives CONOPT the names and values
1331 !! of the non default options and you must
1332 !! register this optional routine with a call to this method before CONOPT is
1333 !! started. The name of your version of Option must be declared as external.
1334 !!
1335 !! \note By default the options defined via an option file are processed before the options defined via the
1336 !! callback routine.
1337 !!
1338 !! @param cntvect the control vector
1339 !! @param coi_option the pointer to the `Option` routine for setting non-default option values
1340 !!
1341 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1342 !!
1343 function coidef_option( CntVect, coi_Option )
1344#if defined (dec_directives_win32)
1345!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_Option
1346!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_OPTION'::COIDEF_Option
1347#endif
1348 use, intrinsic :: iso_c_binding
1349 implicit none
1350 integer(c_int), dimension(*), intent(inout) :: cntvect
1351 integer(c_int), external :: coi_option
1352 integer(c_int) :: coidef_option
1353 end function coidef_option
1354
1355 !> define callback routine for providing the triangular order information.
1356 !!
1357 !! During preprocessing of a model CONOPT can provide information about the
1358 !! solution sequence of triangular parts of a model. This can be useful for
1359 !! analyzing certain types of infeasibilities. If you want to use this feature you
1360 !! must register a `TriOrd` callback routine with a call to this method before CONOPT is started. The
1361 !! name of your version of `TriOrd` must be declared as external.
1362 !!
1363 !! @param cntvect the control vector
1364 !! @param coi_triord the pointer to the `TriOrd` routine for analyzing the solution sequence of triangular parts.
1365 !!
1366 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1367 !!
1368 function coidef_triord( CntVect, coi_TriOrd )
1369#if defined (dec_directives_win32)
1370!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_TriOrd
1371!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_TRIORD'::COIDEF_TriOrd
1372#endif
1373 use, intrinsic :: iso_c_binding
1374 implicit none
1375 integer(c_int), dimension(*), intent(inout) :: cntvect
1376 integer(c_int), external :: coi_triord
1377 integer(c_int) :: coidef_triord
1378 end function coidef_triord
1379
1380 !> define callback routine for performing function and derivative evaluations on intervals.
1381 !!
1382 !! During preprocessing CONOPT can take advantage of interval information for
1383 !! function values and derivatives if this is available. If you can provide
1384 !! interval information you can register an optional `FDInterval` function and
1385 !! derivative evaluation callback routine with a call to this method before CONOPT is
1386 !! started. The name of your version of `FDInterval` must be declared as external.
1387 !!
1388 !! @param cntvect the control vector
1389 !! @param coi_fdinterval the pointer to the `FDInterval` routine for providing interval data for functions and derivatives
1390 !!
1391 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1392 !!
1393 function coidef_fdinterval( CntVect, coi_FDInterval )
1394#if defined (dec_directives_win32)
1395!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_FDInterval
1396!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_FDINTERVAL'::COIDEF_FDInterval
1397#endif
1398 use, intrinsic :: iso_c_binding
1399 implicit none
1400 integer(c_int), dimension(*), intent(inout) :: cntvect
1401 integer(c_int), external :: coi_fdinterval
1402 integer(c_int) :: coidef_fdinterval
1403 end function coidef_fdinterval
1404
1405 !> define callback routine for computing the second derivative for a constraint in a direction.
1406 !!
1407 !! CONOPT can take advantage of 2<sup>nd</sup> derivatives in various forms, as
1408 !! discussed in the \ref API_DEFINING_SECOND_ORDER_INFO_F90 section. If you can provide
1409 !! directional 2<sup>nd</sup> derivatives of the individual constraints then you
1410 !! can register an optional `2DDir` callback routine with a call to this method before CONOPT is
1411 !! started. The name of your version of `2DDir` must be declared as external.
1412 !!
1413 !! @param cntvect the control vector
1414 !! @param coi_2ddir the pointer to the `2DDir` callback routine for supplying directional second derivatives of constraints
1415 !!
1416 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1417 !!
1418 function coidef_2ddir( CntVect, coi_2dDir )
1419#if defined (dec_directives_win32)
1420!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DDir
1421!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DDIR'::COIDEF_2DDir
1422#endif
1423 use, intrinsic :: iso_c_binding
1424 implicit none
1425 integer(c_int), dimension(*), intent(inout) :: cntvect
1426 integer(c_int), external :: coi_2ddir
1427 integer(c_int) :: coidef_2ddir
1428 end function coidef_2ddir
1429
1430 !> define callback routine for initializing the computation of second derivatives for a constraint in a direction.
1431 !!
1432 !! The `2DDir` routine defined above will be called in batches. First it will be
1433 !! called in one point and with a given direction for all nonlinear constraints
1434 !! except pre-triangular constraints and constraints with dual variables equal to
1435 !! zero, then for the same constraints in the same point but with a different
1436 !! direction, and later again in a new point with a new direction and possibly for
1437 !! a different set of constraints (due to changes in the dual variables). If the
1438 !! modeler would like to perform certain common tasks each time the point or the
1439 !! direction changes then this can be done in a callback routine defined with
1440 !! this method.
1441 !! If you would like to provide this initialization routine then you can register an optional
1442 !! `2DDirIni` callback routine with a call to this method before CONOPT is started. The name
1443 !! of your version of `2DDirIni` must be declared as external.
1444 !!
1445 !! @param cntvect the control vector
1446 !! @param coi_2ddirini the pointer to the `2DDirIni` callback routine for initializing tasks when the point or direction changes
1447 !!
1448 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1449 !!
1450 function coidef_2ddirini( CntVect, coi_2dDirIni )
1451#if defined (dec_directives_win32)
1452!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DDirIni
1453!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DDIRINI'::COIDEF_2DDirIni
1454#endif
1455 use, intrinsic :: iso_c_binding
1456 implicit none
1457 integer(c_int), dimension(*), intent(inout) :: cntvect
1458 integer(c_int), external :: coi_2ddirini
1459 integer(c_int) :: coidef_2ddirini
1460 end function coidef_2ddirini
1461
1462 !> define callback routine for termination the computation of second derivatives for a constraint in a direction.
1463 !!
1464 !! After the `2DDir` routine defined above has been called for a number of
1465 !! constraints in a particular point and in a particular direction the optional
1466 !! `2DDirEnd` routine will be called if it has been defined by the modeler. in
1467 !! batches. If the modeler would like to perform certain common cleanup tasks each
1468 !! time the `2DDir` calls for a point or a direction have been finished then this
1469 !! can be done in a callback routine defined with this method as discussed in
1470 !! \ref API_2DDIREND_F90 "2DDirEnd section". If you would like to provide this
1471 !! termination routine then you can register an optional `2DDirEnd` callback
1472 !! routine with a call to
1473 !! this method before CONOPT is started. The name of your version of
1474 !! `2DDirEnd` must be declared as external.
1475 !!
1476 !! @param cntvect the control vector
1477 !! @param coi_2ddirend the pointer to the `2DDirEnd` callback routine for cleanup after processing a point or direction
1478 !!
1479 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1480 !!
1481 function coidef_2ddirend( CntVect, coi_2dDirEnd )
1482#if defined (dec_directives_win32)
1483!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DDirEnd
1484!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DDIREND'::COIDEF_2DDirEnd
1485#endif
1486 use, intrinsic :: iso_c_binding
1487 implicit none
1488 integer(c_int), dimension(*), intent(inout) :: cntvect
1489 integer(c_int), external :: coi_2ddirend
1490 integer(c_int) :: coidef_2ddirend
1491 end function coidef_2ddirend
1492
1493 !> define callback routine for computing the second derivative of the Lagrangian in a direction.
1494 !!
1495 !! CONOPT can take advantage of 2<sup>nd</sup> derivatives in various forms as
1496 !! discussed in \ref API_DEFINING_SECOND_ORDER_INFO_F90. If you can provide directional
1497 !! 2<sup>nd</sup> derivatives of the Lagrangian then you can register an optional
1498 !! `2DDirLagr` callback routine with a call to this method before CONOPT is started. The name
1499 !! of your version of `2DDirLagr` must be declared as external.
1500 !!
1501 !! @param cntvect the control vector
1502 !! @param coi_2ddirlagr the pointer to the `2DDirLagr` callback routine for supplying directional second derivatives of the Lagrangian
1503 !!
1504 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1505 !!
1506 function coidef_2ddirlagr( CntVect, coi_2dDirLagr )
1507#if defined (dec_directives_win32)
1508!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DDirLagr
1509!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DDIRLAGR'::COIDEF_2DDirLagr
1510#endif
1511 use, intrinsic :: iso_c_binding
1512 implicit none
1513 integer(c_int), dimension(*), intent(inout) :: cntvect
1514 integer(c_int), external :: coi_2ddirlagr
1515 integer(c_int) :: coidef_2ddirlagr
1516 end function coidef_2ddirlagr
1517
1518 function coidef_2dlagrsize( CntVect, coi_2dLagrSize )
1519#if defined (dec_directives_win32)
1520!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DLagrSize
1521!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DLAGRSIZE'::COIDEF_2DLagrSize
1522#endif
1523 use, intrinsic :: iso_c_binding
1524 implicit none
1525 integer(c_int), dimension(*), intent(inout) :: cntvect
1526 integer(c_int), external :: coi_2dlagrsize
1527 integer(c_int) :: coidef_2dlagrsize
1528 end function coidef_2dlagrsize
1529
1530 !> define callback routine for providing the structure of the second derivatives of the Lagrangian.
1531 !!
1532 !! CONOPT can take advantage of 2<sup>nd</sup> derivatives in various forms,
1533 !! including the Hessian of the Lagrangian and directional 2<sup>nd</sup>
1534 !! derivatives. If you can provide the Hessian of the Lagrangian as a sparse
1535 !! matrix, you can register the optional 2DLagrStr callback routine with a call to this method
1536 !! before CONOPT is started. The name of your version of 2DLagrStr must be declared
1537 !! as external.
1538 !!
1539 !! @param cntvect the control vector.
1540 !! @param coi_2dlagrstr the pointer to the 2DLagrStr callback routine, which defines the structure of the Hessian of the Lagrangian.
1541 !!
1542 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1543 !!
1544 function coidef_2dlagrstr( CntVect, coi_2dLagrStr )
1545#if defined (dec_directives_win32)
1546!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DLagrStr
1547!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DLAGRSTR'::COIDEF_2DLagrStr
1548#endif
1549 use, intrinsic :: iso_c_binding
1550 implicit none
1551 integer(c_int), dimension(*), intent(inout) :: cntvect
1552 integer(c_int), external :: coi_2dlagrstr
1553 integer(c_int) :: coidef_2dlagrstr
1554 end function coidef_2dlagrstr
1555
1556 !> define callback routine for computing the values of the second derivatives of the Lagrangian.
1557 !!
1558 !! CONOPT can take advantage of 2<sup>nd</sup> derivatives in various forms,
1559 !! including the Hessian of the Lagrangian and directional 2<sup>nd</sup>
1560 !! derivatives. If you can provide the Hessian of the Lagrangian as a sparse
1561 !! matrix, you can register the optional 2DLagrVal callback routine with a call to this method
1562 !! before CONOPT is started. The name of your version of 2DLagrVal must be declared
1563 !! as external.
1564 !!
1565 !! @param cntvect the control vector.
1566 !! @param coi_2dlagrval the pointer to the 2DLagrVal callback routine, which provides the values of the Hessian of the Lagrangian.
1567 !!
1568 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1569 !!
1570 function coidef_2dlagrval( CntVect, coi_2dLagrVal )
1571#if defined (dec_directives_win32)
1572!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_2DLagrVal
1573!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_2DLAGRVAL'::COIDEF_2DLagrVal
1574#endif
1575 use, intrinsic :: iso_c_binding
1576 implicit none
1577 integer(c_int), dimension(*), intent(inout) :: cntvect
1578 integer(c_int), external :: coi_2dlagrval
1579 integer(c_int) :: coidef_2dlagrval
1580 end function coidef_2dlagrval
1581
1582 !> provides a pointer to user memory that is available in all callback functions. NOTE: this is not a callback function, but a
1583 !! pointer to a data structure.
1584 !!
1585 !! Communication between the modeler’s main program and the callback routines can
1586 !! take place via common blocks or global variables. For use in a thread safe
1587 !! application CONOPT offers an alternative communication mechanism called `User
1588 !! Memory`. The modeler can register a memory location (usually the address of the
1589 !! start of a vector) as `User Memory` and CONOPT will provide this address to all
1590 !! callback routines. You register `User Memory` by calling this method with
1591 !! the `User Memory` as the second argument.
1592 !!
1593 !! @param cntvect the control vector
1594 !! @param usrmem the user memory location for communication between the main program and callback routines
1595 !!
1596 !! @ingroup REGISTRATION_OF_OPTIONAL_CALLBACK_ROUTINES_F90
1597 !!
1598 function coidef_usrmem( CntVect, UsrMem )
1599#if defined (dec_directives_win32)
1600!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: COIDEF_UsrMem
1601!DEC$ ATTRIBUTES DECORATE, ALIAS: 'COIDEF_USRMEM'::COIDEF_UsrMem
1602#endif
1603 use, intrinsic :: iso_c_binding
1604 implicit none
1605 integer(c_int), dimension(*), intent(inout) :: cntvect
1606 type(*) :: usrmem
1607 integer(c_int) :: coidef_usrmem
1608 end function coidef_usrmem
1609
1610!
1611! The actual SOLVE call
1612!
1613
1614 !> @defgroup DEF_COI_SOLVE ""
1615 !! method for starting the solving process of CONOPT.
1616
1617 !> @copydoc DEF_COI_SOLVE
1618 !!
1619 !! @param cntvect the control vector
1620 !!
1621 !! @ingroup UTILITY_ROUTINES_F90
1622 function coi_solve( CntVect ) bind(c, name = "COI_Solve")
1623#if defined (dec_directives_win32)
1624!DEC$ ATTRIBUTES STDCALL :: COI_Solve
1625#endif
1626 use, intrinsic :: iso_c_binding
1627 implicit none
1628 integer(c_int), dimension(*), intent(inout) :: cntvect
1629 integer(c_int) :: coi_solve
1630 end function coi_solve
1631!
1632! Various Utility routines
1633!
1634 !> returns the version number. It can be used to ensure that the modeler is linked to the correct version of the
1635 !! CONOPT DLL.
1636 !!
1637 !! @param major major version number
1638 !! @param minor minor version number
1639 !! @param patch patch version number
1640 !!
1641 !! @ingroup UTILITY_ROUTINES_F90
1642 Subroutine coiget_version( major, minor, patch ) bind(c, name = "COIGET_Version")
1643#if defined (dec_directives_win32)
1644!DEC$ ATTRIBUTES STDCALL :: COIGET_Version
1645#endif
1646 use, intrinsic :: iso_c_binding
1647 implicit none
1648 integer(c_int), intent(inout) :: major, minor, patch
1649 end Subroutine coiget_version
1650
1651 !> After a model has been solved this method will return the amount of heap memory used.
1652 !!
1653 !! @param cntvect the control vector
1654 !!
1655 !! @ingroup UTILITY_ROUTINES_F90
1656 function coiget_maxheapused( CntVect ) bind(c, name = "COIGET_MaxHeapUsed")
1657#if defined (dec_directives_win32)
1658!DEC$ ATTRIBUTES STDCALL :: COIGET_MaxHeapUsed
1659#endif
1660 use, intrinsic :: iso_c_binding
1661 implicit none
1662 integer(c_int), dimension(*), intent(inout) :: cntvect
1663 real(c_double) :: coiget_maxheapused
1664 end function coiget_maxheapused
1665
1666 !> returns the maximum number of threads that can be used by CONOPT.
1667 !!
1668 !! If you are using multiple threads it may be necessary to know in advance how many threads CONOPT can use. If
1669 !! called inside a parallel loop, this method will return one---indicating that CONOPT cannot use multiple
1670 !! threads when CONOPT itself is called in parallel. Therefore, this method should be called in some sequential
1671 !! initialization code and not inside a function evaluation routine, that could be called in parallel.
1672 !!
1673 !! @param cntvect the control vector
1674 !!
1675 !! @ingroup UTILITY_ROUTINES_F90
1676 function coiget_maxthreads( CntVect ) bind(c, name = "COIGET_MaxThreads")
1677#if defined (dec_directives_win32)
1678!DEC$ ATTRIBUTES STDCALL :: COIGET_MaxThreads
1679#endif
1680 use, intrinsic :: iso_c_binding
1681 implicit none
1682 integer(c_int), dimension(*), intent(inout) :: cntvect
1683 integer(c_int) :: coiget_maxthreads
1684 end function coiget_maxthreads
1685
1686 !> returns the range errors that were encountered.
1687 !!
1688 !! @param cntvect the control vector
1689 !!
1690 !! @ingroup UTILITY_ROUTINES_F90
1691 function coiget_rangeerrors( CntVect ) bind(c, name = "COIGET_RangeErrors")
1692#if defined (dec_directives_win32)
1693!DEC$ ATTRIBUTES STDCALL :: COIGET_RangeErrors
1694#endif
1695 use, intrinsic :: iso_c_binding
1696 implicit none
1697 integer(c_int), dimension(*), intent(inout) :: cntvect
1698 integer(c_int) :: coiget_rangeerrors
1699 end function coiget_rangeerrors
1700
1701!> @cond KEEP_F90_INTERFACE
1702 end interface
1703!> @endcond
1704
1705 contains
1706
1707 !> initializes CONOPT and creates the control vector.
1708 !!
1709 !! This method calls an initialization step for the Control Vector that places default values in the various positions.
1710 !! In addition, the initialization will set the parameters associated with the
1711 !! base and array indices, i.e. starting at 1 for Fortran and 0 for C.
1712 !!
1713 !! If you have multiple models with multiple Control Vectors then you must call
1714 !! this method for each control vector. If you solve a sequence of different
1715 !! models then you can use the same Control Vector provided you don't need to
1716 !! reinitialize it. If the control vector must be reinitialized, then it is
1717 !! necessary to call conopt::coi_free() followed by conopt::coi_create() between the
1718 !! solves.
1719 !!
1720 !! @param cntvect the control vector
1721 !!
1722 !! @ingroup THE_CONTROL_VECTOR_F90
1723 function coi_create( CntVect )
1724 use, intrinsic :: iso_c_binding
1725 implicit none
1726 integer(c_int), dimension(:), pointer :: cntvect
1727 integer(c_int) :: coi_create
1728
1729 integer(c_int) :: numcallback, alloc_stat
1730
1731 numcallback = coidef_size()
1732 allocate( cntvect(numcallback), stat = alloc_stat )
1733 if ( alloc_stat /= 0 ) then
1734 coi_create = 4 ! MemoryProblem
1735 else
1736 coi_create = coidef_inifort( cntvect )
1737 endif
1738
1739 end function coi_create
1740
1741 !> frees the control vector.
1742 !!
1743 !! @param cntvect the control vector
1744 !!
1745 !! @ingroup THE_CONTROL_VECTOR_F90
1746 function coi_free( CntVect )
1747 use, intrinsic :: iso_c_binding
1748 implicit none
1749 integer(c_int), dimension(:), pointer :: cntvect
1750 integer(c_int) :: coi_free
1751
1752 integer(c_int) :: alloc_stat
1753
1754 if ( associated( cntvect ) ) then
1755 deallocate( cntvect, stat = alloc_stat )
1756 if ( alloc_stat /= 0 ) then
1757 coi_free = 4 ! MemoryProblem
1758 else
1759 nullify( cntvect )
1760 coi_free = 0
1761 endif
1762 else
1763 coi_free = 4 ! MemoryProblem
1764 endif
1765
1766 end function coi_free
1767
1768end module conopt
program fvforall
Main program. A simple setup and call of CONOPT.
Definition fvforall.f90:20
program fvinclin
Main program. A simple setup and call of CONOPT.
Definition fvinclin.f90:20
integer(c_int) function coidef_message(cntvect, coi_message)
define callback routine for handling messages returned during the solution process.
Definition conopt.f90:1265
integer(c_int) function coidef_solution(cntvect, coi_solution)
define callback routine for returning the final solution values.
Definition conopt.f90:1238
integer(c_int) function coidef_status(cntvect, coi_status)
define callback routine for returning the completion status.
Definition conopt.f90:1212
integer(c_int) function coidef_readmatrix(cntvect, coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
Definition conopt.f90:1111
integer(c_int) function coidef_errmsg(cntvect, coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
Definition conopt.f90:1291
integer(c_int) function coidef_fdeval(cntvect, coi_fdeval)
define callback routine for performing function and derivative evaluations.
Definition conopt.f90:1135
integer(c_int) function coidef_2ddirini(cntvect, coi_2ddirini)
define callback routine for initializing the computation of second derivatives for a constraint in a ...
Definition conopt.f90:1453
integer(c_int) function coidef_progress(cntvect, coi_progress)
define callback routine for monitoring the algorithmic progress.
Definition conopt.f90:1317
integer(c_int) function coidef_2dlagrstr(cntvect, coi_2dlagrstr)
define callback routine for providing the structure of the second derivatives of the Lagrangian.
Definition conopt.f90:1547
integer(c_int) function coidef_2ddirend(cntvect, coi_2ddirend)
define callback routine for termination the computation of second derivatives for a constraint in a d...
Definition conopt.f90:1484
integer(c_int) function coidef_fdevalend(cntvect, coi_fdevalend)
define callback routine for the termination of the function and derivative evaluation.
Definition conopt.f90:1186
integer(c_int) function coidef_optfile(cntvect, optfile)
define callback routine for defining an options file.
Definition conopt.f90:928
integer(c_int) function coidef_fdinterval(cntvect, coi_fdinterval)
define callback routine for performing function and derivative evaluations on intervals.
Definition conopt.f90:1396
integer(c_int) function coidef_option(cntvect, coi_option)
define callback routine for defining runtime options.
Definition conopt.f90:1346
integer(c_int) function coidef_2ddir(cntvect, coi_2ddir)
define callback routine for computing the second derivative for a constraint in a direction.
Definition conopt.f90:1421
integer(c_int) function coidef_usrmem(cntvect, usrmem)
provides a pointer to user memory that is available in all callback functions. NOTE: this is not a ca...
Definition conopt.f90:1601
integer(c_int) function coidef_fdevalini(cntvect, coi_fdevalini)
define callback routine to perform initialization tasks for the function and derivative evaluation.
Definition conopt.f90:1161
integer(c_int) function coidef_2dlagrval(cntvect, coi_2dlagrval)
define callback routine for computing the values of the second derivatives of the Lagrangian.
Definition conopt.f90:1573
integer(c_int) function coidef_triord(cntvect, coi_triord)
define callback routine for providing the triangular order information.
Definition conopt.f90:1371
integer(c_int) function coidef_2ddirlagr(cntvect, coi_2ddirlagr)
define callback routine for computing the second derivative of the Lagrangian in a direction.
Definition conopt.f90:1509
integer(c_int) function coidef_inistat(cntvect, inistat)
handling of the initial status values.
Definition conopt.f90:1023
integer(c_int) function coidef_optorder(cntvect, optorder)
define Optfile / Option order.
Definition conopt.f90:563
integer(c_int) function coidef_emptyrow(cntvect, emptyrow)
allow empty rows.
Definition conopt.f90:472
integer(c_int) function coidef_reslim(cntvect, reslim)
define resource limit.
Definition conopt.f90:832
integer(c_int) function coidef_zeronoise(cntvect, zeronoise)
define zero noise level.
Definition conopt.f90:806
integer(c_int) function coidef_fvforall(cntvect, fvforall)
call the FDEval for all constraints, including linear constraints.
Definition conopt.f90:1083
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
Definition conopt.f90:293
integer(c_int) function coidef_stdout(cntvect, tostdout)
allow output to StdOut.
Definition conopt.f90:751
integer(c_int) function coidef_itlim(cntvect, itlim)
define the Iteration Limit.
Definition conopt.f90:323
integer(c_int) function coidef_threadc(cntvect, threadc)
check for thread compatibility.
Definition conopt.f90:727
integer(c_int) function coidef_clearm(cntvect, clearm)
ClearM.
Definition conopt.f90:772
integer(c_int) function coidef_thread2d(cntvect, thread2d)
number of threads allowed for simultaneous 2DDir calls.
Definition conopt.f90:690
integer(c_int) function coidef_square(cntvect, square)
square models.
Definition conopt.f90:447
integer(c_int) function coidef_emptycol(cntvect, emptycol)
allow empty columns.
Definition conopt.f90:499
integer(c_int) function coidef_threadf(cntvect, threadf)
number of threads allowed for simultaneous FDEval calls.
Definition conopt.f90:658
integer(c_int) function coidef_discont(cntvect, discont)
allow discontinuous functions and derivatives.
Definition conopt.f90:592
integer(c_int) function coidef_debugfv(cntvect, debugfv)
turn Debugging of FDEval on and off.
Definition conopt.f90:387
integer(c_int) function coidef_debug2d(cntvect, debug2d)
turn debugging of 2nd derivatives on and off.
Definition conopt.f90:534
integer(c_int) function coidef_fvinclin(cntvect, fvinclin)
include the linear terms in function evaluations.
Definition conopt.f90:1053
integer(c_int) function coidef_hessfac(cntvect, hessfac)
factor for Hessian density relative to Jacobian density HessFac.
Definition conopt.f90:858
integer(c_int) function coidef_errlim(cntvect, errlim)
define the Error Limit.
Definition conopt.f90:352
integer(c_int) function coidef_maxsup(cntvect, maxsup)
limit on superbasics.
Definition conopt.f90:423
integer(c_int) function coidef_threads(cntvect, threads)
number of threads allowed internally in CONOPT.
Definition conopt.f90:627
integer(c_int) function coidef_maxheap(cntvect, maxheap)
define Limit on Heap Memory. ""
Definition conopt.f90:898
integer(c_int) function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
Definition conopt.f90:97
integer(c_int) function coidef_numcon(cntvect, numcon)
defines the number of constraints in the model.
Definition conopt.f90:121
integer(c_int) function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear Nonzeros.
Definition conopt.f90:167
integer(c_int) function coidef_optdir(cntvect, optdir)
defines the Optimization Direction.
Definition conopt.f90:213
integer(c_int) function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
Definition conopt.f90:144
integer(c_int) function coidef_numhess(cntvect, numhess)
defines the Number of Hessian Nonzeros.
Definition conopt.f90:188
integer(c_int) function coidef_objvar(cntvect, objvar)
defines the Objective Variable.
Definition conopt.f90:257
integer(c_int) function coidef_objcon(cntvect, objcon)
defines the Objective Constraint.
Definition conopt.f90:239
integer(c_int) function coi_create(cntvect)
initializes CONOPT and creates the control vector.
Definition conopt.f90:1726
integer(c_int) function coi_free(cntvect)
frees the control vector.
Definition conopt.f90:1749
integer(c_int) function coidef_ini(cntvect)
initializes the Control Vector by placing default values in the various positions.
Definition conopt.f90:54
subroutine coiget_version(major, minor, patch)
returns the version number. It can be used to ensure that the modeler is linked to the correct versio...
Definition conopt.f90:1645
integer(c_int) function coiget_rangeerrors(cntvect)
returns the range errors that were encountered.
Definition conopt.f90:1694
integer(c_int) function coi_solve(cntvect)
method for starting the solving process of CONOPT.
Definition conopt.f90:1625
real(c_double) function coiget_maxheapused(cntvect)
After a model has been solved this method will return the amount of heap memory used.
Definition conopt.f90:1659
integer(c_int) function coiget_maxthreads(cntvect)
returns the maximum number of threads that can be used by CONOPT.
Definition conopt.f90:1679
integer(c_int) function coidef_2dlagrsize(cntvect, coi_2dlagrsize)
Definition conopt.f90:1521
program square
Main program. A simple setup and call of CONOPT.
Definition square.f90:23