GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/decision/decision_engine_old.cpp Lines: 31 39 79.5 %
Date: 2021-05-21 Branches: 51 160 31.9 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Kshitij Bansal, Aina Niemetz, Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Old implementation of the decision engine
14
 */
15
#include "decision/decision_engine_old.h"
16
17
#include "decision/decision_attributes.h"
18
#include "decision/justification_heuristic.h"
19
#include "expr/node.h"
20
#include "options/decision_options.h"
21
#include "options/smt_options.h"
22
#include "util/resource_manager.h"
23
24
using namespace std;
25
26
namespace cvc5 {
27
28
8988
DecisionEngineOld::DecisionEngineOld(context::Context* sc,
29
8988
                                     context::UserContext* uc)
30
    : d_cnfStream(nullptr),
31
      d_satSolver(nullptr),
32
      d_satContext(sc),
33
      d_userContext(uc),
34
      d_result(sc, SAT_VALUE_UNKNOWN),
35
      d_engineState(0),
36
8988
      d_enabledITEStrategy(nullptr)
37
{
38
8988
  Trace("decision") << "Creating decision engine" << std::endl;
39
8988
  Assert(d_engineState == 0);
40
8988
  d_engineState = 1;
41
42
8988
  Trace("decision-init") << "DecisionEngineOld::init()" << std::endl;
43
17976
  Trace("decision-init") << " * options->decisionMode: "
44
61167
                         << options::decisionMode() << std::endl;
45
17976
  Trace("decision-init") << " * options->decisionStopOnly: "
46
1968477
                         << options::decisionStopOnly() << std::endl;
47
48
8988
  if (options::decisionMode() == options::DecisionMode::JUSTIFICATION)
49
  {
50
13832
    d_enabledITEStrategy.reset(new decision::JustificationHeuristic(
51
6916
        this, d_userContext, d_satContext));
52
  }
53
8988
}
54
55
void DecisionEngineOld::shutdown()
56
{
57
  Trace("decision") << "Shutting down decision engine" << std::endl;
58
59
  Assert(d_engineState == 1);
60
  d_engineState = 2;
61
  d_enabledITEStrategy.reset(nullptr);
62
}
63
64
1941586
SatLiteral DecisionEngineOld::getNext(bool& stopSearch)
65
{
66
1941586
  Assert(d_cnfStream != nullptr)
67
      << "Forgot to set cnfStream for decision engine?";
68
1941586
  Assert(d_satSolver != nullptr)
69
      << "Forgot to set satSolver for decision engine?";
70
71
1941586
  return d_enabledITEStrategy == nullptr
72
             ? undefSatLiteral
73
1941586
             : d_enabledITEStrategy->getNext(stopSearch);
74
}
75
76
390957
void DecisionEngineOld::addAssertion(TNode assertion)
77
{
78
  // new assertions, reset whatever result we knew
79
390957
  d_result = SAT_VALUE_UNKNOWN;
80
390957
  if (d_enabledITEStrategy != nullptr)
81
  {
82
252598
    d_enabledITEStrategy->addAssertion(assertion);
83
  }
84
390957
}
85
86
28511
void DecisionEngineOld::addSkolemDefinition(TNode lem, TNode skolem)
87
{
88
  // new assertions, reset whatever result we knew
89
28511
  d_result = SAT_VALUE_UNKNOWN;
90
28511
  if (d_enabledITEStrategy != nullptr)
91
  {
92
21144
    d_enabledITEStrategy->addSkolemDefinition(lem, skolem);
93
  }
94
28511
}
95
96
309976769
}  // namespace cvc5