Example lpex6.c

Shows an example of starting from an advanced basis in the C API.

The example, lpex6.c, resembles one you may have studied in the Getting Started 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 a call to CPXcopybase .

  • 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 application begins with declarations of arrays to store the solution of the problem. Then, before it calls any other CPLEX routine, the application invokes the Callable Library routine CPXopenCPLEX to initialize the CPLEX environment. After the environment has been initialized, the application calls other Callable Library routines, such as CPXsetintparam with the argument CPX_PARAM_SCRIND to direct output to the screen and most importantly, CPXcreateprob to create the problem object. The routine populatebycolumn builds the problem object, and as noted earlier, CPXcopybase copies the advanced starting basis.

Before the application ends, it calls CPXfreeprob to free space allocated to the problem object and CPXcloseCPLEX to free the environment.

The complete program lpex6.c appears online in the standard distribution at yourCPLEXinstallation /examples/src.