Adding reduce() to the ArithPriorityQueue. This reduces the queue from a superset...
authorTim King <taking@cs.nyu.edu>
Wed, 27 Jun 2012 20:55:17 +0000 (20:55 +0000)
committerTim King <taking@cs.nyu.edu>
Wed, 27 Jun 2012 20:55:17 +0000 (20:55 +0000)
src/theory/arith/arith_priority_queue.cpp
src/theory/arith/arith_priority_queue.h

index 04ca62571245b07325037a5d7c5f22667bb00be0..52b9f4a742d64db9ae012604b97ade375d6e87c4 100644 (file)
@@ -326,3 +326,23 @@ std::ostream& CVC4::theory::arith::operator<<(std::ostream& out, ArithPriorityQu
 
   return out;
 }
+
+void  ArithPriorityQueue::reduce(){
+  vector<ArithVar> contents;
+
+  if(inCollectionMode()){
+    contents = d_candidates;
+  } else {
+    ArithVar res = ARITHVAR_SENTINEL;
+    while((res = dequeueInconsistentBasicVariable()) != ARITHVAR_SENTINEL){
+      contents.push_back(res);
+    }
+  }
+  clear();
+  for(vector<ArithVar>::const_iterator iter = contents.begin(), end = contents.end(); iter != end; ++iter){
+    ArithVar curr = *iter;
+    if(d_tableau.isBasic(curr)){
+      enqueueIfInconsistent(curr);
+    }
+  }
+}
index fb80e599e7a62668104ac85f4cac400166fbad9b..d1fac1e58781038202f26bb421c77ed9c8f1764b 100644 (file)
@@ -217,6 +217,13 @@ public:
   void clear();
 
 
+  /**
+   * Reduces the queue to only contain the subset that is still basic
+   * and inconsistent.
+   *Currently, O(n log n) for an easy obviously correct implementation in all modes..
+   */
+  void reduce();
+
   bool collectionModeContains(ArithVar v) const {
     Assert(inCollectionMode());
     return d_varSet.isMember(v);