filename is a file with extension MPS, SAV, or LP (lower case is allowed), and optimizer is one of the following letters:
o | default |
p | primal simplex |
d | dual simplex |
n | network with dual simplex cleanup |
h | barrier with crossover |
b | barrier without crossover |
s | sifting |
c | concurrent |
reads the file example.mps and solves the problem with the dual simplex optimizer.
To illustrate the ease of reading a problem, the example uses the routine CPXreadcopyprob(). This routine detects the type of the file, reads the file, and copies the data into the ILOG CPLEX problem object that is created with a call to CPXcreateprob(). The user need not be concerned with the memory management of the data. Memory management is handled transparently by CPXreadcopyprob().
After calling CPXopenCPLEX() and turning on the screen indicator by setting the CPX_PARAM_SCRIND parameter to CPX_ON, the example creates an empty problem object with a call to CPXcreateprob(). This call returns a pointer, lp, to the new problem object. Then the data is read in by the routine CPXreadcopyprob(). After the data is copied, the appropriate optimization routine is called, based on the command line argument.
After the TERMINATE: label, the data for the solution (x, cstat, and rstat) are freed. Then the problem object is freed by CPXfreeprob(). After the problem is freed, the ILOG CPLEX environment is freed by CPXcloseCPLEX().
The complete program follows. You can also view it online in the file lpex2.c.