GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/decision/decision_engine_old.cpp Lines: 31 39 79.5 %
Date: 2021-05-22 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
9494
DecisionEngineOld::DecisionEngineOld(context::Context* sc,
29
9494
                                     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
9494
      d_enabledITEStrategy(nullptr)
37
{
38
9494
  Trace("decision") << "Creating decision engine" << std::endl;
39
9494
  Assert(d_engineState == 0);
40
9494
  d_engineState = 1;
41
42
9494
  Trace("decision-init") << "DecisionEngineOld::init()" << std::endl;
43
18988
  Trace("decision-init") << " * options->decisionMode: "
44
64268
                         << options::decisionMode() << std::endl;
45
18988
  Trace("decision-init") << " * options->decisionStopOnly: "
46
1990955
                         << options::decisionStopOnly() << std::endl;
47
48
9494
  if (options::decisionMode() == options::DecisionMode::JUSTIFICATION)
49
  {
50
14298
    d_enabledITEStrategy.reset(new decision::JustificationHeuristic(
51
7149
        this, d_userContext, d_satContext));
52
  }
53
9494
}
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
1962548
SatLiteral DecisionEngineOld::getNext(bool& stopSearch)
65
{
66
1962548
  Assert(d_cnfStream != nullptr)
67
      << "Forgot to set cnfStream for decision engine?";
68
1962548
  Assert(d_satSolver != nullptr)
69
      << "Forgot to set satSolver for decision engine?";
70
71
1962548
  return d_enabledITEStrategy == nullptr
72
             ? undefSatLiteral
73
1962548
             : d_enabledITEStrategy->getNext(stopSearch);
74
}
75
76
403559
void DecisionEngineOld::addAssertion(TNode assertion)
77
{
78
  // new assertions, reset whatever result we knew
79
403559
  d_result = SAT_VALUE_UNKNOWN;
80
403559
  if (d_enabledITEStrategy != nullptr)
81
  {
82
261756
    d_enabledITEStrategy->addAssertion(assertion);
83
  }
84
403559
}
85
86
30870
void DecisionEngineOld::addSkolemDefinition(TNode lem, TNode skolem)
87
{
88
  // new assertions, reset whatever result we knew
89
30870
  d_result = SAT_VALUE_UNKNOWN;
90
30870
  if (d_enabledITEStrategy != nullptr)
91
  {
92
23206
    d_enabledITEStrategy->addSkolemDefinition(lem, skolem);
93
  }
94
30870
}
95
96
317542230
}  // namespace cvc5