NO FRAMES

CPXsetsolvecallbackfunc

public int CPXsetsolvecallbackfunc(CPXENVptr env, int(CPXPUBLIC *solvecallback)(CALLBACK_SOLVE_ARGS), void * cbhandle)
Definition file: cplex.h
Note

This is an advanced routine. Advanced routines typically demand a thorough 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 CPXsetsolvecallbackfunc sets and modifies the user-written callback to be called during MIP optimization to optimize the subproblem.

Example

 status = CPXsetsolvecallbackfunc(env, mysolvefunc, mydata);

See also the example admipex1.c in the standard distribution.

Parameters

env

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

solvecallback

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

cbhandle

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

Callback description

 int callback (CPXCENVptr env,
               void       *cbdata,
               int        wherefrom,
               void       *cbhandle,
               int        *useraction_p);
 

ILOG CPLEX calls the solve callback before ILOG CPLEX solves the subproblem defined by the current node. The user can choose to solve the subproblem in the solve callback instead by setting the user action argument of the callback. The optimization that the user provides to solve the subproblem must provide a CPLEX solution. That is, the Callable Library routine CPXgetstat must return a nonzero value. The user may access the lp pointer of the subproblem with the Callable Library routine CPXgetcallbacknodelp.

Callback return value

The callback returns zero if successful 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 reporting where in the optimization this function was called. It will have the value CPX_CALLBACK_MIP_SOLVE.

cbhandle

A pointer to user private data.

useraction_p

A pointer to an integer specifying the action to be taken on completion of the user callback. Table 11 summarizes the possible actions.

Actions to be Taken after a User-Written Solve Callback
ValueSymbolic ConstantAction
0CPX_CALLBACK_DEFAULTUse ILOG CPLEX subproblem optimizer
1CPX_CALLBACK_FAILExit optimization
2CPX_CALLBACK_SETThe subproblem has been solved in the callback

Returns:

The routine returns zero if successful and nonzero if an error occurs.