Using CPLEX for MATLAB
Presents an overview of how to solve an optimization problem.
IBM® ILOG® CPLEX® Optimizers provides a tool for solving optimization, or mathematical programming, problems.
The most basic mathematical programming problem is commonly referred to as Linear Programming (LP) problem. The basic form of an LP problem is:
Maximize (or Minimize) | f*x |
subject to | Aeq*x = beq Aineq*x <= bineq |
with these bounds | l <= x <= u |
where Aeq and Aineq are matrices, f, beq, bineq, l and u are vectors such that the upper bounds u(i) and lower bounds l(i) may be positive infinity, negative infinity, or any real number. Both sparse and dense format can be used in all places where matrices/vectors are used.
The elements of data you provide as input for this LP problem are:
Data provided as input for an LP problem | |
---|---|
Objective function coefficients | f |
Constraint coefficients | Aeq Aineq |
Righthand sides | beq bineq |
Upper and lower bounds | u l |
The optimal solution that CPLEX computes and returns is:
Variables | x |
CPLEX for MATLAB can also solve several extensions to LP:
Quadratic Programming (QP) problems, where the LP objective function is expanded to include quadratic terms.
Quadratically Constrained Programming (QCP) problems that include quadratic terms among the constraints. In fact, CPLEX can solve Second Order Cone Programming (SOCP) problems.
Mixed Integer Programming (MIP) problems, where any or all of the LP, QP, or QCP variables are further restricted to take integer values in the optimal solution and where MIP itself is extended to include constructs like Special Ordered Sets (SOS), semi-continuous variables, and indicator variables.
Least Squares (LSQ) problems, where the objective is to minimize a norm. The problem can be constrained linearly or quadratically, and the variables may be restricted to take integer values in the solution.
The standard MATLAB vector and matrix format is used for the elements of data that you need to provide. For example, the CPLEX for MATLAB Toolbox function cplexlp solves the problem specified by
min f*x
st. Aineq*x <= bineq
Aeq*x = beq
lb <= x <= ub
where f, bineq, beq, lb, and ub are MATLAB double vectors, and Aineq and Aeq are MATLAB double matrices.
The vector x returned by the function call
x = cplexlp(f,Aineq,bineq,Aeq,beq,lb,ub)
contains the optimal solution to the specified linear programming problem.
Provided in CPLEX for MATLAB is both a toolbox of functions and a class API. The toolbox contains functions for solving optimization problems, where the input matrices are provided to the function and results returned. With the class API, objects can be created, and those objects carry a state.
The benefits of using the Cplex class API include the ability to:
build up a model by manipulating a Cplex object.
use computation methods such as Cplex.solve() and Cplex.refineConflict() that modify the object so results can be queried as needed.
perform restarts after manipulation.
attach an output parser, a GUI with stop buttons, and other controls.