NO FRAMES

CPXsetcutcallbackfunc

int CPXPUBLIC CPXsetcutcallbackfunc(CPXENVptr env, int(CPXPUBLIC *cutcallback)(CALLBACK_CUT_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 CPXsetcutcallbackfunc sets and modifies the user-written callback for adding cuts. The user-written callback is called by ILOG CPLEX during MIP branch & cut for every node that has an LP optimal solution with objective value below the cutoff and is integer infeasible. The callback routine adds globally valid cuts to the LP subproblem. The cut may be for the original problem if the parameter CPX_PARAM_MIPCBREDLP was set to CPX_OFF before the call to CPXmipopt that calls the callback. Otherwise, the cut is for the presolved problem.

Within the user-written cut callback, the routine CPXgetcallbacknodelp and other query routines from the Callable Library access information about the subproblem. The routines CPXgetcallbacknodeintfeas and CPXgetcallbacksosinfo examines the status of integer entities.

The routine CPXcutcallbackadd adds cuts to the problem. Cuts added to the problem are first put into a cut pool, so they are not present in the subproblem LP until after the user-written cut callback is finished.

Any cuts that are duplicates of cuts already in the subproblem are not added to the subproblem. Cuts that are added remain part of all subsequent subproblems; there is no cut deletion.

If cuts have been added, the subproblem is re-solved and evaluated, and, if the LP solution is still integer infeasible and not cut off, the cut callback is called again.

If the problem has names, user-added cuts have names of the form Xnumber where number is a sequence number among all cuts generated.

The parameter CPX_PARAM_REDUCE must be set to CPX_PREREDUCE_PRIMALONLY (1) or CPX_PREREDUCE_NOPRIMALORDUAL (0) if the constraints to be added in the callback are lazy constraints, that is, not implied by the constraints in the constraint matrix. The parameter CPX_PARAM_PRELINEAR must be set to 0 if the constraints to be added are in terms of the original problem and the constraints are valid cutting planes.

Example

 status = CPXsetcutcallbackfunc(env, mycutfunc, mydata);

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

Parameters

env

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

cutcallback

The pointer to the current user-written cut callback. If no callback has been set, the pointer evaluates to NULL.

cbhandle

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

Callback description

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

ILOG CPLEX calls the cut callback when the LP subproblem for a node has an optimal solution with objective value below the cutoff and is integer infeasible.

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 has the value CPX_CALLBACK_MIP_CUT.

cbhandle

A pointer to user private data.

useraction_p

A pointer to an integer indicating the action for ILOG CPLEX to take at the completion of the user callback. The table summarizes possible actions.

Actions to be Taken After a User-Written Cut Callback
ValueSymbolic ConstantAction
0CPX_CALLBACK_DEFAULTUse cuts as added
1CPX_CALLBACK_FAILExit optimization
2CPX_CALLBACK_SETUse cuts as added

Returns:

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