diff options
author | ajreynol <andrew.j.reynolds@gmail.com> | 2015-09-28 16:18:32 +0200 |
---|---|---|
committer | ajreynol <andrew.j.reynolds@gmail.com> | 2015-09-28 16:18:32 +0200 |
commit | ef7b7bba7bc9b207d5a2198518f21b13490caa32 (patch) | |
tree | 43867e7dcab54bd77bc07167e096cc518b0be035 /src | |
parent | 187e5d57adeda59c8899321c882db1d5b9a6f2ba (diff) |
Improve quantifiers engine wrt incremental presolve. Add regressions.
Diffstat (limited to 'src')
-rw-r--r-- | src/theory/quantifiers/term_database.cpp | 12 | ||||
-rw-r--r-- | src/theory/quantifiers_engine.cpp | 32 | ||||
-rw-r--r-- | src/theory/quantifiers_engine.h | 14 |
3 files changed, 37 insertions, 21 deletions
diff --git a/src/theory/quantifiers/term_database.cpp b/src/theory/quantifiers/term_database.cpp index d6f8b3af7..366c7ce07 100644 --- a/src/theory/quantifiers/term_database.cpp +++ b/src/theory/quantifiers/term_database.cpp @@ -420,11 +420,13 @@ void TermDb::setHasTerm( Node n ) { } void TermDb::presolve() { - //reset the caches that are SAT context-independent - d_op_map.clear(); - d_type_map.clear(); - d_processed.clear(); - d_iclosure_processed.clear(); + if( options::incrementalSolving() ){ + //reset the caches that are SAT context-independent + d_op_map.clear(); + d_type_map.clear(); + d_processed.clear(); + d_iclosure_processed.clear(); + } } void TermDb::reset( Theory::Effort effort ){ diff --git a/src/theory/quantifiers_engine.cpp b/src/theory/quantifiers_engine.cpp index e5b5c4080..f1c47a21a 100644 --- a/src/theory/quantifiers_engine.cpp +++ b/src/theory/quantifiers_engine.cpp @@ -83,7 +83,11 @@ QuantifiersEngine::QuantifiersEngine(context::Context* c, context::UserContext* d_te( te ), d_lemmas_produced_c(u), d_skolemized(u), -d_presolve(u, true){ +d_presolve(u, true), +d_presolve_in(u), +d_presolve_cache(u), +d_presolve_cache_wq(u), +d_presolve_cache_wic(u){ d_eq_query = new EqualityQueryQuantifiersEngine( this ); d_term_db = new quantifiers::TermDb( c, u, this ); d_tr_trie = new inst::TriggerTrie; @@ -300,13 +304,12 @@ void QuantifiersEngine::presolve() { } d_term_db->presolve(); d_presolve = false; - //clear presolve cache - for( unsigned i=0; i<d_presolve_cache.size(); i++ ){ - addTermToDatabase( d_presolve_cache[i], d_presolve_cache_wq[i], d_presolve_cache_wic[i] ); + //add all terms to database + if( options::incrementalSolving() ){ + for( unsigned i=0; i<d_presolve_cache.size(); i++ ){ + addTermToDatabase( d_presolve_cache[i], d_presolve_cache_wq[i], d_presolve_cache_wic[i] ); + } } - d_presolve_cache.clear(); - d_presolve_cache_wq.clear(); - d_presolve_cache_wic.clear(); } void QuantifiersEngine::check( Theory::Effort e ){ @@ -627,11 +630,16 @@ quantifiers::TermDbSygus* QuantifiersEngine::getTermDatabaseSygus() { } void QuantifiersEngine::addTermToDatabase( Node n, bool withinQuant, bool withinInstClosure ){ - if( d_presolve ){ - d_presolve_cache.push_back( n ); - d_presolve_cache_wq.push_back( withinQuant ); - d_presolve_cache_wic.push_back( withinInstClosure ); - }else{ + if( options::incrementalSolving() ){ + if( d_presolve_in.find( n )==d_presolve_in.end() ){ + d_presolve_in.insert( n ); + d_presolve_cache.push_back( n ); + d_presolve_cache_wq.push_back( withinQuant ); + d_presolve_cache_wic.push_back( withinInstClosure ); + } + } + //only wait if we are doing incremental solving + if( !d_presolve || !options::incrementalSolving() ){ std::set< Node > added; getTermDatabase()->addTerm( n, added, withinQuant, withinInstClosure ); //maybe have triggered instantiations if we are doing eager instantiation diff --git a/src/theory/quantifiers_engine.h b/src/theory/quantifiers_engine.h index 4e3bba501..30c4dabdf 100644 --- a/src/theory/quantifiers_engine.h +++ b/src/theory/quantifiers_engine.h @@ -29,6 +29,8 @@ #include <ext/hash_set> #include <iostream> #include <map> +#include "context/cdchunk_list.h" +#include "context/cdhashset.h" namespace CVC4 { @@ -113,8 +115,11 @@ class QuantifiersEngine { friend class quantifiers::RewriteEngine; friend class quantifiers::QuantConflictFind; friend class inst::InstMatch; -private: typedef context::CDHashMap< Node, bool, NodeHashFunction > BoolMap; + typedef context::CDChunkList<Node> NodeList; + typedef context::CDChunkList<bool> BoolList; + typedef context::CDHashSet<Node, NodeHashFunction> NodeSet; +private: /** reference to theory engine object */ TheoryEngine* d_te; /** vector of modules for quantifiers */ @@ -197,9 +202,10 @@ private: /** has presolve been called */ context::CDO< bool > d_presolve; /** presolve cache */ - std::vector< Node > d_presolve_cache; - std::vector< bool > d_presolve_cache_wq; - std::vector< bool > d_presolve_cache_wic; + NodeSet d_presolve_in; + NodeList d_presolve_cache; + BoolList d_presolve_cache_wq; + BoolList d_presolve_cache_wic; private: KEEP_STATISTIC(TimerStat, d_time, "theory::QuantifiersEngine::time"); public: |