Quadratic terms in LP file format
CPLEX conforms to these rules about quadratic terms in LP file format.
This rule applies to applications that solve problems with quadratic terms in them, that is, quadratic programming problems and quadratically constrained programs (QPs and QCPs). Quadratic coefficients can appear in the objective function. Quadratic coefficients can also appear in constraints under certain conditions. If there are quadratically constrained variables in the problem, see also rules about Variable names in LP file format and Constraints in LP file format in this manual, as well as Solving problems with quadratic constraints (QCP) in the CPLEX User’s Manual.
The algebraic coefficients of the
function x'Qx are specified inside square brackets []
.
The square brackets must be followed by a divide sign followed by
the number 2. This convention denotes that all coefficients inside
the square brackets will be divided by 2 in evaluating the quadratic
terms of the objective function. All quadratic coefficients must appear
inside square brackets. Multiple square bracket sections may be specified.
Inside of the square brackets, two variables are multiplied
by an asterisk (*
). For example, [4x*y]
indicates that the coefficients of both of
the off-diagonal terms of Q, corresponding to the variables x
and y
in the model
are 2, since 4x*y
equals 2x*y + 2x*y
.
Each pair of off-diagonal terms of Q is specified only once. CPLEX
automatically creates both off-diagonal entries of Q. Diagonal terms
in Q (that is, terms with an exponent of 2) are indicated by the caret
(^
) followed by 2. For example, 4x^2
indicates that the coefficient of the diagonal
term of Q corresponding to the variable x
in
the model is 4.
For example, this problem
Minimize a + b + 1/2(a2 + 4ab +7b2)
subject to a + b ≥ 10 and a, b ≥ 0
in LP format looks like this:
Minimize
obj: a + b + [ a^2 + 4 a * b + 7 b^2 ]/2
Subject To
c1: a + b >= 10
End