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.

◆◆cbdata, a pointer to <strong>ILOG</strong> <strong>CPLEX</strong> internal data structures needed byCPXgetcallbackinfo;wherefrom, indicates which optimizer is calling the callback;◆ cbhandle, a pointer supplied when your application calls CPXsetlpcallbackfunc orCPXsetmipcallbackfunc (so that the callback has access to private user data).The arguments wherefrom and cbdata should be used only in calls toCPXgetcallbackinfo.Example: Using Callbacks lpex4.cThis example shows you how to use callbacks effectively with routines from the<strong>ILOG</strong> <strong>CPLEX</strong> Callable Library. It is based on lpex1.c, a program from the <strong>ILOG</strong> <strong>CPLEX</strong>Getting Started manual. This example about callbacks differs from that simpler one inseveral ways:◆◆To make the output more interesting, this example optimizes a slightly different linearprogram.The <strong>ILOG</strong> <strong>CPLEX</strong> screen indicator (that is, the parameter CPX_PARAM_SCRIND) is notturned on. Only the callback function produces output. Consequently, this program callsCPXgeterrorstring to retrieve any error messages and then prints them. After theTERMINATE: label, the program uses separate status variables so that if an error occurredearlier, its error status will not be lost or destroyed by freeing the problem object andclosing the <strong>ILOG</strong> <strong>CPLEX</strong> environment. Table 30.3 summarizes those status variables.Table 30.3Status Variables in lpex4.cVariablefrstatusclstatusRepresents status returned by this routineCPXfreeprobCPXclose<strong>CPLEX</strong>◆The function mycallback at the end of the program is called by the optimizer. Thisfunction tests whether the primal simplex optimizer has been called. If so, then a call toCPXgetcallbackinfo gets the following information:●●●iteration count;feasibility indicator;sum of infeasibilities (if infeasible);● objective value (if feasible).The function then prints these values to indicate progress.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 461

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

Saved successfully!

Ooh no, something went wrong!