Browse Source

Added ability to check properties from property file to cli utility.

Added minimal example for lra on dtmc


Former-commit-id: eec774f05a
tempestpy_adaptions
David_Korzeniewski 10 years ago
parent
commit
7d84b0a4c5
  1. 1
      examples/dtmc/tiny_lra/tiny_lra.pctl
  2. 16
      examples/dtmc/tiny_lra/tiny_lra.pm
  3. 63
      src/utility/cli.h

1
examples/dtmc/tiny_lra/tiny_lra.pctl

@ -0,0 +1 @@
LRA=? [ "a" ]

16
examples/dtmc/tiny_lra/tiny_lra.pm

@ -0,0 +1,16 @@
// tiny LRA example
dtmc
module main
s : [0..2] init 0;
[] s=0 -> 1:(s'=1);
[] s=1 -> 0.5:(s'=1) + 0.5:(s'=2);
[] s=2 -> 0.5:(s'=1) + 0.5:(s'=2);
endmodule
label "a" = s=1;

63
src/utility/cli.h

@ -583,8 +583,9 @@ namespace storm {
}
// Then proceed to parsing the property (if given), since the model we are building may depend on the property.
boost::optional<std::shared_ptr<storm::logic::Formula>> formula;
std::vector<boost::optional<std::shared_ptr<storm::logic::Formula>>> formulas;
if (settings.isPropertySet()) {
boost::optional<std::shared_ptr<storm::logic::Formula>> formula;
if (program) {
storm::parser::FormulaParser formulaParser(program.get().getManager().getSharedPointer());
formula = formulaParser.parseFromString(settings.getProperty());
@ -592,23 +593,61 @@ namespace storm {
storm::parser::FormulaParser formulaParser;
formula = formulaParser.parseFromString(settings.getProperty());
}
formulas.push_back(formula);
}
else if (settings.isPropertyFileSet()) {
std::cout << "Reading properties from " << settings.getPropertiesFilename() << std::endl;
std::ifstream inputFileStream(settings.getPropertiesFilename(), std::ios::in);
std::vector<std::string> properties;
if (inputFileStream.good()) {
try {
std::string prop;
std::getline(inputFileStream, prop);
properties.push_back(prop);
}
catch (std::exception& e) {
inputFileStream.close();
throw e;
}
inputFileStream.close();
} else {
STORM_LOG_ERROR("Unable to read property file.");
}
for (std::string prop : properties) {
boost::optional<std::shared_ptr<storm::logic::Formula>> formula;
if (program) {
storm::parser::FormulaParser formulaParser(program.get().getManager().getSharedPointer());
formula = formulaParser.parseFromString(prop);
} else {
storm::parser::FormulaParser formulaParser;
formula = formulaParser.parseFromString(prop);
}
formulas.push_back(formula);
}
std::cout << "Parsed " << formulas.size() << " properties from file " << settings.getPropertiesFilename() << std::endl;
}
if (settings.isSymbolicSet()) {
for (boost::optional<std::shared_ptr<storm::logic::Formula>> formula : formulas) {
if (settings.isSymbolicSet()) {
#ifdef STORM_HAVE_CARL
if (settings.isParametricSet()) {
buildAndCheckSymbolicModel<storm::RationalFunction>(program.get(), formula);
} else {
if (settings.isParametricSet()) {
buildAndCheckSymbolicModel<storm::RationalFunction>(program.get(), formula);
} else {
#endif
buildAndCheckSymbolicModel<double>(program.get(), formula);
buildAndCheckSymbolicModel<double>(program.get(), formula);
#ifdef STORM_HAVE_CARL
}
}
#endif
} else if (settings.isExplicitSet()) {
buildAndCheckExplicitModel<double>(formula);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model.");
}
} else if (settings.isExplicitSet()) {
buildAndCheckExplicitModel<double>(formula);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model.");
}
}
}
}
}

Loading…
Cancel
Save