quadprog(c, Q, A, sense, b, l, u, solver)¶
Solves the quadratic programming problem:
cis the objective vector, always in the sense of minimization
Qis the Hessian matrix of the objective
Ais the constraint matrix, with rows \(a_i\) (viewed as column-oriented vectors)
senseis a vector of constraint sense characters
bis the right-hand side vector
lis the vector of lower bounds on the variables
uis the vector of upper bounds on the variables, and
solverspecifies the desired solver, see choosing solvers.
A scalar is accepted for the
u arguments, in which case its value is replicated. The values
Inf are interpreted to mean that there is no corresponding lower or upper bound.
Quadratic programming solvers extensively exploit the sparsity of the Hessian matrix
Q and the constraint matrix
A. While both dense and sparse matrices are accepted, for large-scale problems sparse matrices should be provided if permitted by the problem structure.
quadprog function returns an instance of the type:
type QuadprogSolution status objval sol attrs end
status is a termination status symbol, one of
:UserLimit (iteration limit or timeout),
:Error (and maybe others).
:Optimal, the other members have the following values:
objval– optimal objective value
sol– primal solution vector
attrs– a dictionary that may contain other relevant attributes (not currently used).
Analogous shortened and range-constraint versions are available as well.
We can solve the three-dimensional QP (see
using MathProgBase, Ipopt sol = quadprog([0., 0., 0.],[2. 1. 0.; 1. 2. 1.; 0. 1. 2.],[1. 2. 3.; 1. 1. 0.],'>',[4., 1.],-Inf,Inf, IpoptSolver()) if sol.status == :Optimal println("Optimal objective value is $(sol.objval)") println("Optimal solution vector is: [$(sol.sol), $(sol.sol), $(sol.sol)]") else println("Error: solution status $(sol.status)") end