Browse Source
Initial version of reward model checking for DTMCs. Added two convenience operators to PCTL (Eventually and Globally) and added missing reward formulas.
tempestpy_adaptions
Initial version of reward model checking for DTMCs. Added two convenience operators to PCTL (Eventually and Globally) and added missing reward formulas.
tempestpy_adaptions
dehnert
12 years ago
21 changed files with 1457 additions and 260 deletions
-
2src/formula/BoundedUntil.h
-
115src/formula/CumulativeReward.h
-
125src/formula/Eventually.h
-
9src/formula/Formulas.h
-
125src/formula/Globally.h
-
115src/formula/InstantaneousReward.h
-
4src/formula/ProbabilisticIntervalOperator.h
-
158src/formula/ProbabilisticOperator.h
-
122src/formula/ReachabilityReward.h
-
171src/formula/RewardIntervalOperator.h
-
110src/formula/RewardNoBoundsOperator.h
-
145src/modelChecker/DtmcPrctlModelChecker.h
-
296src/modelChecker/GmmxxDtmcPrctlModelChecker.h
-
25src/models/Dtmc.h
-
25src/solver/GraphAnalyzer.h
-
32src/storage/SquareSparseMatrix.h
-
22src/storm.cpp
-
20src/utility/CommandLine.cpp
-
24src/utility/CommandLine.h
-
53src/utility/ConstTemplates.h
-
19src/utility/Vector.h
@ -0,0 +1,115 @@ |
|||
/* |
|||
* InstantaneousReward.h |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_CUMULATIVEREWARD_H_ |
|||
#define STORM_FORMULA_CUMULATIVEREWARD_H_ |
|||
|
|||
#include "PctlPathFormula.h" |
|||
#include "PctlStateFormula.h" |
|||
#include "boost/integer/integer_mask.hpp" |
|||
#include <string> |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL (path) formula tree with a Cumulative Reward node as root. |
|||
* |
|||
* The subtrees are seen as part of the object and deleted with the object |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
* |
|||
* @see PctlPathFormula |
|||
* @see PctlFormula |
|||
*/ |
|||
template <class T> |
|||
class CumulativeReward : public PctlPathFormula<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
CumulativeReward() { |
|||
bound = 0; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param bound The time bound of the reward formula |
|||
*/ |
|||
CumulativeReward(uint_fast64_t bound) { |
|||
this->bound = bound; |
|||
} |
|||
|
|||
/*! |
|||
* Empty destructor. |
|||
*/ |
|||
virtual ~CumulativeReward() { |
|||
// Intentionally left empty. |
|||
} |
|||
|
|||
/*! |
|||
* @returns the time instance for the instantaneous reward operator |
|||
*/ |
|||
uint_fast64_t getBound() const { |
|||
return bound; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the the time instance for the instantaneous reward operator |
|||
* |
|||
* @param bound the new bound. |
|||
*/ |
|||
void setBound(uint_fast64_t bound) { |
|||
this->bound = bound; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "C<="; |
|||
result += std::to_string(bound); |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 BoundedUntil-object that is identical the called object. |
|||
*/ |
|||
virtual PctlPathFormula<T>* clone() const { |
|||
return new CumulativeReward(bound); |
|||
} |
|||
|
|||
|
|||
/*! |
|||
* 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::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkCumulativeReward(*this); |
|||
} |
|||
|
|||
private: |
|||
uint_fast64_t bound; |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_INSTANTANEOUSREWARD_H_ */ |
@ -0,0 +1,125 @@ |
|||
/* |
|||
* Next.h |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_EVENTUALLY_H_ |
|||
#define STORM_FORMULA_EVENTUALLY_H_ |
|||
|
|||
#include "PctlPathFormula.h" |
|||
#include "PctlStateFormula.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL (path) formula tree with an Eventually node as root. |
|||
* |
|||
* Has one PCTL state formula as sub formula/tree. |
|||
* |
|||
* @par Semantics |
|||
* The formula holds iff eventually \e child holds. |
|||
* |
|||
* The subtree is seen as part of the object and deleted with the object |
|||
* (this behavior can be prevented by setting them to nullptr before deletion) |
|||
* |
|||
* @see PctlPathFormula |
|||
* @see PctlFormula |
|||
*/ |
|||
template <class T> |
|||
class Eventually : public PctlPathFormula<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
Eventually() { |
|||
this->child = nullptr; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param child The child node |
|||
*/ |
|||
Eventually(PctlStateFormula<T>* child) { |
|||
this->child = child; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor. |
|||
* |
|||
* Also deletes the subtree. |
|||
* (this behaviour can be prevented by setting the subtrees to nullptr before deletion) |
|||
*/ |
|||
virtual ~Eventually() { |
|||
if (child != nullptr) { |
|||
delete child; |
|||
} |
|||
} |
|||
|
|||
/*! |
|||
* @returns the child node |
|||
*/ |
|||
const PctlStateFormula<T>& getChild() const { |
|||
return *child; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the subtree |
|||
* @param child the new child node |
|||
*/ |
|||
void setChild(PctlStateFormula<T>* child) { |
|||
this->child = child; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "F "; |
|||
result += child->toString(); |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 BoundedUntil-object that is identical the called object. |
|||
*/ |
|||
virtual PctlPathFormula<T>* clone() const { |
|||
Eventually<T>* result = new Eventually<T>(); |
|||
if (child != nullptr) { |
|||
result->setChild(child); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkEventually(*this); |
|||
} |
|||
|
|||
private: |
|||
PctlStateFormula<T>* child; |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_EVENTUALLY_H_ */ |
@ -0,0 +1,125 @@ |
|||
/* |
|||
* Next.h |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_GLOBALLY_H_ |
|||
#define STORM_FORMULA_GLOBALLY_H_ |
|||
|
|||
#include "PctlPathFormula.h" |
|||
#include "PctlStateFormula.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL (path) formula tree with a Globally node as root. |
|||
* |
|||
* Has one PCTL state formula as sub formula/tree. |
|||
* |
|||
* @par Semantics |
|||
* The formula holds iff globally \e child holds. |
|||
* |
|||
* The subtree is seen as part of the object and deleted with the object |
|||
* (this behavior can be prevented by setting them to nullptr before deletion) |
|||
* |
|||
* @see PctlPathFormula |
|||
* @see PctlFormula |
|||
*/ |
|||
template <class T> |
|||
class Globally : public PctlPathFormula<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
Globally() { |
|||
this->child = nullptr; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param child The child node |
|||
*/ |
|||
Globally(PctlStateFormula<T>* child) { |
|||
this->child = child; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor. |
|||
* |
|||
* Also deletes the subtree. |
|||
* (this behaviour can be prevented by setting the subtrees to nullptr before deletion) |
|||
*/ |
|||
virtual ~Globally() { |
|||
if (child != nullptr) { |
|||
delete child; |
|||
} |
|||
} |
|||
|
|||
/*! |
|||
* @returns the child node |
|||
*/ |
|||
const PctlStateFormula<T>& getChild() const { |
|||
return *child; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the subtree |
|||
* @param child the new child node |
|||
*/ |
|||
void setChild(PctlStateFormula<T>* child) { |
|||
this->child = child; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "G "; |
|||
result += child->toString(); |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 BoundedUntil-object that is identical the called object. |
|||
*/ |
|||
virtual PctlPathFormula<T>* clone() const { |
|||
Next<T>* result = new Next<T>(); |
|||
if (child != nullptr) { |
|||
result->setChild(child); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkGlobally(*this); |
|||
} |
|||
|
|||
private: |
|||
PctlStateFormula<T>* child; |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_GLOBALLY_H_ */ |
@ -0,0 +1,115 @@ |
|||
/* |
|||
* InstantaneousReward.h |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_INSTANTANEOUSREWARD_H_ |
|||
#define STORM_FORMULA_INSTANTANEOUSREWARD_H_ |
|||
|
|||
#include "PctlPathFormula.h" |
|||
#include "PctlStateFormula.h" |
|||
#include "boost/integer/integer_mask.hpp" |
|||
#include <string> |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL (path) formula tree with a Instantaneous Reward node as root. |
|||
* |
|||
* The subtrees are seen as part of the object and deleted with the object |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
* |
|||
* @see PctlPathFormula |
|||
* @see PctlFormula |
|||
*/ |
|||
template <class T> |
|||
class InstantaneousReward : public PctlPathFormula<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
InstantaneousReward() { |
|||
bound = 0; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param bound The time instance of the reward formula |
|||
*/ |
|||
InstantaneousReward(uint_fast64_t bound) { |
|||
this->bound = bound; |
|||
} |
|||
|
|||
/*! |
|||
* Empty destructor. |
|||
*/ |
|||
virtual ~InstantaneousReward() { |
|||
// Intentionally left empty. |
|||
} |
|||
|
|||
/*! |
|||
* @returns the time instance for the instantaneous reward operator |
|||
*/ |
|||
uint_fast64_t getBound() const { |
|||
return bound; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the the time instance for the instantaneous reward operator |
|||
* |
|||
* @param bound the new bound. |
|||
*/ |
|||
void setBound(uint_fast64_t bound) { |
|||
this->bound = bound; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "I="; |
|||
result += std::to_string(bound); |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 BoundedUntil-object that is identical the called object. |
|||
*/ |
|||
virtual PctlPathFormula<T>* clone() const { |
|||
return new InstantaneousReward(bound); |
|||
} |
|||
|
|||
|
|||
/*! |
|||
* 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::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkInstantaneousReward(*this); |
|||
} |
|||
|
|||
private: |
|||
uint_fast64_t bound; |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_INSTANTANEOUSREWARD_H_ */ |
@ -1,158 +0,0 @@ |
|||
/* |
|||
* ProbabilisticOperator.h |
|||
* |
|||
* Created on: 07.12.2012 |
|||
* Author: Thomas Heinemann |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_PROBABILISTICOPERATOR_H_ |
|||
#define STORM_FORMULA_PROBABILISTICOPERATOR_H_ |
|||
|
|||
#include "PctlStateFormula.h" |
|||
|
|||
namespace storm { |
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL formula tree with a P (probablistic) operator node over a single real valued |
|||
* probability as root. |
|||
* |
|||
* If the probability interval consist just of one single value (i.e. it is [x,x] for some |
|||
* real number x), the class ProbabilisticOperator should be used instead. |
|||
* |
|||
* |
|||
* Has one PCTL path formula as sub formula/tree. |
|||
* |
|||
* @par Semantics |
|||
* The formula holds iff the probability that the path formula holds is equal to the probablility |
|||
* specified in this operator |
|||
* |
|||
* The subtree is seen as part of the object and deleted with it |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
* |
|||
* |
|||
* @see PctlStateFormula |
|||
* @see PctlPathFormula |
|||
* @see ProbabilisticIntervalOperator |
|||
* @see ProbabilisticNoBoundsOperator |
|||
* @see PctlFormula |
|||
*/ |
|||
template<class T> |
|||
class ProbabilisticOperator : public storm::formula::PctlStateFormula<T> { |
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
ProbabilisticOperator() { |
|||
this->pathFormula = NULL; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param bound The expected value for path formulas |
|||
* @param pathFormula The child node |
|||
*/ |
|||
ProbabilisticOperator(T bound, PctlPathFormula<T>* pathFormula) { |
|||
this->bound = bound; |
|||
this->pathFormula = *pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* Destructor |
|||
* |
|||
* The subtree is deleted with the object |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
*/ |
|||
virtual ~ProbabilisticOperator() { |
|||
if (pathFormula != NULL) { |
|||
delete pathFormula; |
|||
} |
|||
} |
|||
|
|||
/*! |
|||
* @returns the child node (representation of a PCTL path formula) |
|||
*/ |
|||
const PctlPathFormula<T>& getPathFormula () const { |
|||
return *pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* @returns the bound for the probability |
|||
*/ |
|||
const T& getBound() const { |
|||
return bound; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the child node |
|||
* |
|||
* @param pathFormula the path formula that becomes the new child node |
|||
*/ |
|||
void setPathFormula(PctlPathFormula<T>* pathFormula) { |
|||
this->pathFormula = pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the expected probability that the path formula holds. |
|||
* |
|||
* @param bound The bound for the probability |
|||
*/ |
|||
void setBound(T bound) { |
|||
this->bound = bound; |
|||
} |
|||
|
|||
/*! |
|||
* 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 ProbabilisticOperator-object that is identical to the called object. |
|||
*/ |
|||
virtual PctlStateFormula<T>* clone() const { |
|||
ProbabilisticOperator<T>* result = new ProbabilisticOperator<T>(); |
|||
result->setBound(bound); |
|||
if (pathFormula != NULL) { |
|||
result->setPathFormula(pathFormula->clone()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 bit vector indicating all states that satisfy the formula represented by the |
|||
* called object. |
|||
*/ |
|||
virtual storm::storage::BitVector *check( |
|||
const storm::modelChecker::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkProbabilisticOperator(*this); |
|||
} |
|||
|
|||
/*! |
|||
* Returns a string representation of this PctlStateFormula |
|||
* |
|||
* @returns a string representation of this PctlStateFormula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = " P="; |
|||
result += std::to_string(bound); |
|||
result += " ("; |
|||
result += pathFormula->toString(); |
|||
result += ")"; |
|||
return result; |
|||
} |
|||
private: |
|||
T bound; |
|||
PctlPathFormula<T>* pathFormula; |
|||
}; |
|||
|
|||
} /* namespace formula */ |
|||
} /* namespace storm */ |
|||
|
|||
#endif /* STORM_FORMULA_PROBABILISTICOPERATOR_H_ */ |
@ -0,0 +1,122 @@ |
|||
/* |
|||
* Next.h |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_REACHABILITYREWARD_H_ |
|||
#define STORM_FORMULA_REACHABILITYREWARD_H_ |
|||
|
|||
#include "PctlPathFormula.h" |
|||
#include "PctlStateFormula.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL (path) formula tree with an Reachability Reward node as root. |
|||
* |
|||
* Has one PCTL state formula as sub formula/tree. |
|||
* |
|||
* The subtree is seen as part of the object and deleted with the object |
|||
* (this behavior can be prevented by setting them to nullptr before deletion) |
|||
* |
|||
* @see PctlPathFormula |
|||
* @see PctlFormula |
|||
*/ |
|||
template <class T> |
|||
class ReachabilityReward : public PctlPathFormula<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
ReachabilityReward() { |
|||
this->child = nullptr; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param child The child node |
|||
*/ |
|||
ReachabilityReward(PctlStateFormula<T>* child) { |
|||
this->child = child; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor. |
|||
* |
|||
* Also deletes the subtree. |
|||
* (this behaviour can be prevented by setting the subtrees to nullptr before deletion) |
|||
*/ |
|||
virtual ~ReachabilityReward() { |
|||
if (child != nullptr) { |
|||
delete child; |
|||
} |
|||
} |
|||
|
|||
/*! |
|||
* @returns the child node |
|||
*/ |
|||
const PctlStateFormula<T>& getChild() const { |
|||
return *child; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the subtree |
|||
* @param child the new child node |
|||
*/ |
|||
void setChild(PctlStateFormula<T>* child) { |
|||
this->child = child; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "F "; |
|||
result += child->toString(); |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 BoundedUntil-object that is identical the called object. |
|||
*/ |
|||
virtual PctlPathFormula<T>* clone() const { |
|||
ReachabilityReward<T>* result = new ReachabilityReward<T>(); |
|||
if (child != nullptr) { |
|||
result->setChild(child); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkReachabilityReward(*this); |
|||
} |
|||
|
|||
private: |
|||
PctlStateFormula<T>* child; |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_REACHABILITYREWARD_H_ */ |
@ -0,0 +1,171 @@ |
|||
/* |
|||
* ProbabilisticOperator.h |
|||
* |
|||
* Created on: 19.10.2012 |
|||
* Author: Thomas Heinemann |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_REWARDINTERVALOPERATOR_H_ |
|||
#define STORM_FORMULA_REWARDINTERVALOPERATOR_H_ |
|||
|
|||
#include "PctlStateFormula.h" |
|||
#include "PctlPathFormula.h" |
|||
#include "utility/ConstTemplates.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL formula tree with a R (reward) operator node over a reward interval as root. |
|||
* |
|||
* Has a reward path formula as sub formula/tree. |
|||
* |
|||
* @par Semantics |
|||
* The formula holds iff the reward of the reward path formula is inside the bounds |
|||
* specified in this operator |
|||
* |
|||
* The subtree is seen as part of the object and deleted with it |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
* |
|||
* |
|||
* @see PctlStateFormula |
|||
* @see PctlPathFormula |
|||
* @see ProbabilisticOperator |
|||
* @see ProbabilisticNoBoundsOperator |
|||
* @see PctlFormula |
|||
*/ |
|||
template<class T> |
|||
class RewardIntervalOperator : public PctlStateFormula<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
RewardIntervalOperator() { |
|||
upper = storm::utility::constGetZero<T>(); |
|||
lower = storm::utility::constGetZero<T>(); |
|||
pathFormula = nullptr; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param lowerBound The lower bound for the probability |
|||
* @param upperBound The upper bound for the probability |
|||
* @param pathFormula The child node |
|||
*/ |
|||
RewardIntervalOperator(T lowerBound, T upperBound, PctlPathFormula<T>& pathFormula) { |
|||
this->lower = lowerBound; |
|||
this->upper = upperBound; |
|||
this->pathFormula = &pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* Destructor |
|||
* |
|||
* The subtree is deleted with the object |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
*/ |
|||
virtual ~RewardIntervalOperator() { |
|||
if (pathFormula != nullptr) { |
|||
delete pathFormula; |
|||
} |
|||
} |
|||
|
|||
/*! |
|||
* @returns the child node (representation of a PCTL path formula) |
|||
*/ |
|||
const PctlPathFormula<T>& getPathFormula () const { |
|||
return *pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* @returns the lower bound for the probability |
|||
*/ |
|||
const T& getLowerBound() const { |
|||
return lower; |
|||
} |
|||
|
|||
/*! |
|||
* @returns the upper bound for the probability |
|||
*/ |
|||
const T& getUpperBound() const { |
|||
return upper; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the child node |
|||
* |
|||
* @param pathFormula the path formula that becomes the new child node |
|||
*/ |
|||
void setPathFormula(PctlPathFormula<T>* pathFormula) { |
|||
this->pathFormula = pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the interval in which the probability that the path formula holds may lie in. |
|||
* |
|||
* @param lowerBound The lower bound for the probability |
|||
* @param upperBound The upper bound for the probability |
|||
*/ |
|||
void setInterval(T lowerBound, T upperBound) { |
|||
this->lower = lowerBound; |
|||
this->upper = upperBound; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "R ["; |
|||
result += std::to_string(lower); |
|||
result += ", "; |
|||
result += std::to_string(upper); |
|||
result += "] ["; |
|||
result += pathFormula->toString(); |
|||
result += "]"; |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 AND-object that is identical the called object. |
|||
*/ |
|||
virtual PctlStateFormula<T>* clone() const { |
|||
RewardIntervalOperator<T>* result = new RewardIntervalOperator<T>(); |
|||
result->setInterval(lower, upper); |
|||
if (pathFormula != nullptr) { |
|||
result->setPathFormula(pathFormula->clone()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/*! |
|||
* 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 bit vector indicating all states that satisfy the formula represented by the called object. |
|||
*/ |
|||
virtual storm::storage::BitVector *check(const storm::modelChecker::DtmcPrctlModelChecker<T>& modelChecker) const { |
|||
return modelChecker.checkRewardIntervalOperator(*this); |
|||
} |
|||
|
|||
private: |
|||
T lower; |
|||
T upper; |
|||
PctlPathFormula<T>* pathFormula; |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_REWARDINTERVALOPERATOR_H_ */ |
@ -0,0 +1,110 @@ |
|||
/* |
|||
* RewardNoBoundsOperator.h |
|||
* |
|||
* Created on: 12.12.2012 |
|||
* Author: thomas |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_REWARDNOBOUNDSOPERATOR_H_ |
|||
#define STORM_FORMULA_REWARDNOBOUNDSOPERATOR_H_ |
|||
|
|||
#include "PctlFormula.h" |
|||
#include "PctlPathFormula.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL formula tree with a R (reward) operator without declaration of reward values |
|||
* as root. |
|||
* |
|||
* Checking a formula with this operator as root returns the reward for the reward path formula for |
|||
* each state |
|||
* |
|||
* Has one PCTL path formula as sub formula/tree. |
|||
* |
|||
* @note |
|||
* This class is a hybrid of a state and path formula, and may only appear as the outermost operator. |
|||
* Hence, it is seen as neither a state nor a path formula, but is directly derived from PctlFormula. |
|||
* |
|||
* @note |
|||
* This class does not contain a check() method like the other formula classes. |
|||
* The check method should only be called by the model checker to infer the correct check function for sub |
|||
* formulas. As this operator can only appear at the root, the method is not useful here. |
|||
* Use the checkRewardNoBoundsOperator method from the DtmcPrctlModelChecker class instead. |
|||
* |
|||
* The subtree is seen as part of the object and deleted with it |
|||
* (this behavior can be prevented by setting them to NULL before deletion) |
|||
* |
|||
* |
|||
* @see PctlStateFormula |
|||
* @see PctlPathFormula |
|||
* @see ProbabilisticOperator |
|||
* @see ProbabilisticIntervalOperator |
|||
* @see PctlFormula |
|||
*/ |
|||
template <class T> |
|||
class RewardNoBoundsOperator: public storm::formula::PctlFormula<T> { |
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
RewardNoBoundsOperator() { |
|||
this->pathFormula = nullptr; |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param pathFormula The child node. |
|||
*/ |
|||
RewardNoBoundsOperator(PctlPathFormula<T>* pathFormula) { |
|||
this->pathFormula = pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* Destructor |
|||
*/ |
|||
virtual ~RewardNoBoundsOperator() { |
|||
if (pathFormula != nullptr) { |
|||
delete pathFormula; |
|||
} |
|||
} |
|||
|
|||
/*! |
|||
* @returns the child node (representation of a PCTL path formula) |
|||
*/ |
|||
const PctlPathFormula<T>& getPathFormula () const { |
|||
return *pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* Sets the child node |
|||
* |
|||
* @param pathFormula the path formula that becomes the new child node |
|||
*/ |
|||
void setPathFormula(PctlPathFormula<T>* pathFormula) { |
|||
this->pathFormula = pathFormula; |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = " R=? ["; |
|||
result += pathFormula->toString(); |
|||
result += "]"; |
|||
return result; |
|||
} |
|||
|
|||
private: |
|||
PctlPathFormula<T>* pathFormula; |
|||
}; |
|||
|
|||
} /* namespace formula */ |
|||
|
|||
} /* namespace storm */ |
|||
|
|||
#endif /* STORM_FORMULA_REWARDNOBOUNDSOPERATOR_H_ */ |
@ -0,0 +1,20 @@ |
|||
/*
|
|||
* CommandLine.cpp |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#include <ostream>
|
|||
|
|||
namespace storm { |
|||
|
|||
namespace utility { |
|||
|
|||
void printSeparationLine(std::ostream& out) { |
|||
out << "------------------------------------------------------" << std::endl; |
|||
} |
|||
|
|||
} // namespace utility
|
|||
|
|||
} // namespace storm
|
@ -0,0 +1,24 @@ |
|||
/* |
|||
* CommandLine.h |
|||
* |
|||
* Created on: 26.12.2012 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_UTILITY_COMMANDLINE_H_ |
|||
#define STORM_UTILITY_COMMANDLINE_H_ |
|||
|
|||
namespace storm { |
|||
|
|||
namespace utility { |
|||
|
|||
/*! |
|||
* Prints a separation line on the command line. |
|||
*/ |
|||
void printSeparationLine(std::ostream& out); |
|||
|
|||
} //namespace utility |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_UTILITY_COMMANDLINE_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue