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.

exceptions are caught as well, and a simple error message is issued. Next the model objectand the cplex object are constructed. The function populatebycolumn builds the problemobject and, as noted earlier, cplex.setBasisStatuses copies the advanced starting basis.The call to cplex.solve optimizes the problem, and the subsequent print of the iterationcount demonstrates that the advanced basis took effect. In fact, this basis is immediatelydetected as optimal, resulting in zero iterations being performed, in contrast to the behaviorseen in the example program ilolpex1.cpp where the same model is solved without theuse of an advanced basis.The complete program ilolpex6.cpp appears online in the standard distribution atyour<strong>CPLEX</strong>installation/examples/src.Example lpex6.cThe example, lpex6.c, resembles one you may have studied in the <strong>ILOG</strong> <strong>CPLEX</strong> GettingStarted manual, lpex1.c. This example differs from that one in these ways:◆◆In the main routine, the arrays cstat and rstat set the status of the initial basis.After the problem data has been copied into the problem object, the basis is copied by acall to CPXcopybase.◆ After the problem has been optimized, the iteration count is printed. For the given dataand basis, the basis is optimal, so no iterations are required to optimize the problem.The application begins with declarations of arrays to store the solution of the problem. Then,before it calls any other <strong>ILOG</strong> <strong>CPLEX</strong> routine, the application invokes the Callable Libraryroutine CPXopen<strong>CPLEX</strong> to initialize the <strong>ILOG</strong> <strong>CPLEX</strong> environment. After the environmenthas been initialized, the application calls other <strong>ILOG</strong> <strong>CPLEX</strong> Callable Library routines,such as CPXsetintparam with the argument CPX_PARAM_SCRIND to direct output to thescreen and most importantly, CPXcreateprob to create the problem object. The routinepopulatebycolumn builds the problem object, and as noted earlier, CPXcopybase copiesthe advanced starting basis.Before the application ends, it calls CPXfreeprob to free space allocated to the problemobject and CPXclose<strong>CPLEX</strong> to free the environment.The complete program lpex6.c appears online in the standard distribution atyour<strong>CPLEX</strong>installation/examples/src.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 195

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

Saved successfully!

Ooh no, something went wrong!