From 9a28e5b580da618d581a37e042611776bc5375a0 Mon Sep 17 00:00:00 2001 From: masawei Date: Fri, 30 May 2014 23:06:22 +0200 Subject: [PATCH] Added proper formula string method to filters. - Lots of debugging - Changed the way the filter keeps information about the scheduler to use for probability/reward queries. | This was done by keeping a special action at the first position of the action list. | Which was not exactly consistent with the idea behind the filter actions. | Now the filter keeps this information as an enum value in a member variable. - All but one tests are green. So we almost reestablished full functionality. |- The last test that still fails is SparseMdpPrctlModelCheckerTest.Dice where the second to last model check returns the wrong result. Next up: Debug. Then introduce the full range of filter actions. Former-commit-id: fd311966cc55c005b4b331bc127933b56f156a8e --- src/formula/AbstractFilter.h | 41 +++++- src/formula/Actions/MinMaxAction.h | 68 ---------- src/formula/Csl/CslFilter.h | 113 +++++++++++++--- src/formula/Csl/ProbabilisticBoundOperator.h | 4 +- src/formula/Csl/SteadyStateBoundOperator.h | 4 +- src/formula/Csl/TimeBoundedEventually.h | 6 +- src/formula/Csl/TimeBoundedUntil.h | 4 +- src/formula/Prctl/BoundedNaryUntil.h | 2 +- src/formula/Prctl/PrctlFilter.h | 125 ++++++++++++++---- .../Prctl/ProbabilisticBoundOperator.h | 4 +- src/formula/Prctl/RewardBoundOperator.h | 4 +- src/modelchecker/prctl/AbstractModelChecker.h | 18 +-- .../prctl/SparseDtmcPrctlModelChecker.h | 8 +- src/parser/CslParser.cpp | 60 ++++----- src/parser/PrctlParser.cpp | 60 ++++----- .../SparseMdpPrctlModelCheckerTest.cpp | 36 ++--- test/functional/parser/CslParserTest.cpp | 10 +- test/functional/parser/PrctlParserTest.cpp | 10 +- .../SparseMdpPrctlModelCheckerTest.cpp | 28 ++-- 19 files changed, 353 insertions(+), 252 deletions(-) delete mode 100644 src/formula/Actions/MinMaxAction.h diff --git a/src/formula/AbstractFilter.h b/src/formula/AbstractFilter.h index 4031125d5..fe9798fca 100644 --- a/src/formula/AbstractFilter.h +++ b/src/formula/AbstractFilter.h @@ -15,20 +15,25 @@ namespace storm { namespace property { +/*! + * + */ +enum OptimizingOperator {MINIMIZE, MAXIMIZE, UNDEFINED}; + template class AbstractFilter { public: - AbstractFilter() { + AbstractFilter(OptimizingOperator opt = UNDEFINED) : opt(opt) { // Intentionally left empty. } - AbstractFilter(action::AbstractAction* action) { + AbstractFilter(action::AbstractAction* action, OptimizingOperator opt = UNDEFINED) : opt(opt) { actions.push_back(action); } - AbstractFilter(std::vector*> actions) : actions(actions) { + AbstractFilter(std::vector*> actions, OptimizingOperator opt = UNDEFINED) : actions(actions), opt(opt) { // Intentionally left empty. } @@ -36,16 +41,30 @@ public: actions.clear(); } - std::string toFormulaString() const { + virtual std::string toString() const { std::string desc = "filter("; + + for(auto action : actions) { + desc += action->toString(); + desc += ", "; + } + + // Remove the last ", ". + if(!actions.empty()) { + desc.pop_back(); + desc.pop_back(); + } + + desc += ")"; + return desc; } - std::string toString() const { + virtual std::string toPrettyString() const { std::string desc = "Filter: "; desc += "\nActions:"; for(auto action : actions) { - desc += "\n\t" + action.toString(); + desc += "\n\t" + action->toString(); } return desc; } @@ -66,9 +85,19 @@ public: return actions.size(); } + void setOptimizingOperator(OptimizingOperator opt) { + this->opt = opt; + } + + OptimizingOperator getOptimizingOperator() const { + return opt; + } + protected: std::vector*> actions; + + OptimizingOperator opt; }; } //namespace property diff --git a/src/formula/Actions/MinMaxAction.h b/src/formula/Actions/MinMaxAction.h deleted file mode 100644 index c775700e7..000000000 --- a/src/formula/Actions/MinMaxAction.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * MinMaxAction.h - * - * Created on: Apr 30, 2014 - * Author: Manuel Sascha Weiand - */ - -#ifndef STORM_FORMULA_ACTION_MINMAXACTION_H_ -#define STORM_FORMULA_ACTION_MINMAXACTION_H_ - -#include "src/formula/Actions/AbstractAction.h" - -namespace storm { -namespace property { -namespace action { - -template -class MinMaxAction : public AbstractAction { - -public: - - MinMaxAction() : minimize(true) { - //Intentionally left empty. - } - - explicit MinMaxAction(bool minimize) : minimize(minimize) { - //Intentionally left empty. - } - - /*! - * Virtual destructor - * To ensure that the right destructor is called - */ - virtual ~MinMaxAction() { - //Intentionally left empty - } - - /*! - * - */ - virtual std::string toString() const override { - return minimize ? "min" : "max"; - } - - /*! - * - */ - virtual std::string toFormulaString() const override { - return minimize ? "min" : "max"; - } - - /*! - * - */ - bool getMinimize() { - return minimize; - } - -private: - bool minimize; - -}; - -} //namespace action -} //namespace property -} //namespace storm - -#endif /* STORM_FORMULA_ACTION_MINMAXACTION_H_ */ diff --git a/src/formula/Csl/CslFilter.h b/src/formula/Csl/CslFilter.h index dbbd22368..14c578be7 100644 --- a/src/formula/Csl/CslFilter.h +++ b/src/formula/Csl/CslFilter.h @@ -13,7 +13,6 @@ #include "src/formula/Csl/AbstractPathFormula.h" #include "src/formula/Csl/AbstractStateFormula.h" #include "src/modelchecker/csl/AbstractModelChecker.h" -#include "src/formula/Actions/MinMaxAction.h" namespace storm { namespace property { @@ -24,23 +23,19 @@ class CslFilter : public storm::property::AbstractFilter { public: - CslFilter() : child(nullptr) { + CslFilter() : AbstractFilter(UNDEFINED), child(nullptr), steadyStateQuery(false) { // Intentionally left empty. } - CslFilter(AbstractCslFormula* child) : child(child) { + CslFilter(AbstractCslFormula* child, OptimizingOperator opt = UNDEFINED, bool steadyStateQuery = false) : AbstractFilter(opt), child(child), steadyStateQuery(steadyStateQuery) { // Intentionally left empty. } - CslFilter(AbstractCslFormula* child, bool minimize) : child(child) { - this->actions.push_back(new storm::property::action::MinMaxAction(minimize)); + CslFilter(AbstractCslFormula* child, action::AbstractAction* action, OptimizingOperator opt = UNDEFINED, bool steadyStateQuery = false) : AbstractFilter(action, opt), child(child), steadyStateQuery(steadyStateQuery) { + // Intentionally left empty } - CslFilter(AbstractCslFormula* child, action::AbstractAction* action) : child(child) { - this->actions.push_back(action); - } - - CslFilter(AbstractCslFormula* child, std::vector*> actions) : AbstractFilter(actions), child(child) { + CslFilter(AbstractCslFormula* child, std::vector*> actions, OptimizingOperator opt = UNDEFINED, bool steadyStateQuery = false) : AbstractFilter(actions, opt), child(child), steadyStateQuery(steadyStateQuery) { // Intentionally left empty. } @@ -145,12 +140,94 @@ public: return true; } - std::string toFormulaString() const { - std::string desc = "filter("; + virtual std::string toString() const override { + std::string desc = ""; + + if(dynamic_cast*>(child) == nullptr) { + + // The formula is not a state formula so we have a probability query. + if(this->actions.empty()){ + + // Since there are no actions given we do legacy support. + + desc += "P "; + switch(this->opt) { + case MINIMIZE: + desc += "min "; + break; + case MAXIMIZE: + desc += "max "; + break; + default: + break; + } + desc += "= ? "; + + } else { + desc = "filter["; + + switch(this->opt) { + case MINIMIZE: + desc += "min, "; + break; + case MAXIMIZE: + desc += "max, "; + break; + default: + break; + } + + for(auto action : this->actions) { + desc += action->toString(); + desc += ", "; + } + + // Remove the last ", ". + desc.pop_back(); + desc.pop_back(); + + desc += "]"; + } + + } else { + + if(this->actions.empty()) { + + if(steadyStateQuery) { + + // Legacy support for the steady state query. + desc += "S = ? "; + + } else { + + // There are no filter actions but only the raw state formula. So just print that. + return child->toString(); + } + } else { + + desc = "filter["; + + for(auto action : this->actions) { + desc += action->toString(); + desc += ", "; + } + + // Remove the last ", ". + desc.pop_back(); + desc.pop_back(); + + desc += "]"; + } + } + + desc += "("; + desc += child->toString(); + desc += ")"; + return desc; } - std::string toString() const { + virtual std::string toPrettyString() const override{ std::string desc = "Filter: "; desc += "\nActions:"; for(auto action : this->actions) { @@ -174,9 +251,9 @@ private: // First, get the model checking result. storm::storage::BitVector result = modelchecker.checkMinMaxOperator(formula); - if(this->getActionCount() != 0 && dynamic_cast*>(this->getAction(0)) != nullptr) { + if(this->opt != UNDEFINED) { // If there is an action specifying that min/max probabilities should be computed, call the appropriate method of the model checker. - result = modelchecker.checkMinMaxOperator(formula, static_cast*>(this->getAction(0))->getMinimize()); + result = modelchecker.checkMinMaxOperator(formula, this->opt == MINIMIZE ? true : false); } else { result = formula->check(modelchecker); } @@ -193,9 +270,9 @@ private: // First, get the model checking result. std::vector result; - if(this->getActionCount() != 0 && dynamic_cast*>(this->getAction(0)) != nullptr) { + if(this->opt != UNDEFINED) { // If there is an action specifying that min/max probabilities should be computed, call the appropriate method of the model checker. - result = modelchecker.checkMinMaxOperator(formula, static_cast*>(this->getAction(0))->getMinimize()); + result = modelchecker.checkMinMaxOperator(formula, this->opt == MINIMIZE ? true : false); } else { result = formula->check(modelchecker, false); } @@ -208,6 +285,8 @@ private: } AbstractCslFormula* child; + + bool steadyStateQuery; }; } //namespace csl diff --git a/src/formula/Csl/ProbabilisticBoundOperator.h b/src/formula/Csl/ProbabilisticBoundOperator.h index 4b4e5d937..d40bb90e2 100644 --- a/src/formula/Csl/ProbabilisticBoundOperator.h +++ b/src/formula/Csl/ProbabilisticBoundOperator.h @@ -139,9 +139,9 @@ public: } result += " "; result += std::to_string(bound); - result += " ["; + result += " ("; result += pathFormula->toString(); - result += "]"; + result += ")"; return result; } diff --git a/src/formula/Csl/SteadyStateBoundOperator.h b/src/formula/Csl/SteadyStateBoundOperator.h index c8d9e8de4..ecaad5ad4 100644 --- a/src/formula/Csl/SteadyStateBoundOperator.h +++ b/src/formula/Csl/SteadyStateBoundOperator.h @@ -135,9 +135,9 @@ public: case GREATER_EQUAL: result += ">= "; break; } result += std::to_string(bound); - result += " ["; + result += " ("; result += stateFormula->toString(); - result += "]"; + result += ")"; return result; } diff --git a/src/formula/Csl/TimeBoundedEventually.h b/src/formula/Csl/TimeBoundedEventually.h index ac601b7d8..c80eecb4b 100644 --- a/src/formula/Csl/TimeBoundedEventually.h +++ b/src/formula/Csl/TimeBoundedEventually.h @@ -50,7 +50,7 @@ public: setInterval(lowerBound, upperBound); } - TimeBoundedEventually(T lowerBound, T upperBound, AbstractStateFormula* child) : child(nullptr) { + TimeBoundedEventually(T lowerBound, T upperBound, AbstractStateFormula* child) : child(child) { setInterval(lowerBound, upperBound); } @@ -104,9 +104,9 @@ public: virtual std::string toString() const override { std::string result = "F"; if (upperBound == std::numeric_limits::infinity()) { - result = ">=" + std::to_string(lowerBound); + result += ">=" + std::to_string(lowerBound); } else { - result = "["; + result += "["; result += std::to_string(lowerBound); result += ","; result += std::to_string(upperBound); diff --git a/src/formula/Csl/TimeBoundedUntil.h b/src/formula/Csl/TimeBoundedUntil.h index 560bb8df8..3da7fa968 100644 --- a/src/formula/Csl/TimeBoundedUntil.h +++ b/src/formula/Csl/TimeBoundedUntil.h @@ -123,9 +123,9 @@ public: std::string result = left->toString(); result += " U"; if (upperBound == std::numeric_limits::infinity()) { - result = ">=" + std::to_string(lowerBound); + result += ">=" + std::to_string(lowerBound); } else { - result = "["; + result += "["; result += std::to_string(lowerBound); result += ","; result += std::to_string(upperBound); diff --git a/src/formula/Prctl/BoundedNaryUntil.h b/src/formula/Prctl/BoundedNaryUntil.h index f59431447..9c27158ba 100644 --- a/src/formula/Prctl/BoundedNaryUntil.h +++ b/src/formula/Prctl/BoundedNaryUntil.h @@ -143,7 +143,7 @@ public: std::stringstream result; result << "( " << left->toString(); for (auto it = this->right->begin(); it != this->right->end(); ++it) { - result << " U[" << std::get<1>(*it) << "," << std::get<2>(*it) << "] " << std::get<0>(*it)->toString(); + result << " U(" << std::get<1>(*it) << "," << std::get<2>(*it) << ") " << std::get<0>(*it)->toString(); } result << ")"; return result.str(); diff --git a/src/formula/Prctl/PrctlFilter.h b/src/formula/Prctl/PrctlFilter.h index 7302148a3..407b4f6c3 100644 --- a/src/formula/Prctl/PrctlFilter.h +++ b/src/formula/Prctl/PrctlFilter.h @@ -13,7 +13,6 @@ #include "src/formula/Prctl/AbstractPathFormula.h" #include "src/formula/Prctl/AbstractStateFormula.h" #include "src/modelchecker/prctl/AbstractModelChecker.h" -#include "src/formula/Actions/MinMaxAction.h" namespace storm { namespace property { @@ -24,23 +23,19 @@ class PrctlFilter : public storm::property::AbstractFilter { public: - PrctlFilter() : child(nullptr) { + PrctlFilter() : AbstractFilter(UNDEFINED), child(nullptr) { // Intentionally left empty. } - PrctlFilter(AbstractPrctlFormula* child) : child(child) { + PrctlFilter(AbstractPrctlFormula* child, OptimizingOperator opt = UNDEFINED) : AbstractFilter(opt), child(child) { // Intentionally left empty. } - PrctlFilter(AbstractPrctlFormula* child, bool minimize) : child(child) { - this->actions.push_back(new storm::property::action::MinMaxAction(minimize)); - } - - PrctlFilter(AbstractPrctlFormula* child, action::AbstractAction* action) : child(child) { - this->actions.push_back(action); + PrctlFilter(AbstractPrctlFormula* child, action::AbstractAction* action, OptimizingOperator opt = UNDEFINED) : AbstractFilter(action, opt), child(child) { + // Intentionally left empty. } - PrctlFilter(AbstractPrctlFormula* child, std::vector*> actions) : AbstractFilter(actions), child(child) { + PrctlFilter(AbstractPrctlFormula* child, std::vector*> actions, OptimizingOperator opt = UNDEFINED) : AbstractFilter(actions, opt), child(child) { // Intentionally left empty. } @@ -53,8 +48,8 @@ public: // Write out the formula to be checked. std::cout << std::endl; - LOG4CPLUS_INFO(logger, "Model checking formula\t" << this->toFormulaString()); - std::cout << "Model checking formula:\t" << this->toFormulaString() << std::endl; + LOG4CPLUS_INFO(logger, "Model checking formula\t" << this->toString()); + std::cout << "Model checking formula:\t" << this->toString() << std::endl; // Do a dynamic cast to test for the actual formula type and call the correct evaluation function. if(dynamic_cast*>(child) != nullptr) { @@ -177,12 +172,94 @@ public: return true; } - std::string toFormulaString() const { - std::string desc = "filter("; + virtual std::string toString() const override { + std::string desc = ""; + + if(dynamic_cast*>(child) == nullptr) { + + // The formula is not a state formula so we either have a probability query or a reward query. + if(this->actions.empty()){ + + // There is exactly one action in the list, the minmax action. Again, we do legacy support- + + if(dynamic_cast*>(child) != nullptr) { + // It is a probability query. + desc += "P "; + + } else { + // It is a reward query. + desc += "R "; + } + + switch(this->opt) { + case MINIMIZE: + desc += "min "; + break; + case MAXIMIZE: + desc += "max "; + break; + default: + break; + } + + desc += "= ? "; + + } else { + desc = "filter["; + + switch(this->opt) { + case MINIMIZE: + desc += " min, "; + break; + case MAXIMIZE: + desc += " max, "; + break; + default: + break; + } + + for(auto action : this->actions) { + desc += action->toString(); + desc += ", "; + } + + // Remove the last ", ". + desc.pop_back(); + desc.pop_back(); + + desc += "]"; + } + + } else { + + if(this->actions.empty()) { + + // There are no filter actions but only the raw state formula. So just print that. + return child->toString(); + } + + desc = "filter["; + + for(auto action : this->actions) { + desc += action->toString(); + desc += ", "; + } + + // Remove the last ", ". + desc.pop_back(); + desc.pop_back(); + + desc += "]"; + } + + desc += "("; + desc += child->toString(); + desc += ")"; + return desc; } - std::string toString() const { + virtual std::string toPrettyString() const override{ std::string desc = "Filter: "; desc += "\nActions:"; for(auto action : this->actions) { @@ -206,9 +283,9 @@ private: // First, get the model checking result. storm::storage::BitVector result; - if(this->getActionCount() != 0 && dynamic_cast*>(this->getAction(0)) != nullptr) { - // If there is an action specifying that min/max probabilities should be computed, call the appropriate method of the model checker. - result = modelchecker.checkMinMaxOperator(*formula, static_cast*>(this->getAction(0))->getMinimize()); + if(this->opt != UNDEFINED) { + // If it is specified that min/max probabilities/rewards should be computed, call the appropriate method of the model checker. + result = modelchecker.checkOptimizingOperator(*formula, this->opt == storm::property::MINIMIZE ? true : false); } else { result = formula->check(modelchecker); } @@ -225,9 +302,9 @@ private: // First, get the model checking result. std::vector result; - if(this->getActionCount() != 0 && dynamic_cast*>(this->getAction(0)) != nullptr) { - // If there is an action specifying that min/max probabilities should be computed, call the appropriate method of the model checker. - result = modelchecker.checkMinMaxOperator(*formula, dynamic_cast*>(this->getAction(0))->getMinimize()); + if(this->opt != UNDEFINED) { + // If it is specified that min/max probabilities/rewards should be computed, call the appropriate method of the model checker. + result = modelchecker.checkOptimizingOperator(*formula, this->opt == storm::property::MINIMIZE ? true : false); } else { result = formula->check(modelchecker, false); } @@ -243,9 +320,9 @@ private: // First, get the model checking result. std::vector result; - if(this->getActionCount() != 0 && dynamic_cast*>(this->getAction(0)) != nullptr) { - // If there is an action specifying that min/max probabilities should be computed, call the appropriate method of the model checker. - result = modelchecker.checkMinMaxOperator(*formula, dynamic_cast*>(this->getAction(0))->getMinimize()); + if(this->opt != UNDEFINED) { + // If it is specified that min/max probabilities/rewards should be computed, call the appropriate method of the model checker. + result = modelchecker.checkOptimizingOperator(*formula, this->opt == storm::property::MINIMIZE ? true : false); } else { result = formula->check(modelchecker, false); } diff --git a/src/formula/Prctl/ProbabilisticBoundOperator.h b/src/formula/Prctl/ProbabilisticBoundOperator.h index 9cbcee34c..e1c325ef2 100644 --- a/src/formula/Prctl/ProbabilisticBoundOperator.h +++ b/src/formula/Prctl/ProbabilisticBoundOperator.h @@ -139,9 +139,9 @@ public: } result += " "; result += std::to_string(bound); - result += " ["; + result += " ("; result += pathFormula->toString(); - result += "]"; + result += ")"; return result; } diff --git a/src/formula/Prctl/RewardBoundOperator.h b/src/formula/Prctl/RewardBoundOperator.h index bf12d471d..ac9b721cc 100644 --- a/src/formula/Prctl/RewardBoundOperator.h +++ b/src/formula/Prctl/RewardBoundOperator.h @@ -137,9 +137,9 @@ public: } result += " "; result += std::to_string(bound); - result += " ["; + result += " ("; result += pathFormula->toString(); - result += "]"; + result += ")"; return result; } diff --git a/src/modelchecker/prctl/AbstractModelChecker.h b/src/modelchecker/prctl/AbstractModelChecker.h index fcaf0c2a9..e877cc672 100644 --- a/src/modelchecker/prctl/AbstractModelChecker.h +++ b/src/modelchecker/prctl/AbstractModelChecker.h @@ -233,11 +233,11 @@ public: * Checks the given formula and determines whether minimum or maximum probabilities are to be computed for the formula. * * @param formula The formula to check. - * @param minimumOperator True iff minimum probabilities are to be computed. + * @param optOperator True iff minimum probabilities are to be computed. * @returns The probabilities to satisfy the formula, represented by a vector. */ - virtual std::vector checkMinMaxOperator(storm::property::prctl::AbstractPathFormula const & formula, bool minimumOperator) const { - minimumOperatorStack.push(minimumOperator); + virtual std::vector checkOptimizingOperator(storm::property::prctl::AbstractPathFormula const & formula, bool optOperator) const { + minimumOperatorStack.push(optOperator); std::vector result = formula.check(*this, false); minimumOperatorStack.pop(); return result; @@ -247,11 +247,11 @@ public: * Checks the given formula and determines whether minimum or maximum rewards are to be computed for the formula. * * @param formula The formula to check. - * @param minimumOperator True iff minimum rewards are to be computed. + * @param optOperator True iff minimum rewards are to be computed. * @returns The the rewards accumulated by the formula, represented by a vector. */ - virtual std::vector checkMinMaxOperator(storm::property::prctl::AbstractRewardPathFormula const & formula, bool minimumOperator) const { - minimumOperatorStack.push(minimumOperator); + virtual std::vector checkOptimizingOperator(storm::property::prctl::AbstractRewardPathFormula const & formula, bool optOperator) const { + minimumOperatorStack.push(optOperator); std::vector result = formula.check(*this, false); minimumOperatorStack.pop(); return result; @@ -261,11 +261,11 @@ public: * Checks the given formula and determines whether minimum or maximum probabilities or rewards are to be computed for the formula. * * @param formula The formula to check. - * @param minimumOperator True iff minimum probabilities/rewards are to be computed. + * @param optOperator True iff minimum probabilities/rewards are to be computed. * @returns The set of states satisfying the formula represented by a bit vector. */ - virtual storm::storage::BitVector checkMinMaxOperator(storm::property::prctl::AbstractStateFormula const & formula, bool minimumOperator) const { - minimumOperatorStack.push(minimumOperator); + virtual storm::storage::BitVector checkOptimizingOperator(storm::property::prctl::AbstractStateFormula const & formula, bool optOperator) const { + minimumOperatorStack.push(optOperator); storm::storage::BitVector result = formula.check(*this); minimumOperatorStack.pop(); return result; diff --git a/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h b/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h index ba61201c7..acdb6945c 100644 --- a/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h +++ b/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h @@ -488,10 +488,10 @@ public: * should be computed for the formula makes no sense in the context of a deterministic model. * * @param formula The formula to check. - * @param minimumOperator True iff minimum probabilities/rewards are to be computed. + * @param optOperator True iff minimum probabilities/rewards are to be computed. * @returns The probabilities to satisfy the formula or the rewards accumulated by it, represented by a vector. */ - virtual std::vector checkMinMaxOperator(storm::property::prctl::AbstractPathFormula const & formula, bool minimumOperator) const override { + virtual std::vector checkOptimizingOperator(storm::property::prctl::AbstractPathFormula const & formula, bool optOperator) const override { LOG4CPLUS_WARN(logger, "Formula contains min/max operator, which is not meaningful over deterministic models."); @@ -506,10 +506,10 @@ public: * should be computed for the formula makes no sense in the context of a deterministic model. * * @param formula The formula to check. - * @param minimumOperator True iff minimum probabilities/rewards are to be computed. + * @param optOperator True iff minimum probabilities/rewards are to be computed. * @returns The set of states satisfying the formula represented by a bit vector. */ - virtual storm::storage::BitVector checkMinMaxOperator(storm::property::prctl::AbstractStateFormula const & formula, bool minimumOperator) const override { + virtual storm::storage::BitVector checkOptimizingOperator(storm::property::prctl::AbstractStateFormula const & formula, bool optOperator) const override { LOG4CPLUS_WARN(logger, "Formula contains min/max operator, which is not meaningful over deterministic models."); diff --git a/src/parser/CslParser.cpp b/src/parser/CslParser.cpp index 5ae34df1c..296deecc0 100644 --- a/src/parser/CslParser.cpp +++ b/src/parser/CslParser.cpp @@ -11,7 +11,6 @@ // The action class headers. #include "src/formula/Actions/AbstractAction.h" -#include "src/formula/Actions/MinMaxAction.h" #include "src/formula/Actions/RangeAction.h" // If the parser fails due to ill-formed data, this exception is thrown. @@ -38,7 +37,6 @@ typedef boost::spirit::classic::position_iterator2 PositionIte namespace qi = boost::spirit::qi; namespace phoenix = boost::phoenix; - namespace storm { namespace parser { @@ -60,31 +58,31 @@ struct CslParser::CslGrammar : qi::grammar *(qi::lit("|") > andFormula)[qi::_val = phoenix::new_>(qi::_val, qi::_1)]; - orFormula.name("state formula"); + orFormula.name("or formula"); andFormula = notFormula[qi::_val = qi::_1] > *(qi::lit("&") > notFormula)[qi::_val = phoenix::new_>(qi::_val, qi::_1)]; - andFormula.name("state formula"); + andFormula.name("and formula"); notFormula = atomicStateFormula[qi::_val = qi::_1] | (qi::lit("!") > atomicStateFormula)[qi::_val = phoenix::new_>(qi::_1)]; - notFormula.name("state formula"); + notFormula.name("not formula"); //This block defines rules for "atomic" state formulas //(Propositions, probabilistic/reward formulas, and state formulas in brackets) atomicStateFormula %= probabilisticBoundOperator | steadyStateBoundOperator | atomicProposition | qi::lit("(") >> stateFormula >> qi::lit(")"); - atomicStateFormula.name("state formula"); + atomicStateFormula.name("atomic state formula"); atomicProposition = (freeIdentifierName)[qi::_val = phoenix::new_>(qi::_1)]; - atomicProposition.name("state formula"); + atomicProposition.name("atomic proposition"); probabilisticBoundOperator = ( (qi::lit("P") >> comparisonType > qi::double_ > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = phoenix::new_ >(qi::_1, qi::_2, qi::_3)] ); - probabilisticBoundOperator.name("state formula"); + probabilisticBoundOperator.name("probabilistic bound operator"); steadyStateBoundOperator = ( (qi::lit("S") >> comparisonType > qi::double_ > qi::lit("[") > stateFormula > qi::lit("]"))[qi::_val = phoenix::new_ >(qi::_1, qi::_2, qi::_3)] ); - steadyStateBoundOperator.name("state formula"); + steadyStateBoundOperator.name("steady state bound operator"); //This block defines rules for parsing probabilistic path formulas pathFormula = (timeBoundedEventually | eventually | globally | next | timeBoundedUntil | until); @@ -97,16 +95,16 @@ struct CslParser::CslGrammar : qi::grammar> (qi::lit(">=") | qi::lit(">")) > qi::double_ > stateFormula)[qi::_val = phoenix::new_>(qi::_1, std::numeric_limits::infinity(), qi::_2)] ); - timeBoundedEventually.name("path formula (for probabilistic operator)"); + timeBoundedEventually.name("time bounded eventually"); eventually = (qi::lit("F") > stateFormula)[qi::_val = phoenix::new_ >(qi::_1)]; - eventually.name("path formula (for probabilistic operator)"); + eventually.name("eventually"); next = (qi::lit("X") > stateFormula)[qi::_val = phoenix::new_ >(qi::_1)]; - next.name("path formula (for probabilistic operator)"); + next.name("next"); globally = (qi::lit("G") > stateFormula)[qi::_val = phoenix::new_ >(qi::_1)]; - globally.name("path formula (for probabilistic operator)"); + globally.name("globally"); timeBoundedUntil = ( (stateFormula[qi::_a = phoenix::construct>>(qi::_1)] >> qi::lit("U") >> qi::lit("[") > qi::double_ > qi::lit(",") > qi::double_ > qi::lit("]") > stateFormula) [qi::_val = phoenix::new_>(qi::_2, qi::_3, phoenix::bind(&storm::property::csl::AbstractStateFormula::clone, phoenix::bind(&std::shared_ptr>::get, qi::_a)), qi::_4)] | @@ -115,10 +113,10 @@ struct CslParser::CslGrammar : qi::grammar>>(qi::_1)] >> qi::lit("U") >> (qi::lit(">=") | qi::lit(">")) > qi::double_ > stateFormula) [qi::_val = phoenix::new_>(qi::_2, std::numeric_limits::infinity(), phoenix::bind(&storm::property::csl::AbstractStateFormula::clone, phoenix::bind(&std::shared_ptr>::get, qi::_a)), qi::_3)] ); - timeBoundedUntil.name("path formula (for probabilistic operator)"); + timeBoundedUntil.name("time bounded until"); until = (stateFormula[qi::_a = phoenix::construct>>(qi::_1)] >> qi::lit("U") > stateFormula)[qi::_val = phoenix::new_>(phoenix::bind(&storm::property::csl::AbstractStateFormula::clone, phoenix::bind(&std::shared_ptr>::get, qi::_a)), qi::_2)]; - until.name("path formula (for probabilistic operator)"); + until.name("until formula"); formula = (pathFormula | stateFormula); formula.name("CSL formula"); @@ -128,40 +126,35 @@ struct CslParser::CslGrammar : qi::grammar> qi::lit("min") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> pathFormula >> qi::lit("]"))[qi::_val = - phoenix::new_>(qi::_1, true)]; + phoenix::new_>(qi::_1, storm::property::MINIMIZE)] | (qi::lit("P") >> qi::lit("max") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> pathFormula >> qi::lit("]"))[qi::_val = - phoenix::new_>(qi::_1, false)]; + phoenix::new_>(qi::_1, storm::property::MAXIMIZE)] | (qi::lit("P") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> pathFormula >> qi::lit("]"))[qi::_val = phoenix::new_>(qi::_1)]; - probabilisticNoBoundOperator.name("no bound operator"); + probabilisticNoBoundOperator.name("probabilistic no bound operator"); steadyStateNoBoundOperator = (qi::lit("S") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> stateFormula >> qi::lit("]"))[qi::_val = - phoenix::new_>(qi::_1)]; - steadyStateNoBoundOperator.name("no bound operator"); - - minMaxAction = qi::lit("minmax") >> qi::lit(",") >> ( - qi::lit("min")[qi::_val = - phoenix::new_>(true)] | - qi::lit("min")[qi::_val = - phoenix::new_>(false)]); - minMaxAction.name("minmax action for the formula filter"); + phoenix::new_>(qi::_1, storm::property::UNDEFINED, true)]; + steadyStateNoBoundOperator.name("steady state no bound operator"); rangeAction = (qi::lit("range") >> qi::lit(",") >> qi::uint_ >> qi::lit(",") >> qi::uint_)[qi::_val = phoenix::new_>(qi::_1, qi::_2)]; rangeAction.name("range action for the formula filter"); - abstractAction = (rangeAction | minMaxAction) >> (qi::eps | qi::lit(",")); + abstractAction = (rangeAction) >> (qi::eps | qi::lit(",")); abstractAction.name("filter action"); filter = (qi::lit("filter") >> qi::lit("[") >> +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val = phoenix::new_>(qi::_2, qi::_1)] | - (formula)[qi::_val = - phoenix::new_>(qi::_1)] | (noBoundOperator)[qi::_val = - qi::_1]; - filter.name("PRCTL formula filter"); + qi::_1] | + (formula)[qi::_val = + phoenix::new_>(qi::_1)]; + + filter.name("CSL formula filter"); start = (((filter) > (comment | qi::eps))[qi::_val = qi::_1] | comment ) > qi::eoi; - start.name("CSL formula filter"); + start.name("CSL formula filter start"); + } qi::rule*(), Skipper> start; @@ -173,7 +166,6 @@ struct CslParser::CslGrammar : qi::grammar*(), Skipper> abstractAction; qi::rule*(), Skipper> rangeAction; - qi::rule*(), Skipper> minMaxAction; qi::rule*(), Skipper> formula; qi::rule*(), Skipper> comment; diff --git a/src/parser/PrctlParser.cpp b/src/parser/PrctlParser.cpp index d92cd6178..49bfe281b 100644 --- a/src/parser/PrctlParser.cpp +++ b/src/parser/PrctlParser.cpp @@ -4,7 +4,6 @@ // The action class headers. #include "src/formula/Actions/AbstractAction.h" -#include "src/formula/Actions/MinMaxAction.h" #include "src/formula/Actions/RangeAction.h" // If the parser fails due to ill-formed data, this exception is thrown. @@ -54,31 +53,31 @@ struct PrctlParser::PrctlGrammar : qi::grammar *(qi::lit("|") > andFormula)[qi::_val = phoenix::new_>(qi::_val, qi::_1)]; - orFormula.name("state formula"); + orFormula.name("or formula"); andFormula = notFormula[qi::_val = qi::_1] > *(qi::lit("&") > notFormula)[qi::_val = phoenix::new_>(qi::_val, qi::_1)]; - andFormula.name("state formula"); + andFormula.name("and formula"); notFormula = atomicStateFormula[qi::_val = qi::_1] | (qi::lit("!") > atomicStateFormula)[qi::_val = phoenix::new_>(qi::_1)]; - notFormula.name("state formula"); + notFormula.name("not formula"); //This block defines rules for "atomic" state formulas //(Propositions, probabilistic/reward formulas, and state formulas in brackets) - atomicStateFormula %= probabilisticBoundOperator | rewardBoundOperator | atomicProposition | qi::lit("(") >> stateFormula >> qi::lit(")"); - atomicStateFormula.name("state formula"); + atomicStateFormula %= probabilisticBoundOperator | rewardBoundOperator | atomicProposition | qi::lit("(") >> stateFormula >> qi::lit(")") | qi::lit("[") >> stateFormula >> qi::lit("]"); + atomicStateFormula.name("atomic state formula"); atomicProposition = (freeIdentifierName)[qi::_val = phoenix::new_>(qi::_1)]; - atomicProposition.name("state formula"); + atomicProposition.name("atomic proposition"); probabilisticBoundOperator = ((qi::lit("P") >> comparisonType > qi::double_ > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = phoenix::new_ >(qi::_1, qi::_2, qi::_3)]); - probabilisticBoundOperator.name("state formula"); + probabilisticBoundOperator.name("probabilistic bound operator"); rewardBoundOperator = ((qi::lit("R") >> comparisonType > qi::double_ > qi::lit("[") > rewardPathFormula > qi::lit("]"))[qi::_val = phoenix::new_ >(qi::_1, qi::_2, qi::_3)]); - rewardBoundOperator.name("state formula"); + rewardBoundOperator.name("reward bound operator"); //This block defines rules for parsing probabilistic path formulas - pathFormula = (boundedEventually | eventually | next | globally | boundedUntil | until); + pathFormula = (boundedEventually | eventually | next | globally | boundedUntil | until | qi::lit("(") >> pathFormula >> qi::lit(")") | qi::lit("[") >> pathFormula >> qi::lit("]")); pathFormula.name("path formula"); boundedEventually = (qi::lit("F") >> qi::lit("<=") > qi::int_ > stateFormula)[qi::_val = phoenix::new_>(qi::_2, qi::_1)]; @@ -100,7 +99,7 @@ struct PrctlParser::PrctlGrammar : qi::grammar> rewardPathFormula >> qi::lit(")") | qi::lit("[") >> rewardPathFormula >> qi::lit("]")); rewardPathFormula.name("path formula (for reward operator)"); cumulativeReward = (qi::lit("C") > qi::lit("<=") > qi::double_)[qi::_val = phoenix::new_>(qi::_1)]; @@ -122,50 +121,44 @@ struct PrctlParser::PrctlGrammar : qi::grammar> qi::lit("min") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> pathFormula >> qi::lit("]"))[qi::_val = - phoenix::new_ >(qi::_1, true)] | - (qi::lit("P") >> qi::lit("max") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> pathFormula >> qi::lit("]"))[qi::_val = - phoenix::new_ >(qi::_1, false)] | - (qi::lit("P") >> qi::lit("=") >> qi::lit("?") > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = + (qi::lit("P") >> qi::lit("min") >> qi::lit("=") > qi::lit("?") >> pathFormula )[qi::_val = + phoenix::new_ >(qi::_1, storm::property::MINIMIZE)] | + (qi::lit("P") >> qi::lit("max") >> qi::lit("=") > qi::lit("?") >> pathFormula )[qi::_val = + phoenix::new_ >(qi::_1, storm::property::MAXIMIZE)] | + (qi::lit("P") >> qi::lit("=") > qi::lit("?") >> pathFormula )[qi::_val = phoenix::new_ >(qi::_1)] ); probabilisticNoBoundOperator.name("no bound operator"); rewardNoBoundOperator = ( - (qi::lit("R") >> qi::lit("min") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> rewardPathFormula >> qi::lit("]"))[qi::_val = - phoenix::new_ >(qi::_1, true)] | - (qi::lit("R") >> qi::lit("max") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> rewardPathFormula >> qi::lit("]"))[qi::_val = - phoenix::new_ >(qi::_1, false)] | - (qi::lit("R") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> rewardPathFormula >> qi::lit("]"))[qi::_val = + (qi::lit("R") >> qi::lit("min") >> qi::lit("=") > qi::lit("?") >> rewardPathFormula )[qi::_val = + phoenix::new_ >(qi::_1, storm::property::MINIMIZE)] | + (qi::lit("R") >> qi::lit("max") >> qi::lit("=") > qi::lit("?") >> rewardPathFormula )[qi::_val = + phoenix::new_ >(qi::_1, storm::property::MAXIMIZE)] | + (qi::lit("R") >> qi::lit("=") >> qi::lit("?") >> rewardPathFormula )[qi::_val = phoenix::new_ >(qi::_1)] ); rewardNoBoundOperator.name("no bound operator"); - minMaxAction = qi::lit("minmax") >> qi::lit(",") >> ( - qi::lit("min")[qi::_val = - phoenix::new_>(true)] | - qi::lit("min")[qi::_val = - phoenix::new_>(false)]); - minMaxAction.name("minmax action for the formula filter"); - rangeAction = (qi::lit("range") >> qi::lit(",") >> qi::uint_ >> qi::lit(",") >> qi::uint_)[qi::_val = phoenix::new_>(qi::_1, qi::_2)]; rangeAction.name("range action for the formula filter"); - abstractAction = (rangeAction | minMaxAction) >> (qi::eps | qi::lit(",")); + abstractAction = (rangeAction) >> (qi::eps | qi::lit(",")); abstractAction.name("filter action"); - filter = (qi::lit("filter") >> qi::lit("[") >> +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val = + filter = (qi::lit("filter") > qi::lit("[") >> +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val = phoenix::new_>(qi::_2, qi::_1)] | - (formula)[qi::_val = - phoenix::new_>(qi::_1)] | (noBoundOperator)[qi::_val = - qi::_1]; + qi::_1] | + (formula)[qi::_val = + phoenix::new_>(qi::_1)]; filter.name("PRCTL formula filter"); start = (((filter) > (comment | qi::eps))[qi::_val = qi::_1] | comment[qi::_val = nullptr]) > qi::eoi; start.name("PRCTL formula filter"); + } qi::rule*(), Skipper> start; @@ -177,7 +170,6 @@ struct PrctlParser::PrctlGrammar : qi::grammar*(), Skipper> abstractAction; qi::rule*(), Skipper> rangeAction; - qi::rule*(), Skipper> minMaxAction; qi::rule*(), Skipper> formula; qi::rule*(), Skipper> comment; diff --git a/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp b/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp index 2fd8e148e..538bfc6f8 100644 --- a/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp +++ b/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp @@ -22,11 +22,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Dice) { storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("two"); storm::property::prctl::Eventually* eventuallyFormula = new storm::property::prctl::Eventually(apFormula); - std::vector result = mc.checkMinMaxOperator(*eventuallyFormula, true); + std::vector result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 0.0277777612209320068), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 0.0277777612209320068), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -35,11 +35,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Dice) { apFormula = new storm::property::prctl::Ap("three"); eventuallyFormula = new storm::property::prctl::Eventually(apFormula); - result = mc.checkMinMaxOperator(*eventuallyFormula, true); + result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 0.0555555224418640136), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 0.0555555224418640136), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -48,11 +48,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Dice) { apFormula = new storm::property::prctl::Ap("four"); eventuallyFormula = new storm::property::prctl::Eventually(apFormula); - result = mc.checkMinMaxOperator(*eventuallyFormula, true); + result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 0.083333283662796020508), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 0.083333283662796020508), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -61,11 +61,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Dice) { apFormula = new storm::property::prctl::Ap("done"); storm::property::prctl::ReachabilityReward* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, true); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, true); ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, false); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, false); ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -82,11 +82,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Dice) { apFormula = new storm::property::prctl::Ap("done"); reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, true); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, true); ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, false); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, false); ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -103,11 +103,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Dice) { apFormula = new storm::property::prctl::Ap("done"); reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, true); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, true); ASSERT_LT(std::abs(result[0] - 14.666658998), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, false); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, false); ASSERT_LT(std::abs(result[0] - 14.666658998), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -130,11 +130,11 @@ TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::Eventually* eventuallyFormula = new storm::property::prctl::Eventually(apFormula); - std::vector result = mc.checkMinMaxOperator(*eventuallyFormula, true); + std::vector result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 1), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 1), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -143,11 +143,11 @@ TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::BoundedEventually* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 25); - result = mc.checkMinMaxOperator(*boundedEventuallyFormula, true); + result = mc.checkOptimizingOperator(*boundedEventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 0.0625), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*boundedEventuallyFormula, false); + result = mc.checkOptimizingOperator(*boundedEventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 0.0625), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -156,11 +156,11 @@ TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::ReachabilityReward* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, true); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, true); ASSERT_LT(std::abs(result[0] - 4.285689611), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, false); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, false); ASSERT_LT(std::abs(result[0] - 4.285689611), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); diff --git a/test/functional/parser/CslParserTest.cpp b/test/functional/parser/CslParserTest.cpp index 9b8ad7ea9..929d72c71 100644 --- a/test/functional/parser/CslParserTest.cpp +++ b/test/functional/parser/CslParserTest.cpp @@ -58,7 +58,7 @@ TEST(CslParserTest, parseProbabilisticFormulaTest) { ASSERT_EQ(0.5, op->getBound()); // Test the string representation for the parsed formula. - ASSERT_EQ("P > 0.500000 [F a]", formula->toString()); + ASSERT_EQ("P > 0.500000 (F a)", formula->toString()); delete formula; } @@ -78,7 +78,7 @@ TEST(CslParserTest, parseSteadyStateBoundFormulaTest) { ASSERT_EQ(15.0, op->getBound()); // Test the string representation for the parsed formula. - ASSERT_EQ("S >= 15.000000 [P < 0.200000 [a U[0.000000,3.000000] b]]", formula->toString()); + ASSERT_EQ("S >= 15.000000 (P < 0.200000 (a U[0.000000,3.000000] b))", formula->toString()); delete formula; } @@ -94,7 +94,7 @@ TEST(CslParserTest, parseSteadyStateNoBoundFormulaTest) { ASSERT_NE(formula, nullptr); // The input was parsed correctly. - ASSERT_EQ("S = ? [P <= 0.500000 [F[0.000000,3.000000] a]]", formula->toString()); + ASSERT_EQ("S = ? (P <= 0.500000 (F[0.000000,3.000000] a))", formula->toString()); delete formula; } @@ -110,7 +110,7 @@ TEST(CslParserTest, parseProbabilisticNoBoundFormulaTest) { ASSERT_NE(formula, nullptr); // The input was parsed correctly. - ASSERT_EQ("P = ? [a U[3.000000,4.000000] (b & !c)]", formula->toString()); + ASSERT_EQ("P = ? (a U[3.000000,4.000000] (b & !c))", formula->toString()); delete formula; } @@ -127,7 +127,7 @@ TEST(CslParserTest, parseComplexFormulaTest) { ASSERT_NE(formula, nullptr); // The input was parsed correctly. - ASSERT_EQ("(S <= 0.500000 [P <= 0.500000 [a U c]] & (P > 0.500000 [G b] | !P < 0.400000 [G P > 0.900000 [F>=7.000000 (a & b)]]))", formula->toString()); + ASSERT_EQ("(S <= 0.500000 (P <= 0.500000 (a U c)) & (P > 0.500000 (G b) | !P < 0.400000 (G P > 0.900000 (F>=7.000000 (a & b)))))", formula->toString()); delete formula; } diff --git a/test/functional/parser/PrctlParserTest.cpp b/test/functional/parser/PrctlParserTest.cpp index 5db06c465..49b618ee7 100644 --- a/test/functional/parser/PrctlParserTest.cpp +++ b/test/functional/parser/PrctlParserTest.cpp @@ -63,7 +63,7 @@ TEST(PrctlParserTest, parseProbabilisticFormulaTest) { ASSERT_EQ(0.5, op->getBound()); // Test the string representation for the parsed formula. - ASSERT_EQ("P > 0.500000 [F a]", formula->toString()); + ASSERT_EQ("P > 0.500000 (F a)", formula->toString()); delete formula; @@ -86,7 +86,7 @@ TEST(PrctlParserTest, parseRewardFormulaTest) { ASSERT_EQ(15.0, op->getBound()); // Test the string representation for the parsed formula. - ASSERT_EQ("R >= 15.000000 [I=5]", formula->toString()); + ASSERT_EQ("R >= 15.000000 (I=5)", formula->toString()); delete formula; } @@ -102,7 +102,7 @@ TEST(PrctlParserTest, parseRewardNoBoundFormulaTest) { ASSERT_NE(formula, nullptr); // The input was parsed correctly. - ASSERT_EQ("R = ? [F a]", formula->toString()); + ASSERT_EQ("R = ? (F a)", formula->toString()); delete formula; } @@ -118,7 +118,7 @@ TEST(PrctlParserTest, parseProbabilisticNoBoundFormulaTest) { ASSERT_NE(formula, nullptr); // The input was parsed correctly. - ASSERT_EQ("P = ? [a U<=4 (b & !c)]", formula->toString()); + ASSERT_EQ("P = ? (a U<=4 (b & !c))", formula->toString()); delete formula; } @@ -134,7 +134,7 @@ TEST(PrctlParserTest, parseComplexFormulaTest) { ASSERT_NE(formula, nullptr); // The input was parsed correctly. - ASSERT_EQ("(R <= 0.500000 [S] & (R > 15.000000 [C <= 0.500000] | !P < 0.400000 [G P > 0.900000 [F<=7 (a & b)]]))", formula->toString()); + ASSERT_EQ("(R <= 0.500000 (S) & (R > 15.000000 (C <= 0.500000) | !P < 0.400000 (G P > 0.900000 (F<=7 (a & b)))))", formula->toString()); delete formula; } diff --git a/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp b/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp index 98db638df..259fb6c73 100644 --- a/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp +++ b/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp @@ -22,11 +22,11 @@ TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::Eventually* eventuallyFormula = new storm::property::prctl::Eventually(apFormula); - std::vector result = mc.checkMinMaxOperator(*eventuallyFormula, true); + std::vector result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -35,11 +35,11 @@ TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::BoundedEventually* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 25); - result = mc.checkMinMaxOperator(*boundedEventuallyFormula, true); + result = mc.checkOptimizingOperator(*boundedEventuallyFormula, true); ASSERT_LT(std::abs(result[0] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*boundedEventuallyFormula, false); + result = mc.checkOptimizingOperator(*boundedEventuallyFormula, false); ASSERT_LT(std::abs(result[0] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -48,11 +48,11 @@ TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::ReachabilityReward* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, true); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, true); ASSERT_LT(std::abs(result[0] - 6.172433512), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, false); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, false); ASSERT_LT(std::abs(result[0] - 6.1724344), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -78,7 +78,7 @@ TEST(SparseMdpPrctlModelCheckerTest, Consensus) { storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::Eventually* eventuallyFormula = new storm::property::prctl::Eventually(apFormula); - std::vector result = mc.checkMinMaxOperator(*eventuallyFormula, true); + std::vector result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[31168] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -89,7 +89,7 @@ TEST(SparseMdpPrctlModelCheckerTest, Consensus) { storm::property::prctl::And* andFormula = new storm::property::prctl::And(apFormula, apFormula2); eventuallyFormula = new storm::property::prctl::Eventually(andFormula); - result = mc.checkMinMaxOperator(*eventuallyFormula, true); + result = mc.checkOptimizingOperator(*eventuallyFormula, true); ASSERT_LT(std::abs(result[31168] - 0.4374282832), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -100,7 +100,7 @@ TEST(SparseMdpPrctlModelCheckerTest, Consensus) { andFormula = new storm::property::prctl::And(apFormula, apFormula2); eventuallyFormula = new storm::property::prctl::Eventually(andFormula); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[31168] - 0.5293286369), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -112,7 +112,7 @@ TEST(SparseMdpPrctlModelCheckerTest, Consensus) { andFormula = new storm::property::prctl::And(apFormula, notFormula); eventuallyFormula = new storm::property::prctl::Eventually(andFormula); - result = mc.checkMinMaxOperator(*eventuallyFormula, false); + result = mc.checkOptimizingOperator(*eventuallyFormula, false); ASSERT_LT(std::abs(result[31168] - 0.10414097), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -121,11 +121,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Consensus) { apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::BoundedEventually* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 50ull); - result = mc.checkMinMaxOperator(*boundedEventuallyFormula, true); + result = mc.checkOptimizingOperator(*boundedEventuallyFormula, true); ASSERT_LT(std::abs(result[31168] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*boundedEventuallyFormula, false); + result = mc.checkOptimizingOperator(*boundedEventuallyFormula, false); ASSERT_LT(std::abs(result[31168] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); @@ -134,11 +134,11 @@ TEST(SparseMdpPrctlModelCheckerTest, Consensus) { apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::ReachabilityReward* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, true); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, true); ASSERT_LT(std::abs(result[31168] - 1725.593313), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble()); - result = mc.checkMinMaxOperator(*reachabilityRewardFormula, false); + result = mc.checkOptimizingOperator(*reachabilityRewardFormula, false); ASSERT_LT(std::abs(result[31168] - 2183.142422), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());