From ebbd03c15b29b4d25438f413cb35ad5091efec17 Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 21 Jan 2016 16:48:06 +0100 Subject: [PATCH 1/3] fixed some warning-related stuff. introduced abstraction-refinement engine in options and entrypoints that currently only throws not-implemented exception Former-commit-id: 7a4bb8e18c6140bf6424291e5ec957edbfb187b9 --- CMakeLists.txt | 2 +- src/cli/entrypoints.h | 85 ++++++++++++++---------- src/parser/SpiritParserDefinitions.h | 5 ++ src/settings/modules/GeneralSettings.cpp | 7 +- src/settings/modules/GeneralSettings.h | 2 +- src/utility/storm.h | 3 + 6 files changed, 63 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2abc6a992..9f6a50f70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops") add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations") # Turn on popcnt instruction if desired (yes by default) diff --git a/src/cli/entrypoints.h b/src/cli/entrypoints.h index 93f9e1777..4eaa264cb 100644 --- a/src/cli/entrypoints.h +++ b/src/cli/entrypoints.h @@ -3,6 +3,8 @@ #include "src/utility/storm.h" +#include "src/exceptions/NotImplementedException.h" + namespace storm { namespace cli { @@ -47,6 +49,11 @@ namespace storm { } #endif + template + void verifySymbolicModelWithAbstractionRefinementEngine(storm::prism::Program const& program, std::vector> const& formulas) { + STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Abstraction Refinement is not yet implemented."); + } + template void verifySymbolicModelWithHybridEngine(std::shared_ptr> model, std::vector> const& formulas) { for (auto const& formula : formulas) { @@ -108,50 +115,56 @@ namespace storm { template void buildAndCheckSymbolicModel(storm::prism::Program const& program, std::vector> const& formulas) { - storm::storage::ModelProgramPair modelProgramPair = buildSymbolicModel(program, formulas); - STORM_LOG_THROW(modelProgramPair.model != nullptr, storm::exceptions::InvalidStateException, "Model could not be constructed for an unknown reason."); - - // Preprocess the model if needed. - BRANCH_ON_MODELTYPE(modelProgramPair.model, modelProgramPair.model, ValueType, LibraryType, preprocessModel, formulas); - - // Print some information about the model. - modelProgramPair.model->printModelInformationToStream(std::cout); + storm::settings::modules::GeneralSettings const& settings = storm::settings::generalSettings(); - // Verify the model, if a formula was given. - if (!formulas.empty()) { - // There may be constants of the model appearing in the formulas, so we replace all their occurrences - // by their definitions in the translated program. + if (settings.getEngine() == storm::settings::modules::GeneralSettings::Engine::AbstractionRefinement) { + verifySymbolicModelWithAbstractionRefinementEngine(program, formulas); + } else { + storm::storage::ModelProgramPair modelProgramPair = buildSymbolicModel(program, formulas); + STORM_LOG_THROW(modelProgramPair.model != nullptr, storm::exceptions::InvalidStateException, "Model could not be constructed for an unknown reason."); - // Start by building a mapping from constants of the (translated) model to their defining expressions. - std::map constantSubstitution; - for (auto const& constant : modelProgramPair.program.getConstants()) { - if (constant.isDefined()) { - constantSubstitution.emplace(constant.getExpressionVariable(), constant.getExpression()); - } - } + // Preprocess the model if needed. + BRANCH_ON_MODELTYPE(modelProgramPair.model, modelProgramPair.model, ValueType, LibraryType, preprocessModel, formulas); - std::vector> preparedFormulas; - for (auto const& formula : formulas) { - preparedFormulas.emplace_back(formula->substitute(constantSubstitution)); - } + // Print some information about the model. + modelProgramPair.model->printModelInformationToStream(std::cout); - if (modelProgramPair.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 : preparedFormulas) { - generateCounterexample(program, modelProgramPair.model->as>(), formula); + // Verify the model, if a formula was given. + if (!formulas.empty()) { + // There may be constants of the model appearing in the formulas, so we replace all their occurrences + // by their definitions in the translated program. + + // Start by building a mapping from constants of the (translated) model to their defining expressions. + std::map constantSubstitution; + for (auto const& constant : modelProgramPair.program.getConstants()) { + if (constant.isDefined()) { + constantSubstitution.emplace(constant.getExpressionVariable(), constant.getExpression()); } - } else { - verifySparseModel(modelProgramPair.model->as>(), preparedFormulas); } - } else if (modelProgramPair.model->isSymbolicModel()) { - if (storm::settings::generalSettings().getEngine() == storm::settings::modules::GeneralSettings::Engine::Hybrid) { - verifySymbolicModelWithHybridEngine(modelProgramPair.model->as>(), preparedFormulas); + + std::vector> preparedFormulas; + for (auto const& formula : formulas) { + preparedFormulas.emplace_back(formula->substitute(constantSubstitution)); + } + + if (modelProgramPair.model->isSparseModel()) { + if(settings.isCounterexampleSet()) { + // If we were requested to generate a counterexample, we now do so for each formula. + for(auto const& formula : preparedFormulas) { + generateCounterexample(program, modelProgramPair.model->as>(), formula); + } + } else { + verifySparseModel(modelProgramPair.model->as>(), preparedFormulas); + } + } else if (modelProgramPair.model->isSymbolicModel()) { + if (settings.getEngine() == storm::settings::modules::GeneralSettings::Engine::Hybrid) { + verifySymbolicModelWithHybridEngine(modelProgramPair.model->as>(), preparedFormulas); + } else { + verifySymbolicModelWithSymbolicEngine(modelProgramPair.model->as>(), preparedFormulas); + } } else { - verifySymbolicModelWithSymbolicEngine(modelProgramPair.model->as>(), preparedFormulas); + STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Invalid input model type."); } - } else { - STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Invalid input model type."); } } } diff --git a/src/parser/SpiritParserDefinitions.h b/src/parser/SpiritParserDefinitions.h index 20c922863..b4d1e183d 100644 --- a/src/parser/SpiritParserDefinitions.h +++ b/src/parser/SpiritParserDefinitions.h @@ -1,6 +1,9 @@ #ifndef STORM_PARSER_SPIRITPARSERDEFINITIONS_H_ #define STORM_PARSER_SPIRITPARSERDEFINITIONS_H_ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wno-#pragma-messages" + // Include boost spirit. #define BOOST_SPIRIT_USE_PHOENIX_V3 #include @@ -9,6 +12,8 @@ #include #include +#pragma clang diagnostic pop + namespace qi = boost::spirit::qi; namespace phoenix = boost::phoenix; diff --git a/src/settings/modules/GeneralSettings.cpp b/src/settings/modules/GeneralSettings.cpp index 701422587..95a48931b 100644 --- a/src/settings/modules/GeneralSettings.cpp +++ b/src/settings/modules/GeneralSettings.cpp @@ -96,9 +96,9 @@ namespace storm { .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The file from which to read the choice labels.").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, dontFixDeadlockOptionName, false, "If the model contains deadlock states, they need to be fixed by setting this option.").setShortName(dontFixDeadlockOptionShortName).build()); - std::vector engines = {"sparse", "hybrid", "dd"}; + std::vector engines = {"sparse", "hybrid", "dd", "abs"}; this->addOption(storm::settings::OptionBuilder(moduleName, engineOptionName, false, "Sets which engine is used for model building and model checking.").setShortName(engineOptionShortName) - .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the engine to use. Available are {sparse, hybrid, dd}.").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator(engines)).setDefaultValueString("sparse").build()).build()); + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the engine to use. Available are {sparse, hybrid, dd, ar}.").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator(engines)).setDefaultValueString("sparse").build()).build()); std::vector linearEquationSolver = {"gmm++", "native"}; this->addOption(storm::settings::OptionBuilder(moduleName, eqSolverOptionName, false, "Sets which solver is preferred for solving systems of linear equations.") @@ -346,10 +346,11 @@ namespace storm { engine = GeneralSettings::Engine::Hybrid; } else if (engineStr == "dd") { engine = GeneralSettings::Engine::Dd; + } else if (engineStr == "abs") { + engine = GeneralSettings::Engine::AbstractionRefinement; } else { STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown engine '" << engineStr << "'."); } - } bool GeneralSettings::check() const { diff --git a/src/settings/modules/GeneralSettings.h b/src/settings/modules/GeneralSettings.h index d6803b600..8144c0a1f 100644 --- a/src/settings/modules/GeneralSettings.h +++ b/src/settings/modules/GeneralSettings.h @@ -27,7 +27,7 @@ namespace storm { // An enumeration of all engines. enum class Engine { - Sparse, Hybrid, Dd + Sparse, Hybrid, Dd, AbstractionRefinement }; /*! diff --git a/src/utility/storm.h b/src/utility/storm.h index af70bb89c..03e297ca5 100644 --- a/src/utility/storm.h +++ b/src/utility/storm.h @@ -232,6 +232,9 @@ namespace storm { STORM_LOG_THROW(ddModel != nullptr, storm::exceptions::InvalidArgumentException, "Dd engine requires a dd input model"); return verifySymbolicModelWithDdEngine(ddModel, formula); } + case storm::settings::modules::GeneralSettings::Engine::AbstractionRefinement: { + STORM_LOG_ASSERT(false, "This position should not be reached, as at this point no model has been built."); + } } } From 0f8bd821250a285eb8f68521ec38a5121b093d43 Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 21 Jan 2016 16:50:14 +0100 Subject: [PATCH 2/3] corrected clang pragma Former-commit-id: 1f8a475d9576baad70e2f3c706b5977c5ceb1b6e --- src/parser/SpiritParserDefinitions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/SpiritParserDefinitions.h b/src/parser/SpiritParserDefinitions.h index b4d1e183d..abd13bc94 100644 --- a/src/parser/SpiritParserDefinitions.h +++ b/src/parser/SpiritParserDefinitions.h @@ -2,7 +2,7 @@ #define STORM_PARSER_SPIRITPARSERDEFINITIONS_H_ #pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wno-#pragma-messages" +#pragma clang diagnostic ignored "-W#pragma-messages" // Include boost spirit. #define BOOST_SPIRIT_USE_PHOENIX_V3 From e20942393e4eaddecbc358649fe4e410a51de31a Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 22 Jan 2016 13:23:59 +0100 Subject: [PATCH 3/3] added some primes Former-commit-id: f0da396762c4dd37e355fe1a33b5e62d664630a1 --- src/storage/BitVectorHashMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/BitVectorHashMap.cpp b/src/storage/BitVectorHashMap.cpp index 1726847ab..c184b764b 100644 --- a/src/storage/BitVectorHashMap.cpp +++ b/src/storage/BitVectorHashMap.cpp @@ -7,7 +7,7 @@ namespace storm { namespace storage { template - const std::vector BitVectorHashMap::sizes = {5, 13, 31, 79, 163, 277, 499, 1021, 2029, 3989, 8059, 16001, 32099, 64301, 127921, 256499, 511111, 1024901, 2048003, 4096891, 8192411, 15485863, 32142191}; + const std::vector BitVectorHashMap::sizes = {5, 13, 31, 79, 163, 277, 499, 1021, 2029, 3989, 8059, 16001, 32099, 64301, 127921, 256499, 511111, 1024901, 2048003, 4096891, 8192411, 15485863, 32142191, 64285127, 128572517, 257148523, 514299959, 102863003}; template BitVectorHashMap::BitVectorHashMapIterator::BitVectorHashMapIterator(BitVectorHashMap const& map, BitVector::const_iterator indexIt) : map(map), indexIt(indexIt) {