> Continuous Optimization > Solving Problems with a Quadratic Objective (QP) > Entering QPs |
Entering QPs |
INDEX PREVIOUS NEXT |
ILOG CPLEX supports two views of quadratic objective functions, a matrix view and an algebraic view.
In the matrix view, commonly found in textbook presentations of QP, the objective function is defined as 1/2 xTQx + cTx, where Q must be symmetric and positive semi-definite for a minimization problem, or negative semi-definite for a maximization problem. This view is supported by the MPS file format and the Callable Library routines, where the quadratic objective function information is specified by providing the matrix Q. Thus, by definition, the factor of 1/2 must be considered when entering a model using the matrix view, as it will be implicitly assumed by the optimization routines. Similarly, symmetry of the Q matrix data is required; the MPS reader will return an error status code if the file contains unequal off-diagonal components, such as a nonzero value for one and zero (or omitted) for the other.
In the algebraic view, a quadratic objective function is specified as an expressions of the form:
This view is supported by the LP format, when entering quadratic objective functions in the Interactive Optimizer, and by Concert Technology. Again, a quadratic objective function must be convex in the case of a minimization problem, or concave in the case of a maximization problem. When entering a quadratic objective with the algebraic view, neither symmetry considerations nor any implicit factors need to be considered, and indeed attempting to specify both of the off-diagonal elements for one of the quadratic terms may result in double the intended value of the coefficient.
Examples:
ILOG CPLEX LP format requires the factor of 1/2 to be explicitly specified in the file.
Minimize obj: [ 100 x1 ^2 - 200 x1 * x2 + 100 x2 ^2 ] / 2 |
MPS
format for this same objective function would contain the following.
QMATRIX x1 x1 100 x1 x2 -100 x2 x1 -100 x2 x2 100 |
A C++ Concert program having such an objective function might include the following.
model.add(IloMinimize(env, 0.5 * (100*x[0]*x[0] + 100*x[1]*x[1] - 200*x[0]*x[1] ) )); |
Or since the algebraic view is supported, the factor of ½ could be simplified as in the following equivalent expression
model.add(IloMinimize(env, (50*x[0]*x[0] + 50*x[1]*x[1] - 100*x[0]*x[1] ) )); |
A similar Java program using Concert might express it this way:
Again, the user could choose to simplify the above expression algebraically if that suits the purposes of the application better.
Finally, a Callable Library application in C might construct the quadratic objective function in a way similar to the following:
zqmatind[0] = 0; zqmatind[2] = 0; zqmatval[0] = 100.0; zqmatval[2] = -100.0; zqmatind[1] = 1; zqmatind[3] = 1; zqmatval[1] =-100.0; zqmatval[3] = 100.0; |
To re-emphasize the point about the factor of 1/2 in any of these methods, if that objective function is evaluated with a solution of x1 = 1.000000
and x2 = 3.000000
, the result to be expected is 200
, not 400
.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |