Browse Source

Better distinction between parametric and non-parametric DFTs

Former-commit-id: 57ac698a38
tempestpy_adaptions
Mavo 9 years ago
parent
commit
c8d2cf1724
  1. 80
      src/storm-dyftee.cpp

80
src/storm-dyftee.cpp

@ -5,24 +5,62 @@
#include "modelchecker/results/CheckResult.h"
#include "utility/storm.h"
#define VALUE_TYPE storm::RationalFunction
/*!
* Load DFT from filename, build corresponding CTMC and check against given property.
*
* @param filename Path to DFT file in Galileo format.
* @param property PCTC formula capturing the property to check.
*/
template <typename ValueType>
void analyzeDFT(std::string filename, std::string property) {
// Parsing DFT
std::cout << "Parsing DFT file..." << std::endl;
storm::parser::DFTGalileoParser<ValueType> parser;
storm::storage::DFT<ValueType> dft = parser.parseDFT(filename);
std::cout << "Built data structure" << std::endl;
// Building CTMC
std::cout << "Building CTMC..." << std::endl;
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft);
std::shared_ptr<storm::models::sparse::Model<ValueType>> model = builder.buildCTMC();
std::cout << "Built CTMC" << std::endl;
// Model checking
std::cout << "Model checking..." << std::endl;
std::vector<std::shared_ptr<storm::logic::Formula>> formulas = storm::parseFormulasForExplicit(property);
assert(formulas.size() == 1);
std::unique_ptr<storm::modelchecker::CheckResult> resultCtmc(storm::verifySparseModel(model, formulas[0]));
assert(resultCtmc);
std::cout << "Result (initial states): ";
resultCtmc->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates()));
std::cout << *resultCtmc << std::endl;
std::cout << "Checked CTMC" << std::endl;
}
/*
/*!
* Entry point for the DyFTeE backend.
*
* @param argc The argc argument of main().
* @param argv The argv argument of main().
* @return Return code, 0 if successfull, not 0 otherwise.
*/
int main(int argc, char** argv) {
if(argc < 2) {
std::cout << "Storm-DyFTeE should be called with a filename as argument." << std::endl;
return 1;
}
// Construct PCTL forumla
std::string inputFormula;
if (argc < 3) {
// Set explicit reachability formula
inputFormula = "Pmax=?[true U \"failed\"]";
// Parse cli arguments
bool parametric = false;
std::string filename = argv[1];
std::string pctlFormula = "Pmax=?[true U \"failed\"]";
for (int i = 2; i < argc; ++i) {
std::string option = argv[i];
if (option == "--parametric") {
parametric = true;
} else {
// Read formula from input
inputFormula = argv[2];
pctlFormula = option;
}
}
storm::utility::setUp();
@ -30,23 +68,11 @@ int main(int argc, char** argv) {
logger.setLogLevel(level);
logger.getAppender("mainConsoleAppender")->setThreshold(level);
std::cout << "Parsing DFT file..." << std::endl;
storm::parser::DFTGalileoParser<VALUE_TYPE> parser;
storm::storage::DFT<VALUE_TYPE> dft = parser.parseDFT(argv[1]);
std::cout << "Built data structure" << std::endl;
std::cout << "Running " << (parametric ? "parametric " : "") << "DFT analysis on file " << filename << " with property " << pctlFormula << std::endl;
// Verify the model as CTMC
std::cout << "Building CTMC..." << std::endl;
storm::builder::ExplicitDFTModelBuilder<VALUE_TYPE> builder(dft);
std::shared_ptr<storm::models::sparse::Model<VALUE_TYPE>> model = builder.buildCTMC();
std::cout << "Built CTMC" << std::endl;
std::cout << "Model checking..." << std::endl;
std::vector<std::shared_ptr<storm::logic::Formula>> formulas = storm::parseFormulasForExplicit(inputFormula);
assert(formulas.size() == 1);
std::unique_ptr<storm::modelchecker::CheckResult> resultCtmc(storm::verifySparseModel(model, formulas[0]));
assert(resultCtmc);
std::cout << "Result (initial states): ";
resultCtmc->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates()));
std::cout << *resultCtmc << std::endl;
std::cout << "Checked CTMC" << std::endl;
if (parametric) {
analyzeDFT<storm::RationalFunction>(filename, pctlFormula);
} else {
analyzeDFT<double>(filename, pctlFormula);
}
}
Loading…
Cancel
Save