From 8dfa141a4a02622e9c1d202813f8b2ff23e74561 Mon Sep 17 00:00:00 2001 From: TimQu Date: Wed, 24 May 2017 16:08:15 +0200 Subject: [PATCH] Exporting .dot for explicit input. removed duplicated code for explicit input with parametric engine --- src/storm/cli/cli.cpp | 6 ++++++ src/storm/cli/entrypoints.h | 36 ++++++++---------------------------- src/storm/utility/storm.h | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/storm/cli/cli.cpp b/src/storm/cli/cli.cpp index 7310f56c6..181a67480 100644 --- a/src/storm/cli/cli.cpp +++ b/src/storm/cli/cli.cpp @@ -322,6 +322,12 @@ namespace storm { buildAndCheckExplicitModel(properties, true); #else STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "No parameters are supported in this build."); +#endif + } else if (generalSettings.isExactSet()) { +#ifdef STORM_HAVE_CARL + buildAndCheckExplicitModel(properties, true); +#else + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "No exact numbers are supported in this build."); #endif } else { buildAndCheckExplicitModel(properties, true); diff --git a/src/storm/cli/entrypoints.h b/src/storm/cli/entrypoints.h index b43db8bd9..5c04891eb 100644 --- a/src/storm/cli/entrypoints.h +++ b/src/storm/cli/entrypoints.h @@ -437,35 +437,15 @@ namespace storm { STORM_LOG_THROW(model->isSparseModel(), storm::exceptions::InvalidStateException, "Expected sparse model."); verifySparseModel(model->as>(), properties, onlyInitialStatesRelevant); } - } - -#ifdef STORM_HAVE_CARL - template<> - void buildAndCheckExplicitModel(std::vector const& properties, bool onlyInitialStatesRelevant) { - storm::settings::modules::IOSettings const& settings = storm::settings::getModule(); - - STORM_LOG_THROW(settings.isExplicitSet() || settings.isExplicitDRNSet(), storm::exceptions::InvalidStateException, "Unable to build explicit model without model files."); - - storm::utility::Stopwatch modelBuildingWatch(true); - std::shared_ptr model; - STORM_LOG_THROW(!settings.isExplicitSet(), storm::exceptions::NotSupportedException, "Parametric explicit model files are not supported."); - model = buildExplicitDRNModel(settings.getExplicitDRNFilename()); - modelBuildingWatch.stop(); - STORM_PRINT_AND_LOG("Time for model construction: " << modelBuildingWatch << "." << std::endl); - - // Preprocess the model if needed. - BRANCH_ON_MODELTYPE(model, model, storm::RationalFunction, storm::dd::DdType::CUDD, preprocessModel, extractFormulasFromProperties(properties)); - - // Print some information about the model. - model->printModelInformationToStream(std::cout); - - // Verify the model, if a formula was given. - if (!properties.empty()) { - STORM_LOG_THROW(model->isSparseModel(), storm::exceptions::InvalidStateException, "Expected sparse model."); - verifySparseModel(model->as>(), properties, onlyInitialStatesRelevant); + + // Export DOT if required. + if(storm::settings::getModule().isExportDotSet()) { + std::ofstream stream; + storm::utility::openFile(storm::settings::getModule().getExportDotFilename(), stream); + model->as>()->writeDotToStream(stream); + storm::utility::closeFile(stream); } - } -#endif + } } } diff --git a/src/storm/utility/storm.h b/src/storm/utility/storm.h index 0600c36d2..5c105b439 100644 --- a/src/storm/utility/storm.h +++ b/src/storm/utility/storm.h @@ -113,16 +113,27 @@ namespace storm { class FormulaParser; } + template - std::shared_ptr> buildExplicitModel(std::string const& transitionsFile, std::string const& labelingFile, boost::optional const& stateRewardsFile = boost::none, boost::optional const& transitionRewardsFile = boost::none, boost::optional const& choiceLabelingFile = boost::none) { - return storm::parser::AutoParser<>::parseModel(transitionsFile, labelingFile, stateRewardsFile ? stateRewardsFile.get() : "", transitionRewardsFile ? transitionRewardsFile.get() : "", choiceLabelingFile ? choiceLabelingFile.get() : "" ); + inline std::shared_ptr> buildExplicitModel(std::string const&, std::string const&, boost::optional const& = boost::none, boost::optional const& = boost::none, boost::optional const& = boost::none) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Exact or parametric models with explicit input are not supported."); } + template<> + inline std::shared_ptr> buildExplicitModel(std::string const& transitionsFile, std::string const& labelingFile, boost::optional const& stateRewardsFile, boost::optional const& transitionRewardsFile, boost::optional const& choiceLabelingFile) { + return storm::parser::AutoParser::parseModel(transitionsFile, labelingFile, stateRewardsFile ? stateRewardsFile.get() : "", transitionRewardsFile ? transitionRewardsFile.get() : "", choiceLabelingFile ? choiceLabelingFile.get() : "" ); + } + template - std::shared_ptr> buildExplicitDRNModel(std::string const& drnFile) { + inline std::shared_ptr> buildExplicitDRNModel(std::string const& drnFile) { return storm::parser::DirectEncodingParser::parseModel(drnFile); } + template<> + inline std::shared_ptr> buildExplicitDRNModel(std::string const&) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Exact models with direct encoding are not supported."); + } + std::vector> extractFormulasFromProperties(std::vector const& properties); std::pair> parseJaniModel(std::string const& path); storm::prism::Program parseProgram(std::string const& path);