diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index c9e0aa7e6..36b6df27e 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -1,4 +1,5 @@ #include "cli.h" +#include "entrypoints.h" #include "../utility/storm.h" @@ -7,6 +8,7 @@ #include "src/utility/storm-version.h" + // Includes for the linked libraries and versions header. #ifdef STORM_HAVE_INTELTBB # include "tbb/tbb_stddef.h" @@ -110,7 +112,7 @@ namespace storm { std::cout << "Compiled with CUDA support, but an error occured trying to find CUDA devices." << std::endl; } #endif - + // "Compute" the command line argument string with which STORM was invoked. std::stringstream commandStream; for (int i = 1; i < argc; ++i) { diff --git a/src/utility/storm.h b/src/utility/storm.h index bb3a0a8a5..19f84b85d 100644 --- a/src/utility/storm.h +++ b/src/utility/storm.h @@ -209,22 +209,7 @@ namespace storm { return result; } - - template - void verifySparseModel(std::shared_ptr> model, std::vector> const& formulas) { - for (auto const& formula : formulas) { - std::cout << std::endl << "Model checking property: " << *formula << " ..."; - std::unique_ptr result(verifySparseModel(model, formula)); - if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; - result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates())); - std::cout << *result << std::endl; - } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; - } - } - } + #ifdef STORM_HAVE_CARL inline void exportParametricResultToFile(storm::RationalFunction const& result, storm::models::sparse::Dtmc::ConstraintCollector const& constraintCollector, std::string const& path) { @@ -242,39 +227,22 @@ namespace storm { std::copy(constraintCollector.getGraphPreservingConstraints().begin(), constraintCollector.getGraphPreservingConstraints().end(), std::ostream_iterator>(filestream, "\n")); filestream.close(); } - - template<> - inline void verifySparseModel(std::shared_ptr> model, std::vector> const& formulas) { - - for (auto const& formula : formulas) { - STORM_LOG_THROW(model->getType() == storm::models::ModelType::Dtmc, storm::exceptions::InvalidSettingsException, "Currently parametric verification is only available for DTMCs."); - std::shared_ptr> dtmc = model->template as>(); - - std::cout << std::endl << "Model checking property: " << *formula << " ..."; - std::unique_ptr result; - - storm::modelchecker::SparseDtmcEliminationModelChecker> modelchecker(*dtmc); - if (modelchecker.canHandle(*formula)) { - result = modelchecker.check(*formula); - } else { - STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "The parametric engine currently does not support this property."); - } - if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; - result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(dtmc->getInitialStates())); - std::cout << *result << std::endl; - } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; - } + template<> + inline std::unique_ptr verifySparseModel(std::shared_ptr> model, std::shared_ptr const& formula) { + std::unique_ptr result; + std::shared_ptr> dtmc = model->template as>(); - storm::settings::modules::ParametricSettings const& parametricSettings = storm::settings::parametricSettings(); - if (parametricSettings.exportResultToFile()) { - exportParametricResultToFile(result->asExplicitQuantitativeCheckResult()[*dtmc->getInitialStates().begin()], storm::models::sparse::Dtmc::ConstraintCollector(*dtmc), parametricSettings.exportResultPath()); - } + storm::modelchecker::SparseDtmcEliminationModelChecker> modelchecker(*dtmc); + if (modelchecker.canHandle(*formula)) { + result = modelchecker.check(*formula); + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "The parametric engine currently does not support this property."); } + return result; } + + #endif template @@ -304,22 +272,6 @@ namespace storm { return result; } - template - void verifySymbolicModelWithHybridEngine(std::shared_ptr> model, std::vector> const& formulas) { - for (auto const& formula : formulas) { - std::cout << std::endl << "Model checking property: " << *formula << " ..."; - std::unique_ptr result(verifySymbolicModelWithHybridEngine(model, formula)); - - if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; - result->filter(storm::modelchecker::SymbolicQualitativeCheckResult(model->getReachableStates(), model->getInitialStates())); - std::cout << *result << std::endl; - } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; - } - } - } template std::unique_ptr verifySymbolicModelWithDdEngine(std::shared_ptr> model, std::shared_ptr const& formula) { @@ -341,76 +293,6 @@ namespace storm { } return result; } - - template - void verifySymbolicModelWithSymbolicEngine(std::shared_ptr> model, std::vector> const& formulas) { - for (auto const& formula : formulas) { - std::cout << std::endl << "Model checking property: " << *formula << " ..."; - std::unique_ptr result(verifySymbolicModelWithDdEngine(model, formula)); - if (result) { - std::cout << " done." << std::endl; - std::cout << "Result (initial states): "; - result->filter(storm::modelchecker::SymbolicQualitativeCheckResult(model->getReachableStates(), model->getInitialStates())); - std::cout << *result << std::endl; - } else { - std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; - } - } - } - - - template - void buildAndCheckSymbolicModel(storm::prism::Program const& program, std::vector> const& formulas) { - std::shared_ptr model = buildSymbolicModel(program, formulas); - STORM_LOG_THROW(model != nullptr, storm::exceptions::InvalidStateException, "Model could not be constructed for an unknown reason."); - - // Preprocess the model if needed. - model = preprocessModel(model, formulas); - - // Print some information about the model. - model->printModelInformationToStream(std::cout); - - // Verify the model, if a formula was given. - if (!formulas.empty()) { - if (model->isSparseModel()) { - if(storm::settings::generalSettings().isCounterexampleSet()) { - // If we were requested to generate a counterexample, we now do so for each formula. - for(auto const& formula : formulas) { - generateCounterexample(program, model->as>(), formula); - } - } else { - verifySparseModel(model->as>(), formulas); - } - } else if (model->isSymbolicModel()) { - if (storm::settings::generalSettings().getEngine() == storm::settings::modules::GeneralSettings::Engine::Hybrid) { - verifySymbolicModelWithHybridEngine(model->as>(), formulas); - } else { - verifySymbolicModelWithSymbolicEngine(model->as>(), formulas); - } - } else { - STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Invalid input model type."); - } - } - } - - template - void buildAndCheckExplicitModel(std::vector> const& formulas) { - storm::settings::modules::GeneralSettings const& settings = storm::settings::generalSettings(); - - STORM_LOG_THROW(settings.isExplicitSet(), storm::exceptions::InvalidStateException, "Unable to build explicit model without model files."); - std::shared_ptr model = buildExplicitModel(settings.getTransitionFilename(), settings.getLabelingFilename(), settings.isStateRewardsSet() ? settings.getStateRewardsFilename() : boost::optional(), settings.isTransitionRewardsSet() ? settings.getTransitionRewardsFilename() : boost::optional(), settings.isChoiceLabelingSet() ? settings.getChoiceLabelingFilename() : boost::optional()); - // Preprocess the model if needed. - model = preprocessModel(model, formulas); - - // Print some information about the model. - model->printModelInformationToStream(std::cout); - - // Verify the model, if a formula was given. - if (!formulas.empty()) { - STORM_LOG_THROW(model->isSparseModel(), storm::exceptions::InvalidStateException, "Expected sparse model."); - verifySparseModel(model->as>(), formulas); - } - } }