1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Aina Niemetz |
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 |
|
* Module for managing options of an SmtEngine. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "smt/options_manager.h" |
17 |
|
|
18 |
|
#include "base/output.h" |
19 |
|
#include "expr/expr_iomanip.h" |
20 |
|
#include "options/base_options.h" |
21 |
|
#include "options/expr_options.h" |
22 |
|
#include "options/smt_options.h" |
23 |
|
#include "smt/command.h" |
24 |
|
#include "smt/dump.h" |
25 |
|
#include "smt/set_defaults.h" |
26 |
|
#include "util/resource_manager.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace smt { |
30 |
|
|
31 |
10094 |
OptionsManager::OptionsManager(Options* opts) : d_options(opts) |
32 |
|
{ |
33 |
|
// set options that must take effect immediately |
34 |
74122 |
if (opts->wasSetByUser(options::defaultExprDepth)) |
35 |
|
{ |
36 |
|
notifySetOption(options::expr::defaultExprDepth__name); |
37 |
|
} |
38 |
31488 |
if (opts->wasSetByUser(options::defaultDagThresh)) |
39 |
|
{ |
40 |
17 |
notifySetOption(options::expr::defaultDagThresh__name); |
41 |
|
} |
42 |
20192 |
if (opts->wasSetByUser(options::dumpModeString)) |
43 |
|
{ |
44 |
4 |
notifySetOption(options::smt::dumpModeString__name); |
45 |
|
} |
46 |
20249 |
if (opts->wasSetByUser(options::printSuccess)) |
47 |
|
{ |
48 |
9 |
notifySetOption(options::base::printSuccess__name); |
49 |
|
} |
50 |
10092 |
if (opts->wasSetByUser(options::diagnosticChannelName)) |
51 |
|
{ |
52 |
|
notifySetOption(options::smt::diagnosticChannelName__name); |
53 |
|
} |
54 |
10092 |
if (opts->wasSetByUser(options::regularChannelName)) |
55 |
|
{ |
56 |
|
notifySetOption(options::smt::regularChannelName__name); |
57 |
|
} |
58 |
10092 |
if (opts->wasSetByUser(options::dumpToFileName)) |
59 |
|
{ |
60 |
|
notifySetOption(options::smt::dumpToFileName__name); |
61 |
|
} |
62 |
|
// set this as a listener to be notified of options changes from now on |
63 |
10092 |
opts->setListener(this); |
64 |
10092 |
} |
65 |
|
|
66 |
20184 |
OptionsManager::~OptionsManager() {} |
67 |
|
|
68 |
9304 |
void OptionsManager::notifySetOption(const std::string& key) |
69 |
|
{ |
70 |
18608 |
Trace("smt") << "SmtEnginePrivate::notifySetOption(" << key << ")" |
71 |
9304 |
<< std::endl; |
72 |
9304 |
if (key == options::expr::defaultExprDepth__name) |
73 |
|
{ |
74 |
|
int depth = (*d_options)[options::defaultExprDepth]; |
75 |
|
Debug.getStream() << expr::ExprSetDepth(depth); |
76 |
|
Trace.getStream() << expr::ExprSetDepth(depth); |
77 |
|
Notice.getStream() << expr::ExprSetDepth(depth); |
78 |
|
Chat.getStream() << expr::ExprSetDepth(depth); |
79 |
|
CVC5Message.getStream() << expr::ExprSetDepth(depth); |
80 |
|
Warning.getStream() << expr::ExprSetDepth(depth); |
81 |
|
// intentionally exclude Dump stream from this list |
82 |
|
} |
83 |
9304 |
else if (key == options::expr::defaultDagThresh__name) |
84 |
|
{ |
85 |
18 |
int dag = (*d_options)[options::defaultDagThresh]; |
86 |
18 |
Debug.getStream() << expr::ExprDag(dag); |
87 |
18 |
Trace.getStream() << expr::ExprDag(dag); |
88 |
18 |
Notice.getStream() << expr::ExprDag(dag); |
89 |
18 |
Chat.getStream() << expr::ExprDag(dag); |
90 |
18 |
CVC5Message.getStream() << expr::ExprDag(dag); |
91 |
18 |
Warning.getStream() << expr::ExprDag(dag); |
92 |
18 |
Dump.getStream() << expr::ExprDag(dag); |
93 |
|
} |
94 |
9286 |
else if (key == options::smt::dumpModeString__name) |
95 |
|
{ |
96 |
3 |
const std::string& value = (*d_options)[options::dumpModeString]; |
97 |
3 |
Dump.setDumpFromString(value); |
98 |
|
} |
99 |
9283 |
else if (key == options::base::printSuccess__name) |
100 |
|
{ |
101 |
36 |
bool value = (*d_options)[options::printSuccess]; |
102 |
36 |
Debug.getStream() << Command::printsuccess(value); |
103 |
36 |
Trace.getStream() << Command::printsuccess(value); |
104 |
36 |
Notice.getStream() << Command::printsuccess(value); |
105 |
36 |
Chat.getStream() << Command::printsuccess(value); |
106 |
36 |
CVC5Message.getStream() << Command::printsuccess(value); |
107 |
36 |
Warning.getStream() << Command::printsuccess(value); |
108 |
319997 |
*options::out() << Command::printsuccess(value); |
109 |
|
} |
110 |
9247 |
else if (key == options::smt::regularChannelName__name) |
111 |
|
{ |
112 |
|
d_managedRegularChannel.set(options::regularChannelName()); |
113 |
|
} |
114 |
9247 |
else if (key == options::smt::diagnosticChannelName__name) |
115 |
|
{ |
116 |
|
d_managedDiagnosticChannel.set(options::diagnosticChannelName()); |
117 |
|
} |
118 |
9247 |
else if (key == options::smt::dumpToFileName__name) |
119 |
|
{ |
120 |
|
d_managedDumpChannel.set(options::dumpToFileName()); |
121 |
|
} |
122 |
|
// otherwise, no action is necessary |
123 |
9303 |
} |
124 |
|
|
125 |
9460 |
void OptionsManager::finishInit(LogicInfo& logic, bool isInternalSubsolver) |
126 |
|
{ |
127 |
|
// ensure that our heuristics are properly set up |
128 |
9460 |
setDefaults(logic, isInternalSubsolver); |
129 |
9459 |
} |
130 |
|
|
131 |
|
} // namespace smt |
132 |
453832 |
} // namespace cvc5 |