Improving arithmetic debugging output.
authorTim King <taking@cs.nyu.edu>
Tue, 7 May 2013 18:35:22 +0000 (14:35 -0400)
committerTim King <taking@cs.nyu.edu>
Tue, 7 May 2013 18:35:22 +0000 (14:35 -0400)
src/theory/arith/partial_model.h
src/theory/arith/theory_arith_private.cpp
src/theory/arith/theory_arith_private.h

index 953c8c0d388e3d925a7ff5f0d24d327a4e50ddda..deafb559af51d7491971fb60d59635b1857f9074 100644 (file)
@@ -204,6 +204,11 @@ private:
   bool isSlack(ArithVar x) const {
     return d_vars[x].d_slack;
   }
+
+  bool integralAssignment(ArithVar x) const {
+    return getAssignment(x).isIntegral();
+  }
+
  private:
 
   typedef std::pair<ArithVar, Constraint> AVCPair;
index 9c43ca962817befe429bb4b2dcd0b630071378f2..d911ecf773ce7de0cc9c9c5328069623a3e29079 100644 (file)
@@ -1721,7 +1721,7 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){
 
 
   if(Debug.isOn("arith::print_assertions")) {
-    debugPrintAssertions();
+    debugPrintAssertions(Debug("arith::print_assertions"));
   }
 
   bool emmittedConflictOrSplit = false;
@@ -1922,7 +1922,9 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){
   }
 
   if(Debug.isOn("paranoid:check_tableau")){ d_linEq.debugCheckTableau(); }
-  if(Debug.isOn("arith::print_model")) { debugPrintModel(); }
+  if(Debug.isOn("arith::print_model")) {
+    debugPrintModel(Debug("arith::print_model"));
+  }
   Debug("arith") << "TheoryArithPrivate::check end" << std::endl;
 }
 
@@ -2043,37 +2045,38 @@ bool TheoryArithPrivate::splitDisequalities(){
  * Should be guarded by at least Debug.isOn("arith::print_assertions").
  * Prints to Debug("arith::print_assertions")
  */
-void TheoryArithPrivate::debugPrintAssertions() {
-  Debug("arith::print_assertions") << "Assertions:" << endl;
+void TheoryArithPrivate::debugPrintAssertions(std::ostream& out) const {
+  out << "Assertions:" << endl;
   for (var_iterator vi = var_begin(), vend = var_end(); vi != vend; ++vi){
     ArithVar i = *vi;
     if (d_partialModel.hasLowerBound(i)) {
       Constraint lConstr = d_partialModel.getLowerBoundConstraint(i);
-      Debug("arith::print_assertions") << lConstr << endl;
+      out << lConstr << endl;
     }
 
     if (d_partialModel.hasUpperBound(i)) {
       Constraint uConstr = d_partialModel.getUpperBoundConstraint(i);
-      Debug("arith::print_assertions") << uConstr << endl;
+      out << uConstr << endl;
     }
   }
   context::CDQueue<Constraint>::const_iterator it = d_diseqQueue.begin();
   context::CDQueue<Constraint>::const_iterator it_end = d_diseqQueue.end();
   for(; it != it_end; ++ it) {
-    Debug("arith::print_assertions") << *it << endl;
+    out << *it << endl;
   }
 }
 
-void TheoryArithPrivate::debugPrintModel(){
-  Debug("arith::print_model") << "Model:" << endl;
+void TheoryArithPrivate::debugPrintModel(std::ostream& out) const{
+  out << "Model:" << endl;
   for (var_iterator vi = var_begin(), vend = var_end(); vi != vend; ++vi){
     ArithVar i = *vi;
     if(d_partialModel.hasNode(i)){
-      Debug("arith::print_model") << d_partialModel.asNode(i) << " : " <<
+      out << d_partialModel.asNode(i) << " : " <<
         d_partialModel.getAssignment(i);
-      if(d_tableau.isBasic(i))
-        Debug("arith::print_model") << " (basic)";
-      Debug("arith::print_model") << endl;
+      if(d_tableau.isBasic(i)){
+        out << " (basic)";
+      }
+      out << endl;
     }
   }
 }
@@ -2406,6 +2409,14 @@ bool TheoryArithPrivate::entireStateIsConsistent(const string& s){
       }
       Warning() << endl;
       result = false;
+    }else if(d_partialModel.isInteger(var) && !d_partialModel.integralAssignment(var)){
+      d_partialModel.printModel(var);
+      Warning() << s << ":" << "Assignment is not integer for integer variable " << var << d_partialModel.asNode(var);
+      if(d_tableau.isBasic(var)){
+        Warning() << " (basic)";
+      }
+      Warning() << endl;
+      result = false;
     }
   }
   return result;
index c8f49ab012608d4415312ccfbdf63c22543b6094..2ea3bb68ee64ee97547c985717b27fb88520d06a 100644 (file)
@@ -534,9 +534,9 @@ private:
                  std::vector<ArithVar>& variables);
 
   /** Routine for debugging. Print the assertions the theory is aware of. */
-  void debugPrintAssertions();
+  void debugPrintAssertions(std::ostream& out) const;
   /** Debugging only routine. Prints the model. */
-  void debugPrintModel();
+  void debugPrintModel(std::ostream& out) const;
 
   inline LogicInfo getLogicInfo() const { return d_containing.getLogicInfo(); }
   inline bool done() const { return d_containing.done(); }