diff --git a/src/storm-pgcl-cli/storm-pgcl.cpp b/src/storm-pgcl-cli/storm-pgcl.cpp index 30a72a09b..73d88e581 100644 --- a/src/storm-pgcl-cli/storm-pgcl.cpp +++ b/src/storm-pgcl-cli/storm-pgcl.cpp @@ -20,6 +20,8 @@ #include "storm/settings/modules/DebugSettings.h" #include "storm-conv/settings/modules/JaniExportSettings.h" #include "storm-conv/api/storm-conv.h" +#include "storm-parsers/api/storm-parsers.h" +#include "storm/storage/SymbolicModelDescription.h" #include "storm/utility/file.h" @@ -38,15 +40,14 @@ void initializeSettings() { storm::settings::addModule(); } -void handleJani(storm::jani::Model& model) { +void handleJani(storm::jani::Model& model, std::vector& properties) { auto const& jani = storm::settings::getModule(); storm::converter::JaniConversionOptions options(jani); - std::vector properties; storm::api::transformJani(model, properties, options); if (storm::settings::getModule().isToJaniSet()) { - storm::api::exportJaniToFile(model, {}, storm::settings::getModule().getWriteToJaniFilename(), jani.isCompactJsonSet()); + storm::api::exportJaniToFile(model, properties, storm::settings::getModule().getWriteToJaniFilename(), jani.isCompactJsonSet()); } else { - storm::api::printJaniToStream(model, {}, std::cout); + storm::api::printJaniToStream(model, properties, std::cout); } } @@ -68,31 +69,40 @@ int main(const int argc, const char** argv) { if (!optionsCorrect) { return -1; } - - if (!storm::settings::getModule().isPgclFileSet()) { + + auto pgcl = storm::settings::getModule(); + if (!pgcl.isPgclFileSet()) { return -1; } - storm::pgcl::PgclProgram prog = storm::parser::PgclParser::parse(storm::settings::getModule().getPgclFilename()); + + storm::pgcl::PgclProgram prog = storm::parser::PgclParser::parse(pgcl.getPgclFilename()); storm::ppg::ProgramGraph* progGraph = storm::builder::ProgramGraphBuilder::build(prog); progGraph->printInfo(std::cout); - if (storm::settings::getModule().isProgramGraphToDotSet()) { + if (pgcl.isProgramGraphToDotSet()) { programGraphToDotFile(*progGraph); } - if (storm::settings::getModule().isToJaniSet()) { + if (pgcl.isToJaniSet()) { storm::builder::JaniProgramGraphBuilderSetting settings; // To disable reward detection, uncomment the following line // TODO add a setting for this. // settings.filterRewardVariables = false; storm::builder::JaniProgramGraphBuilder builder(*progGraph, settings); - if (storm::settings::getModule().isProgramVariableRestrictionSet()) { + if (pgcl.isProgramVariableRestrictionSet()) { // TODO More fine grained control - storm::storage::IntegerInterval restr = storm::storage::parseIntegerInterval(storm::settings::getModule().getProgramVariableRestrictions()); + storm::storage::IntegerInterval restr = storm::storage::parseIntegerInterval(pgcl.getProgramVariableRestrictions()); builder.restrictAllVariables(restr); } storm::jani::Model* model = builder.build(); + delete progGraph; - handleJani(*model); + std::vector properties; + if (pgcl.isPropertyInputSet()) { + boost::optional> propertyFilter = storm::api::parsePropertyFilter(pgcl.getPropertyInputFilter()); + properties = storm::api::parsePropertiesForSymbolicModelDescription(pgcl.getPropertyInput(), *model, propertyFilter); + } + + handleJani(*model, properties); delete model; } else { diff --git a/src/storm-pgcl/settings/modules/PGCLSettings.cpp b/src/storm-pgcl/settings/modules/PGCLSettings.cpp index c466943aa..16b9de190 100644 --- a/src/storm-pgcl/settings/modules/PGCLSettings.cpp +++ b/src/storm-pgcl/settings/modules/PGCLSettings.cpp @@ -22,13 +22,18 @@ namespace storm { const std::string PGCLSettings::programGraphToDotShortOptionName = "pg"; const std::string PGCLSettings::programVariableRestrictionsOptionName = "variable-restrictions"; const std::string PGCLSettings::programVariableRestrictionShortOptionName = "rvar"; - + const std::string PGCLSettings::propertyOptionName = "prop"; + const std::string PGCLSettings::propertyOptionShortName = "prop"; PGCLSettings::PGCLSettings() : ModuleSettings(moduleName) { this->addOption(storm::settings::OptionBuilder(moduleName, pgclFileOptionName, false, "Parses the pgcl program.").setShortName(pgclFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidatorString(ArgumentValidatorFactory::createExistingFileValidator()).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, pgclToJaniOptionName, false, "Transform to JANI.").setShortName(pgclToJaniOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidatorString(ArgumentValidatorFactory::createWritableFileValidator()).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, programGraphToDotOptionName, false, "Destination for the program graph dot output.").setShortName(programGraphToDotShortOptionName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, programVariableRestrictionsOptionName, false, "Restrictions of program variables").setShortName(programVariableRestrictionShortOptionName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("description", "description of the variable restrictions").build()).build()); + this->addOption(storm::settings::OptionBuilder(moduleName, propertyOptionName, false, "Specifies the properties to be checked on the model.").setShortName(propertyOptionShortName) + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("property or filename", "The formula or the file containing the formulas.").build()) + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filter", "The names of the properties to check.").setDefaultValueString("all").build()) + .build()); } bool PGCLSettings::isPgclFileSet() const { @@ -64,6 +69,18 @@ namespace storm { return this->getOption(programVariableRestrictionsOptionName).getArgumentByName("description").getValueAsString(); } + bool PGCLSettings::isPropertyInputSet() const { + return this->getOption(propertyOptionName).getHasOptionBeenSet(); + } + + std::string PGCLSettings::getPropertyInput() const { + return this->getOption(propertyOptionName).getArgumentByName("property or filename").getValueAsString(); + } + + std::string PGCLSettings::getPropertyInputFilter() const { + return this->getOption(propertyOptionName).getArgumentByName("filter").getValueAsString(); + } + void PGCLSettings::finalize() { } diff --git a/src/storm-pgcl/settings/modules/PGCLSettings.h b/src/storm-pgcl/settings/modules/PGCLSettings.h index 8a2edf5eb..3049c7254 100644 --- a/src/storm-pgcl/settings/modules/PGCLSettings.h +++ b/src/storm-pgcl/settings/modules/PGCLSettings.h @@ -54,6 +54,26 @@ namespace storm { */ std::string getProgramVariableRestrictions() const; + /*! + * Retrieves whether the property option was set. + * + * @return True if the property option was set. + */ + bool isPropertyInputSet() const; + + /*! + * Retrieves the property specified with the property option. + * + * @return The property specified with the property option. + */ + std::string getPropertyInput() const; + + /*! + * Retrieves the property filter. + * + * @return The property filter. + */ + std::string getPropertyInputFilter() const; bool check() const override; void finalize() override; @@ -69,7 +89,8 @@ namespace storm { static const std::string programGraphToDotShortOptionName; static const std::string programVariableRestrictionsOptionName; static const std::string programVariableRestrictionShortOptionName; - + static const std::string propertyOptionName; + static const std::string propertyOptionShortName; }; } }