NO FRAMES

CPXsetincumbentcallbackfunc

int CPXPUBLIC CPXsetincumbentcallbackfunc(CPXENVptr env, int(CPXPUBLIC *incumbentallback)(CALLBACK_INCUMBENT_ARGS) , void * cbhandle)
Definition file: cplex.h
Include files: cplex.h
Note

This is an advanced routine. Advanced routines typically demand a profound understanding of the algorithms used by ILOG CPLEX. Thus they incur a higher risk of incorrect behavior in your application, behavior that can be difficult to debug. Therefore, ILOG encourages you to consider carefully whether you can accomplish the same task by means of other Callable Library routines instead.

The routine CPXsetincumbentcallbackfunc sets and modifies the user-written callback routine to be called when an integer solution has been found but before this solution replaces the incumbent. This callback can be used to discard solutions that do not meet criteria beyond that of the mixed integer programming formulation.

Variables are in terms of the original problem if the parameter CPX_PARAM_MIPCBREDLP is set to CPX_OFF before the call to CPXmipopt that calls the callback. Otherwise, variables are in terms of the presolved problem.

Example

 status = CPXsetincumbentcallbackfunc (env, myincumbentcheck,
                                       mydata);

See also Advanced MIP Control Interface in the ILOG CPLEX User's Manual.

Parameters

env

A pointer to the CPLEX environment, as returned by CPXopenCPLEX.

incumbentcallback

A pointer to a user-written incumbent callback. If the callback is set to NULL, no callback can be called during optimization.

cbhandle

A pointer to user private data. This pointer is passed to the callback.

Callback description

 int callback (CPXENVptr env,
               void      *cbdata,
               int       wherefrom,
               void      *cbhandle,
               double    objval,
               double    *x,
               int       *isfeas_p,
               int       *useraction_p);
 

The incumbent callback is called when CPLEX has found an integer solution, but before this solution replaces the incumbent integer solution.

Variables are in terms of the original problem if the parameter CPX_PARAM_MIPCBREDLP is set to CPX_OFF before the call to CPXmipopt that calls the callback. Otherwise, variables are in terms of the presolved problem.

Callback return value

The callback returns zero on success and nonzero if an error occurs.

Callback arguments

env

A pointer to the CPLEX environment, as returned by CPXopenCPLEX.

cbdata

A pointer passed from the optimization routine to the user-written callback that identifies the problem being optimized. The only purpose of this pointer is to pass it to the callback information routines.

wherefrom

An integer value indicating where in the optimization this function was called. It will have the value CPX_CALLBACK_MIP_BRANCH.

cbhandle

A pointer to user private data.

objval

A variable that contains the objective value of the integer solution.

x

An array that contains primal solution values for the integer solution.

isfeas_p

A pointer to an integer variable that indicates whether or not CPLEX should use the integer solution specified in x to replace the current incumbent. A nonzero value indicates that the incumbent should be replaced by x; a zero value indicates that it should not.

useraction_p

A pointer to an integer to contain the indicator for the action to be taken on completion of the user callback. The table summarizes the possible values.

Actions to be Taken after a User-Written Incumbent Callback
ValueSymbolic ConstantAction
0CPX_CALLBACK_DEFAULTProceed with optimization
1CPX_CALLBACK_FAILExit optimization
2CPX_CALLBACK_SETProceed with optimization

See Also:

Returns:

The routine returns zero on success and nonzero if an error occurs.