- Adds the statistic d_avgNumRowsNotContainingOnPivot.
authorTim King <taking@cs.nyu.edu>
Mon, 21 Feb 2011 00:22:18 +0000 (00:22 +0000)
committerTim King <taking@cs.nyu.edu>
Mon, 21 Feb 2011 00:22:18 +0000 (00:22 +0000)
- Removed a bug in row counting in row counting.

src/theory/arith/row_vector.cpp
src/theory/arith/row_vector.h
src/theory/arith/simplex.cpp
src/theory/arith/simplex.h
src/theory/arith/tableau.h
src/theory/arith/theory_arith.cpp

index 07fc0186d726b3cdaf724cac93927cc722cf5bcf..2af03bf085d78924057bd80746fe88c9a6cf3f9e 100644 (file)
@@ -117,7 +117,8 @@ void RowVector::merge(VarCoeffArray& arr,
     }else{
       Rational res = getCoefficient(*curr1) + c * getCoefficient(*curr2);
       if(res != 0){
-        ++counts[getArithVar(*curr2)];
+        //The variable is not new so the count stays the same
+        //bug: ++counts[getArithVar(*curr2)];
 
         arr.push_back(make_pair(getArithVar(*curr1), res));
       }else{
@@ -177,6 +178,7 @@ ReducedRowVector::ReducedRowVector(ArithVar basic,
   merge(d_entries, d_contains, justBasic, Rational(1), d_rowCount);
 
   Assert(wellFormed());
+  Assert(d_rowCount[d_basic] == 1);
 }
 
 void ReducedRowVector::substitute(const ReducedRowVector& row_s){
@@ -192,6 +194,7 @@ void ReducedRowVector::substitute(const ReducedRowVector& row_s){
 
   Assert(!has(x_s));
   Assert(wellFormed());
+  Assert(d_rowCount[basic()] == 1);
 }
 
 void ReducedRowVector::pivot(ArithVar x_j){
@@ -202,6 +205,9 @@ void ReducedRowVector::pivot(ArithVar x_j){
   d_basic = x_j;
 
   Assert(wellFormed());
+  //The invariant Assert(d_rowCount[basic()] == 1); does not hold.
+  //This is because the pivot is within the row first then
+  //is moved through the propagated through the rest of the tableau.
 }
 
 
@@ -237,3 +243,10 @@ Node ReducedRowVector::asEquality(const ArithVarToNodeMap& map) const{
   Node basicVar = (map.find(basic()))->second;
   return NodeBuilder<2>(EQUAL) << basicVar << sum;
 }
+
+
+ReducedRowVector::~ReducedRowVector(){
+  //This executes before the super classes destructor RowVector,
+  // which will set this to 0.
+  Assert(d_rowCount[basic()] == 1);
+}
index 2b48564a4ca837efa2083faad9342e657bd80171..85a1880636c858c345fac03864632e506f3758a3 100644 (file)
@@ -178,6 +178,7 @@ public:
                    const std::vector< Rational >& coefficients,
                    std::vector<uint32_t>& count);
 
+  ~ReducedRowVector();
 
   ArithVar basic() const{
     Assert(basicIsSet());
index 0f4f27a7636e45fd333fa49fc06424bb2b13d79a..d8d39c24f7e86bb9bf1a74b19e2a261bb4a4b490 100644 (file)
@@ -22,7 +22,9 @@ SimplexDecisionProcedure::Statistics::Statistics():
   d_selectInitialConflictTime("theory::arith::selectInitialConflictTime"),
   d_pivotsAfterConflict("theory::arith::pivotsAfterConflict", 0),
   d_checksWithWastefulPivots("theory::arith::checksWithWastefulPivots", 0),
-  d_pivotTime("theory::arith::pivotTime")
+  d_pivotTime("theory::arith::pivotTime"),
+  d_avgNumRowsNotContainingOnUpdate("theory::arith::avgNumRowsNotContainingOnUpdate"),
+  d_avgNumRowsNotContainingOnPivot("theory::arith::avgNumRowsNotContainingOnPivot")
 {
   StatisticsRegistry::registerStat(&d_statPivots);
   StatisticsRegistry::registerStat(&d_statUpdates);
@@ -36,6 +38,9 @@ SimplexDecisionProcedure::Statistics::Statistics():
   StatisticsRegistry::registerStat(&d_pivotsAfterConflict);
   StatisticsRegistry::registerStat(&d_checksWithWastefulPivots);
   StatisticsRegistry::registerStat(&d_pivotTime);
+
+  StatisticsRegistry::registerStat(&d_avgNumRowsNotContainingOnUpdate);
+  StatisticsRegistry::registerStat(&d_avgNumRowsNotContainingOnPivot);
 }
 
 SimplexDecisionProcedure::Statistics::~Statistics(){
@@ -51,6 +56,9 @@ SimplexDecisionProcedure::Statistics::~Statistics(){
   StatisticsRegistry::unregisterStat(&d_pivotsAfterConflict);
   StatisticsRegistry::unregisterStat(&d_checksWithWastefulPivots);
   StatisticsRegistry::unregisterStat(&d_pivotTime);
+
+  StatisticsRegistry::unregisterStat(&d_avgNumRowsNotContainingOnUpdate);
+  StatisticsRegistry::unregisterStat(&d_avgNumRowsNotContainingOnPivot);
 }
 
 /* procedure AssertLower( x_i >= c_i ) */
@@ -188,6 +196,10 @@ void SimplexDecisionProcedure::update(ArithVar x_i, const DeltaRational& v){
 
   d_partialModel.setAssignment(x_i, v);
 
+  Assert(d_tableau.getNumRows() >= d_tableau.getRowCount(x_i));
+  double difference = ((double)d_tableau.getNumRows()) - ((double) d_tableau.getRowCount(x_i));
+
+  (d_statistics.d_avgNumRowsNotContainingOnUpdate).addEntry(difference);
   if(Debug.isOn("paranoid:check_tableau")){
     checkTableau();
   }
@@ -261,8 +273,12 @@ void SimplexDecisionProcedure::pivotAndUpdate(ArithVar x_i, ArithVar x_j, DeltaR
     ++(d_statistics.d_pivotsAfterConflict);
   }
 
+  Assert(d_tableau.getNumRows() >= d_tableau.getRowCount(x_j));
+  double difference = ((double)d_tableau.getNumRows()) - ((double) d_tableau.getRowCount(x_j));
+  (d_statistics.d_avgNumRowsNotContainingOnPivot).addEntry(difference);
   d_tableau.pivot(x_i, x_j);
 
+
   checkBasicVariable(x_j);
 
   // Debug found conflict
index 84d7cdcbb3510edd8cad6e4acd762d72de83c185..c5c4da6611ab1235e6b1f5a07ad9e3827a84872d 100644 (file)
@@ -208,6 +208,10 @@ private:
 
     IntStat d_pivotsAfterConflict, d_checksWithWastefulPivots;
     TimerStat d_pivotTime;
+
+    AverageStat d_avgNumRowsNotContainingOnUpdate;
+    AverageStat d_avgNumRowsNotContainingOnPivot;
+
     Statistics();
     ~Statistics();
   };
index 32c2986e34457502a5c9f733be9f0adc041bd8d3..36d61ba25137f065ffa2099817649241e1a8d05f 100644 (file)
@@ -59,6 +59,10 @@ public:
   {}
   ~Tableau();
 
+  size_t getNumRows() const {
+    return d_basicVariables.size();
+  }
+
   void increaseSize(){
     d_basicVariables.increaseSize();
     d_rowsTable.push_back(NULL);
index 4e84c85db8c907384156d188025a504fca98c1e6..6084e346374d6a5a83dbf85432cc9e19950752e8 100644 (file)
@@ -694,9 +694,11 @@ void TheoryArith::permanentlyRemoveVariable(ArithVar v){
     Node eq = row->asEquality(d_arithVarToNodeMap);
 
     if(Debug.isOn("row::print")) row->printRow();
+    if(Debug.isOn("tableau")) d_tableau.printTableau();
     Debug("arith::permanentlyRemoveVariable") << eq << endl;
     delete row;
 
+    Assert(d_tableau.getRowCount(v) == 0);
     Assert(d_removedRows.find(v) ==  d_removedRows.end());
     d_removedRows[v] = eq;
   }