#include <CGAL/QP_solution.h>
$$
(QP)$$  minimize$$  x^{T}Dx+c^{T}x+c_{0} 
subject to$$  Ax ~ b,  
l x u 
in $$n real variables $$x=(x_{0},...,x_{n1}).
If $$D=0, the program is a linear program; if the variable bounds are $$x 0, we have a nonnegative program. Objects of type Quadratic_program_solution<ET> are returned by any of the four functions solve_quadratic_program, solve_linear_program, solve_nonnegative_quadratic_program, and solve_nonnegative_linear_program.
If the objective function value becomes arbitrarily small over the feasible region (the set of feasible solutions), the program is called unbounded, and bounded otherwise.
Any program that is both feasible and bounded has at least one feasible solution $$x^{*} whose objective function value is not larger than that of any other feasible solution. This is called an optimal solution.
Every convex quadratic program (even if it is infeasible or unbounded) has a 'solution' in form of an object of the class Quadratic_program_solution<ET>.
 
The exact number type that was used to solve the
program.
 
 
An iterator type with value type
Quotient<ET> to go over the values of the variables in the solution.
 
 
An iterator type with value type
ET to go over the numerators of the variable values
with respect to a common denominator.
 
 
An iterator type with value type int
to go over the indices of the basic variables and the basic constraints.
 
 
An iterator type with
value type Quotient<ET> to go over an $$mvector $$ that proves
optimality of the solution.
 
 
An iterator type
with value type ET to go over the numerators of the vector $$
with respect to a common denominator.
 
 
An iterator type with
value type ET to go over an $$mvector $$ that proves
infeasibility of the solution.
 
 
An iterator type with
value type ET to go over an $$nvector $$w that proves unboundedness
of the solution.

 
constructs a void instance of Quadratic_program_solution<ET> that is associated to
no program.

Objects of type Quadratic_program_solution<ET> can be copied and assigned.
Objects of type Quadratic_program_solution<ET> that are associated to an actual program are returned by any of the four functions solve_quadratic_program, solve_linear_program, solve_nonnegative_quadratic_program, and solve_nonnegative_linear_program.

 returns true iff sol is not associated to a program. The condition !sol.is_void() is a precondition for all access methods below. 

 returns true iff sol is an optimal solution of the associated program. 

 returns true iff the associated program is infeasible. 

 returns true iff the associated program is unbounded. 

 returns the status of the solution; this is one of the values QP_OPTIMAL, QP_INFEASIBLE, and QP_UNBOUNDED, depending on whether the program asociated to sol has an optimal solution, is infeasible, or is unbounded. 

 returns the number of iterations that it took to solve the program asociated to sol. 

 returns the objective function value of sol. 

 returns the numerator of the objective function value of sol. 

 
returns the denominator of the objective function value of sol.  

 returns a randomaccess iterator over the values of the variables in sol. The value type is Quotient<ET>, and the valid iterator range has length $$n. 

 returns the corresponding pasttheend iterator. 

 returns a randomaccess iterator it over the values of the variables in sol, with respect to a common denominator of all variables. The value type is ET, and the valid iterator range has length $$n. 

 returns the corresponding pasttheend iterator. 

 
returns the common denominator of the variable values as referred to by the previous two methods. 

 
returns a random access iterator over the indices of the basic variables. The value type is int. It is guaranteed that any variable that is not basic in sol attains one of its bounds. In particular, if the bounds are of type $$x 0, all nonbasic variables have value $$0.  

 returns the corresponding pasttheend iterator. 

 returns the number of basic variables, equivalently the length of the range determined by the previous two iterators. 

 
returns a random access iterator over the indices of the basic constraints in the system $$Ax ~ b. The value type is int. It is guaranteed that any basic constraint is satisfied with equality. In particular, if the system is of type $$Ax=b, all constraints are basic.  

 
returns the corresponding pasttheend iterator.  

 
returns the number of basic constraint, equivalently the length of the range determined by the previous two iterators. 
 

 writes the status of sol to the stream out. In case the status is QP_OPTIMAL, the optimal objective value and the values of the variables at the optimal solution are output as well. For more detailed information about the solution (like basic variables/constraints) please use the dedicated methods of Quadratic_program_solution<ET>. 
