| ILOG CPLEX 11.0 User's Manual > Continuous Optimization > Solving LPs: Simplex Optimizers > Examples: Using a Starting Basis in an LP Problem > Example ilolpex6.cpp |
Example ilolpex6.cpp |
INDEX
PREVIOUS
NEXT
|
The example, ilolpex6.cpp, resembles one you may have studied in the ILOG CPLEX Getting Started manual, ilolpex1.cpp. This example differs from that one in these ways:
populatebycolumn method, and thus no command line arguments are needed to select a construction method.
main routine, the arrays cstat and rstat set the status of the initial basis.
cplex.setBasisStatuses.
The main program starts by declaring the environment and terminates by calling method end for the environment. The code in between is encapsulated in a try block that catches all Concert Technology exceptions and prints them to the C++ error stream cerr. All other exceptions are caught as well, and a simple error message is issued. Next the model object and the cplex object are constructed. The function populatebycolumn builds the problem object 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 iteration count demonstrates that the advanced basis took effect. In fact, this basis is immediately detected as optimal, resulting in zero iterations being performed, in contrast to the behavior seen in the example program ilolpex1.cpp where the same model is solved without the use of an advanced basis.
The complete program ilolpex6.cpp appears online in the standard distribution at yourCPLEXinstallation/examples/src.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |