Browse Source
Made bound/no-bound operators more consistent to reduce similar code. Changed bound operators to have a single bound and a comparison operator instead of an interval.
tempestpy_adaptions
Made bound/no-bound operators more consistent to reduce similar code. Changed bound operators to have a single bound and a comparison operator instead of an interval.
tempestpy_adaptions
dehnert
12 years ago
11 changed files with 398 additions and 393 deletions
-
6CMakeLists.txt
-
104src/formula/BoundOperator.h
-
8src/formula/Formulas.h
-
46src/formula/NoBoundOperator.h
-
96src/formula/ProbabilisticBoundOperator.h
-
83src/formula/ProbabilisticNoBoundOperator.h
-
95src/formula/RewardBoundOperator.h
-
171src/formula/RewardIntervalOperator.h
-
55src/formula/RewardNoBoundOperator.h
-
109src/modelChecker/DtmcPrctlModelChecker.h
-
18src/storm.cpp
@ -0,0 +1,96 @@ |
|||
/* |
|||
* ProbabilisticBoundOperator.h |
|||
* |
|||
* Created on: 19.10.2012 |
|||
* Author: Thomas Heinemann |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_PROBABILISTICBOUNDOPERATOR_H_ |
|||
#define STORM_FORMULA_PROBABILISTICBOUNDOPERATOR_H_ |
|||
|
|||
#include "PctlStateFormula.h" |
|||
#include "PctlPathFormula.h" |
|||
#include "BoundOperator.h" |
|||
#include "utility/ConstTemplates.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL formula tree with a P (probablistic) operator node over a probability interval |
|||
* as root. |
|||
* |
|||
* Has one PCTL path formula as sub formula/tree. |
|||
* |
|||
* @par Semantics |
|||
* The formula holds iff the probability that the path formula holds 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 ProbabilisticBoundOperator : public BoundOperator<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
ProbabilisticBoundOperator() : BoundOperator<T>(storm::utility::constGetZero<T>(), storm::utility::constGetZero<T>(), nullptr) { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param lowerBound The lower bound for the probability |
|||
* @param upperBound The upper bound for the probability |
|||
* @param pathFormula The child node |
|||
*/ |
|||
ProbabilisticBoundOperator(T lowerBound, T upperBound, PctlPathFormula<T>& pathFormula) : BoundOperator<T>(lowerBound, upperBound, pathFormula) { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "P ["; |
|||
result += std::to_string(this->getLowerBound()); |
|||
result += ","; |
|||
result += std::to_string(this->getUpperBound()); |
|||
result += "] ("; |
|||
result += this->getPathFormula()->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 { |
|||
ProbabilisticBoundOperator<T>* result = new ProbabilisticBoundOperator<T>(); |
|||
result->setInterval(this->getLowerBound(), this->getUpperBound()); |
|||
result->setPathFormula(this->getPathFormula()->clone()); |
|||
return result; |
|||
} |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_PROBABILISTICBOUNDOPERATOR_H_ */ |
@ -0,0 +1,83 @@ |
|||
/* |
|||
* ProbabilisticNoBoundOperator.h |
|||
* |
|||
* Created on: 12.12.2012 |
|||
* Author: thomas |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_PROBABILISTICNOBOUNDOPERATOR_H_ |
|||
#define STORM_FORMULA_PROBABILISTICNOBOUNDOPERATOR_H_ |
|||
|
|||
#include "PctlFormula.h" |
|||
#include "PctlPathFormula.h" |
|||
#include "NoBoundOperator.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace formula { |
|||
|
|||
/*! |
|||
* @brief |
|||
* Class for a PCTL formula tree with a P (probablistic) operator without declaration of probabilities |
|||
* as root. |
|||
* |
|||
* Checking a formula with this operator as root returns the probabilities that the path formula holds |
|||
* (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 checkProbabilisticNoBoundOperator 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 ProbabilisticNoBoundOperator: public NoBoundOperator<T> { |
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
ProbabilisticNoBoundOperator() : NoBoundOperator<T>(nullptr) { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param pathFormula The child node. |
|||
*/ |
|||
ProbabilisticNoBoundOperator(PctlPathFormula<T>* pathFormula) : NoBoundOperator<T>(pathFormula) { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = " P=? ["; |
|||
result += this->getPathFormula().toString(); |
|||
result += "]"; |
|||
return result; |
|||
} |
|||
}; |
|||
|
|||
} /* namespace formula */ |
|||
|
|||
} /* namespace storm */ |
|||
|
|||
#endif /* STORM_FORMULA_PROBABILISTICNOBOUNDOPERATOR_H_ */ |
@ -0,0 +1,95 @@ |
|||
/* |
|||
* RewardBoundOperator.h |
|||
* |
|||
* Created on: 19.10.2012 |
|||
* Author: Thomas Heinemann |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_REWARDBOUNDOPERATOR_H_ |
|||
#define STORM_FORMULA_REWARDBOUNDOPERATOR_H_ |
|||
|
|||
#include "PctlStateFormula.h" |
|||
#include "PctlPathFormula.h" |
|||
#include "BoundOperator.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 RewardBoundOperator : public BoundOperator<T> { |
|||
|
|||
public: |
|||
/*! |
|||
* Empty constructor |
|||
*/ |
|||
RewardBoundOperator() : BoundOperator<T>(storm::utility::constGetZero<T>(), storm::utility::constGetZero<T>(), nullptr) { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* Constructor |
|||
* |
|||
* @param lowerBound The lower bound for the probability |
|||
* @param upperBound The upper bound for the probability |
|||
* @param pathFormula The child node |
|||
*/ |
|||
RewardBoundOperator(T lowerBound, T upperBound, PctlPathFormula<T>& pathFormula) : BoundOperator<T>(lowerBound, upperBound, pathFormula) { |
|||
// Intentionally left empty |
|||
} |
|||
|
|||
/*! |
|||
* @returns a string representation of the formula |
|||
*/ |
|||
virtual std::string toString() const { |
|||
std::string result = "R ["; |
|||
result += std::to_string(this->getLowerBound()); |
|||
result += ", "; |
|||
result += std::to_string(this->getUpperBound()); |
|||
result += "] ["; |
|||
result += this->getPathFormula()->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 { |
|||
RewardBoundOperator<T>* result = new RewardBoundOperator<T>(); |
|||
result->setBound(this->getLowerBound(), this->getUpperBound()); |
|||
result->setPathFormula(this->getPathFormula()->clone()); |
|||
return result; |
|||
} |
|||
}; |
|||
|
|||
} //namespace formula |
|||
|
|||
} //namespace storm |
|||
|
|||
#endif /* STORM_FORMULA_REWARDBOUNDOPERATOR_H_ */ |
@ -1,171 +0,0 @@ |
|||
/* |
|||
* 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_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue