29 mpPrimaryBackend( new
Module( mpPassedFormula, mPrimaryBackendFoundAnswer, this ) ),
31 mDebugOutputChannel( std::cout.rdbuf() ),
32 mLogic(
carl::Logic::UNDEFINED ),
33 mInformationRelevantFormula(),
35 #ifdef SMTRAT_STRAT_PARALLEL_MODE
37 mpThreadPool( nullptr ),
38 mNumberOfBranches( 0 ),
40 mRunsParallel( false )
45 auto f = [] (
Module* _module,
const FormulaT& _constraint ) { _module->
inform( _constraint ); };
53 #ifdef SMTRAT_STRAT_PARALLEL_MODE
54 if( mpThreadPool !=
nullptr )
57 #ifndef SMTRAT_STRAT_PARALLEL_MODE
88 if( _containsUnknownConstraints )
90 carl::visit(_subformula, [
this](
const FormulaT& f){
92 case carl::FormulaType::CONSTRAINT:
93 case carl::FormulaType::VARCOMPARE:
94 case carl::FormulaType::BITVECTOR:
95 case carl::FormulaType::UEQ:
96 mpPrimaryBackend->inform(f);
140 std::vector<FormulaT>
result;
144 result.push_back( lem.mLemma );
182 for( ; _levels > 0; --_levels )
209 mLogic = carl::Logic::UNDEFINED;
217 #ifdef SMTRAT_STRAT_PARALLEL_MODE
218 void Manager::initialize()
220 if (mNumberOfCores != 0)
return;
222 if( mNumberOfBranches > 1 )
224 mNumberOfCores = std::thread::hardware_concurrency();
225 if( mNumberOfCores > 1 )
230 mRunsParallel =
true;
231 mpThreadPool =
new ThreadPool(mNumberOfCores);
243 if( infSubSet.size() == 1 )
245 _out << *infSubSet.begin();
249 for(
auto subFormula = infSubSet.begin(); subFormula != infSubSet.end(); ++subFormula )
251 _out << *subFormula << std::endl;
255 _out <<
")" << std::endl;
261 std::size_t btlCounter = 0;
263 _out <<
"btl_" << btlCounter <<
": (and ) skip" << std::endl;
267 _out <<
"btl_" << btlCounter <<
": (and";
269 _out <<
" " << it->formula();
273 _out <<
" )" << std::endl <<
"btl_" << btlCounter <<
": (and";
276 _out <<
" )" << std::endl << std::endl;;
281 #ifdef SMTRAT_STRAT_PARALLEL_MODE
282 std::lock_guard<std::mutex> lock(mBackendsMutex);
284 std::vector<Module*> backends;
289 for (
const auto& iter: factories) {
291 bool moduleExists =
false;
292 for (
const auto&
candidate: allBackends) {
293 if (
candidate->threadPriority() == iter.first) {
301 auto factory = iter.second;
302 assert(factory !=
nullptr);
304 foundAnswers.emplace_back(_foundAnswer);
309 allBackends.emplace_back(newBackend);
310 backends.emplace_back(newBackend);
315 newBackend->
add(form);
322 #ifdef SMTRAT_STRAT_PARALLEL_MODE
323 Answer Manager::runBackends(
const std::vector<Module*>& _modules,
bool _final,
bool _full, carl::Variable _objective) {
324 return mpThreadPool->runBackends(_modules, _final, _full, _objective);
bool inform(const FormulaT &_constraint)
Informs the solver about a constraint.
const std::vector< FormulaSetT > & infeasibleSubsets() const
ModuleInput * mpPassedFormula
the constraints so far passed to the primary backend
void deinform(const FormulaT &_constraint)
The inverse of informing about a constraint.
smtrat::Conditionals mPrimaryBackendFoundAnswer
a vector of flags, which indicate that an answer has been found of an antecessor module of the primar...
Module * mpPrimaryBackend
the primary backends
std::vector< Module * > mGeneratedModules
all generated instances of modules
ModuleInput::iterator remove(ModuleInput::iterator _subformula)
Removes the formula at the given position in the conjunction of formulas, which will be considered fo...
std::vector< Module * > getBackends(Module *_requiredBy, std::atomic_bool *_foundAnswer)
Get the backends to call for the given problem instance required by the given module.
void printInfeasibleSubset(std::ostream &_out=std::cout) const
Prints the first found infeasible subset of the set of received formulas.
StrategyGraph mStrategyGraph
primary strategy
const carl::Variable & objectiveVariable() const
std::map< const Module *const, std::vector< Module * > > mBackendsOfModules
a mapping of each module to its backends
std::list< std::vector< carl::Variable > > getModelEqualities() const
Determines variables assigned by the currently found satisfying assignment to an equal value in their...
std::vector< ModuleInput::iterator > mBacktrackPoints
Contains the backtrack points, that are iterators to the last formula to be kept when backtracking to...
void printAssignment() const
Prints the currently found assignment of variables occurring in the so far added formulas to values o...
~Manager()
Destructs a manager.
bool pop()
Pops a backtrack point from the stack of backtrack points.
bool add(const FormulaT &_subformula, bool _containsUnknownConstraints=true)
Adds the given formula to the conjunction of formulas, which will be considered for the next satisfia...
carl::Logic mLogic
the logic this solver considers
std::vector< FormulaT > lemmas()
Returns the lemmas/tautologies which were made during the last solving provoked by check().
void printBackTrackStack(std::ostream &_out=std::cout) const
Prints the stack of backtrack points.
std::pair< bool, FormulaT > getInputSimplified()
Answer check(bool _full=true)
Checks the so far added formulas for satisfiability.
Manager()
Constructs a manager.
const Model & model() const
A base class for all kind of theory solving methods.
const std::vector< FormulaSetT > & infeasibleSubsets() const
thread_priority threadPriority() const
const ModuleInput * pPassedFormula() const
virtual void updateModel() const
Updates the model, if the solver has detected the consistency of the received formula,...
virtual std::list< std::vector< carl::Variable > > getModelEqualities() const
Partition the variables from the current model into equivalence classes according to their assigned v...
void deinform(const FormulaT &_constraint)
The inverse of informing about a constraint.
ModuleInput::const_iterator firstSubformulaToPass() const
virtual std::pair< bool, FormulaT > getReceivedFormulaSimplified()
void setThreadPriority(thread_priority _threadPriority)
Sets the priority of this module to get a thread for running its check procedure.
bool inform(const FormulaT &_constraint)
Informs the module about the given constraint.
const std::vector< Lemma > & lemmas() const
void setId(std::size_t _id)
Sets this modules unique ID to identify itself.
const Model & model() const
void updateLemmas()
Stores all lemmas of any backend of this module in its own lemma vector.
const smtrat::Conditionals & answerFound() const
virtual Answer check(bool _final=false, bool _full=true, carl::Variable _objective=carl::Variable::NO_VARIABLE)
Checks the received formula for consistency.
virtual void remove(ModuleInput::const_iterator _subformula)
Removes everything related to the given sub-formula of the received formula.
const ModuleInput & rPassedFormula() const
void printModel(std::ostream &_out=std::cout) const
Prints the assignment of this module satisfying its received formula if it satisfiable and this modul...
const carl::FastSet< FormulaT > & informedConstraints() const
bool add(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
ModuleInput * mpPassedFormula
The formula passed to the backends of this module.
std::set< std::pair< thread_priority, AbstractModuleFactory * > > getBackends(std::size_t vertex, const carl::Condition &condition) const
std::size_t numberOfBranches() const
std::size_t getRoot() const
projection_compare::Candidate< Poly > candidate(const Poly &p, const Poly &q, std::size_t level)
Class to create the formulas for axioms.
carl::FormulaSet< Poly > FormulaSetT
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
Answer
An enum with the possible answers a Module can give.
std::vector< std::atomic_bool * > Conditionals
A vector of atomic bool pointers.
std::pair< std::size_t, std::size_t > thread_priority