From 6eaf901af2af24f77db294d6e77992c04e07200f Mon Sep 17 00:00:00 2001 From: Yves Brise Date: Thu, 2 Feb 2012 22:43:24 +0000 Subject: [PATCH] Fix bug in QP_solver and add respective test cases. The bug was that the artificial variable was not correctly expelled at the end of phase one in certain cases of redundant constraints. (This is with permission of Laurent Rineau) --- .gitattributes | 2 + .../include/CGAL/QP_solver/QP_solver_impl.h | 7 +- .../cycle_cases/bug_stich.mps | 105 ++++++++++++++++++ .../cycle_cases/bug_taysom.mps | 30 +++++ 4 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_stich.mps create mode 100644 QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_taysom.mps diff --git a/.gitattributes b/.gitattributes index d4e5d0886cd..f689bdd6b9b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3446,6 +3446,8 @@ QP_solver/test/QP_solver/test_default_bounds.cpp -text QP_solver/test/QP_solver/test_random_qp.cpp -text QP_solver/test/QP_solver/test_random_qp2.cpp -text QP_solver/test/QP_solver/test_solver.cout -text +QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_stich.mps -text +QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_taysom.mps -text QP_solver/test/QP_solver/test_solver_data/cycle_cases/helbling_001.mps -text QP_solver/test/QP_solver/test_solver_data/cycle_cases/helbling_248.mps -text QP_solver/test/QP_solver/test_solver_data/cycle_cases/helbling_39.mps -text diff --git a/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h b/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h index 06b2f970c0d..9f50d333c00 100644 --- a/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h +++ b/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h @@ -1255,12 +1255,7 @@ expel_artificial_variables_from_basis( ) // explicitly are synchronized during transition from phaseI to phaseII for (unsigned int i_ = static_cast(qp_n + slack_A.size()); i_ < static_cast(in_B.size()); ++i_) { if (is_basic(i_)) { // is basic - if (has_ineq) { - row_ind = in_C[ art_A[i_ - qp_n - slack_A.size()].first]; - } else { - row_ind = art_A[i_ - qp_n].first; - } - + row_ind = in_B[i_]; //CGAL_qpe_assertion(row_ind >= 0); diff --git a/QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_stich.mps b/QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_stich.mps new file mode 100644 index 00000000000..269973f10c5 --- /dev/null +++ b/QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_stich.mps @@ -0,0 +1,105 @@ +* Description: Case that was sent in by Sebastian Stich. It used to exibit +* a segfault in expel_artificial_variables (special artificial is linked to a +* constraint that is not active). +* Derivatives: none +NAME MY_MPS +ROWS + N obj + G c0 + G c1 + E c2 + G c3 + G c4 + G c5 + G c6 + G c7 + G c8 + E c9 + G c10 + G c11 + G c12 + E c13 + G c14 + G c15 + E c16 + G c17 + G c18 + G c19 + E c20 +COLUMNS + x0 c0 1 + x0 c1 1 + x0 c2 1 + x0 c3 1 + x0 c4 1 + x1 c5 1 + x1 c6 1 + x1 c7 1 + x1 c8 1 + x1 c9 1 + x1 c10 1 + x1 c11 1 + x2 c0 1 + x2 c5 1 + x2 c12 1 + x2 c13 1 + x3 c1 1 + x3 c6 1 + x3 c12 1 + x3 c14 1 + x3 c15 1 + x3 c16 1 + x4 c7 1 + x4 c13 1 + x4 c17 1 + x4 c18 1 + x4 c19 1 + x5 c2 1 + x6 c3 1 + x6 c8 1 + x6 c14 1 + x6 c17 1 + x6 c20 1 + x7 c9 1 + x8 c4 1 + x8 c10 1 + x8 c15 1 + x8 c18 1 + x8 c20 1 + x9 c11 1 + x9 c16 1 + x9 c19 1 +RHS + rhs c0 1 + rhs c1 1 + rhs c2 1 + rhs c3 1 + rhs c4 1 + rhs c5 1 + rhs c6 1 + rhs c7 1 + rhs c8 1 + rhs c9 1 + rhs c10 1 + rhs c11 1 + rhs c12 1 + rhs c13 1 + rhs c14 1 + rhs c15 1 + rhs c16 1 + rhs c17 1 + rhs c18 1 + rhs c19 1 + rhs c20 1 +BOUNDS + UP BND x0 1 + UP BND x1 1 + UP BND x2 1 + UP BND x3 1 + UP BND x4 1 + UP BND x5 1 + UP BND x6 1 + UP BND x7 1 + UP BND x8 1 + UP BND x9 1 +ENDATA diff --git a/QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_taysom.mps b/QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_taysom.mps new file mode 100644 index 00000000000..c77cc3bf952 --- /dev/null +++ b/QP_solver/test/QP_solver/test_solver_data/cycle_cases/bug_taysom.mps @@ -0,0 +1,30 @@ +* Description: Case that was sent in by William Taysom. It used to exibit +* a segfault in expel_artificial_variables (special artificial is linked to a +* constraint that is not active). +NAME MY_MPS +ROWS + N obj + E c0 + G c1 + G c2 + G c3 +COLUMNS + x0 obj 1 + x0 c0 1 + x0 c1 1 + x0 c2 1 + x0 c3 1 + x1 c0 1 + x1 c1 1 + x1 c3 1 + x2 c0 1 + x2 c1 1 + x2 c2 1 +RHS + rhs c0 4 + rhs c1 4 + rhs c2 3 + rhs c3 3 +BOUNDS + UP BND x0 2 +ENDATA