Browse Source

Fixes in probabilistic operators:

- Constructors and Destructors now work correctly
- Removed check function from ProbabilisticNoBoundsOperator class (and
documented why it does not have one)

Note: I temporarily removed the -Wall parameter from gcc calls, as line
194 of GmmxxDtmcPrctlModelChecker.h throws a warning.
tempestpy_adaptions
Lanchid 12 years ago
parent
commit
1b973545bb
  1. 5
      CMakeLists.txt
  2. 30
      src/formula/ProbabilisticNoBoundsOperator.h
  3. 11
      src/formula/ProbabilisticOperator.h
  4. 4
      src/modelChecker/DtmcPrctlModelChecker.h
  5. 6
      src/modelChecker/GmmxxDtmcPrctlModelChecker.h
  6. 2
      src/mrmc.cpp

5
CMakeLists.txt

@ -60,7 +60,10 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC)
# Set standard flags for GCC
set (CMAKE_CXX_FLAGS "-std=c++0x -Wall -Werror -pedantic")
set (CMAKE_CXX_FLAGS "-std=c++0x -Wall -pedantic")
# -Werror is atm removed as this gave some problems with existing code
# May be re-set later
# (Thomas Heinemann, 2012-12-21)
# Turn on popcnt instruction if possible (yes by default)
if (USE_POPCNT)

30
src/formula/ProbabilisticNoBoundsOperator.h

@ -28,6 +28,12 @@ namespace formula {
* 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 checkProbabilisticNoBoundsOperator 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)
*
@ -45,7 +51,6 @@ public:
* Empty constructor
*/
ProbabilisticNoBoundsOperator() {
// TODO Auto-generated constructor stub
this->pathFormula = NULL;
}
@ -54,15 +59,17 @@ public:
*
* @param pathFormula The child node.
*/
ProbabilisticNoBoundsOperator(PctlPathFormula<T> &pathFormula) {
this->pathFormula = &pathFormula;
ProbabilisticNoBoundsOperator(PctlPathFormula<T>* pathFormula) {
this->pathFormula = pathFormula;
}
/*!
* Destructor
*/
virtual ~ProbabilisticNoBoundsOperator() {
// TODO Auto-generated destructor stub
if (pathFormula != NULL) {
delete pathFormula;
}
}
/*!
@ -81,21 +88,6 @@ public:
this->pathFormula = pathFormula;
}
/*!
* 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 std::vector<T> *check(
const mrmc::modelChecker::DtmcPrctlModelChecker<T>& modelChecker) const {
return modelChecker.checkProbabilisticOperator(*this);
}
/*!
* @returns a string representation of the formula
*/

11
src/formula/ProbabilisticOperator.h

@ -45,8 +45,7 @@ public:
* Empty constructor
*/
ProbabilisticOperator() {
// TODO Auto-generated constructor stub
this->pathFormula = NULL;
}
/*!
@ -55,9 +54,9 @@ public:
* @param bound The expected value for path formulas
* @param pathFormula The child node
*/
ProbabilisticOperator(T bound, PctlPathFormula<T>& pathFormula) {
ProbabilisticOperator(T bound, PctlPathFormula<T>* pathFormula) {
this->bound = bound;
this->pathFormula = &pathFormula;
this->pathFormula = *pathFormula;
}
/*!
@ -67,7 +66,9 @@ public:
* (this behavior can be prevented by setting them to NULL before deletion)
*/
virtual ~ProbabilisticOperator() {
// TODO Auto-generated destructor stub
if (pathFormula != NULL) {
delete pathFormula;
}
}
/*!

4
src/modelChecker/DtmcPrctlModelChecker.h

@ -116,7 +116,7 @@ public:
void check(const mrmc::formula::ProbabilisticNoBoundsOperator<Type>& probabilisticNoBoundsFormula) {
LOG4CPLUS_INFO(logger, "Model checking formula " << probabilisticNoBoundsFormula.toString());
std::cout << "Model checking formula: " << probabilisticNoBoundsFormula.toString() << std::endl;
std::vector<Type>* result = probabilisticNoBoundsFormula.check(*this);
std::vector<Type>* result = checkProbabilisticNoBoundsOperator(probabilisticNoBoundsFormula);
LOG4CPLUS_INFO(logger, "Result for initial states:");
std::cout << "Result for initial states:" << std::endl;
for (auto initialState : *this->getModel().getLabeledStates("init")) {
@ -251,7 +251,7 @@ public:
* @param formula The state formula to check
* @returns The set of states satisfying the formula, represented by a bit vector
*/
std::vector<Type>* checkProbabilisticOperator(
std::vector<Type>* checkProbabilisticNoBoundsOperator(
const mrmc::formula::ProbabilisticNoBoundsOperator<Type>& formula) const {
return formula.getPathFormula().check(*this);
}

6
src/modelChecker/GmmxxDtmcPrctlModelChecker.h

@ -187,7 +187,11 @@ public:
LOG4CPLUS_INFO(logger, "Using QMR method.");
if (precond == "ilu") {
gmm::qmr(*gmmxxMatrix, x, b, gmm::ilu_precond<gmm::csr_matrix<Type>>(*gmmxxMatrix), iter);
} else if (precond == "diagonal" == 0) {
} /* FIXME: The following line throws a warning as there should be brackets around such a construction
* TBH, I don't understand it completely (why the comparison with 0?), so I don't know how to fix it
* (Thomas Heinemann, 2012-12-21)
*/
else if (precond == "diagonal" == 0) {
gmm::qmr(*gmmxxMatrix, x, b, gmm::diagonal_precond<gmm::csr_matrix<Type>>(*gmmxxMatrix), iter);
} else if (precond == "ildlt") {
gmm::qmr(*gmmxxMatrix, x, b, gmm::ildlt_precond<gmm::csr_matrix<Type>>(*gmmxxMatrix), iter);

2
src/mrmc.cpp

@ -152,7 +152,7 @@ void testChecking() {
mrmc::formula::Ap<double>* trueFormula = new mrmc::formula::Ap<double>("true");
mrmc::formula::Ap<double>* observe0Greater1Formula = new mrmc::formula::Ap<double>("observe0Greater1");
mrmc::formula::Until<double>* untilFormula = new mrmc::formula::Until<double>(trueFormula, observe0Greater1Formula);
mrmc::formula::ProbabilisticNoBoundsOperator<double>* probFormula = new mrmc::formula::ProbabilisticNoBoundsOperator<double>(*untilFormula);
mrmc::formula::ProbabilisticNoBoundsOperator<double>* probFormula = new mrmc::formula::ProbabilisticNoBoundsOperator<double>(untilFormula);
mrmc::modelChecker::GmmxxDtmcPrctlModelChecker<double>* mc = new mrmc::modelChecker::GmmxxDtmcPrctlModelChecker<double>(dtmc);
mc->check(*probFormula);

Loading…
Cancel
Save