IBM CPLEX#
IBM ILOG CPLEX has been a well known and widely used large-scale solver for over three decades. Its efficiency and robustness have been demonstrated through varied applications in thousands of commercial installations worldwide. The driver is built on the MP library, which reformulates logical and other expressions that the solver does not accept natively.
Product Page | Modeling guide | Features | Options | Changes
Download CPLEX | Start a CPLEX Trial Now!
This package contains an all-new CPLEX driver, that provides significantly extended modeling support for logical and nonlinear operators through linearizations performed by the MP library. For compatibility, there are two binaries in this package: cplex [options] is the new version, cplexasl [options] is the legacy version. If you are upgrading an existing installation and encounter any issues with the new version please report them to support@ampl.com.
How to use it#
How to install using amplpy:
# Install Python API for AMPL:
$ python -m pip install amplpy --upgrade
# Install AMPL & solver modules:
$ python -m amplpy.modules install cplex # install CPLEX
# Activate your license (e.g., free ampl.com/ce or ampl.com/academia licenses):
$ python -m amplpy.modules activate <your-license-uuid>
How to use:
from amplpy import AMPL
ampl = AMPL()
...
ampl.solve(solver="cplex", cplex_options="option1=value1 option2=value2")
Learn more about what we have to offer to implement and deploy Optimization in Python.
AMPL APIs give access to AMPL from a programming language:
AMPLS (AMPL solver libraries) load an AMPL model
into the solver in C++ or Python and give direct access to the solver’s
own API, for example for callbacks. Python packages: amplpy-gurobi,
amplpy-cplex, amplpy-xpress, amplpy-copt.
CPLEX options consist of a single-word option, or an option followed by an = sign and a value; a space may be used as a separator in place of the =.
ampl: option solver cplex; # change the solver
ampl: option cplex_options 'option1=value1 option2=value2'; # specify options
ampl: solve; # solve the problem
Resources#
Features#
Problem types and algorithms#
Problem types
LP, convex QP and QCP, SOCP, nonconvex QP objective
MILP, MIQP, MIQCP, MISOCP
Received natively: indicator constraints, piecewise-linear functions, SOS, quadratic constraints. Other logical constraints become indicator constraints or big-M rows; other nonlinear functions are approximated piecewise-linearly.
All constructs: native constraints and expressions by driver.
LP and QP: simplex, barrier, sifting, network
alg:method: 0 automatic (default), 1 primal simplex, 2 dual simplex,
3 network simplex, 4 barrier, 5 sifting, 6 concurrent. After
barrier, bar:crossover controls the basis computation.
MIP: branch-and-cut, Benders
Relative and absolute gaps: mip:gap, mip:gapabs. Benders decomposition:
alg:benders=1 (the model needs integer and continuous variables). Most
other controls are mip:... and cut:... options.
Nonconvex quadratic objective
qp:target=3 solves a (MI)QP with a nonconvex quadratic objective to global
optimality; 2 searches for a first-order (local) point of a continuous QP.
Nonconvex quadratic constraints are not supported.
Instrumentation#
For a generic summary of the options and features used most often, see Important features in the MP documentation.
For all models
Model export
Option tech:writemodel. Details
Solution export
Option tech:writesolution. Details
Feasibility relaxation
Option alg:feasrelax. Details
Irreducible inconsistent subset (IIS)
Option iis:find. Details
Basis input and output
Option alg:basis. Details
Condition number (kappa)
Option alg:kappa. Details
Multiple solutions
Option sol:stub. Details
Multiple objectives
Option obj:multi. Details
Sensitivity analysis
Option alg:sens. Details
Unbounded rays and Farkas certificates
Option alg:rays. Details
Warm start
Option alg:start. Details
For MIP models
Fixed model (duals and basis for a MIP)
Option mip:basis. Details
Algorithm for the fixed model: mip:basis:method.
MIP gap
Option mip:return_gap. Details
Best dual bound
Option mip:bestbound. Details
Solver options#
Full list of solver options:
More details on solver options: MP solver options.
Retrieving solutions#
The outcome of the last optimization is stored in the AMPL parameter solve_result_num and the relative message in
solve_result.
display solve_result_num, solve_result;
CPLEX solve result codes can be obtained by running cplex -! or ampl: shell "cplex -!";:
Solve result table for CPLEX 22.2.0
0- 99 solved: optimal for an optimization problem,
feasible for a satisfaction problem
100-199 solved? solution candidate returned but error likely
150 solved? MP solution check failed (option sol:chk:fail)
200-299 infeasible
300-349 unbounded, feasible solution returned
350-399 unbounded, no feasible solution returned
400-449 limit, feasible: stopped, e.g., on iterations or Ctrl-C
450-469 limit, problem is either infeasible or unbounded.
Disable dual reductions or run IIS finder for definitive answer.
470-499 limit, no solution returned
500-999 failure, no solution returned
550 failure: numeric issue, no feasible solution
Solve result codes of the legacy driver cplexasl
Solve result table (AMPL default ranges)
0- 99 solved: optimal for an optimization problem, feasible for a satisfaction problem
100-199 solved? solution candidate returned but error likely
200-299 infeasible
300-399 unbounded
400-499 limit
500-999 failure, no solution returned
For general information, see MP result codes guide.