Browse Source

Code style for formula classes

main
Lanchid 13 years ago
parent
commit
350f1a0990
  1. 138
      src/formula/AP.h
  2. 229
      src/formula/And.h
  3. 275
      src/formula/BoundedUntil.h
  4. 170
      src/formula/Next.h
  5. 164
      src/formula/Not.h
  6. 230
      src/formula/Or.h
  7. 53
      src/formula/PCTLPathFormula.h
  8. 53
      src/formula/PCTLStateFormula.h
  9. 23
      src/formula/PCTLformula.h
  10. 247
      src/formula/ProbabilisticOperator.h
  11. 225
      src/formula/Until.h

138
src/formula/AP.h

@ -25,74 +25,76 @@ namespace formula {
*/ */
template <class T> template <class T>
class AP : public PCTLStateFormula<T> { class AP : public PCTLStateFormula<T> {
private: public:
std::string ap; /*!
public: * Constructor
/*! *
* Constructor * Creates a new atomic proposition leaf, with the label AP
* *
* Creates a new atomic proposition leaf, with the label AP * @param ap The string representing the atomic proposition
* */
* @param ap The string representing the atomic proposition AP(std::string ap) {
*/ this->ap = ap;
AP(std::string ap) { }
this->ap = ap; /*!
} * Constructor
*
/*! * Creates a new atomic proposition leaf, with the label AP
* Constructor *
* * @param ap The string representing the atomic proposition
* Creates a new atomic proposition leaf, with the label AP */
* AP(char* ap) {
* @param ap The string representing the atomic proposition //TODO: Does that really work?
*/ this->ap = ap;
AP(char* ap) { }
//TODO: Does that really work? /*!
this->ap = ap; * Destructor.
} * At this time, empty...
*/
/*! virtual ~AP() { }
* Destructor. /*!
* At this time, empty... * @returns the name of the atomic proposition
*/ */
virtual ~AP() { } std::string getAP() {
return ap;
/*! }
* @returns the name of the atomic proposition /*!
*/ * @returns a string representation of the leaf.
std::string getAP() { *
return ap; */
} virtual std::string toString() {
return getAP();
/*! }
* @returns a string representation of the leaf. /*!
* * Clones the called object.
*/ *
virtual std::string toString() { * @returns a new AP-object that is identical the called object.
return getAP(); */
} virtual PCTLStateFormula<T>* clone() {
return new AP(ap);
/*! }
* Clones the called object. /*!
* * Calls the model checker to check this formula.
* @returns a new AP-object that is identical the called object. * Needed to infer the correct type of formula class.
*/ *
virtual PCTLStateFormula<T>* clone() { * @note This function should only be called in a generic check function of a model checker class. For other uses,
return new AP(ap); * 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.
/*! */
* Calls the model checker to check this formula. virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
* Needed to infer the correct type of formula class. return modelChecker->checkAP(this);
* }
* @note This function should only be called in a generic check function of a model checker class. For other uses, private:
* the methods of the model checker should be used. std::string ap;
*
* @returns A bit vector indicating all states that satisfy the formula represented by the called object.
*/
virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkAP(this);
}
}; };
} //namespace formula } //namespace formula

229
src/formula/And.h

@ -32,121 +32,122 @@ namespace formula {
*/ */
template <class T> template <class T>
class And : public PCTLStateFormula<T> { class And : public PCTLStateFormula<T> {
private:
PCTLStateFormula<T>* left;
PCTLStateFormula<T>* right;
public:
/*!
* Empty constructor.
* Will create an AND-node without subnotes. Will not represent a complete formula!
*/
And() {
left = NULL;
right = NULL;
}
/*!
* Constructor.
* Creates an AND note with the parameters as subtrees.
*
* @param left The left sub formula
* @param right The right sub formula
*/
And(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right) {
this->left = left;
this->right = right;
}
/*!
* Destructor.
*
* The subtrees are deleted with the object
* (this behavior can be prevented by setting them to NULL before deletion)
*/
virtual ~And() {
if (left != NULL) {
delete left;
}
if (right != NULL) {
delete right;
}
}
/*!
* Sets the left child node.
*
* @param newLeft the new left child.
*/
void setLeft(PCTLStateFormula<T>* newLeft) {
left = newLeft;
}
/*!
* Sets the right child node.
*
* @param newRight the new right child.
*/
void setRight(PCTLStateFormula<T>* newRight) {
right = newRight;
}
/*!
* @returns a pointer to the left child node
*/
PCTLStateFormula<T>* getLeft() {
return left;
}
/*!
* @returns a pointer to the right child node
*/
PCTLStateFormula<T>* getRight() {
return right;
}
/*!
* @returns a string representation of the formula
*/
virtual std::string toString() {
std::string result = "(";
result += left->toString();
result += " && ";
result += right->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() {
And<T>* result = new And();
if (this->left != NULL) {
result->setLeft(left->clone());
}
if (this->right != NULL) {
result->setRight(right->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 mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkAnd(this);
}
public:
/*!
* Empty constructor.
* Will create an AND-node without subnotes. Will not represent a complete formula!
*/
And() {
left = NULL;
right = NULL;
}
/*!
* Constructor.
* Creates an AND note with the parameters as subtrees.
*
* @param left The left sub formula
* @param right The right sub formula
*/
And(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right) {
this->left = left;
this->right = right;
}
/*!
* Destructor.
*
* The subtrees are deleted with the object
* (this behavior can be prevented by setting them to NULL before deletion)
*/
virtual ~And() {
if (left != NULL) {
delete left;
}
if (right != NULL) {
delete right;
}
}
/*!
* Sets the left child node.
*
* @param newLeft the new left child.
*/
void setLeft(PCTLStateFormula<T>* newLeft) {
left = newLeft;
}
/*!
* Sets the right child node.
*
* @param newRight the new right child.
*/
void setRight(PCTLStateFormula<T>* newRight) {
right = newRight;
}
/*!
* @returns a pointer to the left child node
*/
PCTLStateFormula<T>* getLeft() {
return left;
}
/*!
* @returns a pointer to the right child node
*/
PCTLStateFormula<T>* getRight() {
return right;
}
/*!
* @returns a string representation of the formula
*/
virtual std::string toString() {
std::string result = "(";
result += left->toString();
result += " && ";
result += right->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() {
And<T>* result = new And();
if (this->left != NULL) {
result->setLeft(left->clone());
}
if (this->right != NULL) {
result->setRight(right->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 mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkAnd(this);
}
private:
PCTLStateFormula<T>* left;
PCTLStateFormula<T>* right;
}; };
} //namespace formula } //namespace formula

275
src/formula/BoundedUntil.h

@ -36,142 +36,145 @@ namespace formula {
*/ */
template <class T> template <class T>
class BoundedUntil : public PCTLPathFormula<T> { class BoundedUntil : public PCTLPathFormula<T> {
PCTLStateFormula<T>* left; public:
PCTLStateFormula<T>* right; /*!
uint_fast64_t bound; * Empty constructor
public: */
/*! BoundedUntil() {
* Empty constructor this->left = NULL;
*/ this->right = NULL;
BoundedUntil() { bound = 0;
this->left = NULL; }
this->right = NULL; /*!
bound = 0; * Constructor
} *
* @param left The left formula subtree
/*! * @param right The left formula subtree
* Constructor * @param bound The maximal number of steps
* */
* @param left The left formula subtree BoundedUntil(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right,
* @param right The left formula subtree uint_fast64_t bound) {
* @param bound The maximal number of steps this->left = left;
*/ this->right = right;;
BoundedUntil(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right, this->bound = bound;
uint_fast64_t bound) { }
this->left = left; /*!
this->right = right;; * Destructor.
this->bound = bound; *
} * Also deletes the subtrees.
* (this behaviour can be prevented by setting the subtrees to NULL before deletion)
/*! */
* Destructor. virtual ~BoundedUntil() {
* if (left != NULL) {
* Also deletes the subtrees. delete left;
* (this behaviour can be prevented by setting the subtrees to NULL before deletion) }
*/ if (right != NULL) {
virtual ~BoundedUntil() { delete right;
if (left != NULL) { }
delete left; }
} /*!
if (right != NULL) { * Sets the left child node.
delete right; *
} * @param newLeft the new left child.
} */
void setLeft(PCTLStateFormula<T>* newLeft) {
/*! left = newLeft;
* Sets the left child node. }
* /*!
* @param newLeft the new left child. * Sets the right child node.
*/ *
void setLeft(PCTLStateFormula<T>* newLeft) { * @param newRight the new right child.
left = newLeft; */
} void setRight(PCTLStateFormula<T>* newRight) {
right = newRight;
/*! }
* Sets the right child node. /*!
* * @returns a pointer to the left child node
* @param newRight the new right child. */
*/ PCTLStateFormula<T>* getLeft() {
void setRight(PCTLStateFormula<T>* newRight) { return left;
right = newRight; }
} /*!
* @returns a pointer to the right child node
/*! */
* @returns a pointer to the left child node PCTLStateFormula<T>* getRight() {
*/ return right;
PCTLStateFormula<T>* getLeft() { }
return left; /*!
} * @returns the maximally allowed number of steps for the bounded until operator
*/
/*! uint_fast64_t getBound() {
* @returns a pointer to the right child node return bound;
*/ }
PCTLStateFormula<T>* getRight() { /*!
return right; * Sets the maximally allowed number of steps for the bounded until operator
} *
* @param bound the new bound.
/*! */
* @returns the maximally allowed number of steps for the bounded until operator void setBound(uint_fast64_t bound) {
*/ this->bound = bound;
uint_fast64_t getBound() { }
return bound; /*!
} * @returns a string representation of the formula
*/
/*! virtual std::string toString() {
* Sets the maximally allowed number of steps for the bounded until operator std::string result = "(";
* result += left->toString();
* @param bound the new bound. result += " U<=";
*/ result += boost::lexical_cast<std::string>(bound);
void setBound(uint_fast64_t bound) { result += " ";
this->bound = bound; result += right->toString();
} result += ")";
return result;
/*! }
* @returns a string representation of the formula /*!
*/ * Clones the called object.
virtual std::string toString() { *
std::string result = "("; * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
result += left->toString(); *
result += " U<="; * @returns a new BoundedUntil-object that is identical the called object.
result += boost::lexical_cast<std::string>(bound); */
result += " "; virtual PCTLPathFormula<T>* clone() {
result += right->toString(); BoundedUntil<T>* result = new BoundedUntil();
result += ")"; result->setBound(bound);
return result; if (left != NULL) {
} result->setLeft(left->clone());
}
/*! if (right != NULL) {
* Clones the called object. result->setRight(right->clone());
* }
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones return result;
* }
* @returns a new BoundedUntil-object that is identical the called object. /*!
*/ * Calls the model checker to check this formula.
virtual PCTLPathFormula<T>* clone() { * Needed to infer the correct type of formula class.
BoundedUntil<T>* result = new BoundedUntil(); *
result->setBound(bound); * @note This function should only be called in a generic check function of a model checker class. For other uses,
if (left != NULL) { * the methods of the model checker should be used.
result->setLeft(left->clone()); *
} * @returns A vector indicating the probability that the formula holds for each state.
if (right != NULL) { */
result->setRight(right->clone()); virtual std::vector<T> *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
} return modelChecker->checkBoundedUntil(this);
return result; }
} private:
PCTLStateFormula<T>* left;
PCTLStateFormula<T>* right;
/*! uint_fast64_t 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(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkBoundedUntil(this);
}
}; };
} //namespace formula } //namespace formula

170
src/formula/Next.h

@ -32,90 +32,92 @@ namespace formula {
*/ */
template <class T> template <class T>
class Next : public PCTLPathFormula<T> { class Next : public PCTLPathFormula<T> {
private: public:
PCTLStateFormula<T>* child; /*!
public: * Empty constructor
/*! */
* Empty constructor Next() {
*/ this->child = NULL;
Next() { }
this->child = NULL; /*!
} * Constructor
*
/*! * @param child The child node
* Constructor */
* Next(PCTLStateFormula<T>* child) {
* @param child The child node this->child = child;
*/ }
Next(PCTLStateFormula<T>* child) { /*!
this->child = child; * Constructor.
} *
* Also deletes the subtree.
/*! * (this behaviour can be prevented by setting the subtrees to NULL before deletion)
* Constructor. */
* virtual ~Next() {
* Also deletes the subtree. if (child != NULL) {
* (this behaviour can be prevented by setting the subtrees to NULL before deletion) delete child;
*/ }
virtual ~Next() { }
if (child != NULL) { /*!
delete child; * @returns the child node
} */
} PCTLStateFormula<T>* getChild() {
return child;
/*! }
* @returns the child node /*!
*/ * Sets the subtree
PCTLStateFormula<T>* getChild() { * @param child the new child node
return child; */
} void setChild(PCTLStateFormula<T>* child) {
this->child = child;
/*! }
* Sets the subtree /*!
* @param child the new child node * @returns a string representation of the formula
*/ */
void setChild(PCTLStateFormula<T>* child) { virtual std::string toString() {
this->child = child; std::string result = "(";
} result += " X ";
result += child->toString();
/*! result += ")";
* @returns a string representation of the formula return result;
*/ }
virtual std::string toString() { /*!
std::string result = "("; * Clones the called object.
result += " X "; *
result += child->toString(); * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
result += ")"; *
return result; * @returns a new BoundedUntil-object that is identical the called object.
} */
virtual PCTLPathFormula<T>* clone() {
/*! Next<T>* result = new Next<T>();
* Clones the called object. if (child != NULL) {
* result->setChild(child);
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones }
* return result;
* @returns a new BoundedUntil-object that is identical the called object. }
*/ /*!
virtual PCTLPathFormula<T>* clone() { * Calls the model checker to check this formula.
Next<T>* result = new Next<T>(); * Needed to infer the correct type of formula class.
if (child != NULL) { *
result->setChild(child); * @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.
return result; *
} * @returns A vector indicating the probability that the formula holds for each state.
*/
/*! virtual std::vector<T> *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
* Calls the model checker to check this formula. return modelChecker->checkNext(this);
* Needed to infer the correct type of formula class. }
* private:
* @note This function should only be called in a generic check function of a model checker class. For other uses, PCTLStateFormula<T>* child;
* 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(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkNext(this);
}
}; };
} //namespace formula } //namespace formula

164
src/formula/Not.h

@ -28,87 +28,89 @@ namespace formula {
*/ */
template <class T> template <class T>
class Not : public PCTLStateFormula<T> { class Not : public PCTLStateFormula<T> {
private: public:
PCTLStateFormula<T>* child; /*!
public: * Empty constructor
/*! */
* Empty constructor Not() {
*/ this->child = NULL;
Not() { }
this->child = NULL; /*!
} * Constructor
* @param child The child node
/*! */
* Constructor Not(PCTLStateFormula<T>* child) {
* @param child The child node this->child = child;
*/ }
Not(PCTLStateFormula<T>* child) { /*!
this->child = child; * Destructor
} *
* Also deletes the subtree
/*! * (this behavior can be prevented by setting them to NULL before deletion)
* Destructor */
* virtual ~Not() {
* Also deletes the subtree if (child != NULL) {
* (this behavior can be prevented by setting them to NULL before deletion) delete child;
*/ }
virtual ~Not() { }
if (child != NULL) { /*!
delete child; * @returns The child node
} */
} PCTLStateFormula<T>* getChild() {
return child;
/*! }
* @returns The child node /*!
*/ * Sets the subtree
PCTLStateFormula<T>* getChild() { * @param child the new child node
return child; */
} void setChild(PCTLStateFormula<T>* child) {
this->child = child;
/*! }
* Sets the subtree /*!
* @param child the new child node * @returns a string representation of the formula
*/ */
void setChild(PCTLStateFormula<T>* child) { virtual std::string toString() {
this->child = child; std::string result = "!";
} result += child->toString();
return result;
/*! }
* @returns a string representation of the formula /*!
*/ * Clones the called object.
virtual std::string toString() { *
std::string result = "!"; * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
result += child->toString(); *
return result; * @returns a new AND-object that is identical the called object.
} */
virtual PCTLStateFormula<T>* clone() {
/*! Not<T>* result = new Not<T>();
* Clones the called object. if (child != NULL) {
* result->setChild(child);
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones }
* return result;
* @returns a new AND-object that is identical the called object. }
*/ /*!
virtual PCTLStateFormula<T>* clone() { * Calls the model checker to check this formula.
Not<T>* result = new Not<T>(); * Needed to infer the correct type of formula class.
if (child != NULL) { *
result->setChild(child); * @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.
return result; *
} * @returns A bit vector indicating all states that satisfy the formula represented by the called object.
*/
/*! virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
* Calls the model checker to check this formula. return modelChecker->checkNot(this);
* Needed to infer the correct type of formula class. }
* private:
* @note This function should only be called in a generic check function of a model checker class. For other uses, PCTLStateFormula<T>* child;
* 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 mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkNot(this);
}
}; };
} //namespace formula } //namespace formula

230
src/formula/Or.h

@ -31,120 +31,122 @@ namespace formula {
*/ */
template <class T> template <class T>
class Or : public PCTLStateFormula<T> { class Or : public PCTLStateFormula<T> {
private: public:
PCTLStateFormula<T>* left; /*!
PCTLStateFormula<T>* right; * Empty constructor.
public: * Will create an AND-node without subnotes. Will not represent a complete formula!
/*! */
* Empty constructor. Or() {
* Will create an AND-node without subnotes. Will not represent a complete formula! left = NULL;
*/ right = NULL;
Or() { }
left = NULL; /*!
right = NULL; * Constructor.
} * Creates an AND note with the parameters as subtrees.
*
/*! * @param left The left sub formula
* Constructor. * @param right The right sub formula
* Creates an AND note with the parameters as subtrees. */
* Or(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right) {
* @param left The left sub formula this->left = left;
* @param right The right sub formula this->right = right;
*/ }
Or(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right) { /*!
this->left = left; * Destructor.
this->right = right; *
} * The subtrees are deleted with the object
* (this behavior can be prevented by setting them to NULL before deletion)
/*! */
* Destructor. virtual ~Or() {
* if (left != NULL) {
* The subtrees are deleted with the object delete left;
* (this behavior can be prevented by setting them to NULL before deletion) }
*/ if (right != NULL) {
virtual ~Or() { delete right;
if (left != NULL) { }
delete left; }
} /*!
if (right != NULL) { * Sets the left child node.
delete right; *
} * @param newLeft the new left child.
} */
void setLeft(PCTLStateFormula<T>* newLeft) {
/*! left = newLeft;
* Sets the left child node. }
* /*!
* @param newLeft the new left child. * Sets the right child node.
*/ *
void setLeft(PCTLStateFormula<T>* newLeft) { * @param newRight the new right child.
left = newLeft; */
} void setRight(PCTLStateFormula<T>* newRight) {
right = newRight;
/*! }
* Sets the right child node. /*!
* * @returns a pointer to the left child node
* @param newRight the new right child. */
*/ PCTLStateFormula<T>* getLeft() {
void setRight(PCTLStateFormula<T>* newRight) { return left;
right = newRight; }
} /*!
* @returns a pointer to the right child node
/*! */
* @returns a pointer to the left child node PCTLStateFormula<T>* getRight() {
*/ return right;
PCTLStateFormula<T>* getLeft() { }
return left; /*!
} * @returns a string representation of the formula
*/
/*! virtual std::string toString() {
* @returns a pointer to the right child node std::string result = "(";
*/ result += left->toString();
PCTLStateFormula<T>* getRight() { result += " || ";
return right; result += right->toString();
} result += ")";
return result;
/*! }
* @returns a string representation of the formula /*!
*/ * Clones the called object.
virtual std::string toString() { *
std::string result = "("; * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
result += left->toString(); *
result += " || "; * @returns a new AND-object that is identical the called object.
result += right->toString(); */
result += ")"; virtual PCTLStateFormula<T>* clone() {
return result; Or<T>* result = new Or();
} if (this->left != NULL) {
result->setLeft(left->clone());
/*! }
* Clones the called object. if (this->right != NULL) {
* result->setRight(right->clone());
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones }
* return result;
* @returns a new AND-object that is identical the called object. }
*/ /*!
virtual PCTLStateFormula<T>* clone() { * Calls the model checker to check this formula.
Or<T>* result = new Or(); * Needed to infer the correct type of formula class.
if (this->left != NULL) { *
result->setLeft(left->clone()); * @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.
if (this->right != NULL) { *
result->setRight(right->clone()); * @returns A bit vector indicating all states that satisfy the formula represented by the called object.
} */
return result; virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
} return modelChecker->checkOr(this);
}
/*! private:
* Calls the model checker to check this formula. PCTLStateFormula<T>* left;
* Needed to infer the correct type of formula class. PCTLStateFormula<T>* right;
*
* @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 mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkOr(this);
}
}; };
} //namespace formula } //namespace formula

53
src/formula/PCTLPathFormula.h

@ -27,34 +27,35 @@ namespace formula {
*/ */
template <class T> template <class T>
class PCTLPathFormula : public PCTLFormula<T> { class PCTLPathFormula : public PCTLFormula<T> {
public:
/*!
* empty destructor
*/
virtual ~PCTLPathFormula() { }
/*! public:
* Clones the called object. /*!
* * empty destructor
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones */
* virtual ~PCTLPathFormula() { }
* @note This function is not implemented in this class.
* @returns a new AND-object that is identical the called object.
*/
virtual PCTLPathFormula<T>* clone() = 0;
/*! /*!
* Calls the model checker to check this formula. * Clones the called object.
* Needed to infer the correct type of formula class. *
* * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
* @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. * @note This function is not implemented in this class.
* * @returns a new AND-object that is identical the called object.
* @note This function is not implemented in this class. */
* virtual PCTLPathFormula<T>* clone() = 0;
* @returns A vector indicating the probability that the formula holds for each state. /*!
*/ * Calls the model checker to check this formula.
virtual std::vector<T>* check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) = 0; * 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.
*
* @note This function is not implemented in this class.
*
* @returns A vector indicating the probability that the formula holds for each state.
*/
virtual std::vector<T>* check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) = 0;
}; };
} //namespace formula } //namespace formula

53
src/formula/PCTLStateFormula.h

@ -27,34 +27,35 @@ namespace formula {
*/ */
template <class T> template <class T>
class PCTLStateFormula : public PCTLFormula<T> { class PCTLStateFormula : public PCTLFormula<T> {
public:
/*!
* empty destructor
*/
virtual ~PCTLStateFormula() { }
/*! public:
* Clones the called object. /*!
* * empty destructor
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones */
* virtual ~PCTLStateFormula() { }
* @note This function is not implemented in this class.
* @returns a new AND-object that is identical the called object.
*/
virtual PCTLStateFormula<T>* clone() = 0;
/*! /*!
* Calls the model checker to check this formula. * Clones the called object.
* Needed to infer the correct type of formula class. *
* * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
* @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. * @note This function is not implemented in this class.
* * @returns a new AND-object that is identical the called object.
* @note This function is not implemented in this class. */
* virtual PCTLStateFormula<T>* clone() = 0;
* @returns A bit vector indicating all states that satisfy the formula represented by the called object. /*!
*/ * Calls the model checker to check this formula.
virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) = 0; * 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.
*
* @note This function is not implemented in this class.
*
* @returns A bit vector indicating all states that satisfy the formula represented by the called object.
*/
virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) = 0;
}; };
} //namespace formula } //namespace formula

23
src/formula/PCTLformula.h

@ -27,17 +27,18 @@ namespace formula {
*/ */
template <class T> template <class T>
class PCTLFormula { class PCTLFormula {
public: public:
/*! /*!
* virtual destructor * virtual destructor
*/ */
virtual ~PCTLFormula() { } virtual ~PCTLFormula() { }
/*!
/*! * @note This function is not implemented in this class.
* @note This function is not implemented in this class. * @returns a string representation of the formula
* @returns a string representation of the formula */
*/ virtual std::string toString() = 0;
virtual std::string toString() = 0;
}; };
} //namespace formula } //namespace formula

247
src/formula/ProbabilisticOperator.h

@ -34,128 +34,131 @@ namespace formula {
*/ */
template<class T> template<class T>
class ProbabilisticOperator : public PCTLStateFormula<T> { class ProbabilisticOperator : public PCTLStateFormula<T> {
T lower; public:
T upper; /*!
PCTLPathFormula<T>* pathFormula; * Empty constructor
public: */
/*! ProbabilisticOperator() {
* Empty constructor upper = mrmc::misc::constGetZero(&upper);
*/ lower = mrmc::misc::constGetZero(&lower);
ProbabilisticOperator() { pathFormula = NULL;
upper = mrmc::misc::constGetZero(&upper); }
lower = mrmc::misc::constGetZero(&lower); /*!
pathFormula = NULL; * Constructor
} *
* @param lowerBound The lower bound for the probability
/*! * @param upperBound The upper bound for the probability
* Constructor * @param pathFormula The child node (can be omitted, is then set to NULL)
* */
* @param lowerBound The lower bound for the probability ProbabilisticOperator(T lowerBound, T upperBound, PCTLPathFormula<T>* pathFormula=NULL) {
* @param upperBound The upper bound for the probability this->lower = lowerBound;
* @param pathFormula The child node (can be omitted, is then set to NULL) this->upper = upperBound;
*/ this->pathFormula = pathFormula;
ProbabilisticOperator(T lowerBound, T upperBound, PCTLPathFormula<T>* pathFormula=NULL) { }
this->lower = lowerBound; /*!
this->upper = upperBound; * Destructor
this->pathFormula = pathFormula; *
} * The subtree is deleted with the object
* (this behavior can be prevented by setting them to NULL before deletion)
/*! */
* Destructor virtual ~ProbabilisticOperator() {
* if (pathFormula != NULL) {
* The subtree is deleted with the object delete pathFormula;
* (this behavior can be prevented by setting them to NULL before deletion) }
*/ }
virtual ~ProbabilisticOperator() { /*!
if (pathFormula != NULL) { * @returns the child node (representation of a PCTL path formula)
delete pathFormula; */
} PCTLPathFormula<T>* getPathFormula () {
} return pathFormula;
}
/*! /*!
* @returns the child node (representation of a PCTL path formula) * @returns the lower bound for the probability
*/ */
PCTLPathFormula<T>* getPathFormula () { T getLowerBound() {
return pathFormula; return lower;
} }
/*!
/*! * @returns the upper bound for the probability
* @returns the lower bound for the probability */
*/ T getUpperBound() {
T getLowerBound() { return upper;
return lower; }
} /*!
* Sets the child node
/*! *
* @returns the upper bound for the probability * @param pathFormula the path formula that becomes the new child node
*/ */
T getUpperBound() { void setPathFormula(PCTLPathFormula<T>* pathFormula) {
return upper; this->pathFormula = pathFormula;
} }
/*!
/*! * Sets the interval in which the probability that the path formula holds may lie.
* Sets the child node *
* * @param lowerBound The lower bound for the probability
* @param pathFormula the path formula that becomes the new child node * @param upperBound The upper bound for the probability
*/ */
void setPathFormula(PCTLPathFormula<T>* pathFormula) { void setInterval(T lowerBound, T upperBound) {
this->pathFormula = pathFormula; this->lower = lowerBound;
} this->upper = upperBound;
}
/*! /*!
* Sets the interval in which the probability that the path formula holds may lie. * @returns a string representation of the formula
* */
* @param lowerBound The lower bound for the probability virtual std::string toString() {
* @param upperBound The upper bound for the probability std::string result = "(";
*/ result += " P[";
void setInterval(T lowerBound, T upperBound) { result += lower;
this->lower = lowerBound; result += ";";
this->upper = upperBound; result += upper;
} result += "] ";
result += pathFormula->toString();
/*! result += ")";
* @returns a string representation of the formula return result;
*/ }
virtual std::string toString() { /*!
std::string result = "("; * Clones the called object.
result += " P["; *
result += lower; * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
result += ";"; *
result += upper; * @returns a new AND-object that is identical the called object.
result += "] "; */
result += pathFormula->toString(); virtual PCTLStateFormula<T>* clone() {
result += ")"; ProbabilisticOperator<T>* result = new ProbabilisticOperator<T>();
return result; result->setInterval(lower, upper);
} if (pathFormula != NULL) {
result->setPathFormula(pathFormula->clone());
/*! }
* Clones the called object. return result;
* }
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones /*!
* * Calls the model checker to check this formula.
* @returns a new AND-object that is identical the called object. * Needed to infer the correct type of formula class.
*/ *
virtual PCTLStateFormula<T>* clone() { * @note This function should only be called in a generic check function of a model checker class. For other uses,
ProbabilisticOperator<T>* result = new ProbabilisticOperator<T>(); * the methods of the model checker should be used.
result->setInterval(lower, upper); *
if (pathFormula != NULL) { * @returns A bit vector indicating all states that satisfy the formula represented by the called object.
result->setPathFormula(pathFormula->clone()); */
} virtual mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return result; return modelChecker->checkProbabilisticOperator(this);
} }
private:
/*! T lower;
* Calls the model checker to check this formula. T upper;
* Needed to infer the correct type of formula class. PCTLPathFormula<T>* pathFormula;
*
* @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 mrmc::storage::BitVector *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkProbabilisticOperator(this);
}
}; };
} //namespace formula } //namespace formula

225
src/formula/Until.h

@ -33,117 +33,120 @@ namespace formula {
*/ */
template <class T> template <class T>
class Until : public PCTLPathFormula<T> { class Until : public PCTLPathFormula<T> {
PCTLStateFormula<T>* left; public:
PCTLStateFormula<T>* right; /*!
public: * Empty constructor
/*! */
* Empty constructor Until() {
*/ this->left = NULL;
Until() { this->right = NULL;
this->left = NULL; }
this->right = NULL; /*!
} * Constructor
*
/*! * @param left The left formula subtree
* Constructor * @param right The left formula subtree
* */
* @param left The left formula subtree Until(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right) {
* @param right The left formula subtree this->left = left;
*/ this->right = right;
Until(PCTLStateFormula<T>* left, PCTLStateFormula<T>* right) { }
this->left = left; /*!
this->right = right; * Destructor.
} *
* Also deletes the subtrees.
/*! * (this behaviour can be prevented by setting the subtrees to NULL before deletion)
* Destructor. */
* virtual ~Until() {
* Also deletes the subtrees. if (left != NULL) {
* (this behaviour can be prevented by setting the subtrees to NULL before deletion) delete left;
*/ }
virtual ~Until() { if (right != NULL) {
if (left != NULL) { delete right;
delete left; }
} }
if (right != NULL) { /*!
delete right; * Sets the left child node.
} *
} * @param newLeft the new left child.
*/
/*! void setLeft(PCTLStateFormula<T>* newLeft) {
* Sets the left child node. left = newLeft;
* }
* @param newLeft the new left child. /*!
*/ * Sets the right child node.
void setLeft(PCTLStateFormula<T>* newLeft) { *
left = newLeft; * @param newRight the new right child.
} */
void setRight(PCTLStateFormula<T>* newRight) {
/*! right = newRight;
* Sets the right child node. }
* /*!
* @param newRight the new right child. * @returns a pointer to the left child node
*/ */
void setRight(PCTLStateFormula<T>* newRight) { PCTLStateFormula<T>* getLeft() {
right = newRight; return left;
} }
/*!
/*! * @returns a pointer to the right child node
* @returns a pointer to the left child node */
*/ PCTLStateFormula<T>* getRight() {
PCTLStateFormula<T>* getLeft() { return right;
return left; }
} /*!
* @returns a string representation of the formula
/*! */
* @returns a pointer to the right child node virtual std::string toString() {
*/ std::string result = "(";
PCTLStateFormula<T>* getRight() { result += left->toString();
return right; result += " U ";
} result += right->toString();
result += ")";
/*! return result;
* @returns a string representation of the formula }
*/ /*!
virtual std::string toString() { * Clones the called object.
std::string result = "("; *
result += left->toString(); * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones
result += " U "; *
result += right->toString(); * @returns a new BoundedUntil-object that is identical the called object.
result += ")"; */
return result; virtual PCTLPathFormula<T>* clone() {
} Until<T>* result = new Until();
if (left != NULL) {
/*! result->setLeft(left->clone());
* Clones the called object. }
* if (right != NULL) {
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones result->setRight(right->clone());
* }
* @returns a new BoundedUntil-object that is identical the called object. return result;
*/ }
virtual PCTLPathFormula<T>* clone() { /*!
Until<T>* result = new Until(); * Calls the model checker to check this formula.
if (left != NULL) { * Needed to infer the correct type of formula class.
result->setLeft(left->clone()); *
} * @note This function should only be called in a generic check function of a model checker class. For other uses,
if (right != NULL) { * the methods of the model checker should be used.
result->setRight(right->clone()); *
} * @returns A vector indicating the probability that the formula holds for each state.
return result; */
} virtual std::vector<T> *check(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkUntil(this);
/*! }
* Calls the model checker to check this formula. private:
* Needed to infer the correct type of formula class. PCTLStateFormula<T>* left;
* PCTLStateFormula<T>* right;
* @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(mrmc::modelChecker::DtmcPrctlModelChecker<T>* modelChecker) {
return modelChecker->checkUntil(this);
}
}; };
} //namespace formula } //namespace formula

|||||||
100:0
Loading…
Cancel
Save