CPLEX

CPLEX is an optimization solver, for Linear/Quadratic Programming, Mixed Linear/Quadratic Integer Programming. CPLEX is a de facto standard solver for solving such problems.

Downloading and Installing CPLEX

CPLEX is freely available for academics.  You can follow this step by step guide to install:

  1. Log in at: https://www-304.ibm.com/ibm/university/academic/pub/jsps/assetredirector.jsp?asset_id=1070.
  2. Follow the instructions on the page. Screenshot 2014-07-20 23.22.37
  3. Download an appropriate version to your system.
  4. Follow this instruction to install.

Installing CPLEX on Mac OS X

The instruction includes how to deal with .bin file on Mac OS X:

  1. Download
 cplex_studio126.osx.bin. Place
the
 file
in
your
home
directory (/Users/[Your
User
Name]).
Copying
and
 pasting
 from
 the
 Download
 directory
 will
work
 fine
here.
  2. To
 install, open
 Terminal.
 To
do
 this,
 click
on
 the
 magnifying
 glass
 in
the
 top
 right
corner of
 your
screen
 and
type
 
Terminal
 and
 hit
 enter.
  3. At
 the
 prompt,
type
 in
 /bin/bash
 ~/cplex_studio126.osx.bin
 and
 hit
 enter. Follow all the prompts.

Using CPLEX Interfaces

Julia

You can use the Julia Language to work with CPLEX solvers. See this instruction.

MATLAB

Inside MATLAB, you can directly call CPLEX solvers. See this help. Run MATLAB, and type pathtool. Add the CPLEX MATLAB folder to the path. The folder location in Mac OS X is:

/User/[your user name]/Applications/IBM/ILOG/CPLEX_Studio126/cplex/matlab

Other Languages

You can use CPLEX with C++, Java, Python. If you want to use C++ or Java to work with CPLEX, you can also do so. C++ is usually faster and proficiency in C++ is very helpful when you seek a job. It’s your call.

Exercise Tasks to Complete

After you install, please do the following task. I attached network example files. One for network structure, the other for travel demand. Please solve the min cost network flow problem based on those data.

  1. Solve the problem as a linear program. (using cplexlp function)
  2. Solve the problem as an integer program. (using cplexmilp function)

Objectives of this task are:

  • To keep your computing environments ready for advanced research works.
  • To be familiar with CPLEX solvers.
  • To learn how to read Excel files in MATLAB.
  • To know how to deal with network data.

Parameter Settings

The CPLEX solver can be fine tuned by adjusting its parameters. Two steps:

  1. Find a correct parameter name in the topical list or the list of all parameters.
  2. Set a value for the parameter and pass it to the solver.

The second step will vary for each programming language. Suppose we want to limit the CPU time of the solver to 3600 seconds. The parameter for this purpose is found here.

MATLAB

MATLAB uses the same names as in Python. So, the parameter name is timelimit. Do the following:

options = cplexoptimset('timelimit', 3600)
x = cplexmilp(f,Aineq,bineq,Aeq,beq,sostype,sosind,soswt,lb,ub,ctype,x0,options)

Read this document.

Java

Read: Setting CPLEX Parameters in Java Revisited.

Julia

In Julia and the JuMP package, the parameter names are same as in C. So the correct parameter name is CPX_PARAM_TILIM in this case.

m = Model(solver=CplexSolver(CPX_PARAM_TILIM=3600))

GAMS

Read this document.

Option ResLim = x;
Sets the time limit in seconds. The algorithm will terminate and pass on the current solution to GAMS.