Browse Source
Convenient file parser for PRCTL, and correct reward formula parsing
Convenient file parser for PRCTL, and correct reward formula parsing
(together with some necessary code for that)tempestpy_adaptions
Lanchid
12 years ago
10 changed files with 251 additions and 134 deletions
-
8src/formula/AbstractFormulaChecker.h
-
9src/formula/CumulativeReward.h
-
3src/formula/Formulas.h
-
106src/formula/SteadyStateReward.h
-
11src/modelchecker/AbstractModelChecker.h
-
88src/modelchecker/DtmcPrctlModelChecker.h
-
71src/parser/PrctlFileParser.cpp
-
38src/parser/PrctlFileParser.h
-
31src/parser/PrctlParser.cpp
-
16test/parser/PrctlParserTest.cpp
@ -0,0 +1,106 @@ |
|||
/* |
|||
* SteadyStateReward.h |
|||
* |
|||
* Created on: 08.04.2013 |
|||
* Author: thomas |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_STEADYSTATEREWARD_H_ |
|||
#define STORM_FORMULA_STEADYSTATEREWARD_H_ |
|||
|
|||
#include "AbstractPathFormula.h" |
|||
#include "AbstractStateFormula.h" |
|||
#include "src/formula/AbstractFormulaChecker.h" |
|||
#include <string> |
|||
|
|||
namespace storm { |
|||
namespace formula { |
|||
|
|||
template <class T> class SteadyStateReward; |
|||
|
|||
/*! |
|||
* @brief Interface class for model checkers that support SteadyStateReward. |
|||
* |
|||
* All model checkers that support the formula class SteadyStateReward must inherit |
|||
* this pure virtual class. |
|||
*/ |
|||
template <class T> |
|||
class ISteadyStateRewardModelChecker { |
|||
public: |
|||
/*! |
|||
* @brief Evaluates CumulativeReward formula within a model checker. |
|||
* |
|||
* @param obj Formula object with subformulas. |
|||
* @return Result of the formula for every node. |
|||
*/ |
|||
virtual std::vector<T>* checkSteadyStateReward(const SteadyStateReward<T>& obj, bool qualitative) const = 0; |
|||
}; |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a Abstract (path) formula tree with a Steady State Reward node as root. |
|||
* |
|||
* @see AbstractPathFormula |
|||
* @see AbstractFormula |
|||
*/ |
|||
template <class T> |
|||
class SteadyStateReward: public storm::formula::AbstractPathFormula<T> { |
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
SteadyStateReward() { |
|||
// Intentionally left empty |
|||
|
|||
} |
|||
virtual ~SteadyStateReward() { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
return "S"; |
|||
} |
|||
|
|||
/*! |
|||
* Clones the called object. |
|||
* |
|||
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones |
|||
* |
|||
* @returns a new SteadyState-object that is identical the called object. |
|||
*/ |
|||
virtual AbstractPathFormula<T>* clone() const { |
|||
return new SteadyStateReward<T>(); |
|||
} |
|||
|
|||
/*! |
|||
* Calls the model checker to check this formula. |
|||
* Needed to infer the correct type of formula class. |
|||
* |
|||
* @note This function should only be called in a generic check function of a model checker class. For other uses, |
|||
* the methods of the model checker should be used. |
|||
* |
|||
* @returns A vector indicating the probability that the formula holds for each state. |
|||
*/ |
|||
virtual std::vector<T> *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker, bool qualitative) const { |
|||
return modelChecker.template as<ISteadyStateRewardModelChecker>()->checkSteadyStateReward(*this, qualitative); |
|||
} |
|||
|
|||
/*! |
|||
* @brief Checks if all subtrees conform to some logic. |
|||
* |
|||
* As SteadyStateReward objects have no subformulas, we return true here. |
|||
* |
|||
* @param checker Formula checker object. |
|||
* @return true |
|||
*/ |
|||
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const { |
|||
return true; |
|||
} |
|||
}; |
|||
|
|||
} /* namespace formula */ |
|||
} /* namespace storm */ |
|||
#endif /* STEADYSTATEREWARD_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue