
Module: ppl/ppl Branch: master Commit: 511e9e86f96884b311d7b053aac33afb977129bb URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=511e9e86f9688...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Sat Feb 20 12:52:19 2010 +0100
Adding no space dims should not invalidate previously computed solution.
---
src/PIP_Problem.cc | 5 +++++ tests/PIP_Problem/pipproblem2.cc | 13 +++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/PIP_Problem.cc b/src/PIP_Problem.cc index 8dbae6d..6c3609e 100644 --- a/src/PIP_Problem.cc +++ b/src/PIP_Problem.cc @@ -510,6 +510,11 @@ void PPL::PIP_Problem ::add_space_dimensions_and_embed(const dimension_type m_vars, const dimension_type m_params) { + // Adding no space dims at all is a no-op: + // this avoids invalidating problem status (if it was optimized). + if (m_vars == 0 && m_params == 0) + return; + // The space dimension of the resulting PIP problem should not // overflow the maximum allowed space dimension. dimension_type available = max_space_dimension() - space_dimension(); diff --git a/tests/PIP_Problem/pipproblem2.cc b/tests/PIP_Problem/pipproblem2.cc index 8a20535..777c3bc 100644 --- a/tests/PIP_Problem/pipproblem2.cc +++ b/tests/PIP_Problem/pipproblem2.cc @@ -286,6 +286,18 @@ test14() { return ok; }
+bool +test15() { + PIP_Problem pip; + bool ok = (pip.solve() == OPTIMIZED_PIP_PROBLEM); + // Adding no space dimension at all is a no-op: + // it does not invalidate the solution computed before. + pip.add_space_dimensions_and_embed(0, 0); + // This would throw an exception if the solution was invalidated. + pip.print_solution(nout); + return ok; +} + } // namespace
BEGIN_MAIN @@ -303,4 +315,5 @@ BEGIN_MAIN DO_TEST(test12); DO_TEST(test13); DO_TEST(test14); + DO_TEST(test15); END_MAIN