diff --git a/QP_solver/doc_tex/QP_solver_ref/Linear_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/Linear_program_from_iterators.tex index 1d523191e3f..8426e81a4b7 100644 --- a/QP_solver/doc_tex/QP_solver_ref/Linear_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/Linear_program_from_iterators.tex @@ -68,7 +68,8 @@ The following example for the simpler model should give you a flavor of the use of this model in practice. -\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h} +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment.cpp} \ccSeeAlso \ccc{LinearProgramInterface} diff --git a/QP_solver/doc_tex/QP_solver_ref/Nonnegative_linear_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/Nonnegative_linear_program_from_iterators.tex index 26e8f291eba..5f93bfe71bf 100644 --- a/QP_solver/doc_tex/QP_solver_ref/Nonnegative_linear_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/Nonnegative_linear_program_from_iterators.tex @@ -56,7 +56,8 @@ 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} +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment.cpp} \ccSeeAlso \ccc{NonnegativeLinearProgramInterface} diff --git a/QP_solver/doc_tex/QP_solver_ref/Nonnegative_quadratic_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/Nonnegative_quadratic_program_from_iterators.tex index 3d7a2974599..a91890859de 100644 --- a/QP_solver/doc_tex/QP_solver_ref/Nonnegative_quadratic_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/Nonnegative_quadratic_program_from_iterators.tex @@ -63,7 +63,9 @@ The following example for the simpler model should give you a flavor of the use of this model in practice. -\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h} +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment.cpp} + \ccSeeAlso \ccc{NonnegativeQuadraticProgramInterface} \ccc{Quadratic_program}\\ diff --git a/QP_solver/doc_tex/QP_solver_ref/Quadratic_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/Quadratic_program_from_iterators.tex index 8cbfb3810fa..5f2d92e8016 100644 --- a/QP_solver/doc_tex/QP_solver_ref/Quadratic_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/Quadratic_program_from_iterators.tex @@ -71,8 +71,8 @@ The following example for the simpler model should give you a flavor of the use of this model in practice. -\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h} - +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment.cpp} \ccSeeAlso \ccc{QuadraticProgramInterface} \ccc{Quadratic_program}\\ diff --git a/QP_solver/doc_tex/QP_solver_ref/make_linear_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/make_linear_program_from_iterators.tex index 29c0ed09061..3c5f838f561 100644 --- a/QP_solver/doc_tex/QP_solver_ref/make_linear_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/make_linear_program_from_iterators.tex @@ -35,7 +35,8 @@ make_linear_program_from_iterators ( 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} +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment2.cpp} \ccSeeAlso \ccc{Linear_program_from_iterators} diff --git a/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_linear_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_linear_program_from_iterators.tex index b5c9a4e9dd3..49178365f82 100644 --- a/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_linear_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_linear_program_from_iterators.tex @@ -26,7 +26,8 @@ make_nonnegative_linear_program_from_iterators ( {returns an instance of \ccc{Nonnegative_linear_program_from_iterators}, constructed from the given iterators.} \ccExample -\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h} +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment2.cpp} \ccSeeAlso \ccc{Nonnegative_linear_program_from_iterators} diff --git a/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_quadratic_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_quadratic_program_from_iterators.tex index 2dfae2b43f7..58ba1919893 100644 --- a/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_quadratic_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/make_nonnegative_quadratic_program_from_iterators.tex @@ -30,7 +30,9 @@ make_nonnegative_quadratic_program_from_iterators ( 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} +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment2.cpp} + \ccSeeAlso \ccc{Nonnegative_quadratic_program_from_iterators} \end{ccRefFunction} diff --git a/QP_solver/doc_tex/QP_solver_ref/make_quadratic_program_from_iterators.tex b/QP_solver/doc_tex/QP_solver_ref/make_quadratic_program_from_iterators.tex index d46bd3728dd..54d9eebb305 100644 --- a/QP_solver/doc_tex/QP_solver_ref/make_quadratic_program_from_iterators.tex +++ b/QP_solver/doc_tex/QP_solver_ref/make_quadratic_program_from_iterators.tex @@ -37,8 +37,8 @@ make_quadratic_program_from_iterators ( 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} - +\ccReferToExampleCode{QP_solver/solve_convex_hull_containment_lp2.h}\\ +\ccReferToExampleCode{QP_solver/convex_hull_containment2.cpp} \ccSeeAlso \ccc{Quadratic_program_from_iterators} diff --git a/QP_solver/examples/QP_solver/convex_hull_containment2.cpp b/QP_solver/examples/QP_solver/convex_hull_containment2.cpp index f5106a6a131..8cb7004edeb 100644 --- a/QP_solver/examples/QP_solver/convex_hull_containment2.cpp +++ b/QP_solver/examples/QP_solver/convex_hull_containment2.cpp @@ -14,7 +14,7 @@ bool is_in_convex_hull (const Point_d& p, { CGAL::Quadratic_program_solution s = solve_convex_hull_containment_lp (p, begin, end, CGAL::MP_Float()); - return s.status() != CGAL::QP_INFEASIBLE; + return !s.is_infeasible(); } int main() diff --git a/QP_solver/examples/QP_solver/double_qp_solver.cpp b/QP_solver/examples/QP_solver/double_qp_solver.cpp deleted file mode 100644 index ace1986178d..00000000000 --- a/QP_solver/examples/QP_solver/double_qp_solver.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 1997-2001 ETH Zurich (Switzerland). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you may redistribute it under -// the terms of the Q Public License version 1.0. -// See the file LICENSE.QPL distributed with CGAL. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Kaspar Fischer -// Bernd Gaertner -#include -#include -#include -#include - -#ifndef CGAL_USE_GMP -#include -#else -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include - - -int main(const int argNr,const char **args) { - using std::cout; - using std::endl; - - // get desired level of additional logging output: - //const int verbosity = argNr < 2? 1 : std::atoi(args[1]); - - // construct QP instance: - typedef double IT; - -#ifndef CGAL_USE_GMP - typedef CGAL::MP_Float ET; -#else - typedef CGAL::Gmpzf ET; -#endif - - typedef CGAL::Quadratic_program_from_mps QP; - QP qp(std::cin); - // check for format errors in MPS f\ile: - if (!qp.is_valid()) { - cout << "Input is not a valid MPS file." << endl - << "Error: " << qp.get_error() << endl; - std::exit(2); - } - - typedef CGAL::Quadratic_program_solution Solution; - Solution s = CGAL::solve_quadratic_program (qp, ET(0)); - - // get solution: - if (s.is_optimal()) { - // output solution: - cout << "Objective function value: " << - CGAL::to_double(s.objective_value()) << endl; - - cout << "Variable values:" << endl; - Solution::Variable_value_iterator vit = - s.variable_values_begin() ; - for (int i=0; i < qp.get_n(); ++vit, ++i) - cout << " " << qp.get_name_of_variable(i) << " = " - << CGAL::to_double(*vit) << endl; - - cout << "Basic variables (index, value):" << endl; - Solution::Index_iterator iit = - s.basic_variable_indices_begin(); - vit = s.variable_values_begin(); - for ( ; iit < s.basic_variable_indices_end(); ++iit) - cout << " (" << *iit << ", " - << CGAL::to_double(vit[*iit]) << ")" << endl; - cout << " There are " << s.number_of_basic_variables() - << " basic variables. " << endl; - - cout << "Basic constraints: " << endl; - Solution::Index_iterator cit = - s.basic_constraint_indices_begin(); - for ( ; cit < s.basic_constraint_indices_end(); ++cit) - cout << *cit << " "; - cout << endl; - cout << " There are " << s.number_of_basic_constraints() - << " basic constraints. " << endl; - - return 0; - } - if (s.status() == CGAL::QP_INFEASIBLE) - cout << "Problem is infeasible." << endl; - else // unbounded - cout << "Problem is unbounded." << endl; - return 0; - -} diff --git a/QP_solver/examples/QP_solver/qp_solver1.cpp b/QP_solver/examples/QP_solver/qp_solver1.cpp deleted file mode 100644 index 4495350cd18..00000000000 --- a/QP_solver/examples/QP_solver/qp_solver1.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// This example program solves the quadratic program -// minimize x^T D x + c^T x + c0 -// subject to A x b -// L <= x <= u -// where stands for a vector of relations from {<=, ==, >=} -// -// In the concrete example below, we have the following data: -// D c A b L U c0 -// --------------------------------------------------------------------- -// 1 0 0 3 1 2 1 0 0 infinity 1 1 -// 0 0 -// -// In other words, we minimize x^2 + 3y + 1 subject to x + 2y = 1 -// and x >= 0, 0 <= y <= 1. Let's see what this gives: if we -// substitute x with 1 - 2y in the objective function, we get -// 4y^2 - y + 1. The derivative is 8y-1, so this is minimzed -// for y = 1/8. This value (as well as x = 1 - 2(1/8) = 3/4) -// are within the bounds, so the solution should be x = 3/4 -// and y = 1/8. The objective function value should be -// 9/16 + 3/8 + 1 = 31/16 - -#include -#include -#include - -#ifndef CGAL_USE_GMP -#include -typedef CGAL::MP_Float ET; -#else -#include -typedef CGAL::Gmpz ET; -#endif - -// program and solution types -typedef CGAL::Quadratic_program_from_pointers Program; -typedef CGAL::Quadratic_program_solution Solution; - -int main() { - int A_col_0[] = {1}; - int A_col_1[] = {2}; - int *cols_of_A[] = {A_col_0, A_col_1}; - int b[] = {1}; - CGAL::Comparison_result rt[] = {CGAL::EQUAL}; - bool fl[] = {true, true}; - int l[] = {0, 0}; - bool fu[] = {false, true}; // x has upper bound infinity... - int u[] = {0, 1}; // ... and it's u-entry is ignored - int D_row_0[] = {2, 0}; - int D_row_1[] = {0, 0}; - int *rows_of_D[] = {D_row_0, D_row_1}; - int c[] = {0, 3}; - int c0 = 1; - - // 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, 1, cols_of_A, b, rt, fl, l, fu, u, rows_of_D, c, c0); - - // solve the program - Solution s = CGAL::solve_quadratic_program(qp, ET()); - - // output solution - if (s.status() == CGAL::QP_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 << "\nOptimal value: " << s.objective_value() << std::endl; - } - - return 0; -} diff --git a/QP_solver/examples/QP_solver/qp_solver2.cpp b/QP_solver/examples/QP_solver/qp_solver2.cpp deleted file mode 100644 index e370e062132..00000000000 --- a/QP_solver/examples/QP_solver/qp_solver2.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// This example program solves the quadratic program -// minimize x^T D x + c^T x + c0 -// subject to A x b -// L <= x <= u -// where stands for a vector of relations from {<=, ==, >=} -// -// In the concrete example below, we have the following data: -// D c A b L U c0 -// ----------------------------------------------------------------------- -// 1.0 0.0 0.0 3.0 0.5 1.0 0.5 0.0 0.0 inf, inf 1 -// 0.0 0.0 -// -// In other words, we minimize x^2 + 3y subject to x/2 + y >= 1/2 -// and x,y >= 0. Let's see what this gives: it is clear that in an -// optimal solution, the constraint is satisfied with equality, -// otherwise, we could decrease the objective function value. Let's -// substitute x with 1 - 2y in the objective function; we get -// 4y^2 - y + 1. The derivative is 8y-1, so this is minimzed -// for y = 1/8. This value (as well as x = 1 - 2(1/8) = 3/4) -// are within the bounds, so the solution should be x = 3/4 -// and y = 1/8. The objective function value should be -// 9/16 + 3/8 + 1 = 31/16 - -#include -#include -#include - -#ifndef CGAL_USE_GMP -#include -typedef CGAL::MP_Float ET; -#else -#include -typedef CGAL::Gmpzf ET; -#endif - -// program and solution types -typedef CGAL::Nonnegative_quadratic_program_from_pointers Program; -typedef CGAL::Quadratic_program_solution Solution; - -int main() { - // program data - double A_col_0[] = {0.5}; - double A_col_1[] = {1.0}; - double *cols_of_A[] = {A_col_0, A_col_1}; - double b[] = {0.5}; - CGAL::Comparison_result rt[] = {CGAL::LARGER}; - double D_row_0[] = {2.0, 0.0}; - double D_row_1[] = {0.0, 0.0}; - double *rows_of_D[] = {D_row_0, D_row_1}; - double c[] = {0.0, 3.0}; - double c0 = 1.0; - - // 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, 1, cols_of_A, b, rt, rows_of_D, c, c0); - // solve the program - Solution s = CGAL::solve_nonnegative_quadratic_program(qp, ET()); - - // output solution - if (s.status() == CGAL::QP_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 << CGAL::to_double(*it) << " "; - std::cout << "\nOptimal value: " << CGAL::to_double(s.objective_value()) - << std::endl; - } - - return 0; -}