mirror of https://github.com/CGAL/cgal
- _from_pointer models removed (they are useless as well)
- fixed and added more examples, and referred to them from manual
This commit is contained in:
parent
630e95f909
commit
ce80f2f8db
|
|
@ -1837,15 +1837,11 @@ QP_solver/doc_tex/QP_solver/first_qp.gif -text svneol=unset#image/gif
|
|||
QP_solver/doc_tex/QP_solver/first_qp.pdf -text svneol=unset#application/pdf
|
||||
QP_solver/doc_tex/QP_solver/qp.png -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Linear_program_from_iterators.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Linear_program_from_pointers.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/MPSFormat.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Nonnegative_linear_program_from_iterators.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Nonnegative_linear_program_from_pointers.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Nonnegative_quadratic_program_from_iterators.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Nonnegative_quadratic_program_from_pointers.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Quadratic_program.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Quadratic_program_from_mps.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Quadratic_program_from_pointers.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/Quadratic_program_solution.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/make_linear_program_from_iterators.tex -text
|
||||
QP_solver/doc_tex/QP_solver_ref/make_nonnegative_linear_program_from_iterators.tex -text
|
||||
|
|
@ -1861,10 +1857,26 @@ QP_solver/doc_tex/QP_solver_ref/solve_nonnegative_quadratic_program.tex -text
|
|||
QP_solver/doc_tex/QP_solver_ref/solve_quadratic_program.tex -text
|
||||
QP_solver/examples/QP_solver/double_qp_solver.cin -text
|
||||
QP_solver/examples/QP_solver/double_qp_solver.data -text
|
||||
QP_solver/examples/QP_solver/first_lp.cpp -text
|
||||
QP_solver/examples/QP_solver/first_lp.mps -text
|
||||
QP_solver/examples/QP_solver/first_lp_from_mps.cpp -text
|
||||
QP_solver/examples/QP_solver/first_nonnegative_lp.cpp -text
|
||||
QP_solver/examples/QP_solver/first_nonnegative_lp.mps -text
|
||||
QP_solver/examples/QP_solver/first_nonnegative_lp_from_mps.cpp -text
|
||||
QP_solver/examples/QP_solver/first_nonnegative_qp.cpp -text
|
||||
QP_solver/examples/QP_solver/first_nonnegative_qp.mps -text
|
||||
QP_solver/examples/QP_solver/first_nonnegative_qp_from_mps.cpp -text
|
||||
QP_solver/examples/QP_solver/first_qp.cpp -text
|
||||
QP_solver/examples/QP_solver/first_qp.mps -text
|
||||
QP_solver/examples/QP_solver/first_qp_from_mps.cpp -text
|
||||
QP_solver/examples/QP_solver/infeasibility_certificate.cpp -text
|
||||
QP_solver/examples/QP_solver/integer_qp_solver.cin -text
|
||||
QP_solver/examples/QP_solver/integer_qp_solver.data -text
|
||||
QP_solver/examples/QP_solver/optimality_certificate.cpp -text
|
||||
QP_solver/examples/QP_solver/print_first_lp.cpp -text
|
||||
QP_solver/examples/QP_solver/print_first_nonnegative_lp.cpp -text
|
||||
QP_solver/examples/QP_solver/print_first_nonnegative_qp.cpp -text
|
||||
QP_solver/examples/QP_solver/print_first_qp.cpp -text
|
||||
QP_solver/examples/QP_solver/rational_qp_solver.cin -text
|
||||
QP_solver/examples/QP_solver/rational_qp_solver.data -text
|
||||
QP_solver/examples/QP_solver/unboundedness_certificate.cpp -text
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ iterators over the program data, see below. The program therefore
|
|||
comes in \emph{dense} representation which includes zero entries.
|
||||
|
||||
\ccHasModels
|
||||
\ccc{CGAL::Linear_program<NT>}\\
|
||||
\ccc{CGAL::Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{CGAL::Linear_program_from_pointers<NT>}\\
|
||||
\ccc{CGAL::Linear_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}
|
||||
|
||||
|
||||
\ccTypes
|
||||
|
||||
|
|
@ -119,6 +119,14 @@ respectively, for \ccc{A_iterator}) must be
|
|||
convertible to some common \ccc{IntegralDomain} \ccc{ET}.
|
||||
|
||||
\ccSeeAlso
|
||||
The models
|
||||
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}
|
||||
|
||||
and the other concepts
|
||||
|
||||
\ccc{QuadraticProgramInterface}\\
|
||||
\ccc{NonnegativeQuadraticProgramInterface}\\
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ This class is simply a wrapper for existing iterators, and it does not
|
|||
copy the program data (if you need a copy, you may use the class
|
||||
\ccc{Linear_program<NT>}).
|
||||
|
||||
It frequently happens that all values in one of the vectors from
|
||||
above are the same, for example if the system $Ax\qprel b$ is
|
||||
actually a system of equations $Ax=b$. To get an iterator over such a
|
||||
vector, it is not necessary to store multiple copies of the value in
|
||||
some container; an instance of the class \ccc{Const_oneset_iterator<T>},
|
||||
constructed from the value in question, does the job more efficiently.
|
||||
|
||||
\ccIsModel
|
||||
\ccc{LinearProgramInterface}
|
||||
|
||||
|
|
@ -49,11 +56,23 @@ copy the program data (if you need a copy, you may use the class
|
|||
const U_it& u,
|
||||
const C_it& c,
|
||||
const std::iterator_traits<C_it>value_type& c0 = 0
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. }
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. How these iterators are supposed to encode the linear program is
|
||||
described in \ccc{LinearProgramInterface}. }
|
||||
|
||||
\ccExample
|
||||
|
||||
\ccReferToExampleCode{QP_solver/first_lp_from_iterators.cpp}
|
||||
|
||||
The following example for the simpler model
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
should give you a flavor of the use of this
|
||||
model in practice.
|
||||
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Linear_program<NT>}\\
|
||||
\ccc{Linear_program_from_pointers<NT>}\\
|
||||
\ccc{Linear_program_from_mps<NT>}
|
||||
\ccc{LinearProgramInterface}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
\begin{ccRefClass}{Linear_program_from_pointers<NT>}
|
||||
|
||||
\ccInclude{CGAL/QP_models.h}
|
||||
|
||||
\ccDefinition
|
||||
An object of class \ccRefName\ describes a linear program of the form
|
||||
%%
|
||||
\begin{eqnarray*}
|
||||
\mbox{(LP)}& \mbox{minimize} & c^{T}x+c_0 \\
|
||||
&\mbox{subject to} & Ax\qprel b, \\
|
||||
& & l \leq x \leq u
|
||||
\end{eqnarray*}
|
||||
%%
|
||||
in $n$ real variables $x=(x_0,\ldots,x_{n-1})$.
|
||||
Here,
|
||||
\begin{itemize}
|
||||
\item $A$ is an $m\times n$ matrix (the constraint matrix),
|
||||
\item $b$ is an $m$-dimensional vector (the right-hand side),
|
||||
\item $\qprel$ is an $m$-dimensional vector of relations
|
||||
from $\{\leq, =, \geq\}$,
|
||||
\item $l$ is an $n$-dimensional vector of lower
|
||||
bounds for $x$,
|
||||
\item $u$ is an $n$-dimensional vector of upper bounds for
|
||||
$x$,
|
||||
\item $c$ is an $n$-dimensional vector (the linear objective
|
||||
function), and
|
||||
\item $c_0$ is a constant.
|
||||
\end{itemize}
|
||||
|
||||
This class specializes the class
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>} for the case where all iterators are of type \ccc{NT**} (for
|
||||
$A$) and \ccc{NT*} otherwise, for some number type \ccc{NT}.
|
||||
The class is simply a wrapper for
|
||||
existing pointers, and it does not copy the program data (if you need
|
||||
a copy, you may use the class \ccc{Linear_program<NT>}).
|
||||
|
||||
\ccIsModel
|
||||
\ccc{LinearProgramInterface}
|
||||
|
||||
\ccTypes
|
||||
\ccNestedType{NT}{The number type of the program entries.}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Linear_program<NT>}\\
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}\\
|
||||
\ccc{Linear_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
\begin{ccRefConcept}{MPSFormat}
|
||||
|
||||
MPS is a commonly used file format for storing linear and quadratic
|
||||
programs according to the concepts \ccc{LinearProgramInterface} and
|
||||
\ccc{QuadraticProgramInterface}. \cgal\ supports a large subset of
|
||||
programs according to the concepts \ccc{QuadraticProgramInterface},
|
||||
\ccc{LinearProgramInterface},
|
||||
\ccc{NonnegativeQuadraticProgramInterface}, and
|
||||
\ccc{NonnegativeLinearProgramInterface}. \cgal\ supports a large subset of
|
||||
this format, but there are MPS files around that we cannot read (for
|
||||
example, files that encode integrality constraints on the variables).
|
||||
Also, there might be some other MPS-based solvers that will not be able
|
||||
|
|
@ -26,7 +28,7 @@ Let's look at an example first. The quadratic program
|
|||
has the following description in MPS format.
|
||||
|
||||
\begin{verbatim}
|
||||
NAME MY_MPS
|
||||
NAME first_qp
|
||||
ROWS
|
||||
N obj
|
||||
L c0
|
||||
|
|
@ -149,5 +151,8 @@ program is a model of the concept \ccc{LinearProgramInterface}.
|
|||
Our MPS format also supports an (optional) \texttt{RANGES} section,
|
||||
but we don't explain this here.
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefConcept}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ iterators over the program data, see below. The program therefore
|
|||
comes in \emph{dense} representation which includes zero entries.
|
||||
|
||||
\ccHasModels
|
||||
\ccc{CGAL::Nonnegative_linear_program<NT>}\\
|
||||
\ccc{CGAL::Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{CGAL::Nonnegative_linear_program_from_pointers<NT>}\\
|
||||
\ccc{CGAL::Nonnegative_linear_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}
|
||||
|
||||
|
||||
\ccTypes
|
||||
|
||||
|
|
@ -83,6 +83,14 @@ respectively, for \ccc{A_iterator}) must be convertible to some common
|
|||
\ccc{IntegralDomain} \ccc{ET}.
|
||||
|
||||
\ccSeeAlso
|
||||
The models
|
||||
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
|
||||
and the other concepts
|
||||
|
||||
\ccc{QuadraticProgramInterface}\\
|
||||
\ccc{LinearProgramInterface}\\
|
||||
\ccc{NonnegativeQuadraticProgramInterface}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,9 @@ iterators over the program data, see below. The program therefore
|
|||
comes in \emph{dense} representation which includes zero entries.
|
||||
|
||||
\ccHasModels
|
||||
\ccc{CGAL::Nonnegative_quadratic_program<NT>}\\
|
||||
\ccc{CGAL::Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{CGAL::Nonnegative_quadratic_program_from_pointers<NT>}\\
|
||||
\ccc{CGAL::Nonnegative_quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
|
||||
\ccTypes
|
||||
|
||||
|
|
@ -95,6 +94,13 @@ respectively, for \ccc{A_iterator} and \ccc{D_iterator}) must be
|
|||
convertible to some common \ccc{IntegralDomain} \ccc{ET}.
|
||||
|
||||
\ccSeeAlso
|
||||
The models
|
||||
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}
|
||||
and the other concepts
|
||||
|
||||
\ccc{QuadraticProgramInterface}\\
|
||||
\ccc{LinearProgramInterface}\\
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,13 @@ This class is simply a wrapper for existing iterators, and it does not
|
|||
copy the program data (if you need a copy, you may use the class
|
||||
\ccc{Nonnegative_linear_program<NT>}).
|
||||
|
||||
It frequently happens that all values in one of the vectors from
|
||||
above are the same, for example if the system $Ax\qprel b$ is
|
||||
actually a system of equations $Ax=b$. To get an iterator over such a
|
||||
vector, it is not necessary to store multiple copies of the value in
|
||||
some container; an instance of the class \ccc{Const_oneset_iterator<T>},
|
||||
constructed from the value in question, does the job more efficiently.
|
||||
|
||||
\ccIsModel
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
|
||||
|
|
@ -41,10 +48,18 @@ copy the program data (if you need a copy, you may use the class
|
|||
const R_it& r,
|
||||
const C_it& c,
|
||||
const std::iterator_traits<C_it>value_type& c0 = 0
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. }
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant
|
||||
\ccc{c0}. The passed iterators are merely stored, no copying of the program
|
||||
data takes place. How these iterators are supposed to encode the nonnegative
|
||||
linear program is described in \ccc{NonnegativeLinearProgramInterface}.}
|
||||
|
||||
\ccExample
|
||||
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_lp_from_iterators.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Nonnegative_linear_program<NT>}\\
|
||||
\ccc{Nonnegative_linear_program_from_pointers<NT>}\\
|
||||
\ccc{Nonnegative_linear_program_from_mps<NT>}
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
\begin{ccRefClass}{Nonnegative_linear_program_from_pointers<NT>}
|
||||
|
||||
\ccInclude{CGAL/QP_models.h}
|
||||
|
||||
\ccDefinition
|
||||
An object of class \ccRefName\ describes a linear program of the form
|
||||
%%
|
||||
\begin{eqnarray*}
|
||||
\mbox{(LP)}& \mbox{minimize} & c^{T}x+c_0 \\
|
||||
&\mbox{subject to} & Ax\qprel b, \\
|
||||
& & x \geq 0
|
||||
\end{eqnarray*}
|
||||
%%
|
||||
in $n$ real variables $x=(x_0,\ldots,x_{n-1})$.
|
||||
Here,
|
||||
\begin{itemize}
|
||||
\item $A$ is an $m\times n$ matrix (the constraint matrix),
|
||||
\item $b$ is an $m$-dimensional vector (the right-hand side),
|
||||
\item $\qprel$ is an $m$-dimensional vector of relations
|
||||
from $\{\leq, =, \geq\}$,
|
||||
\item $c$ is an $n$-dimensional vector (the linear objective
|
||||
function), and
|
||||
\item $c_0$ is a constant.
|
||||
\end{itemize}
|
||||
|
||||
This class specializes the class
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
for the case where all iterators are of type \ccc{NT**} (for
|
||||
$A$) and \ccc{NT*} otherwise, for some number type \ccc{NT}.
|
||||
The class is simply a wrapper for
|
||||
existing pointers, and it does not copy the program data (if you need
|
||||
a copy, you may use the class \ccc{Nonnegative_linear_program<NT>}).
|
||||
|
||||
\ccIsModel
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
|
||||
\ccTypes
|
||||
\ccNestedType{NT}{The number type of the program entries.}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Nonnegative_linear_program<NT>}\\
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}\\
|
||||
\ccc{Nonnegative_linear_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
@ -29,6 +29,13 @@ This class is simply a wrapper for existing iterators, and it does not
|
|||
copy the program data (if you need a copy, you may use the class
|
||||
\ccc{Nonnegative_quadratic_program<NT>}).
|
||||
|
||||
It frequently happens that all values in one of the vectors from
|
||||
above are the same, for example if the system $Ax\qprel b$ is
|
||||
actually a system of equations $Ax=b$. To get an iterator over such a
|
||||
vector, it is not necessary to store multiple copies of the value in
|
||||
some container; an instance of the class \ccc{Const_oneset_iterator<T>},
|
||||
constructed from the value in question, does the job more efficiently.
|
||||
|
||||
\ccIsModel
|
||||
\ccc{NonnegativeQuadraticProgramInterface}
|
||||
|
||||
|
|
@ -44,10 +51,21 @@ copy the program data (if you need a copy, you may use the class
|
|||
const D_it& d,
|
||||
const C_it& c,
|
||||
const std::iterator_traits<C_it>value_type& c0 = 0
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. }
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. How these iterators are supposed to encode the nonnegative
|
||||
quadratic program is described in \ccc{NonnegativeQuadraticProgramInterface}.}
|
||||
|
||||
\ccExample
|
||||
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_qp_from_iterators.cpp}
|
||||
|
||||
The following example for the simpler model
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
should give you a flavor of the use of this
|
||||
model in practice.
|
||||
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}
|
||||
\ccSeeAlso
|
||||
\ccc{Nonnegative_quadratic_program<NT>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_pointers<NT>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_mps<NT>}
|
||||
\ccc{NonnegativeQuadraticProgramInterface}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
\begin{ccRefClass}{Nonnegative_quadratic_program_from_pointers<NT>}
|
||||
|
||||
\ccInclude{CGAL/QP_models.h}
|
||||
|
||||
\ccDefinition
|
||||
An object of class \ccRefName\ describes a convex quadratic program of the form
|
||||
%%
|
||||
\begin{eqnarray*}
|
||||
\mbox{(QP)}& \mbox{minimize} & x^{T}Dx+c^{T}x+c_0 \\
|
||||
&\mbox{subject to} & Ax\qprel b, \\
|
||||
& & x \geq 0
|
||||
\end{eqnarray*}
|
||||
%%
|
||||
in $n$ real variables $x=(x_0,\ldots,x_{n-1})$.
|
||||
Here,
|
||||
\begin{itemize}
|
||||
\item $A$ is an $m\times n$ matrix (the constraint matrix),
|
||||
\item $b$ is an $m$-dimensional vector (the right-hand side),
|
||||
\item $\qprel$ is an $m$-dimensional vector of relations
|
||||
from $\{\leq, =, \geq\}$,
|
||||
\item $D$ is a symmetric positive-semidefinite $n\times n$ matrix (the
|
||||
quadratic objective function),
|
||||
\item $c$ is an $n$-dimensional vector (the linear objective
|
||||
function), and
|
||||
\item $c_0$ is a constant.
|
||||
\end{itemize}
|
||||
|
||||
This class specializes the class
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>} for the case where all iterators are of type \ccc{NT**} (for
|
||||
$A$ and $D$) and \ccc{NT*} otherwise, for some number type \ccc{NT}.
|
||||
The class is simply a wrapper for
|
||||
existing pointers, and it does not copy the program data (if you need
|
||||
a copy, you may use the class \ccc{Nonnegative_quadratic_program<NT>}).
|
||||
|
||||
\ccIsModel
|
||||
\ccc{NonnegativeQuadraticProgramInterface}
|
||||
|
||||
\ccTypes
|
||||
\ccNestedType{NT}{The number type of the program entries.}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Nonnegative_quadratic_program<NT>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
@ -32,10 +32,9 @@ iterators over the program data, see below. The program therefore
|
|||
comes in \emph{dense} representation which includes zero entries.
|
||||
|
||||
\ccHasModels
|
||||
\ccc{CGAL::Quadratic_program<NT>}\\
|
||||
\ccc{CGAL::Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{CGAL::Quadratic_program_from_pointers<NT>}\\
|
||||
\ccc{CGAL::Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}
|
||||
|
||||
\ccTypes
|
||||
|
||||
|
|
@ -131,6 +130,14 @@ respectively, for \ccc{A_iterator} and \ccc{D_iterator}) must be
|
|||
convertible to some common \ccc{IntegralDomain} \ccc{ET}.
|
||||
|
||||
\ccSeeAlso
|
||||
The models
|
||||
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}
|
||||
|
||||
and the other conepts
|
||||
|
||||
\ccc{NonnegativeQuadraticProgramInterface}\\
|
||||
\ccc{LinearProgramInterface}\\
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,17 @@ $x$,
|
|||
\end{itemize}
|
||||
|
||||
This class allows you to build your program entry by entry, using
|
||||
the set-methods below. If you only need to wrap existing (random-access)
|
||||
iterators, then you may use the classes
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>} and \ccc{Quadratic_program_from_pointers<NT>}). If you want
|
||||
to read a quadratic program in \ccc{MPSFormat} from a file, please use
|
||||
the model \ccc{Quadratic_program_from_mps<NT>}.
|
||||
the set-methods below.
|
||||
|
||||
If you only need to wrap existing (random-access)
|
||||
iterators over your own data, then you may use any of the four models
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>},
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>},
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}, and
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}.
|
||||
|
||||
If you want to read a quadratic program in \ccc{MPSFormat} from a stream,
|
||||
please use the model \ccc{Quadratic_program_from_mps<NT>}.
|
||||
|
||||
\ccIsModel
|
||||
\ccc{QuadraticProgramInterface}\\
|
||||
|
|
@ -110,10 +116,18 @@ $2D_{ij}$ and $2D_{ji}$ of \ccVar\ to \ccc{val}. Existing entries are
|
|||
overwritten. \ccVar\ is enlarged if necessary to accomodate these entries.
|
||||
\ccPrecond \ccc{j <= i}}
|
||||
|
||||
\ccExample
|
||||
|
||||
\ccReferToExampleCode{QP_solver/first_qp.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/first_lp.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_qp.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_lp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{Quadratic_program_from_pointers<NT>}\\
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}\\
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,16 @@ $x$,
|
|||
\item $c_0$ is a constant.
|
||||
\end{itemize}
|
||||
|
||||
This class is simply a wrapper for existing iterators, and it does not
|
||||
copy the program data (if you need a copy, you may use the class
|
||||
\ccc{Quadratic_program<NT>}).
|
||||
This class is simply a wrapper for existing iterators over these program
|
||||
data, and it does not copy the program data (if you need a copy, you may
|
||||
use the class \ccc{Quadratic_program<NT>}).
|
||||
|
||||
It frequently happens that all values in one of the vectors from
|
||||
above are the same, for example if the system $Ax\qprel b$ is
|
||||
actually a system of equations $Ax=b$. To get an iterator over such a
|
||||
vector, it is not necessary to store multiple copies of the value in
|
||||
some container; an instance of the class \ccc{Const_oneset_iterator<T>},
|
||||
constructed from the value in question, does the job more efficiently.
|
||||
|
||||
\ccIsModel
|
||||
\ccc{QuadraticProgramInterface}
|
||||
|
|
@ -52,11 +59,23 @@ copy the program data (if you need a copy, you may use the class
|
|||
const D_it& d,
|
||||
const C_it& c,
|
||||
const std::iterator_traits<C_it>value_type& c0 = 0
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. }
|
||||
)}{constructs \ccVar\ from given random-access iterators and the constant \ccc{c0}. The passed iterators are merely stored, no copying of the program data takes place. How these iterators are supposed to encode the quadratic program is
|
||||
described in \ccc{QuadraticProgramInterface}.}
|
||||
|
||||
\ccExample
|
||||
|
||||
\ccReferToExampleCode{QP_solver/first_qp_from_iterators.cpp}
|
||||
|
||||
The following example for the simpler model
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
should give you a flavor of the use of this
|
||||
model in practice.
|
||||
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{QuadraticProgramInterface}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_pointers<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -102,10 +102,17 @@ $2D_{ij}$ and $2D_{ji}$ of \ccVar\ to \ccc{val}. Existing entries are
|
|||
overwritten. \ccVar\ is enlarged if necessary to accomodate these entries.
|
||||
\ccPrecond \ccc{j <= i}}
|
||||
|
||||
\ccExample
|
||||
|
||||
\ccReferToExampleCode{QP_solver/first_qp_from_mps.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/first_lp_from_mps.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_qp_from_mps.cpp}\\
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_lp_from_mps.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{Quadratic_program_from_pointers<NT>}
|
||||
|
||||
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}\\
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
\begin{ccRefClass}{Quadratic_program_from_pointers<NT>}
|
||||
|
||||
\ccInclude{CGAL/QP_models.h}
|
||||
|
||||
\ccDefinition
|
||||
An object of class \ccRefName\ describes a convex quadratic program of the form
|
||||
%%
|
||||
\begin{eqnarray*}
|
||||
\mbox{(QP)}& \mbox{minimize} & x^{T}Dx+c^{T}x+c_0 \\
|
||||
&\mbox{subject to} & Ax\qprel b, \\
|
||||
& & l \leq x \leq u
|
||||
\end{eqnarray*}
|
||||
%%
|
||||
in $n$ real variables $x=(x_0,\ldots,x_{n-1})$.
|
||||
Here,
|
||||
\begin{itemize}
|
||||
\item $A$ is an $m\times n$ matrix (the constraint matrix),
|
||||
\item $b$ is an $m$-dimensional vector (the right-hand side),
|
||||
\item $\qprel$ is an $m$-dimensional vector of relations
|
||||
from $\{\leq, =, \geq\}$,
|
||||
\item $l$ is an $n$-dimensional vector of lower
|
||||
bounds for $x$,
|
||||
\item $u$ is an $n$-dimensional vector of upper bounds for
|
||||
$x$,
|
||||
\item $D$ is a symmetric positive-semidefinite $n\times n$ matrix (the
|
||||
quadratic objective function),
|
||||
\item $c$ is an $n$-dimensional vector (the linear objective
|
||||
function), and
|
||||
\item $c_0$ is a constant.
|
||||
\end{itemize}
|
||||
|
||||
This class specializes the class
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>} for the case where all iterators are of type \ccc{NT**} (for
|
||||
$A$ and $D$) and \ccc{NT*} otherwise, for some number type \ccc{NT}.
|
||||
The class is simply a wrapper for
|
||||
existing pointers, and it does not copy the program data (if you need
|
||||
a copy, you may use the class \ccc{Quadratic_program<NT>}).
|
||||
|
||||
\ccIsModel
|
||||
\ccc{QuadraticProgramInterface}
|
||||
|
||||
\ccTypes
|
||||
\ccNestedType{NT}{The number type of the program entries.}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}
|
||||
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
@ -20,6 +20,9 @@ the four functions
|
|||
\ccc{solve_nonnegative_quadratic_program}, and
|
||||
\ccc{solve_nonnegative_linear_program}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/first_qp.cpp}
|
||||
|
||||
\ccHeading{Terminology}
|
||||
If there is no $x$ that satisfies all the (in)equalities,
|
||||
the program is called \emph{infeasible}, otherwise, it is \emph{feasible},
|
||||
|
|
@ -165,6 +168,9 @@ variables have value $0$.}
|
|||
{returns the number of basic variables, equivalently the length
|
||||
of the range determined by the previous two iterators.}
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/important_variables.cpp}
|
||||
|
||||
\ccMethod{Index_iterator basic_constraint_indices_begin() const;}
|
||||
{returns a random access iterator over the indices of the basic
|
||||
constraints in the system $Ax\qprel b$. The value type is \ccc{int}.
|
||||
|
|
@ -179,6 +185,7 @@ basic.}
|
|||
{returns the number of basic constraint, equivalently the length
|
||||
of the range determined by the previous two iterators.}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\ccHeading{Certificates}
|
||||
|
||||
A certificate is a vector that admits a simple proof for the
|
||||
|
|
@ -200,7 +207,6 @@ then $\lambda_i\geq 0$ ($\lambda_i\leq 0$, respectively).
|
|||
\end{array}\]
|
||||
\end{enumerate}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
{\bf Proof:} Let $x$ be any feasible solution. We need to prove that
|
||||
\[c^Tx + x^TDx \geq c^Tx^* + {x^*}^TDx^*.\]
|
||||
|
||||
|
|
@ -224,7 +230,7 @@ c^Tx + x^TDx - (x-x^*)^TD(x-x^*) \geq c^Tx^* + {x^*}^TDx^*,
|
|||
\]
|
||||
and since $D$ is positive semidefinite, we have
|
||||
$(x-x^*)^TD(x-x^*)\geq 0$ and the lemma follows.
|
||||
\end{ccAdvanced}
|
||||
|
||||
|
||||
\ccMethod{Optimality_certificate_iterator
|
||||
optimality_certifcate_begin() const;}
|
||||
|
|
@ -253,6 +259,9 @@ is \ccc{ET}, and the valid iterator range has length $m$.}
|
|||
{returns the common denominator of the certificate values
|
||||
$\lambda$ as referred to by the previous two methods.}
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/optimality_certificate.cpp}
|
||||
|
||||
{\bf Lemma 2 (infeasibility certificate):} The program (QP) is
|
||||
infeasible if an $m$-vector $\lambda$ with the
|
||||
following properties exist.
|
||||
|
|
@ -271,7 +280,6 @@ then $\lambda_i\geq 0$ ($\lambda_i\leq 0$, respectively).
|
|||
\quad+\quad \sum_{j: \lambda^TA_j >0} \lambda^TA_j l_j.\]
|
||||
\end{enumerate}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
{\bf Proof:} Let us assume for the purpose of obtaining a contradiction
|
||||
that there is a feasible solution $x$. Then we get
|
||||
\[
|
||||
|
|
@ -286,7 +294,7 @@ that there is a feasible solution $x$. Then we get
|
|||
\end{array}
|
||||
\]
|
||||
and this is the desired contradiction $0>0$.
|
||||
\end{ccAdvanced}
|
||||
|
||||
|
||||
\ccMethod{Infeasibility_certificate_iterator
|
||||
infeasibility_certificate_begin() const;}
|
||||
|
|
@ -299,6 +307,9 @@ is \ccc{ET}, and the valid iterator range has length $m$.
|
|||
infeasibility_certificate_end() const;}
|
||||
{returns the corresponding past-the-end iterator.}
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/infeasibility_certificate.cpp}
|
||||
|
||||
{\bf Lemma 3 (unboundedness certificate:)} Let $x^*$ be a feasible
|
||||
solution of (QP). The program (QP) is unbounded if an $n$-vector
|
||||
$w$ with the following properties exist.
|
||||
|
|
@ -318,7 +329,6 @@ w_j &\quad \\
|
|||
|
||||
The vector $w$ is called an \emph{unbounded direction}.
|
||||
|
||||
\begin{ccAdvanced}
|
||||
{\bf Proof:} For a real number $t$, consider the vector $x(t):=x^*+tw$. By 1.
|
||||
and 2., $x(t)$ is feasible for all $t\geq 0$. The objective function value
|
||||
of $x(t)$ is
|
||||
|
|
@ -329,7 +339,6 @@ c^Tx^* + tc^Tw + {x^*}^TDx^* + 2t{x^*}^TDw + t^2 w^TDw \\
|
|||
\end{eqnarray*}
|
||||
By condition 3., this tends to $-\infty$ for $t\rightarrow\infty$, so
|
||||
the problem is indeed unbounded.
|
||||
\end{ccAdvanced}
|
||||
|
||||
\ccMethod{Unboundedness_certificate_iterator
|
||||
unboundedness_certificate_begin() const;}
|
||||
|
|
@ -342,6 +351,10 @@ is \ccc{ET}, and the valid iterator range has length $n$.
|
|||
\ccMethod{Unboundedness_certificate_iterator
|
||||
unboundedness_certificate_end();}
|
||||
{returns the corresponding past-the-end iterator.}
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/unboundedness_certificate.cpp}
|
||||
|
||||
\end{ccAdvanced}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
|
|
|
|||
|
|
@ -44,32 +44,21 @@ $\quad$ (for linear and quadratic programs read from an input stream in
|
|||
|
||||
Then there are specific models for any of the four program concepts above;
|
||||
these are useful if you want to maintain the program data yourself, since
|
||||
they simply wrap random access iterators over the program data.
|
||||
they simply wrap random access iterators over the program data and involve
|
||||
no further copying of data.
|
||||
|
||||
\ccRefIdfierPage{Quadratic_program_from_iterators}\\
|
||||
$\quad$ (for quadratic programs that wrap given iterators, without copying
|
||||
data) \\
|
||||
\ccRefIdfierPage{Quadratic_program_from_pointers}\\
|
||||
$\quad$ (for quadratic programs that wrap given pointers, without copying
|
||||
data)
|
||||
|
||||
\ccRefIdfierPage{Linear_program_from_iterators}\\
|
||||
$\quad$ (for linear programs that wrap given iterators, without copying
|
||||
data) \\
|
||||
\ccRefIdfierPage{Linear_program_from_pointers}\\
|
||||
$\quad$ (for linear programs that wrap given pointers, without copying
|
||||
data)
|
||||
$\quad$ (for linear programs wrapping given iterators)
|
||||
|
||||
\ccRefIdfierPage{Nonnegative_quadratic_program_from_iterators}\\
|
||||
$\quad$ (for nonnegative quadratic programs, wrapping given iterators)\\
|
||||
\ccRefIdfierPage{Nonnegative_quadratic_program_from_pointers}\\
|
||||
$\quad$ (for nonnegative quadratic programs, wrapping given pointers)
|
||||
$\quad$ (for nonnegative quadratic programs, wrapping given iterators)
|
||||
|
||||
\ccRefIdfierPage{Nonnegative_linear_program_from_iterators}\\
|
||||
$\quad$ (for nonnegative linear programs, wrapping given iterators)\\
|
||||
\ccRefIdfierPage{Nonnegative_linear_program_from_pointers}\\
|
||||
$\quad$ (for nonnegative linear programs, wrapping given pointers)
|
||||
|
||||
$\quad$ (for nonnegative linear programs, wrapping given iterators)
|
||||
\ccHeading{Functions}
|
||||
|
||||
In case you want to construct a program from complicated iterators
|
||||
|
|
|
|||
|
|
@ -18,16 +18,12 @@
|
|||
\input{QP_solver_ref/Quadratic_program_from_mps}
|
||||
|
||||
\input{QP_solver_ref/Quadratic_program_from_iterators}
|
||||
\input{QP_solver_ref/Quadratic_program_from_pointers}
|
||||
|
||||
\input{QP_solver_ref/Linear_program_from_iterators}
|
||||
\input{QP_solver_ref/Linear_program_from_pointers}
|
||||
|
||||
\input{QP_solver_ref/Nonnegative_quadratic_program_from_iterators}
|
||||
\input{QP_solver_ref/Nonnegative_quadratic_program_from_pointers}
|
||||
|
||||
\input{QP_solver_ref/Nonnegative_linear_program_from_iterators}
|
||||
\input{QP_solver_ref/Nonnegative_linear_program_from_pointers}
|
||||
|
||||
\input{QP_solver_ref/make_quadratic_program_from_iterators.tex}
|
||||
\input{QP_solver_ref/make_linear_program_from_iterators.tex}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ iterators are too complicated (or of too little interest for you)
|
|||
to write them down explicitly.
|
||||
|
||||
\ccFunction{template <
|
||||
typename A_it,
|
||||
typename B_it,
|
||||
typename R_it,
|
||||
typename FL_it,
|
||||
typename L_it,
|
||||
typename FU_it,
|
||||
typename U_it,
|
||||
typename C_it >
|
||||
A_it,
|
||||
B_it,
|
||||
R_it,
|
||||
FL_it,
|
||||
L_it,
|
||||
FU_it,
|
||||
U_it,
|
||||
C_it >
|
||||
Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>
|
||||
make_linear_program_from_iterators (
|
||||
int n, int m,
|
||||
|
|
@ -27,10 +27,16 @@ make_linear_program_from_iterators (
|
|||
const FU_it& fu,
|
||||
const U_it& u,
|
||||
const C_it& c,
|
||||
typename std::iterator_traits<C_it>::value_type c0 =
|
||||
typename std::iterator_traits<C_it>::value_type(0));}
|
||||
std::iterator_traits<C_it>::value_type c0 =
|
||||
std::iterator_traits<C_it>::value_type(0));}
|
||||
{returns an instance of \ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}, constructed from the given iterators.}
|
||||
|
||||
\ccExample
|
||||
The following example demonstrates the typical usage of makers
|
||||
with the simpler function \ccc{make_nonnegative_linear_program_from_iterators}.
|
||||
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ iterators are too complicated (or of too little interest for you)
|
|||
to write them down explicitly.
|
||||
|
||||
\ccFunction{template <
|
||||
typename A_it,
|
||||
typename B_it,
|
||||
typename R_it,
|
||||
typename C_it >
|
||||
A_it,
|
||||
B_it,
|
||||
R_it,
|
||||
C_it >
|
||||
Nonnegative_linear_program_from_iterators
|
||||
<A_it, B_it, R_it, C_it>
|
||||
make_nonnegative_linear_program_from_iterators (
|
||||
|
|
@ -21,10 +21,13 @@ make_nonnegative_linear_program_from_iterators (
|
|||
const B_it& b,
|
||||
const R_it& r,
|
||||
const C_it& c,
|
||||
typename std::iterator_traits<C_it>::value_type c0 =
|
||||
typename std::iterator_traits<C_it>::value_type(0));}
|
||||
std::iterator_traits<C_it>::value_type c0 =
|
||||
std::iterator_traits<C_it>::value_type(0));}
|
||||
{returns an instance of \ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}, constructed from the given iterators.}
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ iterators are too complicated (or of too little interest for you)
|
|||
to write them down explicitly.
|
||||
|
||||
\ccFunction{template <
|
||||
typename A_it,
|
||||
typename B_it,
|
||||
typename R_it,
|
||||
typename D_it,
|
||||
typename C_it >
|
||||
A_it,
|
||||
B_it,
|
||||
R_it,
|
||||
D_it,
|
||||
C_it >
|
||||
Nonnegative_quadratic_program_from_iterators
|
||||
<A_it, B_it, R_it, D_it, C_it>
|
||||
make_nonnegative_quadratic_program_from_iterators (
|
||||
|
|
@ -22,10 +22,15 @@ make_nonnegative_quadratic_program_from_iterators (
|
|||
const R_it& r,
|
||||
const D_it& d,
|
||||
const C_it& c,
|
||||
typename std::iterator_traits<C_it>::value_type c0 =
|
||||
typename std::iterator_traits<C_it>::value_type(0));}
|
||||
std::iterator_traits<C_it>::value_type c0 =
|
||||
std::iterator_traits<C_it>::value_type(0));}
|
||||
{returns an instance of \ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}, constructed from the given iterators.}
|
||||
|
||||
\ccExample
|
||||
The following example demonstrates the typical usage of makers
|
||||
with the simpler function \ccc{make_nonnegative_linear_program_from_iterators}.
|
||||
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}
|
||||
\ccSeeAlso
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ iterators are too complicated (or of too little interest for you)
|
|||
to write them down explicitly.
|
||||
|
||||
\ccFunction{template <
|
||||
typename A_it,
|
||||
typename B_it,
|
||||
typename R_it,
|
||||
typename FL_it,
|
||||
typename L_it,
|
||||
typename FU_it,
|
||||
typename U_it,
|
||||
typename D_it,
|
||||
typename C_it >
|
||||
A_it,
|
||||
B_it,
|
||||
R_it,
|
||||
FL_it,
|
||||
L_it,
|
||||
FU_it,
|
||||
U_it,
|
||||
D_it,
|
||||
C_it >
|
||||
Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>
|
||||
make_quadratic_program_from_iterators (
|
||||
int n, int m,
|
||||
|
|
@ -29,10 +29,17 @@ make_quadratic_program_from_iterators (
|
|||
const U_it& u,
|
||||
const D_it& d,
|
||||
const C_it& c,
|
||||
typename std::iterator_traits<C_it>::value_type c0 =
|
||||
typename std::iterator_traits<C_it>::value_type(0));}
|
||||
std::iterator_traits<C_it>::value_type c0 =
|
||||
std::iterator_traits<C_it>::value_type(0));}
|
||||
{returns an instance of \ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}, constructed from the given iterators.}
|
||||
|
||||
\ccExample
|
||||
The following example demonstrates the typical usage of makers
|
||||
with the simpler function \ccc{make_nonnegative_linear_program_from_iterators}.
|
||||
|
||||
\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}
|
||||
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,12 @@ by \ccc{problem_name}.}
|
|||
\ccHeading{Requirements}
|
||||
Output operators are defined for all entry types of \ccc{lp}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/print_first_lp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The concept
|
||||
|
||||
\ccc{LinearProgramInterface}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,13 @@ by \ccc{problem_name}.}
|
|||
\ccHeading{Requirements}
|
||||
Output operators are defined for all entry types of \ccc{lp}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/print_first_nonnegative_lp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The concept
|
||||
|
||||
\ccc{NonnegativeLinearProgramInterface}
|
||||
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,12 @@ by \ccc{problem_name}.}
|
|||
\ccHeading{Requirements}
|
||||
Output operators are defined for all entry types of \ccc{qp}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/print_first_nonnegative_qp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The concept
|
||||
|
||||
\ccc{NonnegativeQuadraticProgramInterface}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,13 @@ The name of the program will be the one provided by \ccc{problem_name}.}
|
|||
\ccHeading{Requirements}
|
||||
Output operators are defined for all entry types of \ccc{qp}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/print_first_qp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The concept
|
||||
|
||||
\ccc{QuadraticProgramInterface}
|
||||
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,31 @@ with exact number type \ccc{ET}.}
|
|||
be an exact type, and all entries of \ccc{lp} are convertible to
|
||||
\ccc{ET}.
|
||||
|
||||
Here are some recommended combinations of input type (the type of
|
||||
the \ccc{lp} entries) and \ccc{ET}.
|
||||
|
||||
\begin{tabular}{lll}
|
||||
input type &| & \ccc{ET} \\ \hline
|
||||
\ccc{double} &| & \ccc{MP_Float}, \ccc{Gmpzf}, or \ccc{Gmpq} \\
|
||||
\ccc{int} &| & \ccc{MP_Float}, or \ccc{Gmpz} \\
|
||||
any exact type \ccc{NT} &|& \ccc{NT}
|
||||
\end{tabular}
|
||||
|
||||
{\bf Note:} by default, this function performs a large number of
|
||||
runtime-checks to ensure consistency during the solution process.
|
||||
However, these checks slow down the computations by a considerable
|
||||
factor. For maximum efficiency, it is advisable to define the macros
|
||||
\texttt{CGAL\_QP\_NO\_ASSERTIONS} or \texttt{NDEBUG}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/first_lp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The models of \ccRefIdfierPage{LinearProgramInterface}:
|
||||
|
||||
\ccRefIdfierPage{Quadratic_program}\\
|
||||
\ccRefIdfierPage{Quadratic_program_from_mps}\\
|
||||
\ccRefIdfierPage{Linear_program_from_iterators}\\
|
||||
\ccRefIdfierPage{Linear_program_from_pointers}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Linear_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, C_it>}
|
||||
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Integral Domain \ccc{ET} for its computations.
|
|||
|
||||
\ccFunction{template <NonnegativeLinearProgramInterface, ET>
|
||||
Quadratic_program_solution<ET> solve_nonnegative_linear_program
|
||||
(const NonegativeLinearProgramInterface& lp, const ET&);}
|
||||
(const NonnegativeLinearProgramInterface& lp, const ET&);}
|
||||
{returns the solution of the nonnegative linear program \ccc{lp}, solved
|
||||
with exact number type \ccc{ET}.}
|
||||
|
||||
|
|
@ -17,18 +17,30 @@ with exact number type \ccc{ET}.}
|
|||
be an exact type, and all entries of \ccc{lp} are convertible to
|
||||
\ccc{ET}.
|
||||
|
||||
Here are some recommended combinations of input type (the type of
|
||||
the \ccc{lp} entries) and \ccc{ET}.
|
||||
|
||||
\begin{tabular}{lll}
|
||||
input type &| & \ccc{ET} \\ \hline
|
||||
\ccc{double} &| & \ccc{MP_Float}, \ccc{Gmpzf}, or \ccc{Gmpq} \\
|
||||
\ccc{int} &| & \ccc{MP_Float}, or \ccc{Gmpz} \\
|
||||
any exact type \ccc{NT} &|& \ccc{NT}
|
||||
\end{tabular}
|
||||
|
||||
{\bf Note:} by default, this function performs a large number of
|
||||
runtime-checks to ensure consistency during the solution process.
|
||||
However, these checks slow down the computations by a considerable
|
||||
factor. For maximum efficiency, it is advisable to define the macros
|
||||
\texttt{CGAL\_QP\_NO\_ASSERTIONS} or \texttt{NDEBUG}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_lp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The models of \ccRefIdfierPage{NonnegativeLinearProgramInterface}:
|
||||
|
||||
\ccRefIdfierPage{Quadratic_program}\\
|
||||
\ccRefIdfierPage{Quadratic_program_from_mps}\\
|
||||
\ccRefIdfierPage{Nonnegative_linear_program_from_iterators}\\
|
||||
\ccRefIdfierPage{Nonnegative_linear_program_from_pointers}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Nonnegative_linear_program_from_iterators<A_it, B_it, R_it, C_it>}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,31 @@ with exact number type \ccc{ET}.}
|
|||
be an exact type, and all entries of \ccc{qp} are convertible to
|
||||
\ccc{ET}.
|
||||
|
||||
Here are some recommended combinations of input type (the type of
|
||||
the \ccc{qp} entries) and \ccc{ET}.
|
||||
|
||||
\begin{tabular}{lll}
|
||||
input type &| & \ccc{ET} \\ \hline
|
||||
\ccc{double} &| & \ccc{MP_Float}, \ccc{Gmpzf}, or \ccc{Gmpq} \\
|
||||
\ccc{int} &| & \ccc{MP_Float}, or \ccc{Gmpz} \\
|
||||
any exact type \ccc{NT} &|& \ccc{NT}
|
||||
\end{tabular}
|
||||
|
||||
{\bf Note:} by default, this function performs a large number of
|
||||
runtime-checks to ensure consistency during the solution process.
|
||||
However, these checks slow down the computations by a considerable
|
||||
factor. For maximum efficiency, it is advisable to define the macros
|
||||
\texttt{CGAL\_QP\_NO\_ASSERTIONS} or \texttt{NDEBUG}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/first_nonnegative_qp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The models of \ccRefIdfierPage{NonnegativeQuadraticProgramInterface}:
|
||||
|
||||
\ccRefIdfierPage{Quadratic_program}\\
|
||||
\ccRefIdfierPage{Quadratic_program_from_mps}\\
|
||||
\ccRefIdfierPage{Nonnegative_quadratic_program_from_iterators}\\
|
||||
\ccRefIdfierPage{Nonnegative_quadratic_program_from_pointers}
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Nonnegative_quadratic_program_from_iterators<A_it, B_it, R_it, D_it, C_it>}
|
||||
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,30 @@ with exact number type \ccc{ET}.}
|
|||
be an exact type, and all entries of \ccc{qp} are convertible to
|
||||
\ccc{ET}.
|
||||
|
||||
Here are some recommended combinations of input type (the type of
|
||||
the \ccc{qp} entries) and \ccc{ET}.
|
||||
|
||||
\begin{tabular}{lll}
|
||||
input type &| & \ccc{ET} \\ \hline
|
||||
\ccc{double} &| & \ccc{MP_Float}, \ccc{Gmpzf}, or \ccc{Gmpq} \\
|
||||
\ccc{int} &| & \ccc{MP_Float}, or \ccc{Gmpz} \\
|
||||
any exact type \ccc{NT} &|& \ccc{NT}
|
||||
\end{tabular}
|
||||
|
||||
{\bf Note:} by default, this function performs a large number of
|
||||
runtime-checks to ensure consistency during the solution process.
|
||||
However, these checks slow down the computations by a considerable
|
||||
factor. For maximum efficiency, it is advisable to define the macros
|
||||
\texttt{CGAL\_QP\_NO\_ASSERTIONS} or \texttt{NDEBUG}.
|
||||
|
||||
\ccExample
|
||||
\ccReferToExampleCode{QP_solver/first_qp.cpp}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
The models of \ccRefIdfierPage{QuadraticProgramInterface}:
|
||||
|
||||
\ccRefIdfierPage{Quadratic_program}\\
|
||||
\ccRefIdfierPage{Quadratic_program_from_mps}\\
|
||||
\ccRefIdfierPage{Quadratic_program_from_iterators}\\
|
||||
\ccRefIdfierPage{Quadratic_program_from_pointers}
|
||||
|
||||
\ccc{Quadratic_program<NT>}\\
|
||||
\ccc{Quadratic_program_from_mps<NT>}\\
|
||||
\ccc{Quadratic_program_from_iterators<A_it, B_it, R_it, FL_it, L_it, FU_it, U_it, D_it, C_it>}
|
||||
\end{ccRefFunction}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ bool is_in_convex_hull (const Point_d& p,
|
|||
{
|
||||
CGAL::Quadratic_program_solution<CGAL::MP_Float> s =
|
||||
solve_convex_hull_containment_lp (p, begin, end, CGAL::MP_Float());
|
||||
return s.status() != CGAL::QP_INFEASIBLE;
|
||||
return !s.is_infeasible();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
|
@ -12,29 +13,22 @@ typedef CGAL::Gmpz ET;
|
|||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Linear_program_from_pointers<int> Program;
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Comparison_result
|
||||
r[] = {CGAL::SMALLER, CGAL::SMALLER}; // constraints are "<="
|
||||
bool fl[] = {true, true}; // both x, y are lower-bounded
|
||||
int l[] = {0, 0};
|
||||
bool fu[] = {false, true}; // only y is upper-bounded
|
||||
int u[] = {0, 4}; // x's u-entry is ignored
|
||||
int c[] = {0, -32};
|
||||
int c0 = 64; // constant term
|
||||
|
||||
// now construct the linear program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program lp (2, 2, A, b, r, fl, l, fu, u, c, c0);
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program lp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
lp.set_a(0, 0, 1); lp.set_a(1, 0, 1); lp.set_b(0, 7); // x + y <= 7
|
||||
lp.set_a(0, 1, -1); lp.set_a(1, 1, 2); lp.set_b(1, 4); // -x + 2y <= 4
|
||||
lp.set_u(1, true, 4); // y <= 4
|
||||
lp.set_c(1, -32); // -32y
|
||||
lp.set_c0(64); // +64
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_linear_program(lp, ET());
|
||||
Solution s = CGAL::solve_quadratic_program(lp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
NAME first_lp
|
||||
ROWS
|
||||
N obj
|
||||
L c0
|
||||
L c1
|
||||
COLUMNS
|
||||
x0 c0 1
|
||||
x0 c1 -1
|
||||
x1 obj -32
|
||||
x1 c0 1
|
||||
x1 c1 2
|
||||
RHS
|
||||
rhs obj -64
|
||||
rhs c0 7
|
||||
rhs c1 4
|
||||
BOUNDS
|
||||
UP BND x1 4
|
||||
ENDATA
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Linear_program_from_iterators
|
||||
<int**, // for A
|
||||
int*, // for b
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>, // for r
|
||||
bool*, // for fl
|
||||
int*, // for l
|
||||
bool*, // for fu
|
||||
int*, // for u
|
||||
int*> // for c
|
||||
Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>
|
||||
r( CGAL::SMALLER); // constraints are "<="
|
||||
bool fl[] = {true, true}; // both x, y are lower-bounded
|
||||
int l[] = {0, 0};
|
||||
bool fu[] = {false, true}; // only y is upper-bounded
|
||||
int u[] = {0, 4}; // x's u-entry is ignored
|
||||
int c[] = {0, -32};
|
||||
int c0 = 64; // constant term
|
||||
|
||||
// now construct the linear program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program lp (2, 2, A, b, r, fl, l, fu, u, c, c0);
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_linear_program(lp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_mps<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
std::ifstream in ("first_lp.mps");
|
||||
Program lp(in); // read program from file
|
||||
assert (lp.is_valid()); // we should have a valid mps file,...
|
||||
assert (lp.is_linear());// ...and it encodes a linear program
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_linear_program(lp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
|
@ -12,24 +13,20 @@ typedef CGAL::Gmpz ET;
|
|||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Nonnegative_linear_program_from_pointers<int> Program;
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Comparison_result
|
||||
r[] = {CGAL::SMALLER, CGAL::SMALLER}; // constraints are "<="
|
||||
int c[] = {0, -32};
|
||||
|
||||
// now construct the linear program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program lp (2, 2, A, b, r, c); // constant term defaults to 0
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program lp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
lp.set_a(0, 0, 1); lp.set_a(1, 0, 1); lp.set_b(0, 7); // x + y <= 7
|
||||
lp.set_a(0, 1, -1); lp.set_a(1, 1, 2); lp.set_b(1, 4); // -x + 2y <= 4
|
||||
lp.set_c(1, -32); // -32y
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_nonnegative_linear_program(lp, ET());
|
||||
Solution s = CGAL::solve_quadratic_program(lp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
NAME first_nonnegative_lp
|
||||
ROWS
|
||||
N obj
|
||||
L c0
|
||||
L c1
|
||||
COLUMNS
|
||||
x0 c0 1
|
||||
x0 c1 -1
|
||||
x1 obj -32
|
||||
x1 c0 1
|
||||
x1 c1 2
|
||||
RHS
|
||||
rhs c0 7
|
||||
rhs c1 4
|
||||
ENDATA
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Nonnegative_linear_program_from_iterators
|
||||
<int**, // for A
|
||||
int*, // for b
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>, // for r
|
||||
int*> // for c
|
||||
Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>
|
||||
r( CGAL::SMALLER); // constraints are "<="
|
||||
int c[] = {0, -32};
|
||||
|
||||
// now construct the linear program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program lp (2, 2, A, b, r, c); // constant term defaults to 0
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_nonnegative_linear_program(lp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_mps<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
std::ifstream in ("first_nonnegative_lp.mps");
|
||||
Program lp(in); // read program from file
|
||||
assert (lp.is_valid()); // we should have a valid mps file,...
|
||||
assert (lp.is_linear());// ..and it encodes a linear program,...
|
||||
assert (lp.is_nonnegative()); // ...and it should be nonnegative
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_nonnegative_linear_program(lp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
|
@ -12,28 +13,22 @@ typedef CGAL::Gmpz ET;
|
|||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Nonnegative_quadratic_program_from_pointers<int> Program;
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Comparison_result
|
||||
r[] = {CGAL::SMALLER, CGAL::SMALLER}; // constraints are "<="
|
||||
int D1[] = {2}; // 2D_{1,1}
|
||||
int D2[] = {0, 8}; // 2D_{2,1}, 2D_{2,2}
|
||||
int* D[] = {D1, D2}; // D-entries on/below diagonal
|
||||
int c[] = {0, -32};
|
||||
int c0 = 64; // constant term
|
||||
|
||||
// now construct the quadratic program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program qp (2, 2, A, b, r, D, c, c0);
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program qp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
qp.set_a(0, 0, 1); qp.set_a(1, 0, 1); qp.set_b(0, 7); // x + y <= 7
|
||||
qp.set_a(0, 1, -1); qp.set_a(1, 1, 2); qp.set_b(1, 4); // -x + 2y <= 4
|
||||
qp.set_d(0, 0, 2); qp.set_d (1, 1, 8); // x^2 + 4 y^2
|
||||
qp.set_c(1, -32); // -32y
|
||||
qp.set_c0(64); // +64
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_nonnegative_quadratic_program(qp, ET());
|
||||
Solution s = CGAL::solve_quadratic_program(qp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
NAME first_nonnegative_qp
|
||||
ROWS
|
||||
N obj
|
||||
L c0
|
||||
L c1
|
||||
COLUMNS
|
||||
x0 c0 1
|
||||
x0 c1 -1
|
||||
x1 obj -32
|
||||
x1 c0 1
|
||||
x1 c1 2
|
||||
RHS
|
||||
rhs obj -64
|
||||
rhs c0 7
|
||||
rhs c1 4
|
||||
QMATRIX
|
||||
x0 x0 2
|
||||
x1 x1 8
|
||||
ENDATA
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Nonnegative_quadratic_program_from_iterators
|
||||
<int**, // for A
|
||||
int*, // for b
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>, // for r
|
||||
int**, // for D
|
||||
int*> // for c
|
||||
Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>
|
||||
r( CGAL::SMALLER); // constraints are "<="
|
||||
int D1[] = {2}; // 2D_{1,1}
|
||||
int D2[] = {0, 8}; // 2D_{2,1}, 2D_{2,2}
|
||||
int* D[] = {D1, D2}; // D-entries on/below diagonal
|
||||
int c[] = {0, -32};
|
||||
int c0 = 64; // constant term
|
||||
|
||||
// now construct the quadratic program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program qp (2, 2, A, b, r, D, c, c0);
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_nonnegative_quadratic_program(qp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_mps<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
std::ifstream in ("first_nonnegative_qp.mps");
|
||||
Program qp(in); // read program from file
|
||||
assert (qp.is_valid()); // we should have a valid mps file,...
|
||||
assert (qp.is_nonnegative()); // ...and it should be nonnegative
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_nonnegative_quadratic_program(qp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
|
@ -12,29 +13,20 @@ typedef CGAL::Gmpz ET;
|
|||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_pointers<int> Program;
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Comparison_result
|
||||
r[] = {CGAL::SMALLER, CGAL::SMALLER}; // constraints are "<="
|
||||
bool fl[] = {true, true}; // both x, y are lower-bounded
|
||||
int l[] = {0, 0};
|
||||
bool fu[] = {false, true}; // only y is upper-bounded
|
||||
int u[] = {0, 4}; // x's u-entry is ignored
|
||||
int D1[] = {2}; // 2D_{1,1}
|
||||
int D2[] = {0, 8}; // 2D_{2,1}, 2D_{2,2}
|
||||
int* D[] = {D1, D2}; // D-entries on/below diagonal
|
||||
int c[] = {0, -32};
|
||||
int c0 = 64; // constant term
|
||||
|
||||
// now construct the quadratic program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program qp (2, 2, A, b, r, fl, l, fu, u, D, c, c0);
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program qp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
qp.set_a(0, 0, 1); qp.set_a(1, 0, 1); qp.set_b(0, 7); // x + y <= 7
|
||||
qp.set_a(0, 1, -1); qp.set_a(1, 1, 2); qp.set_b(1, 4); // -x + 2y <= 4
|
||||
qp.set_u(1, true, 4); // y <= 4
|
||||
qp.set_d(0, 0, 2); qp.set_d (1, 1, 8); // x^2 + 4 y^2
|
||||
qp.set_c(1, -32); // -32y
|
||||
qp.set_c0(64); // +64
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_quadratic_program(qp, ET());
|
||||
|
|
@ -49,7 +41,5 @@ int main() {
|
|||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
CGAL::print_quadratic_program(std::cout, qp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
NAME first_qp
|
||||
ROWS
|
||||
N obj
|
||||
L c0
|
||||
L c1
|
||||
COLUMNS
|
||||
x0 c0 1
|
||||
x0 c1 -1
|
||||
x1 obj -32
|
||||
x1 c0 1
|
||||
x1 c1 2
|
||||
RHS
|
||||
rhs obj -64
|
||||
rhs c0 7
|
||||
rhs c1 4
|
||||
BOUNDS
|
||||
UP BND x1 4
|
||||
QMATRIX
|
||||
x0 x0 2
|
||||
x1 x1 8
|
||||
ENDATA
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_iterators
|
||||
<int**, // for A
|
||||
int*, // for b
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>, // for r
|
||||
bool*, // for fl
|
||||
int*, // for l
|
||||
bool*, // for fu
|
||||
int*, // for u
|
||||
int**, // for D
|
||||
int*> // for c
|
||||
Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
int Ax[] = {1, -1}; // column for x
|
||||
int Ay[] = {1, 2}; // column for y
|
||||
int* A[] = {Ax, Ay}; // A comes columnwise
|
||||
int b[] = {7, 4}; // right-hand side
|
||||
CGAL::Const_oneset_iterator<CGAL::Comparison_result>
|
||||
r( CGAL::SMALLER); // constraints are "<="
|
||||
bool fl[] = {true, true}; // both x, y are lower-bounded
|
||||
int l[] = {0, 0};
|
||||
bool fu[] = {false, true}; // only y is upper-bounded
|
||||
int u[] = {0, 4}; // x's u-entry is ignored
|
||||
int D1[] = {2}; // 2D_{1,1}
|
||||
int D2[] = {0, 8}; // 2D_{2,1}, 2D_{2,2}
|
||||
int* D[] = {D1, D2}; // D-entries on/below diagonal
|
||||
int c[] = {0, -32};
|
||||
int c0 = 64; // constant term
|
||||
|
||||
// now construct the quadratic program; the first two parameters are
|
||||
// the number of variables and the number of constraints (rows of A)
|
||||
Program qp (2, 2, A, b, r, fl, l, fu, u, D, c, c0);
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_quadratic_program(qp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// choose exact integral type
|
||||
#ifndef CGAL_USE_GMP
|
||||
#include <CGAL/MP_Float.h>
|
||||
typedef CGAL::MP_Float ET;
|
||||
#else
|
||||
#include <CGAL/Gmpz.h>
|
||||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_mps<int> Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
int main() {
|
||||
std::ifstream in ("first_qp.mps");
|
||||
Program qp(in); // read program from file
|
||||
assert (qp.is_valid()); // we should have a valid mps file
|
||||
|
||||
// solve the program, using ET as the exact type
|
||||
Solution s = CGAL::solve_quadratic_program(qp, ET());
|
||||
|
||||
// output solution
|
||||
if (s.is_optimal()) { // we know that, don't we?
|
||||
std::cout << "Optimal feasible solution: ";
|
||||
for (Solution::Variable_value_iterator it = s.variable_values_begin();
|
||||
it != s.variable_values_end(); ++it)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl << "Optimal objective function value: "
|
||||
<< s.objective_value() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -12,26 +12,29 @@ typedef CGAL::Quadratic_program_solution<CGAL::MP_Float> Solution;
|
|||
int main()
|
||||
{
|
||||
std::vector<Point_d> points;
|
||||
// convex hull: line spanned by {(0,0), (1,0),..., (9,0)}
|
||||
for (int j=0; j<10; ++j)
|
||||
points.push_back (Point_d (j, 0));
|
||||
|
||||
for (double f=0.5; f<10; ++f) {
|
||||
Point_d p (f, 0.0);
|
||||
Solution s = solve_convex_hull_containment_lp
|
||||
(p, points.begin(), points.end(), CGAL::MP_Float());
|
||||
std::cout << p;
|
||||
if (s.status() == CGAL::QP_INFEASIBLE)
|
||||
std::cout << " is not in the convex hull." << std::endl;
|
||||
else {
|
||||
std::cout << " is a convex combination of the points ";
|
||||
Solution::Index_iterator it = s.basic_variable_indices_begin();
|
||||
Solution::Index_iterator end = s.basic_variable_indices_end();
|
||||
for (; it != end; ++it)
|
||||
std::cout << points[*it] << " ";
|
||||
std::cout << std::endl;
|
||||
// convex hull: 4-gon spanned by {(1,0), (4,1), (4,4), (2,3)}
|
||||
points.push_back (Point_d (1, 0));
|
||||
points.push_back (Point_d (4, 1));
|
||||
points.push_back (Point_d (4, 4));
|
||||
points.push_back (Point_d (2, 3));
|
||||
|
||||
// test all 25 integer points in [0,4]^2
|
||||
for (int i=0; i<=4; ++i)
|
||||
for (int j=0; j<=4; ++j) {
|
||||
Point_d p (i, j);
|
||||
Solution s = solve_convex_hull_containment_lp
|
||||
(p, points.begin(), points.end(), CGAL::MP_Float());
|
||||
std::cout << p;
|
||||
if (s.is_infeasible())
|
||||
std::cout << " is not in the convex hull\n";
|
||||
else {
|
||||
assert (s.is_optimal());
|
||||
std::cout << " is a convex combination of the points ";
|
||||
Solution::Index_iterator it = s.basic_variable_indices_begin();
|
||||
Solution::Index_iterator end = s.basic_variable_indices_end();
|
||||
for (; it != end; ++it) std::cout << *it << " ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// program type
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
|
||||
int main() {
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program lp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
lp.set_a(0, 0, 1); lp.set_a(1, 0, 1); lp.set_b(0, 7); // x + y <= 7
|
||||
lp.set_a(0, 1, -1); lp.set_a(1, 1, 2); lp.set_b(1, 4); // -x + 2y <= 4
|
||||
lp.set_u(1, true, 4); // y <= 4
|
||||
lp.set_c(1, -32); // -32y
|
||||
lp.set_c0(64); // +64
|
||||
|
||||
// print the program in MPS format
|
||||
CGAL::print_linear_program(std::cout, lp, "first_lp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// program type
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
|
||||
int main() {
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program lp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
lp.set_a(0, 0, 1); lp.set_a(1, 0, 1); lp.set_b(0, 7); // x + y <= 7
|
||||
lp.set_a(0, 1, -1); lp.set_a(1, 1, 2); lp.set_b(1, 4); // -x + 2y <= 4
|
||||
lp.set_c(1, -32); // -32y
|
||||
|
||||
// print the program in MPS format
|
||||
CGAL::print_nonnegative_linear_program
|
||||
(std::cout, lp, "first_nonnegative_lp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// program type
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
|
||||
int main() {
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program qp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
qp.set_a(0, 0, 1); qp.set_a(1, 0, 1); qp.set_b(0, 7); // x + y <= 7
|
||||
qp.set_a(0, 1, -1); qp.set_a(1, 1, 2); qp.set_b(1, 4); // -x + 2y <= 4
|
||||
qp.set_d(0, 0, 2); qp.set_d (1, 1, 8); // x^2 + 4 y^2
|
||||
qp.set_c(1, -32); // -32y
|
||||
qp.set_c0(64); // +64
|
||||
|
||||
// print the program in MPS format
|
||||
CGAL::print_nonnegative_quadratic_program
|
||||
(std::cout, qp, "first_nonnegative_qp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/QP_models.h>
|
||||
#include <CGAL/QP_functions.h>
|
||||
|
||||
// program type
|
||||
typedef CGAL::Quadratic_program<int> Program;
|
||||
|
||||
int main() {
|
||||
// by default, we have a nonnegative QP with Ax <= b
|
||||
Program qp (CGAL::SMALLER, true, 0, false, 0);
|
||||
|
||||
// now set the non-default entries: 0 <-> x, 1 <-> y
|
||||
qp.set_a(0, 0, 1); qp.set_a(1, 0, 1); qp.set_b(0, 7); // x + y <= 7
|
||||
qp.set_a(0, 1, -1); qp.set_a(1, 1, 2); qp.set_b(1, 4); // -x + 2y <= 4
|
||||
qp.set_u(1, true, 4); // y <= 4
|
||||
qp.set_d(0, 0, 2); qp.set_d (1, 1, 8); // x^2 + 4 y^2
|
||||
qp.set_c(1, -32); // -32y
|
||||
qp.set_c0(64); // +64
|
||||
|
||||
// print the program in MPS format
|
||||
CGAL::print_nonnegative_quadratic_program
|
||||
(std::cout, qp, "first_qp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -33,15 +33,11 @@
|
|||
|
||||
// this file defines the following models:
|
||||
// - Quadratic_program_from_iterators
|
||||
// - Quadratic_program_from_pointers
|
||||
// - Quadratic_program
|
||||
// - Quadratic_program_from_mps
|
||||
// - Nonngative_quadratic_program_from_iterators
|
||||
// - Nonengative_quadratic_program_from_pointers
|
||||
// - Linear_program_from_iterators
|
||||
// - Linear_program_from_pointers
|
||||
// - Nonngative_linear_program_from_iterators
|
||||
// - Nonengative_linear_program_from_pointers
|
||||
|
||||
// for convenience, every model is actually a model of the
|
||||
// concept QuadraticProgramInterface:
|
||||
|
|
@ -177,38 +173,6 @@ make_quadratic_program_from_iterators (
|
|||
(n, m, a, b, r, fl, l, fu, u, d, c, c0);
|
||||
}
|
||||
|
||||
// Quadratic_program_from_pointers
|
||||
// -------------------------------
|
||||
template <typename NT_>
|
||||
class Quadratic_program_from_pointers :
|
||||
public Quadratic_program_from_iterators
|
||||
<NT_**, NT_*, CGAL::Comparison_result*,
|
||||
bool*, NT_*, bool*, NT_*, NT_**, NT_*>
|
||||
{
|
||||
public:
|
||||
typedef NT_ NT;
|
||||
private:
|
||||
typedef Quadratic_program_from_iterators
|
||||
<NT**, NT*, CGAL::Comparison_result*,
|
||||
bool*, NT*, bool*, NT*, NT**, NT*> Base;
|
||||
public:
|
||||
QP_MODEL_ITERATOR_TYPES;
|
||||
Quadratic_program_from_pointers
|
||||
(
|
||||
int n, int m, // number of variables / constraints
|
||||
const A_iterator& a,
|
||||
const B_iterator& b,
|
||||
const R_iterator& r,
|
||||
const FL_iterator& fl,
|
||||
const L_iterator& l,
|
||||
const FU_iterator& fu,
|
||||
const U_iterator& u,
|
||||
const D_iterator& d,
|
||||
const C_iterator& c,
|
||||
const C_entry& c0 = C_entry(0))
|
||||
: Base (n, m, a, b, r, fl, l, fu, u, d, c, c0)
|
||||
{}
|
||||
};
|
||||
|
||||
// Linear_program_from_iterators
|
||||
// -----------------------------
|
||||
|
|
@ -280,35 +244,6 @@ make_linear_program_from_iterators (
|
|||
(n, m, a, b, r, fl, l, fu, u, c, c0);
|
||||
}
|
||||
|
||||
// Linear_program_from_pointers
|
||||
// ----------------------------
|
||||
template <typename NT_>
|
||||
class Linear_program_from_pointers :
|
||||
public Linear_program_from_iterators
|
||||
<NT_**, NT_*, CGAL::Comparison_result*, bool*, NT_*, bool*, NT_*, NT_*>
|
||||
{
|
||||
public:
|
||||
typedef NT_ NT;
|
||||
private:
|
||||
typedef Linear_program_from_iterators
|
||||
<NT**, NT*, CGAL::Comparison_result*, bool*, NT*, bool*, NT*, NT*> Base;
|
||||
public:
|
||||
QP_MODEL_ITERATOR_TYPES;
|
||||
Linear_program_from_pointers (
|
||||
int n, int m, // number of variables / constraints
|
||||
const A_iterator& a,
|
||||
const B_iterator& b,
|
||||
const R_iterator& r,
|
||||
const FL_iterator& fl,
|
||||
const L_iterator& l,
|
||||
const FU_iterator& fu,
|
||||
const U_iterator& u,
|
||||
const C_iterator& c,
|
||||
const C_entry& c0 = C_entry(0)
|
||||
)
|
||||
: Base (n, m, a, b, r, fl, l, fu, u, c, c0)
|
||||
{}
|
||||
};
|
||||
|
||||
// Nonnegative_quadratic_program_from_iterators
|
||||
// --------------------------------------------
|
||||
|
|
@ -379,35 +314,6 @@ make_nonnegative_quadratic_program_from_iterators (
|
|||
(n, m, a, b, r, d, c, c0);
|
||||
}
|
||||
|
||||
// Nonnegative_Quadratic_program_from_pointers
|
||||
// -------------------------------------------
|
||||
template <typename NT_>
|
||||
class Nonnegative_quadratic_program_from_pointers :
|
||||
public Nonnegative_quadratic_program_from_iterators
|
||||
<NT_**, NT_*, CGAL::Comparison_result*, NT_**, NT_*>
|
||||
{
|
||||
public:
|
||||
typedef NT_ NT;
|
||||
private:
|
||||
typedef Nonnegative_quadratic_program_from_iterators
|
||||
<NT**, NT*, CGAL::Comparison_result*, NT**, NT*> Base;
|
||||
public:
|
||||
QP_MODEL_ITERATOR_TYPES;
|
||||
Nonnegative_quadratic_program_from_pointers (
|
||||
int n, int m, // number of variables / constraints
|
||||
const A_iterator& a,
|
||||
const B_iterator& b,
|
||||
const R_iterator& r,
|
||||
const D_iterator& d,
|
||||
const C_iterator& c,
|
||||
const C_entry& c0 = C_entry(0)
|
||||
)
|
||||
: Base (n, m, a, b, r, d, c, c0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Nonnegative_linear_program_from_iterators
|
||||
// -----------------------------------------
|
||||
|
|
@ -475,31 +381,6 @@ make_nonnegative_linear_program_from_iterators (
|
|||
(n, m, a, b, r, c, c0);
|
||||
}
|
||||
|
||||
// Nonnegative_linear_program_from_pointers
|
||||
// ----------------------------------------
|
||||
template <typename NT_>
|
||||
class Nonnegative_linear_program_from_pointers :
|
||||
public Nonnegative_linear_program_from_iterators
|
||||
<NT_**, NT_*, CGAL::Comparison_result*, NT_*>
|
||||
{
|
||||
public:
|
||||
typedef NT_ NT;
|
||||
private:
|
||||
typedef Nonnegative_linear_program_from_iterators
|
||||
<NT**, NT*, CGAL::Comparison_result*, NT*> Base;
|
||||
public:
|
||||
QP_MODEL_ITERATOR_TYPES;
|
||||
Nonnegative_linear_program_from_pointers (
|
||||
int n, int m, // number of variables / constraints
|
||||
const A_iterator& a,
|
||||
const B_iterator& b,
|
||||
const R_iterator& r,
|
||||
const C_iterator& c,
|
||||
const C_entry& c0 = C_entry(0)
|
||||
)
|
||||
: Base (n, m, a, b, r, c, c0)
|
||||
{}
|
||||
};
|
||||
|
||||
namespace QP_model_detail {
|
||||
// maps a container to its begin-iterator, as specified by HowToBegin
|
||||
|
|
@ -579,10 +460,10 @@ private:
|
|||
|
||||
// default settings
|
||||
CGAL::Comparison_result default_r; // from constructor
|
||||
bool default_fl; // true
|
||||
NT default_l; // 0
|
||||
bool default_fu; // false
|
||||
NT default_u; // dummy
|
||||
bool default_fl; // from constructor
|
||||
NT default_l; // from constructor
|
||||
bool default_fu; // from constructor
|
||||
NT default_u; // from constructor
|
||||
protected:
|
||||
bool is_valid_;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -14,13 +14,30 @@ typedef CGAL::MP_Float ET;
|
|||
typedef CGAL::Gmpz ET;
|
||||
#endif
|
||||
|
||||
int fl;
|
||||
int fu;
|
||||
int l;
|
||||
int u;
|
||||
int r;
|
||||
|
||||
// inline void check(bool cond)
|
||||
// {
|
||||
// if (!cond) {
|
||||
// std::cout << "fl = " << fl << ", "
|
||||
// << " l = " << l << ", "
|
||||
// << "fu = " << fu << ", "
|
||||
// << " u = " << u << ", "
|
||||
// << " r = " << r << std::endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
int main()
|
||||
{
|
||||
for (bool fl = false; fl < true; ++fl)
|
||||
for (bool fu = false; fu < true; ++fu)
|
||||
for (int l = -2; l < 0; ++l)
|
||||
for (int u = 0; u < 2; ++u)
|
||||
for (int r = -1; r < 1; ++r) {
|
||||
for (fl = 0; fl < 2; ++fl)
|
||||
for (fu = 0; fu < 2; ++fu)
|
||||
for (l = -2; l <= 0; ++l)
|
||||
for (u = 0; u <= 2; ++u)
|
||||
for (r = -1; r < 1; ++r) {
|
||||
// generate empty program with all possible
|
||||
// defaults, and test solver / bound status functions
|
||||
CGAL::Quadratic_program<int> qp
|
||||
|
|
@ -40,7 +57,7 @@ int main()
|
|||
|
||||
// now manipulate program
|
||||
qp.set_c(0, 1); // min x_0
|
||||
// l <= x_0 <= u
|
||||
// l <= x_0 <= u
|
||||
// test solver
|
||||
s = CGAL::solve_quadratic_program (qp, ET());
|
||||
if (fl) {
|
||||
|
|
@ -101,13 +118,13 @@ int main()
|
|||
assert (s.is_unbounded());
|
||||
|
||||
// manipulate program
|
||||
qp.set_c(0, -1); // max x_0
|
||||
qp.set_c(0, -1); // min -x_0
|
||||
|
||||
// test solver
|
||||
s = CGAL::solve_quadratic_program (qp, ET());
|
||||
if (fu) {
|
||||
assert (s.is_optimal());
|
||||
assert (s.objective_value() == u);
|
||||
assert (s.objective_value() == -u);
|
||||
} else
|
||||
assert (s.is_unbounded());
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,17 @@ typedef CGAL::Gmpz ET;
|
|||
#endif
|
||||
|
||||
// program and solution types
|
||||
typedef CGAL::Quadratic_program_from_pointers<int> Program;
|
||||
typedef CGAL::Quadratic_program_from_iterators
|
||||
<int**, // for A
|
||||
int*, // for b
|
||||
CGAL::Comparison_result*, // for r
|
||||
bool*, // for fl
|
||||
int*, // for l
|
||||
bool*, // for fu
|
||||
int*, // for u
|
||||
int**, // for D
|
||||
int*> // for c
|
||||
Program;
|
||||
typedef CGAL::Quadratic_program_solution<ET> Solution;
|
||||
|
||||
// randum number generator
|
||||
|
|
|
|||
Loading…
Reference in New Issue