12.07.2015 Views

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Notice the comma (,) between the type and the argument object in the macro invocation.Here is how the macro expands with ellipsis (...) representing the actual implementation:class CtCallbackI : public IloCplex::LazyConstraintCallbackI {IloExprArray lhs;IloNumArray rhs;IloNum eps;public:IloCplex::CallbackI* duplicateCallback() const {return (new(getEnv()) CtCallbackI(*this));}CtCallbackI(IloEnv env, IloExprArray xx1, IloNumArray xx2, IloNum xx3) :IloCplex::LazyConstraintCallbackI(env), lhs(xx1), rhs(xx2), eps(xx3) {}void main();};IloCplex::CallbackCtCallback(IloEnv env, IloExprArray lhs, IloNumArray rhs, IloNum eps) {return (IloCplex::Callback(new(env) CtCallbackI(env, lhs, rhs, eps)));}void CtCallbackI::main() {...}Similar macros are provided for other numbers of arguments ranging from 0 through 7 forall callback classes.The first argument lhs is an array of expressions, and the argument rhs is an array ofvalues. These arguments are the lefthand side and righthand side values of cuts of the formlhs ≤ rhs to be tested for violation and potentially added. The third argument eps gives atolerance by which a cut must at least be violated in order to be added to the problem beingsolved.The implementation of this example cut-callback looks for cuts that are violated by thecurrent LP solution of the node where the callback is invoked. It loops over the potentialcuts, checking each for violation by querying the value of the lhs expression with respect tothe current solution. This query calls getValue with this expression as an argument. Thisvalue is tested for violation of more than the tolerance argument eps with the correspondingrighthand side value.Tip: A numeric tolerance is always a wise thing to consider when dealing with anynontrivial model, to avoid certain logical inconsistencies that could otherwise occur due tonumeric roundoff. Here the standard <strong>ILOG</strong> <strong>CPLEX</strong> simplex feasibility tolerance serves thispurpose, to make sure there is consistency with the way <strong>ILOG</strong> <strong>CPLEX</strong> is treating the rest ofthe model.If a violation is detected, the callback creates an IloRange object to represent the cut:lhs[i] ≤ rhs[i]. It is added to the LP by calling the method add. Adding a cut to<strong>ILOG</strong> <strong>CPLEX</strong>, unlike extracting a model, only copies the cut into the <strong>ILOG</strong> <strong>CPLEX</strong> datastructures, without maintaining a notification link between the two. Thus, after a cut has464 <strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!