5 #include "../ResourceLimitation.h"
55 this->instructionQueue.push(bind);
61 while (!this->instructionQueue.empty()) {
62 this->instructionQueue.front()();
63 this->instructionQueue.pop();
81 const auto&
get_info(
const std::string& key)
const {
82 return infos.find(key)->second;
85 T
option(
const std::string& key)
const {
86 return this->options.
get<T>(key);
89 if (!this->options.
has<
bool>(
"print-instruction"))
return false;
90 return this->options.
get<
bool>(
"print-instruction");
95 std::map<std::string, std::ofstream>
streams;
97 void setStream(
const std::string& s, std::ostream& os) {
98 if (s ==
"stdout") os.rdbuf(std::cout.rdbuf());
99 else if (s ==
"stderr") os.rdbuf(std::cerr.rdbuf());
100 else if (s ==
"stdlog") os.rdbuf(std::clog.rdbuf());
102 if (this->streams.count(s) == 0) {
103 this->streams[s].open(s);
105 os.rdbuf(this->streams[s].rdbuf());
112 smtrat::resource::Limiter::getInstance().initialize();
115 for (
auto& it: this->streams) it.second.close();
144 virtual void declareSort(
const std::string&,
const unsigned&) = 0;
145 virtual void defineSort(
const std::string&,
const std::vector<std::string>&,
const carl::Sort&) = 0;
146 virtual void echo(
const std::string& s) {
149 virtual void qe() = 0;
155 if (this->infos.count(key) > 0)
regular() <<
"(:" << key <<
" " << this->infos[key] <<
")" << std::endl;
156 else error() <<
"no info set for :" << key;
161 if (this->options.count(key) > 0)
regular() <<
"(:" << key <<
" " << this->options[key] <<
")" << std::endl;
162 else error() <<
"no option set for :" << key;
166 virtual void getValue(
const std::vector<carl::Variable>&) = 0;
168 virtual void pop(std::size_t) = 0;
169 virtual void push(std::size_t) = 0;
172 this->options.clear();
176 if (this->infos.count(attr.
key) > 0)
warn() <<
"overwriting info for :" << attr.
key;
177 if (attr.
key ==
"name" || attr.
key ==
"authors" || attr.
key ==
"version")
error() <<
"The info :" << attr.
key <<
" is read-only.";
178 else this->infos[attr.
key] = attr.
value;
182 std::string key =
option.key;
183 if (this->options.count(key) > 0)
warn() <<
"overwriting option for :" << key;
184 this->options[key] =
option.value;
185 if (key ==
"diagnostic-output-channel") this->
diagnostic(this->options.
get<std::string>(key));
186 else if (key ==
"expand-definitions") this->
error() <<
"The option :expand-definitions is not supported.";
187 else if (key ==
"interactive-mode") {
190 else if (key ==
"print-instruction") {
193 else if (key ==
"print-success") {
196 else if (key ==
"produce-assignments") {
199 else if (key ==
"produce-models") {
202 else if (key ==
"produce-proofs") {
203 this->
error() <<
"The option :produce-proofs is not supported.";
205 else if (key ==
"produce-unsat-cores") {
208 else if (key ==
"random-seed") {
209 this->
error() <<
"The option :random-seed is not supported.";
211 else if (key ==
"regular-output-channel") this->
regular(this->options.
get<std::string>(key));
212 else if (key ==
"verbosity") {
215 else if (key ==
"timeout") {
218 this->
info() <<
"Setting timeout to " << timeout <<
" seconds";
219 smtrat::resource::Limiter::getInstance().setTimeout(timeout);
221 else if (key ==
"memout") {
223 smtrat::resource::Limiter::getInstance().setMemout(carl::to_int<carl::uint>(
options.
get<
Rational>(
"memout")));
const T & get(const Key &key) const
Returns the value associated with the given key as type T.
bool has(const Key &key) const
Checks if there is a value of the specified type for the given key.
void assertType(const Key &key, Output out) const
Asserts that the value that is associated with the given key has a specified type.
void setOption(const Attribute &option)
virtual void add(const FormulaT &f)=0
void getOption(const std::string &key)
void getInfo(const std::string &key)
virtual void addSoft(const FormulaT &f, Rational weight, const std::string &id)=0
virtual void resetAssertions()=0
std::vector< smtrat::ModelVariable > mArtificialVariables
virtual void defineSort(const std::string &, const std::vector< std::string > &, const carl::Sort &)=0
void setArtificialVariables(std::vector< smtrat::ModelVariable > &&vars)
virtual void declareSort(const std::string &, const unsigned &)=0
void setInfo(const Attribute &attr)
void cleanModel(smtrat::Model &model) const
virtual void echo(const std::string &s)
std::ostream & diagnostic()
void addInstruction(std::function< void()> bind)
void diagnostic(const std::string &s)
virtual void getObjectives()=0
virtual void declareFun(const carl::Variable &)=0
bool has_info(const std::string &key) const
const auto & get_info(const std::string &key) const
virtual void setLogic(const carl::Logic &)=0
virtual void getUnsatCore()=0
virtual void getAssignment()=0
virtual void pop(std::size_t)=0
virtual void getAssertions()=0
T option(const std::string &key) const
virtual void getAllModels()=0
virtual ~InstructionHandler()
virtual void push(std::size_t)=0
VariantMap< std::string, Value > options
types::AttributeValue Value
virtual void annotateName(const FormulaT &f, const std::string &name)=0
void regular(const std::string &s)
std::queue< std::function< void()> > instructionQueue
bool printInstruction() const
VariantMap< std::string, Value > infos
virtual void getValue(const std::vector< carl::Variable > &)=0
std::map< std::string, std::ofstream > streams
void setStream(const std::string &s, std::ostream &os)
virtual void getProof()=0
bool hasInstructions() const
virtual void addObjective(const Poly &p, OptimizationType ot)=0
virtual void getModel()=0
OutputWrapper(std::ostream &o, const std::string &prefix, const std::string &suffix)
OutputWrapper(const OutputWrapper &&o)
OutputWrapper & operator<<(const T &t)
std::vector< T > prefix(const std::vector< T > vars, std::size_t prefixSize)
carl::mpl_variant_of< AttributeTypes >::type AttributeValue
Variant type for all attributes.
std::ostream & operator<<(std::ostream &os, OptimizationType ot)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
carl::MultivariatePolynomial< Rational > Poly