By passing a suitable option to the solution function, you can make sure that this check is done automatically after the solution of the program, see Quadratic_program_options. If the check fails, a logfile is generated that contains the details, and an error message is written to std::cerr (see QP_solver/cycling.cpp for an example that uses this option).
 

 
returns true iff sol solves the quadratic program qp. If the result is false, you can get a message that describes the problem, through the method get_error(). 
 

 
returns true iff sol solves the linear program lp. If the result is false, you can get a message that describes the problem, through the method get_error(). 
 

 
returns true iff sol solves the nonnegative quadratic program qp. If the result is false, you can get a message that describes the problem, through the method get_error(). 
QP_solver/first_nonnegative_qp.cpp
 

 
returns true iff sol solves the nonnegative linear program lp. If the result is false, you can get a message that describes the problem, through the method get_error(). 
QP_solver/first_nonnegative_lp.cpp
advanced 
A certificate is a vector that admits a simple proof for the correctness of the solution. Any nonvoid object of Quadratic_program_solution<ET> comes with such a certificate.
Lemma 1 (optimality certificate): A feasible $$nvector $$x^{*} is an optimal solution of (QP) if an $$mvector $$ with the following properties exist.
$$
0,  if $$x^{*}_{j} = l_{j} < u_{j}$$  
(c^{T} + ^{T} A + 2x^{*}^{T}D)_{j}  = 0,  if $$l_{j} < x^{*}_{j} < u_{j}$$  
0,  if $$l_{j} < u_{j} = x^{*}_{j}.$$ 
Proof: Let $$x be any feasible solution. We need to prove that
$$c^{T}x+ x^{T}Dx c^{T}x^{*} + x^{*}^{T}Dx^{*}.
For this, we argue as follows.
$$
c^{T}x+ 2x^{*}^{T}Dx  c^{T}x+ 2x^{*}^{T}Dx+ ^{T}(Axb)  (by $$Ax ~ b and 1.)$$  
=  (c^{T} + ^{T} A + 2x^{*}^{T}D)x ^{T}b  
(c^{T} + ^{T} A + 2x^{*}^{T}D)x^{*}  ^{T}b  (by $$l x u and 3.)$$  
=  c^{T}x^{*} + 2x^{*}^{T}Dx^{*}  (by 2.)$$ 
After adding $$x^{T}Dx x^{T}Dx x^{*}^{T}Dx^{*} = x^{*}^{T}Dx^{*} to both sides of this inequality, we get
$$ c^{T}x+ x^{T}Dx (xx^{*})^{T}D(xx^{*}) c^{T}x^{*} + x^{*}^{T}Dx^{*},
and since $$D is positive semidefinite, we have $$(xx^{*})^{T}D(xx^{*}) 0 and the lemma follows.

 
returns a random access iterator over the optimality certificate
$$ as given in Lemma 1, with respect to the solution $$x^{*}
obtained from sol.variable_values_begin(). The value type
is Quotient<ET>, and the valid iterator range has length $$m.
 

 returns the corresponding pasttheend iterator.  
 
 
returns a random access iterator over the numerator values of the optimality certificate $$, with respect to the common denominator returned by sol.variables_common_denominator(). The value type is ET, and the valid iterator range has length $$m.  
 
 
returns the corresponding pasttheend iterator. 
Lemma 2 (infeasibility certificate): The program (QP) is infeasible if an $$mvector $$ with the following properties exist.
$$
0  if $$u_{j}= $$  
^{T} A_{j}  
0  if $$l_{j}= .$$ 
$$^{T}b < _{j: TAj <0} ^{T}A_{j} u_{j} + _{j: TAj >0} ^{T}A_{j} l_{j}.
Proof: Let us assume for the purpose of obtaining a contradiction that there is a feasible solution $$x. Then we get
$$
0  ^{T}(Axb)  (by $$Ax ~ b and 1.)$$  
=  _{j: TAj <0} ^{T}A_{j} x_{j} + _{j: TAj >0} ^{T}A_{j} x_{j}  ^{T} b  
_{j: TAj <0} ^{T}A_{j} u_{j} + _{j: TAj >0} ^{T}A_{j} l_{j}  ^{T} b  (by $$l x u and 2.)$$  
>  0  (by 3.)$$, 
and this is the desired contradiction $$0>0.
Lemma 3 (unboundedness certificate:) Let $$x^{*} be a feasible solution of (QP). The program (QP) is unbounded if an $$nvector $$w with the following properties exist.
$$
0  if $$l_{j} is finite$$  
w_{j}  
0  if $$u_{j} is finite.$$ 
The vector $$w is called an unbounded direction.
Proof: For a real number $$t, consider the vector $$x(t):=x^{*}+tw. By 1. and 2., $$x(t) is feasible for all $$t 0. The objective function value of $$x(t) is
$$
c^{T} x(t) + x(t)^{T}D x(t)  =  c^{T}x^{*} + tc^{T}w+ x^{*}^{T}Dx^{*} + 2tx^{*}^{T}Dw+ t^{2} w^{T}Dw 
=  c^{T}x^{*} + x^{*}^{T}Dx^{*} + t(c^{T} + 2x^{*}^{T}D)w+ t^{2}w^{T}Dw. 
By condition 3., this tends to $$ for $$t , so the problem is indeed unbounded.
 
 
returns a random acess iterator over the unbounded direction $$w
as given in Lemma 3,with respect to the solution $$x^{*}
obtained from sol.variable_values_begin(). The value type
is ET, and the valid iterator range has length $$n.
 
 
 
returns the corresponding pasttheend iterator. 
advanced 
The program concepts
QuadraticProgram
LinearProgram
NonnegativeQuadraticProgram
NonnegativeLinearProgram
and the functions that compute objects of class Quadratic_program_solution<ET> from models of these concepts:
solve_quadratic_program
solve_linear_program
solve_nonnegative_quadratic_program
solve_nonnegative_linear_program