summaryrefslogtreecommitdiff
path: root/src/decision/decision_engine.h
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-05-04 19:25:25 -0500
committerGitHub <noreply@github.com>2021-05-04 19:25:25 -0500
commit8a7c43f82b17a444c2f9518bc27f4ea8afe21201 (patch)
tree12f66f7bde98f4855b06038d813b49829ea82509 /src/decision/decision_engine.h
parent67c43a7294442a7c660a26faf230cd983b21117d (diff)
Move current decision engine to decision engine old (#6466)
The decision engine is the class that contains strategies for doing e.g. justification heuristic. The current implementation is hardcoded for the old implementation of justification heuristic. Since both implementations will be maintained in the short term, this splits the parts of DecisionEngine that are specific to the old implementation to a class DecisionEngineOld. It refactors the interface of DecisionEngine in a way that is compatible with both implementations.
Diffstat (limited to 'src/decision/decision_engine.h')
-rw-r--r--src/decision/decision_engine.h136
1 files changed, 28 insertions, 108 deletions
diff --git a/src/decision/decision_engine.h b/src/decision/decision_engine.h
index c10fe2bb9..de88d656e 100644
--- a/src/decision/decision_engine.h
+++ b/src/decision/decision_engine.h
@@ -18,110 +18,41 @@
#ifndef CVC5__DECISION__DECISION_ENGINE_H
#define CVC5__DECISION__DECISION_ENGINE_H
-#include "base/output.h"
-#include "context/cdo.h"
-#include "decision/decision_strategy.h"
#include "expr/node.h"
#include "prop/cnf_stream.h"
#include "prop/sat_solver.h"
#include "prop/sat_solver_types.h"
-#include "util/result.h"
-
-using namespace cvc5::prop;
-using namespace cvc5::decision;
namespace cvc5 {
-namespace decision {
-
-class DecisionEngine {
-
- // PropEngine* d_propEngine;
- CnfStream* d_cnfStream;
- CDCLTSatSolverInterface* d_satSolver;
-
- context::Context* d_satContext;
- context::UserContext* d_userContext;
- // Does decision engine know the answer?
- context::CDO<SatValue> d_result;
+namespace prop {
+class SkolemDefManager;
+}
- // Disable creating decision engine without required parameters
- DecisionEngine();
+class DecisionEngineOld;
- // init/shutdown state
- unsigned d_engineState; // 0=pre-init; 1=init,pre-shutdown; 2=shutdown
- /** Pointer to resource manager for associated SmtEngine */
- ResourceManager* d_resourceManager;
+namespace decision {
+class DecisionEngine
+{
public:
- // Necessary functions
-
/** Constructor */
DecisionEngine(context::Context* sc,
context::UserContext* uc,
+ prop::SkolemDefManager* skdm,
ResourceManager* rm);
- /** Destructor, currently does nothing */
- ~DecisionEngine() {
- Trace("decision") << "Destroying decision engine" << std::endl;
- }
-
- void setSatSolver(CDCLTSatSolverInterface* ss)
- {
- // setPropEngine should not be called more than once
- Assert(d_satSolver == NULL);
- Assert(ss != NULL);
- d_satSolver = ss;
- }
-
- void setCnfStream(CnfStream* cs) {
- // setPropEngine should not be called more than once
- Assert(d_cnfStream == NULL);
- Assert(cs != NULL);
- d_cnfStream = cs;
- }
-
- /* Enables decision strategy based on options. */
- void init();
+ /** Finish initialize */
+ void finishInit(prop::CDCLTSatSolverInterface* ss, prop::CnfStream* cs);
- /**
- * This is called by SmtEngine, at shutdown time, just before
- * destruction. It is important because there are destruction
- * ordering issues between some parts of the system.
- */
- void shutdown();
-
- // Interface for External World to use our services
+ /** Presolve, called at the beginning of each check-sat call */
+ void presolve();
/** Gets the next decision based on strategies that are enabled */
- SatLiteral getNext(bool& stopSearch);
+ prop::SatLiteral getNext(bool& stopSearch);
/** Is the DecisionEngine in a state where it has solved everything? */
- bool isDone() {
- Trace("decision") << "DecisionEngine::isDone() returning "
- << (d_result != SAT_VALUE_UNKNOWN)
- << (d_result != SAT_VALUE_UNKNOWN ? "true" : "false")
- << std::endl;
- return (d_result != SAT_VALUE_UNKNOWN);
- }
-
- /** */
- Result getResult() {
- switch(d_result.get()) {
- case SAT_VALUE_TRUE: return Result(Result::SAT);
- case SAT_VALUE_FALSE: return Result(Result::UNSAT);
- case SAT_VALUE_UNKNOWN: return Result(Result::SAT_UNKNOWN, Result::UNKNOWN_REASON);
- default: Assert(false) << "d_result is garbage";
- }
- return Result();
- }
-
- /** */
- void setResult(SatValue val) {
- d_result = val;
- }
-
- // External World helping us help the Strategies
+ bool isDone();
/**
* Notify this class that assertion is an (input) assertion, not corresponding
@@ -129,38 +60,27 @@ class DecisionEngine {
*/
void addAssertion(TNode assertion);
/**
+ * TODO: remove this interface
* Notify this class that lem is the skolem definition for skolem, which is
* a part of the current assertions.
*/
void addSkolemDefinition(TNode lem, TNode skolem);
-
- // Interface for Strategies to use stuff stored in Decision Engine
- // (which was possibly requested by them on initialization)
-
- // Interface for Strategies to get information about External World
-
- bool hasSatLiteral(TNode n) {
- return d_cnfStream->hasLiteral(n);
- }
- SatLiteral getSatLiteral(TNode n) {
- return d_cnfStream->getLiteral(n);
- }
- SatValue getSatValue(SatLiteral l) {
- return d_satSolver->value(l);
- }
- SatValue getSatValue(TNode n) {
- return getSatValue(getSatLiteral(n));
- }
- Node getNode(SatLiteral l) {
- return d_cnfStream->getNode(l);
- }
+ /**
+ * Notify this class that the literal n has been asserted, possibly
+ * propagated by the SAT solver.
+ */
+ void notifyAsserted(TNode n);
private:
- /** The ITE decision strategy we have allocated */
- std::unique_ptr<ITEDecisionStrategy> d_enabledITEStrategy;
-};/* DecisionEngine class */
+ /** The old implementation */
+ std::unique_ptr<DecisionEngineOld> d_decEngineOld;
+ /** Pointer to resource manager for associated SmtEngine */
+ ResourceManager* d_resourceManager;
+ /** using old implementation? */
+ bool d_useOld;
+};
-}
+} // namespace decision
} // namespace cvc5
#endif /* CVC5__DECISION__DECISION_ENGINE_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback