XSLPsetcboptnode
XSLPsetcboptnode |
Purpose
Set a user callback to be called during MISLP when an optimal SLP solution is obtained at a node
Synopsis
int XPRS_CC XSLPsetcboptnode(XSLPprob Prob, int (XPRS_CC *UserFunc) (XSLPprob myProb, void *myObject, int *feas), void *Object);
Arguments
Prob
|
The current SLP problem.
|
UserFunc
|
The function to be called when an optimal SLP solution is obtained at a node.
UserFunc returns an integer value. If the return value is nonzero, or if the feasibility flag is set nonzero, then further processing of the node will be terminated (it is declared infeasible).
|
myProb
|
The problem passed to the callback function.
|
myObject
|
The user-defined object passed as
Object to
XSLPsetcboptnode.
|
feas
|
Address of an integer containing the feasibility flag. If
UserFunc sets the flag nonzero, the node is declared infeasible.
|
Object
|
Address of a user-defined object, which can be used for any purpose by the function.
Object is passed to
UserFunc as
myObject.
|
Example
The following example defines a callback function to be executed at each node when an SLP optimal solution is found. If there are significant penalty errors in the solution, the node is declared infeasible.
XSLPsetcboptnode(Prob, CBOptNode, NULL);
A suitable callback function might resemble the following:
int XPRS_CC CBOptNode(XSLPprob myProb, void *Obj, int *feas) { double Total, ObjVal; XSLPgetdblattrib(myProb, XSLP_ERRORCOSTS, &Total); XSLPgetdblattrib(myProb, XSLP_OBJVAL, &ObjVal); if (fabs(Total) > fabs(ObjVal) * 0.001 && fabs(Total) > 1) *feas = 1; return 0;
Further information
If a node is declared infeasible from the callback function, the cost of exploring the node further will be avoided.
This callback must be used in place of XPRSsetcboptnode when optimizing with MISLP.
Related topics