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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

IloCplex::Callback mycallback = cplex.use(MyCallback(env, 10));The callback that is added to cplex is returned by the method use and stored in the variablemycallback. This allows you to call mycallback.endto remove the callback fromcplex. If you do not intend to access your callback (for example, in order to delete it beforeending the environment), you may safely leave out the declaration and initialization of thevariable mycallback.Callback InterfaceTwo callback classes in the hierarchy need extra attention. The first is the base classIloCplex::CallbackI (IloCplex.CallbackI). Since there is no correspondingcallback in the Callable Library, this class cannot be used for implementing user callbacks.Instead, its purpose is to provide an interface common to all callback functions. This consistsof the methods getModel, which returns the model that is extracted to the IloCplex objectthat is calling the callback, getEnv, which returns the corresponding environment (C++only), and abort, which aborts the current optimization. Further, methods getNrows andgetNcols allow you to query the number of rows and columns of the current cplex LPmatrix. These methods can be called from all callbacks.Note: For C++ users, no manipulation of the model or, more precisely, any extractedmodeling object is allowed during the execution of a callback. No modification is allowedof any array or expression not local to the callback function itself (that is, constructed andended in it). The only exception is the modification of array elements. For example, x[i]= 0 would be permissible, whereas x.add(0) would not unless x is a local array of thecallback.The Continuous CallbackThe second special callback class is IloCplex::ContinuousCallbackI(IloCplex.ContinuousCallback). If you create a Continuous callback and use it withan IloCplex object, it will be used for both the barrier and the simplex callback. In otherwords, implementing and using one Continuous callback is equivalent to writing and usingthese two callbacks independently.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 457

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

Saved successfully!

Ooh no, something went wrong!