added options for controlling resource step-count for various solving stages
authorLiana Hadarean <lianahady@gmail.com>
Thu, 28 May 2015 14:03:10 +0000 (15:03 +0100)
committerLiana Hadarean <lianahady@gmail.com>
Thu, 28 May 2015 14:03:10 +0000 (15:03 +0100)
35 files changed:
src/decision/decision_engine.h
src/parser/parser.cpp
src/prop/bvminisat/bvminisat.h
src/prop/bvminisat/core/Solver.cc
src/prop/bvminisat/core/Solver.h
src/prop/cnf_stream.cpp
src/prop/minisat/core/Solver.cc
src/prop/minisat/core/Solver.h
src/prop/prop_engine.cpp
src/prop/prop_engine.h
src/prop/sat_solver.h
src/prop/theory_proxy.cpp
src/prop/theory_proxy.h
src/smt/options
src/smt/smt_engine.cpp
src/theory/arith/theory_arith.cpp
src/theory/arrays/theory_arrays.cpp
src/theory/bv/bitblaster_template.h
src/theory/bv/bv_eager_solver.cpp
src/theory/bv/bv_subtheory_bitblast.cpp
src/theory/bv/bv_subtheory_core.cpp
src/theory/bv/bv_subtheory_inequality.cpp
src/theory/bv/eager_bitblaster.cpp
src/theory/bv/lazy_bitblaster.cpp
src/theory/bv/theory_bv.cpp
src/theory/bv/theory_bv.h
src/theory/output_channel.h
src/theory/quantifiers_engine.cpp
src/theory/rewriter.cpp
src/theory/theory_engine.cpp
src/theory/theory_engine.h
src/theory/theory_test_utils.h
src/theory/uf/theory_uf.cpp
src/util/resource_manager.cpp
src/util/resource_manager.h

