Quadratic Programming |
This topic contains the following sections:
General form of quadratic programming problem has the form:
where
- symmetric matrix that represents the quadratic in the objective function.
- linear objective function vector,
- matrix for linear equality constraints,
- vector for linear equality constraints,
- matrix for linear inequality constraints,
- vector for linear inequality constraints,
- vector of lower bounds,
- vector of upper bounds.
The quadratic programming solver implements a variant of Mehrotra's predictor-corrector algorithm, a primal-dual interior-point method. A number of preprocessing steps occur before the algorithm begins to iterate. The quadratic programming solver is implemented by the QuadraticProgramming class. The constructor of this class has the following prototype:
The class implements the IConstrainedProgramming interface.
Constructor | Description | Performance |
---|---|---|
H, A and C - dense matrices | Creates new instance of QuadraticProgramming class. QuadraticProgramming(Matrix, Vector, Matrix, Vector, Matrix, Vector, Vector, Vector) | |
H, A and C - sparse matrices | Creates new instance of QuadraticProgramming class. |
The class implements an event LogMessage that occurs every time the INumericalOptimization wants to send a log message, and the following methods:
Method | Description | Performance |
---|---|---|
minimum | Finds minimum of constrained multivariable function and returns true in case the optimization algorithm succeeded. | |
minimum with initial point provided | Finds minimum of constrained multivariable function and returns true in case the optimization algorithm succeeded. The initial point for the algorithm is passed as a parameter. |
Class provides the following properties:
Property | Description | Performance |
---|---|---|
iterations done | Number of iterations done. | |
iterations limit | Maximum number of iterations allowed, a positive integer. | |
minimum point | Minimum point of objective function. | |
minimum value | Minimum value of objective function. | |
status | Status of algorithm termination. | |
tolerance | Algorithm termination tolerance, a positive scalar. |
Note |
---|
Usually the default tolerance settings provide good convergence so there is no need to adjust them. |
The example demonstrate how to determine input parameters in standard form and use the QP solver for the following problem:
To present this problem in the standard form, there should be:
The following code solves the problem:
1using System; 2using FinMath.LinearAlgebra; 3using FinMath.NumericalOptimization.Constrained; 4 5namespace FinMath.Samples 6{ 7 class QuadraticProgrammingSample 8 { 9 static void Main() 10 { 11 // Objective function. 12 Matrix H = new Matrix(new Double[,] { { 2.0, 0.0 }, { 0.0, 2.0 } }); 13 Vector F = new Vector(new Double[] { -2.0, -50.0 }); 14 15 // Linear inequality constraints. 16 Matrix Ai = new Matrix(new Double[,] { { -1.0, 2.0 }, { 1.0, 2.0 } }); 17 Vector Bi = new Vector(new Double[] { 2.0, 6.0 }); 18 19 // Lower bounds on variables. 20 Vector L = new Vector(new Double[] { 0.0, 0.0 }); 21 22 // Create an instance of the solver. 23 QuadraticProgramming solver = new QuadraticProgramming(H, F, null, null, Ai, Bi, L, null); 24 25 // Setting of the solver. 26 solver.Tolerance = 1.0E-8; 27 solver.IterationsLimit = 50; 28 29 // Delegate used to print messages. 30 solver.LogMessage += Console.WriteLine; 31 32 // Find minimum. 33 solver.Minimize(); 34 35 // Get minimum point. 36 if (solver.Status == FMStatus.MethodSucceeded) 37 { 38 Console.WriteLine("MinimumPoint = " + solver.MinimumPoint.ToString("")); 39 } 40 else 41 { 42 Console.WriteLine("Linear programming solver failed."); 43 } 44 } 45 } 46}