Example ilolpex6.cpp
Shows an example of starting from in advanced basis in the C++ API.
The example, ilolpex6.cpp,
resembles one you may have studied in the Getting
Started manual, ilolpex1.cpp.
This example differs from that one in these ways:
Arrays are constructed using the
populatebycolumnmethod, and thus no command line arguments are needed to select a construction method.In the
mainroutine, the arrayscstatandrstatset the status of the initial basis.After the problem data has been copied into the problem object, the basis is copied by a call to
cplex.setBasisStatuses.After the problem has been optimized, the iteration count is printed. For the given data and basis, the basis is optimal, so no iterations are required to optimize the problem.
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.