[PPL-devel] [GIT] ppl/ppl(sparse_matrices): PIP_Solution_Node: modify generate_cut() to be efficient even with backends that have slow insertions.

Marco Poletti poletti.marco at gmail.com
Wed Mar 24 14:45:16 CET 2010


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

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Wed Mar 24 14:12:34 2010 +0100

PIP_Solution_Node: modify generate_cut() to be efficient even with backends that have slow insertions.

---

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

diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index b35d093..7fea489 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -3238,6 +3238,28 @@ PIP_Solution_Node::generate_cut(const dimension_type index,
         matrix_const_row_const_iterator j_end = row_t.end();
         matrix_row_iterator itr1 = ctx1.end();
         matrix_row_iterator itr2 = ctx2.end();
+        if (j != j_end && (*j).first == 0) {
+          mod_assign(mod, (*j).second, den);
+          if (mod != 0) {
+            itr1 = ctx1.find_create(0, den);
+            (*itr1).second -= mod;
+            itr2 = ctx2.find_create(0, (*itr1).second);
+            neg_assign((*itr2).second);
+            // ctx2[0] += den-1;
+            (*itr2).second += den;
+            --(*itr2).second;
+          } else {
+            // ctx2[0] += den-1;
+            itr2 = ctx2.find_create(0,den);
+            --(*itr2).second;
+          }
+          ++j;
+        } else {
+          // ctx2[0] += den-1;
+          Coefficient& ctx2_0 = ctx2[0];
+          ctx2_0 += den;
+          --ctx2_0;
+        }
         for ( ; j != j_end; ++j) {
           mod_assign(mod, (*j).second, den);
           if (mod != 0) {
@@ -3272,10 +3294,6 @@ PIP_Solution_Node::generate_cut(const dimension_type index,
           ctx2.find_create(num_params ,den);
         }
       }
-      // ctx2[0] += den-1;
-      Coefficient& ctx2_0 = ctx2[0];
-      ctx2_0 += den;
-      --ctx2_0;
 #ifdef NOISY_PIP
       {
         using namespace IO_Operators;




More information about the PPL-devel mailing list