3 * @author YOUR NAME <YOUR EMAIL ADDRESS>
6 * Created on 2015-09-10.
13 template<class Settings>
14 FPPModule<Settings>::FPPModule( const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager ):
15 PModule( _formula, _conditionals, _manager, Settings::moduleName )
18 template<class Settings>
19 FPPModule<Settings>::~FPPModule()
22 template<class Settings>
23 bool FPPModule<Settings>::informCore( const FormulaT& _constraint )
25 return mPreprocessor.inform( _constraint );
28 template<class Settings>
29 void FPPModule<Settings>::init()
33 template<class Settings>
34 bool FPPModule<Settings>::addCore( ModuleInput::const_iterator )
39 template<class Settings>
40 void FPPModule<Settings>::removeCore( ModuleInput::const_iterator )
44 template<class Settings>
45 void FPPModule<Settings>::updateModel() const
48 if( solverState() != UNSAT )
51 mModel.update(mPartialModel);
52 excludeNotReceivedVariablesFromModel();
56 template<class Settings>
57 Answer FPPModule<Settings>::checkCore()
59 // set the objective for all preprocessing modules. Each module has to check
60 // whether it is sound to perform the preprocessing on optimizing solver calls.
61 mPreprocessor.setObjectiveVariable(objective());
63 std::size_t iterations = 0;
64 Answer answer = UNKNOWN;
65 FormulaT formulaBeforePreprocessing = FormulaT(rReceivedFormula());
66 mPartialModel.clear();
67 while (Settings::max_iterations < 0 || iterations < (std::size_t)Settings::max_iterations) {
69 // call the preprocessing on the current formula
71 mPreprocessor.add(formulaBeforePreprocessing);
72 answer = mPreprocessor.check(mFullCheck);
73 // preprocessing detects satisfiability or unsatisfiability
74 if (answer != UNKNOWN) {
78 SMTRAT_LOG_INFO("smtrat.fpp", "Retrieving simplified input and partial model...");
79 std::pair<bool,FormulaT> res = mPreprocessor.getInputSimplified();
80 SMTRAT_LOG_INFO("smtrat.fpp", "Curent model:" << mPartialModel);
81 SMTRAT_LOG_INFO("smtrat.fpp", "Preprocessor model:" << mPreprocessor.model());
82 mPartialModel.update(mPreprocessor.model());
83 SMTRAT_LOG_INFO("smtrat.fpp", "Backtracking");
85 if (res.first && (formulaBeforePreprocessing != res.second)) {
86 SMTRAT_LOG_INFO("smtrat.fpp", "Formula has been simplified from\n\t" << formulaBeforePreprocessing << std::endl << "to\n\t" << res.second);
87 SMTRAT_LOG_INFO("smtrat.fpp", "Current partial model:" << std::endl << mPartialModel);
88 assert(formulaBeforePreprocessing != res.second);
89 mFormulaAfterPreprocessing = res.second;
92 mFormulaAfterPreprocessing = formulaBeforePreprocessing;
95 // after preprocessing is before preprocessing
96 formulaBeforePreprocessing = mFormulaAfterPreprocessing;
99 if (answer == UNKNOWN) {
100 // run the backends on the fix point of the iterative application of preprocessing
101 // TODO: make this incremental
102 SMTRAT_LOG_INFO("smtrat.fpp", "Calling backend with\n\t" << mFormulaAfterPreprocessing);
103 clearPassedFormula();
104 addSubformulaToPassedFormula(mFormulaAfterPreprocessing);
105 answer = runBackends();
107 // obtain an infeasible subset, if the received formula is unsatisfiable
108 if (answer == UNSAT) {
109 generateTrivialInfeasibleSubset(); // TODO: compute a better infeasible subset