[PPL-devel] [GIT] ppl/ppl(master): Fixed bug introduced when improving coding style in PIP_Solution_Node:: solve.

Enea Zaffanella zaffanella at cs.unipr.it
Tue Feb 16 22:42:33 CET 2010


Module: ppl/ppl
Branch: master
Commit: 53e86bccd511369b2fa500d60b355ebee824fc2b
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=53e86bccd511369b2fa500d60b355ebee824fc2b

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Tue Feb 16 22:40:01 2010 +0100

Fixed bug introduced when improving coding style in PIP_Solution_Node::solve.
Corrected wrong assertion in PIP_Solution_Node::generate_cut.

---

 src/PIP_Tree.cc |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index e92664f..60b8fbf 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -1788,18 +1788,26 @@ PIP_Solution_Node::solve(const PIP_Problem& problem,
       PPL_DIRTY_TEMP_COEFFICIENT(gcd);
       PPL_DIRTY_TEMP_COEFFICIENT(scale_factor);
 
-      // Create identity rows corresponding to basic variable pj.
+      // Creating identity rows corresponding to basic variable pj:
+      // 1. add them to tableau so as to have proper size and capacity;
       tableau.s.add_zero_rows(1, Row::Flags());
       tableau.t.add_zero_rows(1, Row::Flags());
-      Row& s_pivot = tableau.s[num_rows];
-      Row& t_pivot = tableau.t[num_rows];
+      // 2. swap the rows just added with empty ones.
+      Row s_pivot(0, Row::Flags());
+      Row t_pivot(0, Row::Flags());
+      s_pivot.swap(tableau.s[num_rows]);
+      t_pivot.swap(tableau.t[num_rows]);
+      // 3. drop rows previously added at end of tableau.
+      tableau.s.erase_to_end(num_rows);
+      tableau.t.erase_to_end(num_rows);
+
       // Save current pivot denominator.
       PPL_DIRTY_TEMP_COEFFICIENT(pivot_den);
       pivot_den = tableau.get_denominator();
       // Let the (scaled) pivot coordinate be 1.
       s_pivot[pj] = pivot_den;
 
-      // Swap identity row with the pivot row previosuly found.
+      // Swap identity row with the pivot row previously found.
       s_pivot.swap(tableau.s[pi]);
       t_pivot.swap(tableau.t[pi]);
       sign[pi] = ZERO;
@@ -1897,10 +1905,6 @@ PIP_Solution_Node::solve(const PIP_Problem& problem,
         }
       }
 
-      // Drop rows previously added at end of tableau.
-      tableau.s.erase_to_end(num_rows);
-      tableau.t.erase_to_end(num_rows);
-
       // Pivoting process ended: jump to next iteration.
       solution_valid = false;
       continue;
@@ -2211,7 +2215,7 @@ PIP_Solution_Node::generate_cut(const dimension_type index,
   PPL_ASSERT(index < num_rows);
   const dimension_type num_vars = tableau.s.num_columns();
   const dimension_type num_params = tableau.t.num_columns();
-  PPL_ASSERT(num_params == parameters.size());
+  PPL_ASSERT(num_params == 1 + parameters.size());
   const Coefficient& den = tableau.get_denominator();
 
   PPL_DIRTY_TEMP_COEFFICIENT(mod);




More information about the PPL-devel mailing list