index 61900e59ddafd02aaead33eb39c26fa7ba27a149..ffcf2db638aab0cde75db2b9ccf3ecc2557d7da9 100644 (file)
@@ -118,7 +118,7 @@ public:
 
   /** Gets the next decision based on strategies that are enabled */
   SatLiteral getNext(bool &stopSearch) {
-    NodeManager::currentResourceManager()->spendResource();
+    NodeManager::currentResourceManager()->spendResource(options::decisionStep());
     Assert(d_cnfStream != NULL,
            "Forgot to set cnfStream for decision engine?");
     Assert(d_satSolver != NULL,
index 10a729420af22ca8ca41addc2e277e05cdec2bb1..d17d5d1414765aeb6567a679f20252cc1c02507b 100644 (file)
@@ -31,6 +31,7 @@
 #include "util/output.h"
 #include "util/resource_manager.h"
 #include "options/options.h"
+#include "smt/options.h"
 
 using namespace std;
 using namespace CVC4::kind;
@@ -499,14 +500,14 @@ Command* Parser::nextCommand() throw(ParserException, UnsafeInterruptException)
       dynamic_cast<QuitCommand*>(cmd) == NULL) {
     // don't count set-option commands as to not get stuck in an infinite
     // loop of resourcing out
-    d_resourceManager->spendResource();
+    d_resourceManager->spendResource(d_exprManager->getOptions()[options::parseStep]);
   }
   return cmd;
 }
 
 Expr Parser::nextExpression() throw(ParserException, UnsafeInterruptException) {
   Debug("parser") << "nextExpression()" << std::endl;
-  d_resourceManager->spendResource();
+  d_resourceManager->spendResource(d_exprManager->getOptions()[options::parseStep]);
   Expr result;
   if(!done()) {
     try {
index 6246e68856670172653e2db0a5d775d63bc8208a..2c966265591a484fadbab5290fb92e8923c8e39d 100644 (file)
@@ -46,11 +46,11 @@ private:
       d_notify->notify(satClause);
     }
 
-    void spendResource() {
-      d_notify->spendResource();
+    void spendResource(uint64_t ammount) {
+      d_notify->spendResource(ammount);
     }
-    void safePoint() {
-      d_notify->safePoint();
+    void safePoint(uint64_t ammount) {
+      d_notify->safePoint(ammount);
     }
   };
 
index b6238460b64e55d2c927e7aed3e0577ef1cac43d..1267561fbd0c3bb4d73515933bc32a4c60c0c354 100644 (file)
@@ -29,6 +29,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
 #include "util/utility.h"
 #include "util/exception.h"
 #include "theory/bv/options.h"
+#include "smt/options.h"
 #include "theory/interrupted.h"
 using namespace BVMinisat;
 
@@ -871,7 +872,7 @@ lbool Solver::search(int nof_conflicts, UIP uip)
             // NO CONFLICT
             bool isWithinBudget;
             try {
-              isWithinBudget = withinBudget(); 
+              isWithinBudget = withinBudget(CVC4::options::bvSatConflictStep()); 
             }
             catch (const CVC4::theory::Interrupted& e) {
               // do some clean-up and rethrow 
@@ -1021,7 +1022,7 @@ lbool Solver::solve_()
     while (status == l_Undef){
         double rest_base = luby_restart ? luby(restart_inc, curr_restarts) : pow(restart_inc, curr_restarts);
         status = search(rest_base * restart_first);
-        if (!withinBudget()) break;
+        if (!withinBudget(CVC4::options::bvSatConflictStep())) break;
         curr_restarts++;
     }
 
index 3fcf341857ee266468b0015533b46836811027cb..7d2a978b9de90788e5c32187d3fbfc4fbf0a2375 100644 (file)
@@ -52,8 +52,8 @@ public:
    */
   virtual void notify(vec<Lit>& learnt) = 0;
 
-  virtual void spendResource() = 0;
-  virtual void safePoint() = 0;
+  virtual void spendResource(uint64_t ammount) = 0;
+  virtual void safePoint(uint64_t ammount) = 0;
 };
 
 //=================================================================================================
@@ -324,7 +324,7 @@ protected:
     CRef     reason           (Var x) const;
     int      level            (Var x) const;
     double   progressEstimate ()      const; // DELETE THIS ?? IT'S NOT VERY USEFUL ...
-    bool     withinBudget     ()      const;
+    bool     withinBudget     (uint64_t ammount)      const;
 
     // Static helpers:
     //
@@ -412,10 +412,10 @@ inline void     Solver::setPropBudget(int64_t x){ propagation_budget = propagati
 inline void     Solver::interrupt(){ asynch_interrupt = true; }
 inline void     Solver::clearInterrupt(){ asynch_interrupt = false; }
 inline void     Solver::budgetOff(){ conflict_budget = propagation_budget = -1; }
-inline bool     Solver::withinBudget() const {
+inline bool     Solver::withinBudget(uint64_t ammount) const {
     Assert (notify);
-    notify->spendResource();
-    notify->safePoint();
+    notify->spendResource(ammount);
+    notify->safePoint(0);
 
     return !asynch_interrupt &&
            (conflict_budget    < 0 || conflicts < (uint64_t)conflict_budget) &&
index c8d86c73dd490fce4686fce99d163b90a6f7be9a..f03cc994404f6dfb2cf7e63272426caf35ef0821 100644 (file)
@@ -679,7 +679,7 @@ void TseitinCnfStream::convertAndAssert(TNode node, bool negated, ProofRule proo
   Debug("cnf") << "convertAndAssert(" << node << ", negated = " << (negated ? "true" : "false") << ")" << endl;
 
   if (d_convertAndAssertCounter % ResourceManager::getFrequencyCount() == 0) {
-    NodeManager::currentResourceManager()->spendResource();
+    NodeManager::currentResourceManager()->spendResource(options::cnfStep());
     d_convertAndAssertCounter = 0;
   }
   ++d_convertAndAssertCounter;
index 56316ca0b933a9b074ae658c6693aab606ce5216..2c94401fb79fe71f1b88d0e97d5a85ef9e2250ed 100644 (file)
@@ -1205,7 +1205,8 @@ lbool Solver::search(int nof_conflicts)
               check_type = CHECK_WITH_THEORY;
             }
 
-            if (nof_conflicts >= 0 && conflictC >= nof_conflicts || !withinBudget()) {
+            if (nof_conflicts >= 0 && conflictC >= nof_conflicts ||
+                !withinBudget(options::satConflictStep())) {
                 // Reached bound on number of conflicts:
                 progress_estimate = progressEstimate();
                 cancelUntil(0);
@@ -1343,11 +1344,11 @@ lbool Solver::solve_()
     while (status == l_Undef){
         double rest_base = luby_restart ? luby(restart_inc, curr_restarts) : pow(restart_inc, curr_restarts);
         status = search(rest_base * restart_first);
-        if (!withinBudget()) break;
+        if (!withinBudget(options::satConflictStep())) break; // FIXME add restart option?
         curr_restarts++;
     }
 
-    if(!withinBudget())
+    if(!withinBudget(options::satConflictStep()))
         status = l_Undef;
 
     if (verbosity >= 1)
@@ -1599,7 +1600,7 @@ CRef Solver::updateLemmas() {
   Debug("minisat::lemmas") << "Solver::updateLemmas() begin" << std::endl;
 
   // Avoid adding lemmas indefinitely without resource-out
-  proxy->spendResource();
+  proxy->spendResource(options::lemmaStep());
 
   CRef conflict = CRef_Undef;
 
@@ -1717,11 +1718,11 @@ CRef Solver::updateLemmas() {
   return conflict;
 }
 
-inline bool Solver::withinBudget() const {
+inline bool Solver::withinBudget(uint64_t ammount) const {
   Assert (proxy);
   // spendResource sets async_interrupt or throws UnsafeInterruptException
   // depending on whether hard-limit is enabled
-  proxy->spendResource();
+  proxy->spendResource(ammount);
 
   bool within_budget =  !asynch_interrupt &&
     (conflict_budget    < 0 || conflicts < (uint64_t)conflict_budget) &&
index 9243a2b356207908d84b158790348215240ed1f1..1508e3e356721655584db80c0eb024fcb57c51c8 100644 (file)
@@ -424,7 +424,7 @@ protected:
     int      trail_index      (Var x) const; // Index in the trail
     double   progressEstimate ()      const; // DELETE THIS ?? IT'S NOT VERY USEFUL ...
 public:
-    bool     withinBudget     ()      const;
+    bool     withinBudget     (uint64_t amount)      const;
 protected:
 
     // Static helpers:
index c7dae533ec24d9cbfd75bd89440f85011e543c2d..e6d965f8f174044c495dab75d90785d41ae7a666 100644 (file)
@@ -281,8 +281,8 @@ void PropEngine::interrupt() throw(ModalException) {
   Debug("prop") << "interrupt()" << endl;
 }
 
-void PropEngine::spendResource() throw (UnsafeInterruptException) {
-  d_resourceManager->spendResource();
+void PropEngine::spendResource(uint64_t ammount) throw (UnsafeInterruptException) {
+  d_resourceManager->spendResource(ammount);
 }
 
 bool PropEngine::properExplanation(TNode node, TNode expl) const {
index 2750319e6ff8203ec6d58c0a274dfc31749f1024..17ac394c369217c4d65d2e31c3476d52239b4c88 100644 (file)
@@ -228,7 +228,7 @@ public:
    * Informs the ResourceManager that a resource has been spent.  If out of
    * resources, can throw an UnsafeInterruptException exception.
    */
-  void spendResource() throw (UnsafeInterruptException);
+  void spendResource(uint64_t ammount) throw (UnsafeInterruptException);
 
   /**
    * For debugging.  Return true if "expl" is a well-formed
index 8effa818947666b96f833410b17d3abcc28ee176..79758a425fe2182466c100d711f51d13d2d1014a 100644 (file)
@@ -97,8 +97,8 @@ public:
      * Notify about a learnt clause.
      */
     virtual void notify(SatClause& clause) = 0;
-    virtual void spendResource() = 0;
-    virtual void safePoint() = 0;
+    virtual void spendResource(uint64_t ammount) = 0;
+    virtual void safePoint(uint64_t ammount) = 0;
     
   };/* class BVSatSolverInterface::Notify */
 
index 59e87dd339472ddda46deb504ee7370732eb9053..5b80b7596949bdd44bd80cf18de5d13705a47733 100644 (file)
@@ -103,7 +103,7 @@ TNode TheoryProxy::getNode(SatLiteral lit) {
 }
 
 void TheoryProxy::notifyRestart() {
-  d_propEngine->spendResource();
+  d_propEngine->spendResource(options::restartStep());
   d_theoryEngine->notifyRestart();
 
   static uint32_t lemmaCount = 0;
@@ -179,8 +179,8 @@ void TheoryProxy::logDecision(SatLiteral lit) {
 #endif /* CVC4_REPLAY */
 }
 
-void TheoryProxy::spendResource() {
-  d_theoryEngine->spendResource();
+void TheoryProxy::spendResource(uint64_t ammount) {
+  d_theoryEngine->spendResource(ammount);
 }
 
 bool TheoryProxy::isDecisionRelevant(SatVariable var) {
index 3565aa5015e6fca1faf89ebe39572fbd4210224b..d978edefd99b5a7aa38b6f19122059a3460210ea 100644 (file)
@@ -111,7 +111,7 @@ public:
 
   void logDecision(SatLiteral lit);
 
-  void spendResource();
+  void spendResource(uint64_t ammount);
 
   bool isDecisionEngineDone();
 
index b23d739433139cb45f68074ece5be6a4d18fc4e1..dbee33f5aea32104335c5936777d2b5fd684e0e2 100644 (file)
@@ -104,6 +104,44 @@ common-option hardLimit hard-limit --hard-limit bool :default false
 common-option cpuTime cpu-time --cpu-time bool :default false
  measures CPU time if set to true and wall time if false (default false)
 
+# Resource spending options for SPARK
+expert-option rewriteStep rewrite-step --rewrite-step uint64_t :default 1
+ ammount of resources spent for each rewrite step
+
+expert-option theoryCheckStep theory-check-step --theory-check-step uint64_t :default 1
+ ammount of resources spent for each theory check call
+
+expert-option decisionStep decision-step --decision-step uint64_t :default 1
+ ammount of getNext decision calls in the decision engine
+expert-option bitblastStep bitblast-step --bitblast-step uint64_t :default 1
+ ammount of resources spent for each bitblast step
+expert-option parseStep parse-step --parse-step uint64_t :default 1
+ ammount of resources spent for each command/expression parsing
+expert-option lemmaStep lemma-step --lemma-step uint64_t :default 1
+ ammount of resources spent when adding lemmas
+expert-option restartStep restart-step --restart-step uint64_t :default 1
+ ammount of resources spent for each theory restart
+expert-option cnfStep cnf-step --cnf-step uint64_t :default 1
+ ammount of resources spent for each call to cnf conversion
+expert-option preprocessStep preprocess-step --preprocess-step uint64_t :default 1
+ ammount of resources spent for each preprocessing step in SmtEngine
+expert-option quantifierStep quantifier-step --quantifier-step uint64_t :default 1
+ ammount of resources spent for quantifier instantiations
+expert-option satConflictStep sat-conflict-step --sat-conflict-step uint64_t :default 1
+ ammount of resources spent for each sat conflict (main sat solver)
+expert-option bvSatConflictStep bv-sat-conflict-step --bv-sat-conflict-step uint64_t :default 1
+ ammount of resources spent for each sat conflict (bitvectors)
 expert-option rewriteApplyToConst rewrite-apply-to-const --rewrite-apply-to-const bool :default false
  eliminate function applications, rewriting e.g. f(5) to a new symbol f_5
 
index bc594a47e80db7c07438c60271aff2ce5ee4c59a..c7c0bc71a854899772c4735cf3ba2a471b65ec0e 100644 (file)
@@ -492,8 +492,8 @@ public:
   }
 
   ResourceManager* getResourceManager() { return d_resourceManager; }
-  void spendResource() throw(UnsafeInterruptException) {
-    d_resourceManager->spendResource();
+  void spendResource(uint64_t ammount) throw(UnsafeInterruptException) {
+    d_resourceManager->spendResource(ammount);
   }
 
   void nmNotifyNewSort(TypeNode tn, uint32_t flags) {
@@ -1776,7 +1776,7 @@ Node SmtEnginePrivate::expandDefinitions(TNode n, hash_map<Node, Node, NodeHashF
   // or upward pass).
 
   do {
-    spendResource();
+    spendResource(options::preprocessStep());
     n = worklist.top().first;                      // n is the input / original
     Node node = worklist.top().second;             // node is the output / result
     bool childrenPushed = worklist.top().third;
@@ -1912,7 +1912,7 @@ Node SmtEnginePrivate::expandDefinitions(TNode n, hash_map<Node, Node, NodeHashF
 
 void SmtEnginePrivate::removeITEs() {
   d_smt.finalOptionsAreSet();
-  spendResource();
+  spendResource(options::preprocessStep());
   Trace("simplify") << "SmtEnginePrivate::removeITEs()" << endl;
 
   // Remove all of the ITE occurrences and normalize
@@ -1924,7 +1924,7 @@ void SmtEnginePrivate::removeITEs() {
 
 void SmtEnginePrivate::staticLearning() {
   d_smt.finalOptionsAreSet();
-  spendResource();
+  spendResource(options::preprocessStep());
 
   TimerStat::CodeTimer staticLearningTimer(d_smt.d_stats->d_staticLearningTime);
 
@@ -1957,7 +1957,7 @@ static void dumpAssertions(const char* key, const AssertionPipeline& assertionLi
 
 // returns false if it learns a conflict
 bool SmtEnginePrivate::nonClausalSimplify() {
-  spendResource();
+  spendResource(options::preprocessStep());
   d_smt.finalOptionsAreSet();
 
   if(options::unsatCores()) {
@@ -2286,7 +2286,7 @@ void SmtEnginePrivate::bvAbstraction() {
 
 void SmtEnginePrivate::bvToBool() {
   Trace("bv-to-bool") << "SmtEnginePrivate::bvToBool()" << endl;
-  spendResource();
+  spendResource(options::preprocessStep());
   std::vector<Node> new_assertions;
   d_smt.d_theoryEngine->ppBvToBool(d_assertions.ref(), new_assertions);
   for (unsigned i = 0; i < d_assertions.size(); ++ i) {
@@ -2297,13 +2297,13 @@ void SmtEnginePrivate::bvToBool() {
 bool SmtEnginePrivate::simpITE() {
   TimerStat::CodeTimer simpITETimer(d_smt.d_stats->d_simpITETime);
 
-  spendResource();
+  spendResource(options::preprocessStep());
 
   Trace("simplify") << "SmtEnginePrivate::simpITE()" << endl;
 
   unsigned numAssertionOnEntry = d_assertions.size();
   for (unsigned i = 0; i < d_assertions.size(); ++i) {
-    spendResource();
+    spendResource(options::preprocessStep());
     Node result = d_smt.d_theoryEngine->ppSimpITE(d_assertions[i]);
     d_assertions.replace(i, result);
     if(result.isConst() && !result.getConst<bool>()){
@@ -2350,7 +2350,7 @@ void SmtEnginePrivate::compressBeforeRealAssertions(size_t before){
 
 void SmtEnginePrivate::unconstrainedSimp() {
   TimerStat::CodeTimer unconstrainedSimpTimer(d_smt.d_stats->d_unconstrainedSimpTime);
-  spendResource();
+  spendResource(options::preprocessStep());
   Trace("simplify") << "SmtEnginePrivate::unconstrainedSimp()" << endl;
   d_smt.d_theoryEngine->ppUnconstrainedSimp(d_assertions.ref());
 }
@@ -2799,7 +2799,7 @@ void SmtEnginePrivate::doMiplibTrick() {
 // returns false if simplification led to "false"
 bool SmtEnginePrivate::simplifyAssertions()
   throw(TypeCheckingException, LogicException, UnsafeInterruptException) {
-  spendResource();
+  spendResource(options::preprocessStep());
   Assert(d_smt.d_pendingPops == 0);
   try {
     ScopeCounter depth(d_simplifyAssertionsDepth);
@@ -3042,7 +3042,7 @@ bool SmtEnginePrivate::checkForBadSkolems(TNode n, TNode skolem, hash_map<Node,
 Node SmtEnginePrivate::rewriteBooleanTerms(TNode n) {
   TimerStat::CodeTimer codeTimer(d_smt.d_stats->d_rewriteBooleanTermsTime);
 
-  spendResource();
+  spendResource(options::preprocessStep());
 
   if(d_booleanTermConverter == NULL) {
     // This needs to be initialized _after_ the whole SMT framework is in place, subscribed
@@ -3077,7 +3077,7 @@ Node SmtEnginePrivate::rewriteBooleanTerms(TNode n) {
 
 void SmtEnginePrivate::processAssertions() {
   TimerStat::CodeTimer paTimer(d_smt.d_stats->d_processAssertionsTime);
-  spendResource();
+  spendResource(options::preprocessStep());
   Assert(d_smt.d_fullyInited);
   Assert(d_smt.d_pendingPops == 0);
 
@@ -3199,7 +3199,7 @@ void SmtEnginePrivate::processAssertions() {
                         << "applying substitutions" << endl;
       for (unsigned i = 0; i < d_assertions.size(); ++ i) {
         Trace("simplify") << "applying to " << d_assertions[i] << endl;
-         spendResource();
+         spendResource(options::preprocessStep());
         d_assertions.replace(i, Rewriter::rewrite(d_topLevelSubstitutions.apply(d_assertions[i])));
         Trace("simplify") << "  got " << d_assertions[i] << endl;
       }
@@ -3759,7 +3759,7 @@ Expr SmtEngine::simplify(const Expr& ex) throw(TypeCheckingException, LogicExcep
 }
 
 Expr SmtEngine::expandDefinitions(const Expr& ex) throw(TypeCheckingException, LogicException, UnsafeInterruptException) {
-  d_private->spendResource();
+  d_private->spendResource(options::preprocessStep());
 
   Assert(ex.getExprManager() == d_exprManager);
   SmtScope smts(this);
index 7b5b40c8b58c137b7ffd53a3706bce7c0d11de2b..565c69514de163a482ccbe5e46cacac121d6d063 100644 (file)
@@ -18,6 +18,7 @@
 #include "theory/arith/theory_arith.h"
 #include "theory/arith/theory_arith_private.h"
 #include "theory/arith/infer_bounds.h"
+#include "smt/options.h"
 
 using namespace std;
 using namespace CVC4::kind;
@@ -70,6 +71,7 @@ void TheoryArith::ppStaticLearn(TNode n, NodeBuilder<>& learned) {
 }
 
 void TheoryArith::check(Effort effortLevel){
+  getOutputChannel().spendResource(options::theoryCheckStep());
   d_internal->check(effortLevel);
 }
 
index c770fb7ae640dd3c5afe4748a729d7e28c62462a..8bdf38ca3fa367f578d4db42076bc981edf5a984 100644 (file)
@@ -23,6 +23,7 @@
 #include "expr/command.h"
 #include "theory/theory_model.h"
 #include "theory/arrays/options.h"
+#include "smt/options.h"
 #include "smt/logic_exception.h"
 
 
@@ -1031,6 +1032,9 @@ void TheoryArrays::check(Effort e) {
   if (done() && !fullEffort(e)) {
     return;
   }
+  
+  getOutputChannel().spendResource(options::theoryCheckStep());
+
   TimerStat::CodeTimer checkTimer(d_checkTime);
 
   while (!done() && !d_conflict)
@@ -1209,7 +1213,7 @@ void TheoryArrays::checkModel(Effort e)
   int numrestarts = 0;
   while (true || numrestarts < 1 || fullEffort(e) || combination(e)) {
     ++numrestarts;
-    d_out->safePoint();
+    d_out->safePoint(1);
     int level = getSatContext()->getLevel();
     d_getModelValCache.clear();
     for (constraintIdx = 0; constraintIdx < d_modelConstraints.size(); ++constraintIdx) {
index d4d7bc04cb7edf3175b54b0ebb1107b9052396d5..4d953b03c0d37242985b7682c18574fa7ffa1764 100644 (file)
@@ -135,8 +135,8 @@ class TLazyBitblaster :  public TBitblaster<Node> {
     {}
     bool notify(prop::SatLiteral lit);
     void notify(prop::SatClause& clause);
-    void spendResource();
-    void safePoint();
+    void spendResource(uint64_t ammount);
+    void safePoint(uint64_t ammount);
   };
   
   TheoryBV *d_bv;
@@ -240,10 +240,10 @@ public:
   MinisatEmptyNotify() {}
   bool notify(prop::SatLiteral lit) { return true; }
   void notify(prop::SatClause& clause) { }
-  void spendResource() {
-    NodeManager::currentResourceManager()->spendResource();
+  void spendResource(uint64_t ammount) {
+    NodeManager::currentResourceManager()->spendResource(ammount);
   }
-  void safePoint() {}
+  void safePoint(uint64_t ammount) {}
 };
 
 
index 57a635c20dc85ab6f4ea683ba7e3d1368cc1186e..0c087ddb94cb38db20dfc2a815751d3f98e2b8c2 100644 (file)
@@ -67,7 +67,7 @@ bool EagerBitblastSolver::isInitialized() {
 }
 
 void EagerBitblastSolver::assertFormula(TNode formula) {
-  d_bv->spendResource();
+  d_bv->spendResource(1);
   Assert (isInitialized());
   Debug("bitvector-eager") << "EagerBitblastSolver::assertFormula "<< formula <<"\n"; 
   d_assertionSet.insert(formula);
index c86572ead5fc4fbb183e3acdc21006711f1160c7..7e3ed46c82ab6cf7b3f48a87a6459d125e80a3d9 100644 (file)
@@ -152,7 +152,7 @@ bool BitblastSolver::check(Theory::Effort e) {
 
   // We need to ensure we are fully propagated, so propagate now
   if (d_useSatPropagation) {
-    d_bv->spendResource();
+    d_bv->spendResource(1);
     bool ok = d_bitblaster->propagate();
     if (!ok) {
       std::vector<TNode> conflictAtoms;
index 9481b98943a90947cd72a6f58af33b846809b23d..13c31463bda1e35f22a52780fda3731754ff32a7 100644 (file)
@@ -21,6 +21,7 @@
 #include "theory/bv/slicer.h"
 #include "theory/theory_model.h"
 #include "theory/bv/options.h"
+#include "smt/options.h"
 
 using namespace std;
 using namespace CVC4;
@@ -167,7 +168,7 @@ bool CoreSolver::decomposeFact(TNode fact) {
 bool CoreSolver::check(Theory::Effort e) {
   Trace("bitvector::core") << "CoreSolver::check \n";
 
-  d_bv->spendResource();
+  d_bv->spendResource(options::theoryCheckStep());
 
   d_checkCalled = true; 
   Assert (!d_bv->inConflict());
index 660551fe2338c4cbbf657727d925446e0349958a..55dcbb03affd76b38d2334f13978100c612c01b5 100644 (file)
@@ -18,6 +18,7 @@
 #include "theory/bv/theory_bv.h"
 #include "theory/bv/theory_bv_utils.h"
 #include "theory/theory_model.h"
+#include "smt/options.h"
 
 using namespace std;
 using namespace CVC4;
@@ -29,7 +30,7 @@ using namespace CVC4::theory::bv::utils;
 bool InequalitySolver::check(Theory::Effort e) {
   Debug("bv-subtheory-inequality") << "InequalitySolveR::check("<< e <<")\n";
   ++(d_statistics.d_numCallstoCheck);
-  d_bv->spendResource();
+  d_bv->spendResource(options::theoryCheckStep());
 
   bool ok = true;
   while (!done() && ok) {
index 065d5d5ef556a88804ca82dc5d9e89d37edb9195..eca9f12ab34183d0eed2c5f133d65df84f9b007a 100644 (file)
@@ -103,7 +103,7 @@ void EagerBitblaster::bbTerm(TNode node, Bits& bits) {
     return;
   }
 
-  d_bv->spendResource();
+  d_bv->spendResource(options::bitblastStep());
   Debug("bitvector-bitblast") << "Bitblasting node " << node <<"\n";
 
   d_termBBStrategies[node.getKind()] (node, bits, this);
index 080f231438f00923d1d16a2a547e14338dc064f9..61472fd79bf8c65e0e9a0ae0e87ffa7ab0a23895 100644 (file)
@@ -170,7 +170,7 @@ void TLazyBitblaster::bbTerm(TNode node, Bits& bits) {
     return;
   }
 
-  d_bv->spendResource();
+  d_bv->spendResource(options::bitblastStep());
   Debug("bitvector-bitblast") << "Bitblasting node " << node <<"\n";
   ++d_statistics.d_numTerms;
 
@@ -356,12 +356,12 @@ void TLazyBitblaster::MinisatNotify::notify(prop::SatClause& clause) {
   }
 }
 
-void TLazyBitblaster::MinisatNotify::spendResource() {
-  d_bv->spendResource();
+void TLazyBitblaster::MinisatNotify::spendResource(uint64_t ammount) {
+  d_bv->spendResource(ammount);
 }
 
-void TLazyBitblaster::MinisatNotify::safePoint() {
-  d_bv->d_out->safePoint();
+void TLazyBitblaster::MinisatNotify::safePoint(uint64_t ammount) {
+  d_bv->d_out->safePoint(ammount);
 }
 
 
index 9dcd5ac6269538abbab4485a66aff25880578eb4..6f399cb7aa074cbd721adf1a4afab4cd64be7eba 100644 (file)
@@ -107,8 +107,8 @@ void TheoryBV::setMasterEqualityEngine(eq::EqualityEngine* eq) {
   }
 }
 
-void TheoryBV::spendResource() throw(UnsafeInterruptException) {
-  getOutputChannel().spendResource();
+void TheoryBV::spendResource(uint64_t ammount) throw(UnsafeInterruptException) {
+  getOutputChannel().spendResource(ammount);
 }
 
 TheoryBV::Statistics::Statistics():
index 11d8cb895a52066b1d1019163a20f8b4ad1dfb47..3317d1b010d2ac5ef9bb30f7e9ef81c909188140 100644 (file)
@@ -103,7 +103,7 @@ private:
 
   Statistics d_statistics;
 
-  void spendResource() throw(UnsafeInterruptException);
+  void spendResource(uint64_t ammount) throw(UnsafeInterruptException);
 
   /**
    * Return the uninterpreted function symbol corresponding to division-by-zero
index bef39f5360101e8fd8ea1ab760eda8efad256850..f340c994cc2c2e9a46425e8388dc56f1de6f1cbb 100644 (file)
@@ -86,7 +86,7 @@ public:
    * With safePoint(), the theory signals that it is at a safe point
    * and can be interrupted.
    */
-  virtual void safePoint() throw(Interrupted, UnsafeInterruptException, AssertionException) {
+  virtual void safePoint(uint64_t ammount) throw(Interrupted, UnsafeInterruptException, AssertionException) {
   }
 
   /**
@@ -213,7 +213,7 @@ public:
    * long-running operations, they cannot rely on resource() to break
    * out of infinite or intractable computations.
    */
-  virtual void spendResource() throw(UnsafeInterruptException) {}
+  virtual void spendResource(uint64_t ammount) throw(UnsafeInterruptException) {}
 
   /**
    * Handle user attribute.
index afc607470c82ad3200661e8de6617e9b54cff9ac..2177ebc32e091556d99c77e8354de20c2e323352 100644 (file)
@@ -767,7 +767,7 @@ bool QuantifiersEngine::addInstantiation( Node f, InstMatch& m, bool mkRep, bool
 
 bool QuantifiersEngine::addInstantiation( Node f, std::vector< Node >& terms, bool mkRep, bool modEq, bool modInst ) {
   // For resource-limiting (also does a time check).
-  getOutputChannel().safePoint();
+  getOutputChannel().safePoint(options::quantifierStep());
 
   Assert( terms.size()==f[0].getNumChildren() );
   Trace("inst-add-debug") << "Add instantiation: ";
index a940bcc3d5cff74e4a67b4b62190b3663ecb51c8..842df69c598cf50d40202d01b2d188dfd8b9826d 100644 (file)
@@ -116,7 +116,7 @@ Node Rewriter::rewriteTo(theory::TheoryId theoryId, Node node) {
 
     if (hasSmtEngine &&
                d_iterationCount % ResourceManager::getFrequencyCount() == 0) {
-      rm->spendResource();
+      rm->spendResource(options::rewriteStep());
       d_iterationCount = 0;
     }
 
index bbeec5125db1df8f2c72fa7a3e3f05beefaf02de..75dafb7f61a740df9ba690a3eeefa6238578f382 100644 (file)
@@ -1756,6 +1756,6 @@ std::pair<bool, Node> TheoryEngine::entailmentCheck(theory::TheoryOfMode mode, T
   return th->entailmentCheck(lit, params, seffects);
 }
 
-void TheoryEngine::spendResource() {
-  d_resourceManager->spendResource();
+void TheoryEngine::spendResource(uint64_t ammount) {
+  d_resourceManager->spendResource(ammount);
 }
index 8aedc65f07104b348623d4ad1a7cf14cfbf1f03f..bb4d4c16d7a967b8147aab868af12ff3f988ce55 100644 (file)
@@ -282,8 +282,8 @@ class TheoryEngine {
     {
     }
 
-      void safePoint() throw(theory::Interrupted, UnsafeInterruptException, AssertionException) {
-      spendResource();
+      void safePoint(uint64_t ammount) throw(theory::Interrupted, UnsafeInterruptException, AssertionException) {
+      spendResource(ammount);
       if (d_engine->d_interrupted) {
         throw theory::Interrupted();
       }
@@ -347,8 +347,8 @@ class TheoryEngine {
       d_engine->setIncomplete(d_theory);
     }
 
-    void spendResource() throw(UnsafeInterruptException) {
-      d_engine->spendResource();
+    void spendResource(uint64_t ammount) throw(UnsafeInterruptException) {
+      d_engine->spendResource(ammount);
     }
 
     void handleUserAttribute( const char* attr, theory::Theory* t ){
@@ -488,7 +488,7 @@ public:
   /**
    * "Spend" a resource during a search or preprocessing.
    */
-  void spendResource();
+  void spendResource(uint64_t ammount);
 
   /**
    * Adds a theory. Only one theory per TheoryId can be present, so if
index 46a717cc5c5208b98eb9f133be7698e10d739282..6fe92eb6e56a911103410fecc4caf27989d22f91 100644 (file)
@@ -69,7 +69,7 @@ public:
 
   ~TestOutputChannel() {}
 
-  void safePoint()  throw(Interrupted, AssertionException) {}
+  void safePoint(uint64_t ammount)  throw(Interrupted, AssertionException) {}
 
   void conflict(TNode n)
     throw(AssertionException, UnsafeInterruptException) {
index b00fdd6ee5dca274664a1f4d0c5d92b0e84f8d53..073399894915621cc94eea9fcb8e0ff2bde54d1a 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "theory/uf/theory_uf.h"
 #include "theory/uf/options.h"
+#include "smt/options.h"
 #include "theory/quantifiers/options.h"
 #include "theory/uf/theory_uf_strong_solver.h"
 #include "theory/theory_model.h"
@@ -92,7 +93,7 @@ void TheoryUF::check(Effort level) {
   if (done() && !fullEffort(level)) {
     return;
   }
-
+  getOutputChannel().spendResource(options::theoryCheckStep());
   TimerStat::CodeTimer checkTimer(d_checkTime);
 
   while (!done() && !d_conflict)
index 6d32120d978cd77fb18acdcaf5b4eab9699c6db0..37fea2c67f6082952fa1a8a1eb5d03daa7c1313d 100644 (file)
@@ -170,13 +170,13 @@ uint64_t ResourceManager::getTimeRemaining() const {
   return d_thisCallTimeBudget - time_passed;
 }
 
-void ResourceManager::spendResource() throw (UnsafeInterruptException) {
+void ResourceManager::spendResource(uint64_t ammount) throw (UnsafeInterruptException) {
   ++d_spendResourceCalls;
-  ++d_cumulativeResourceUsed;
+  d_cumulativeResourceUsed += ammount;
   if (!d_on) return;
 
   Debug("limit") << "ResourceManager::spendResource()" << std::endl;
-  ++d_thisCallResourceUsed;
+  d_thisCallResourceUsed += ammount;
   if(out()) {
     Trace("limit") << "ResourceManager::spendResource: interrupt!" << std::endl;
        Trace("limit") << "                 on call " << d_spendResourceCalls << std::endl;
index d1ec0456a0b5f666a12f8d7ae5665aef0738f721..9c2812f0f13363d5bfdd043d0b813dda27c6a879 100644 (file)
@@ -128,7 +128,7 @@ public:
     return d_thisCallResourceBudget;
   }
 
-  void spendResource() throw(UnsafeInterruptException);
+  void spendResource(uint64_t ammount) throw(UnsafeInterruptException);
 
   void setHardLimit(bool value);
   void setResourceLimit(uint64_t units, bool cumulative = false);