Research Computing >> Software >> CPLEX Optimization Package

CPLEX Optimization Package


CPLEX 11.2 is installed on the Kellogg research server skew4. It can be used interactively, as well as called from C and C++ programs. Our license allows up to 2 simultaneous users.


CPLEX solver from IBM is a high performance solver for linear programming (LP), mixed integer programming (MIP) and some quadratic programming (QP/QCP/MIQP/MIQCP) problems.

Vendor Information

IBM Corp.
1 New Orchard Road
Armonk, New York 10504-1722
United States


There are two ways to use CPLEX: either through an interactive command line-based interface, or by calling the CPLEX library from your C or C++ code.

Using the Interactive CPLEX optimizer:

The interactive CPLEX optimizer is invoked by a command cplex on skew4. It allows to enter a model or load it from an external file, try different solution methods, and export the results. You can type help at the CPLEX prompt to get help on commands.

Below is an example of using it to solve a simple mixed-integer linear programming problem with equality and inequality constraints.

1. Create a problem description file toy.lp as follows:

obj: 5.8 x_1 + 3 x_2

r1: x_1 + 2.1 x_2 = 6
r2: 3 x_2 < 4.2

x_1 >= 0
x_2 >= 0



2. Type cplex to start the interactive optimizer:

[zzz123@skew4]$ cplex
ILOG CPLEX 11.210, licensed to "northwestern-evanston, il", options: e m b q use=2

Welcome to CPLEX Interactive Optimizer 11.2.1
  with Simplex, Mixed Integer & Barrier Optimizers
Copyright (c) ILOG 1997-2008
CPLEX is a registered trademark of ILOG

Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.

3. Load a problem:

CPLEX> read toy.lp
Problem 'toy.lp' read.
Read time =    0.00 sec.

4. Solve using the default optimizer:

CPLEX> opt
Tried aggregator 1 time.
MIP Presolve eliminated 2 rows and 2 columns.
All rows and columns eliminated.
Presolve time =    0.00 sec.

Solution pool: 1 solution saved.

MIP - Integer optimal solution:  Objective =  2.6057142857e+01
Solution time =    0.00 sec.  Iterations = 0  Nodes = 0

5. Save results into file results.sol:

CPLEX> write results.sol
Solution pool written to file 'results.sol'.

This saves the solution. You can specify options to save other information, see "help write". The output file is in XML format. Most statistical software has functions to read XML. For example, this function (matlabcentral) provides a wrapper to read CPLEX solution files from within Matlab:

>> read_cplexsol('results.sol')

ans =


Using interactive CPLEX in batch mode

It is also possible to run the command-line CPLEX in batch mode. To do so, you need to create an input CPLEX command file. For example, to run the previous example, we can create a file toy.cmd as follows:

read toy.lp
write results.sol

It can then be executed simply by

cat toy.cmd | cplex &

Please note that the command file must end with a "quit" followed by an empty line. Also note the "y" after the "write" command: it is there to confirm overwriting in case the file "results.sol" already exists.

Calling CPLEX from C and C++

CPLEX comes with a large number of examples, located in /usr/local/cplex112/examples on skew4. Various compiler and linker options have to be set properly (see /usr/local/cplex112/readme.html on skew4), so the best way to get started is to to copy one of the examples and modify it to your purposes. Below are the instructions on how to compile the provided examples in C and C++:

1. Copy example files to your home directory

mkdir ~/mycplex
cp -r /usr/local/cplex112/examples ~/mycplex
cd ~/mycplex/examples/x86_64_debian4.0_4.1/static_pic

2. Edit the Makefile, changing lines 12 and 13 to the skew4 installation directories:

CPLEXDIR = /usr/local/cplex112
CONCERTDIR = /usr/local/concert27

3. Compile and run all examples:

make execute_c
make execute_cpp


Installed version (CPLEX 11.2)

  • Full documentation is available in /usr/local/cplex112/doc on skew4

Other references

These external links refer to the versions of CPLEX other than 11.2 and may contain information that is not applicable to our system:

© 2001-2008 Kellogg School of Management, Northwestern University