summaryrefslogtreecommitdiff
path: root/src/smt/options_manager.cpp
blob: f449e79cb1f7b664e122e00ffcf12e3b95dfa5c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*********************                                                        */
/*! \file options_manager.cpp
 ** \verbatim
 ** Top contributors (to current version):
 **   Andrew Reynolds, Aina Niemetz
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
 ** in the top-level source directory and their institutional affiliations.
 ** All rights reserved.  See the file COPYING in the top-level source
 ** directory for licensing information.\endverbatim
 **
 ** \brief Module for managing options of an SmtEngine.
 **/

#include "smt/options_manager.h"

#include "base/output.h"
#include "expr/expr_iomanip.h"
#include "options/base_options.h"
#include "options/expr_options.h"
#include "options/smt_options.h"
#include "smt/command.h"
#include "smt/dump.h"
#include "smt/set_defaults.h"
#include "util/resource_manager.h"

namespace CVC4 {
namespace smt {

OptionsManager::OptionsManager(Options* opts, ResourceManager* rm)
    : d_options(opts), d_resourceManager(rm)
{
  // set options that must take effect immediately
  if (opts->wasSetByUser(options::defaultExprDepth))
  {
    notifySetOption(options::defaultExprDepth.getName());
  }
  if (opts->wasSetByUser(options::defaultDagThresh))
  {
    notifySetOption(options::defaultDagThresh.getName());
  }
  if (opts->wasSetByUser(options::dumpModeString))
  {
    notifySetOption(options::dumpModeString.getName());
  }
  if (opts->wasSetByUser(options::printSuccess))
  {
    notifySetOption(options::printSuccess.getName());
  }
  if (opts->wasSetByUser(options::diagnosticChannelName))
  {
    notifySetOption(options::diagnosticChannelName.getName());
  }
  if (opts->wasSetByUser(options::regularChannelName))
  {
    notifySetOption(options::regularChannelName.getName());
  }
  if (opts->wasSetByUser(options::dumpToFileName))
  {
    notifySetOption(options::dumpToFileName.getName());
  }
  // set this as a listener to be notified of options changes from now on
  opts->setListener(this);
}

OptionsManager::~OptionsManager() {}

void OptionsManager::notifySetOption(const std::string& key)
{
  Trace("smt") << "SmtEnginePrivate::notifySetOption(" << key << ")"
               << std::endl;
  if (key == options::defaultExprDepth.getName())
  {
    int depth = (*d_options)[options::defaultExprDepth];
    Debug.getStream() << expr::ExprSetDepth(depth);
    Trace.getStream() << expr::ExprSetDepth(depth);
    Notice.getStream() << expr::ExprSetDepth(depth);
    Chat.getStream() << expr::ExprSetDepth(depth);
    CVC4Message.getStream() << expr::ExprSetDepth(depth);
    Warning.getStream() << expr::ExprSetDepth(depth);
    // intentionally exclude Dump stream from this list
  }
  else if (key == options::defaultDagThresh.getName())
  {
    int dag = (*d_options)[options::defaultDagThresh];
    Debug.getStream() << expr::ExprDag(dag);
    Trace.getStream() << expr::ExprDag(dag);
    Notice.getStream() << expr::ExprDag(dag);
    Chat.getStream() << expr::ExprDag(dag);
    CVC4Message.getStream() << expr::ExprDag(dag);
    Warning.getStream() << expr::ExprDag(dag);
    Dump.getStream() << expr::ExprDag(dag);
  }
  else if (key == options::dumpModeString.getName())
  {
    const std::string& value = (*d_options)[options::dumpModeString];
    Dump.setDumpFromString(value);
  }
  else if (key == options::printSuccess.getName())
  {
    bool value = (*d_options)[options::printSuccess];
    Debug.getStream() << Command::printsuccess(value);
    Trace.getStream() << Command::printsuccess(value);
    Notice.getStream() << Command::printsuccess(value);
    Chat.getStream() << Command::printsuccess(value);
    CVC4Message.getStream() << Command::printsuccess(value);
    Warning.getStream() << Command::printsuccess(value);
    *options::out() << Command::printsuccess(value);
  }
  else if (key == options::regularChannelName.getName())
  {
    d_managedRegularChannel.set(options::regularChannelName());
  }
  else if (key == options::diagnosticChannelName.getName())
  {
    d_managedDiagnosticChannel.set(options::diagnosticChannelName());
  }
  else if (key == options::dumpToFileName.getName())
  {
    d_managedDumpChannel.set(options::dumpToFileName());
  }
  // otherwise, no action is necessary
}

void OptionsManager::finishInit(LogicInfo& logic, bool isInternalSubsolver)
{
  // set up the timeouts and resource limits
  if ((*d_options)[options::perCallResourceLimit] != 0)
  {
    d_resourceManager->setResourceLimit(options::perCallResourceLimit(), false);
  }
  if ((*d_options)[options::cumulativeResourceLimit] != 0)
  {
    d_resourceManager->setResourceLimit(options::cumulativeResourceLimit(),
                                        true);
  }
  if ((*d_options)[options::perCallMillisecondLimit] != 0)
  {
    d_resourceManager->setTimeLimit(options::perCallMillisecondLimit());
  }
  // ensure that our heuristics are properly set up
  setDefaults(logic, isInternalSubsolver);
}

}  // namespace smt
}  // namespace CVC4
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback