qpipoptmat
Solves a linear quadratic problem.
Calling Sequence
xopt = qpipoptmat(H,f)
xopt = qpipoptmat(H,f,A,b)
xopt = qpipoptmat(H,f,A,b,Aeq,beq)
xopt = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub)
xopt = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0)
xopt = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0,param)
[xopt,fopt,exitflag,output,lamda] = qpipoptmat( ... )
Input Parameters
H :
A symmetric matrix of doubles, representing the Hessian of the quadratic problem.
f :
A vector of doubles, representing coefficients of the linear terms in the quadratic problem.
A :
A matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where 'm' is the number of linear inequality constraints.
b :
A vector of doubles, related to 'A' and containing the the Right hand side equation of the linear inequality constraints of size (m X 1).
Aeq :
A matrix of doubles, containing the coefficients of linear equality constraints of size (m1 X n) where 'm1' is the number of linear equality constraints.
beq :
A vector of doubles, related to 'Aeq' and containing the the Right hand side equation of the linear equality constraints of size (m1 X 1).
lb :
A vector of doubles, containing the lower bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of variables.
ub :
A vector of doubles, containing the upper bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of variables.
x0 :
A vector of doubles, containing the starting values of variables of size (1 X n) or (n X 1) where 'n' is the number of variables.
param :
A list, containing the option for user to specify. See below for details.
Outputs
xopt :
A vector of doubles, containing the computed solution of the optimization problem.
fopt :
A double, containing the value of the function at xopt.
exitflag :
An integer, containing the flag which denotes the reason for termination of algorithm. See below for details.
output :
A structure, containing the information about the optimization. See below for details.
lambda :
A structure, containing the Lagrange multipliers of the lower bounds, upper bounds and constraints at the optimized point. See below for details.
Description
Search the minimum of a constrained linear quadratic optimization problem specified by :
\begin{eqnarray}
\hspace{1pt} &\mbox{min}_{x}
\hspace{1pt} & 1/2⋅x^T⋅H⋅x + f^T⋅x \\
\hspace{1pt} & \text{Subjected to: } & A⋅x \leq b \\
\end{eqnarray}\\
\begin{eqnarray}
\hspace{115pt} & Aeq⋅x = beq \\
\hspace{115pt} & lb \leq x \leq ub \\
\end{eqnarray}
qpipoptmat calls Ipopt, an optimization library written in C++, to solve the optimization problem.
Options
The options allow the user to set various parameters of the Optimization problem. The syntax for the options is given by:
options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "Hessian", ---, "GradCon", ---);
The options should be defined as type "list" and consist of the following fields:
MaxIter : A Scalar, specifying the maximum number of iterations that the solver should take.
CpuTime : A Scalar, specifying the maximum amount of CPU time in seconds that the solver should take.
The default values for the various items are given as:
options = list("MaxIter", [3000], "CpuTime", [600]);
The exitflag allows the user to know the status of the optimization which is returned by Ipopt. The values it can take and what they indicate is described below:
0 : Optimal Solution Found
1 : Maximum Number of Iterations Exceeded. Output may not be optimal.
2 : Maximum amount of CPU Time exceeded. Output may not be optimal.
3 : Stop at Tiny Step.
4 : Solved To Acceptable Level.
5 : Converged to a point of local infeasibility.
For more details on exitflag, see the Ipopt documentation which can be found on http://www.coin-or.org/Ipopt/documentation/
The output data structure contains detailed information about the optimization process.
It is of type "struct" and contains the following fields.
output.iterations: The number of iterations performed.
output.constrviolation: The max-norm of the constraint violation.
The lambda data structure contains the Lagrange multipliers at the end of optimization. In the current version, the values are returned only when the the solution is optimal.
It has type "struct" and contains the following fields.
lambda.lower: The Lagrange multipliers for the lower bound constraints.
lambda.upper: The Lagrange multipliers for the upper bound constraints.
lambda.eqlin: The Lagrange multipliers for the linear equality constraints.
lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.
Example
Here we solve a simple objective function.
Find x in R^6 such that it minimizes:
\begin{eqnarray}
\mbox{min}_{x}\ f(x) &= \dfrac{1}{2}x'\boldsymbol{\cdot} H\boldsymbol{\cdot}x + f' \boldsymbol{\cdot} x\\
\text{Where: } H &= I_{6}\\
F &=
\begin{array}{cccccc}
[1 & 2 & 3 & 4 & 5 & 6]
\end{array}
\end{eqnarray}
Example
We proceed to add simple linear inequality constraints.
\begin{eqnarray}
\hspace{1pt} &x_{2} + x_{4}+ 2x_{5} - x_{6}&\leq -1\\
\hspace{1pt} &-x_{1} + 2x_{3} + x_{4} + x_{5}&\leq 2.5\\
\end{eqnarray}
Example
Here we build up on the previous example by adding linear equality constraints.
We add the following constraints to the problem specified above:
\begin{eqnarray}
\hspace{1pt} &x_{1} - x_{2} + x_{3} + 3x_{5} + x_{6}&= 1 \\
\hspace{1pt} &-x_{1} + 2x_{3}+ x_{4} + x_{5}&= 2\\
\hspace{1pt} &2x_{1} + 5x_{2}+ 3x_{3} + x_{5}&= 3
\end{eqnarray}
Example
In this example, we proceed to add the upper and lower bounds to the objective function.
\begin{eqnarray}
-1000 &\leq x_{1} &\leq 10000\\
-10000 &\leq x_{2} &\leq 100\\
0 &\leq x_{3} &\leq 1.5\\
-1000 &\leq x_{4} &\leq 100\\
-1000 &\leq x_{5} &\leq 100\\
-1000 &\leq x_{6} &\leq 1000
\end{eqnarray}
Example
In this example, we initialize the values of x to speed up the computation. We further enhance the functionality of qpipoptmat by setting input options.
Example
Infeasible Problems: Find x in R^6 such that it minimizes the following objective function under the given constraints:
\begin{eqnarray}
\hspace{70pt} &x_{2} + x_{4}+ 2x_{5} - x_{6}&\leq -1\\
\hspace{70pt} &-x_{1} + 2x_{3} + x_{4} + x_{5}&\leq 2.5\\
\hspace{70pt} &x_{2} + x_{4}+ 2x_{5} - x_{6}&= 4 \\
\hspace{70pt} &-x_{1} + 2x_{3}+ x_{4} + x_{5}&= 2\\
\\ \end{eqnarray}
Example
Unbounded Problems: Find x in R^6 such that it minimizes the objective function used above under the following constraints:
\begin{eqnarray}
\mbox{min}_{x}\ f(x) &= \dfrac{1}{2}x'\boldsymbol{\cdot} H\boldsymbol{\cdot}x + f' \boldsymbol{\cdot} x\\
\text{Where H is specified below and}\\
F &=
\begin{array}{cccccc}
[1 & 2 & 3 & 4 & 5 & 6]
\end{array}
\end{eqnarray}\\
\text{Subjected to: }\\
\begin{eqnarray}
\hspace{70pt} &x_{2} + x_{4}+ 2x_{5} - x_{6}&\leq -1\\
\hspace{70pt} &-x_{1} + 2x_{3} + x_{4} + x_{5}&\leq 2.5\\
\hspace{70pt} &x_{1} - x_{2} + x_{3} + 3x_{5} + x_{6}&= 1 \\
\hspace{70pt} &-x_{1} + 2x_{3}+ x_{4} + x_{5}&= 2\\
\\ \end{eqnarray}
Authors
Keyur Joshi, Saikiran, Iswarya, Harpreet Singh