CONOPT
Loading...
Searching...
No Matches
Evaluating Non-linear Function Values and Derivatives

Methods for computing the values and derivatives for non-linear functions.

The first callback routine described in this section, FDEval, defines the nonlinearities of the model by returning numerical values. It must be defined by the modeler and registered with COIDEF_FDEval() if the model is nonlinear, i.e. if COIDEF_NumNlNz() has been called with a nonzero value of NumNlNZ. The routine is called repeatedly during the optimization so it should be implemented efficiently. Some arguments are provided by CONOPT. The remaining arguments must be defined by the modeler. Note that FDEval works on one row or equation at a time.

The second callback routine described in this section, FDEvalIni, is optional. If FDEvalIni is registered, it will be called each time the point of interest has changed, and it will define the coming point and tell which constraints CONOPT will need during the following calls to FDEval. FDEvalIni can for example be used to transfer the point used by CONOPT into a format recognized by the modeler, or to optimize the computation of common terms that appear in several constraints.



The third callback routine, FDEvalEnd, is optional. If FDEvalEnd is registered, it will be called at the end of the function evaluation stage. This can be used to clean up any user data generated, such as in FDEvalIni, that was used to improve the efficiency of the function and derivative evaluation.



The last callback routine described in this section, FDInterval, defines intervals for the nonlinearities of the model, again by returning numerical values. It can optionally be defined by the modeler and registered with COIDEF_FDInterval(). The routine is used to improve the quality of the preprocessing phase. It is not called very often so efficiency is not important.


FDEval – Function and Derivative Evaluator

Note
This is a mandatory callback if the model has nonlinear parts.
int COI_CALLCONV FDEval( double* X, double* G, double* JAC,
int* ROWNO, int* JCNM, int* MODE, int* IGNERR,
int* ERRCNT, int* N, int* NJ, void* USRMEM );

where:

FVforAll \ FVincLin 0 1
0 G includes nonlinear terms only. FDEval is only called for nonlinear rows. G includes linear and nonlinear terms. FDEval is only called for nonlinear rows.
1 G includes nonlinear and constant terms. FDEval is called for all rows. G includes linear, nonlinear, and constant terms. FDEval is called for all rows.

You should notice the difference between the ERRCNT and the return code of FDEval. A nonzero value returned in ERRCNT indicates that the current point defined in X is bad. The function value G or the derivatives JAC could not be computed and CONOPT should try to backtrack to a safe point. A nonzero value returned as the value of FDEval indicates that there is a serious or permanent error and there is no reason to continue the optimization. The return code on FDEval can for example be used if a data file is not found, or if FDEval is called with a value of ROWNO that was not expected.


FDEvalIni – Function and Derivative Evaluator Initialization

int COI_CALLCONV FDEvalIni( double* X, int* ROWLIST, int* MODE,
int* LISTSIZE, int* NUMTHREAD, int* IGNERR,
int* ERRCNT, int* N, void* USRMEM );

where:


FDEvalEnd – Function and Derivative Evaluator Termination

int COI_CALLCONV FDEvalEnd( int* IGNERR, int* ERRCNT,
void* USRMEM );

where:


FDInterval – Function and Derivative Interval Evaluator

CONOPT can take advantage of interval information during its preprocesing phase. If the user can provide intervals for function values and/or derivatives values as a function of intervals for the variables, then CONOPT may perform more efficiently. The intervals must be defined in a callback routine that must be registered with the COIDEF_FDInterval() routine.

int COI_CALLCONV FDInterval( double* XMIN, double* XMAX,
double* GMIN, double* GMAX, double* JMIN,
double* JAMX, int* ROWNO, int* JCNM,
int* MODE, double* PINF, int* N, int* NJ,
void* USRMEM );

where:

There are a few points to note:

  1. FDInterval works on one constraint at a time.
  2. CONOPT will initialize GMIN to –PINF, GMAX to +PINF and similarly for the relevant elements in JMIN and JMAX. Therefore, if you do not have a bound on a function or a derivative value or if the value is infinite, then ignore the return value (or use –PINF and +PINF).
  3. Currently FDInterval does not use FVincLin and FVforAll which means that GMIN and GMAX only should include information about nonlinear terms.
  4. There is no error counter similar to ERRCNT in FDEval. If there are potential function evaluation errors in an interval this will usually translate into the lower and/or upper bounds being infinite.