From f0b591be77e55c1dfe44f165a1a41d714cf94f55 Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 12 Feb 2015 23:05:39 +0100 Subject: [PATCH] Further work on reintegrating parametric model checking into main executable. Former-commit-id: be95ce272279dfbda94e6e8a677ca750bd621abb --- CMakeLists.txt | 21 ++++++------------- src/builder/ExplicitPrismModelBuilder.cpp | 9 +++++++- .../ExplicitQuantitativeCheckResult.cpp | 2 ++ src/settings/modules/GeneralSettings.cpp | 10 ++++++++- src/settings/modules/GeneralSettings.h | 6 ++++++ src/storage/SparseMatrix.cpp | 15 +------------ ...tronglyConnectedComponentDecomposition.cpp | 1 - .../expressions/ExpressionEvaluator.cpp | 2 +- src/utility/ConstantsComparator.h | 2 +- src/utility/cli.h | 8 +++++++ 10 files changed, 42 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd7d430ca..275473505 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,6 @@ set(MSAT_ROOT "" CACHE STRING "The root directory of MathSAT (if available).") set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.") set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.") set(CUSTOM_BOOST_ROOT "" CACHE STRING "A custom path to the Boost root directory.") -option(PARAMETRIC_SYSTEMS "Sets whether models with parameters are supported." ON) ############################################################# ## ## Inclusion of required libraries @@ -89,17 +88,15 @@ else() set(ENABLE_MSAT ON) endif() -if(${PARAMETRIC_SYSTEMS}) - find_package(carl REQUIRED) +find_package(carl QUIET) +if(carl_FOUND) + message(STATUS "StoRM - Activating CArL.") set(STORM_HAVE_CARL ON) endif() message(STATUS "StoRM - CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(STATUS "StoRM - CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}") - - - ############################################################# ## ## Compiler specific settings and definitions @@ -258,8 +255,7 @@ include_directories("${PROJECT_BINARY_DIR}/include") file(GLOB_RECURSE STORM_HEADERS ${PROJECT_SOURCE_DIR}/src/*.h) file(GLOB_RECURSE STORM_SOURCES_WITHOUT_MAIN ${PROJECT_SOURCE_DIR}/src/*/*.cpp) file(GLOB_RECURSE STORM_MAIN_FILE ${PROJECT_SOURCE_DIR}/src/storm.cpp) -file(GLOB_RECURSE STORM_PARAMETRIC_MAIN_FILE ${PROJECT_SOURCE_DIR}/src/stormParametric.cpp) -set(STORM_SOURCES "${STORM_SOURCES_WITHOUT_MAIN};${STORM_MAIN_FILE};${STORM_PARAMETRIC_MAIN_FILE};") +set(STORM_SOURCES "${STORM_SOURCES_WITHOUT_MAIN};${STORM_MAIN_FILE};") file(GLOB_RECURSE STORM_ADAPTERS_FILES ${PROJECT_SOURCE_DIR}/src/adapters/*.h ${PROJECT_SOURCE_DIR}/src/adapters/*.cpp) file(GLOB_RECURSE STORM_BUILDER_FILES ${PROJECT_SOURCE_DIR}/src/builder/*.h ${PROJECT_SOURCE_DIR}/src/builder/*.cpp) file(GLOB_RECURSE STORM_EXCEPTIONS_FILES ${PROJECT_SOURCE_DIR}/src/exceptions/*.h ${PROJECT_SOURCE_DIR}/src/exceptions/*.cpp) @@ -379,11 +375,6 @@ add_library(storm ${STORM_SOURCES_WITHOUT_MAIN} ${STORM_HEADERS}) add_executable(storm-main ${STORM_MAIN_FILE}) target_link_libraries(storm-main storm) set_target_properties(storm-main PROPERTIES OUTPUT_NAME "storm") -if(PARAMETRIC_SYSTEMS) - add_executable(storm-main-param ${STORM_PARAMETRIC_MAIN_FILE}) - target_link_libraries(storm-main-param storm) - set_target_properties(storm-main-param PROPERTIES OUTPUT_NAME "pstorm") -endif() add_executable(storm-functional-tests ${STORM_FUNCTIONAL_TEST_MAIN_FILE} ${STORM_FUNCTIONAL_TEST_FILES}) target_link_libraries(storm-functional-tests storm) add_executable(storm-performance-tests ${STORM_PERFORMANCE_TEST_MAIN_FILE} ${STORM_PERFORMANCE_TEST_FILES}) @@ -471,8 +462,8 @@ endif(ENABLE_Z3) ## ############################################################# -if(PARAMETRIC_SYSTEMS) - message(STATUS "StoRM - Linking with carl") +if(STORM_HAVE_CARL) + message(STATUS "StoRM - Linking with carl.") include_directories("${carl_INCLUDE_DIR}") target_link_libraries(storm lib_carl) target_link_libraries(storm-functional-tests lib_carl) diff --git a/src/builder/ExplicitPrismModelBuilder.cpp b/src/builder/ExplicitPrismModelBuilder.cpp index 7079b69b9..5ac83af33 100644 --- a/src/builder/ExplicitPrismModelBuilder.cpp +++ b/src/builder/ExplicitPrismModelBuilder.cpp @@ -103,7 +103,11 @@ namespace storm { } // If the program still contains undefined constants and we are not in a parametric setting, assemble an appropriate error message. - if (!std::is_same::value && preparedProgram.hasUndefinedConstants()) { +#ifdef STORM_HAVE_CARL + if (!std::is_same::value && preparedProgram.hasUndefinedConstants()) { +#else + if (preparedProgram.hasUndefinedConstants()) { +#endif std::vector> undefinedConstants = preparedProgram.getUndefinedConstants(); std::stringstream stream; bool printComma = false; @@ -788,6 +792,9 @@ namespace storm { // Explicitly instantiate the class. template class ExplicitPrismModelBuilder; + +#ifdef STORM_HAVE_CARL template class ExplicitPrismModelBuilder; +#endif } } \ No newline at end of file diff --git a/src/modelchecker/results/ExplicitQuantitativeCheckResult.cpp b/src/modelchecker/results/ExplicitQuantitativeCheckResult.cpp index 90d7b09ef..31b7e5296 100644 --- a/src/modelchecker/results/ExplicitQuantitativeCheckResult.cpp +++ b/src/modelchecker/results/ExplicitQuantitativeCheckResult.cpp @@ -184,11 +184,13 @@ namespace storm { } } +#ifdef STORM_HAVE_CARL template<> std::unique_ptr ExplicitQuantitativeCheckResult::compareAgainstBound(storm::logic::ComparisonType comparisonType, double bound) const { // Since it is not possible to compare rational functions against bounds, we simply call the base class method. return QuantitativeCheckResult::compareAgainstBound(comparisonType, bound); } +#endif template ValueType& ExplicitQuantitativeCheckResult::operator[](storm::storage::sparse::state_type state) { diff --git a/src/settings/modules/GeneralSettings.cpp b/src/settings/modules/GeneralSettings.cpp index d38cf4305..05c03618a 100644 --- a/src/settings/modules/GeneralSettings.cpp +++ b/src/settings/modules/GeneralSettings.cpp @@ -41,7 +41,10 @@ namespace storm { const std::string GeneralSettings::statisticsOptionShortName = "stats"; const std::string GeneralSettings::bisimulationOptionName = "bisimulation"; const std::string GeneralSettings::bisimulationOptionShortName = "bisim"; + +#ifdef STORM_HAVE_CARL const std::string GeneralSettings::parametricOptionName = "parametric"; +#endif GeneralSettings::GeneralSettings(storm::settings::SettingsManager& settingsManager) : ModuleSettings(settingsManager, moduleName) { this->addOption(storm::settings::OptionBuilder(moduleName, helpOptionName, false, "Shows all available options, arguments and descriptions.").setShortName(helpOptionShortName) @@ -85,7 +88,10 @@ namespace storm { this->addOption(storm::settings::OptionBuilder(moduleName, constantsOptionName, false, "Specifies the constant replacements to use in symbolic models. Note that Note that this requires the model to be given as an symbolic model (i.e., via --" + symbolicOptionName + ").").setShortName(constantsOptionShortName) .addArgument(storm::settings::ArgumentBuilder::createStringArgument("values", "A comma separated list of constants and their value, e.g. a=1,b=2,c=3.").setDefaultValueString("").build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, statisticsOptionName, false, "Sets whether to display statistics if available.").setShortName(statisticsOptionShortName).build()); + +#ifdef STORM_HAVE_CARL this->addOption(storm::settings::OptionBuilder(moduleName, parametricOptionName, false, "Sets whether to use the parametric engine.").build()); +#endif } bool GeneralSettings::isHelpSet() const { @@ -245,10 +251,12 @@ namespace storm { return this->getOption(bisimulationOptionName).getHasOptionBeenSet(); } +#ifdef STORM_HAVE_CARL bool GeneralSettings::isParametricSet() const { return this->getOption(parametricOptionName).getHasOptionBeenSet(); } - +#endif + bool GeneralSettings::check() const { // Ensure that the model was given either symbolically or explicitly. STORM_LOG_THROW(!isSymbolicSet() || !isExplicitSet(), storm::exceptions::InvalidSettingsException, "The model may be either given in an explicit or a symbolic format, but not both."); diff --git a/src/settings/modules/GeneralSettings.h b/src/settings/modules/GeneralSettings.h index e0d84e894..db3810af5 100644 --- a/src/settings/modules/GeneralSettings.h +++ b/src/settings/modules/GeneralSettings.h @@ -1,6 +1,7 @@ #ifndef STORM_SETTINGS_MODULES_GENERALSETTINGS_H_ #define STORM_SETTINGS_MODULES_GENERALSETTINGS_H_ +#include "storm-config.h" #include "src/settings/modules/ModuleSettings.h" namespace storm { @@ -286,12 +287,14 @@ namespace storm { */ bool isBisimulationSet() const; +#ifdef STORM_HAVE_CARL /*! * Retrieves whether the option enabling parametric model checking is set. * * @return True iff the option was set. */ bool isParametricSet() const; +#endif bool check() const override; @@ -332,7 +335,10 @@ namespace storm { static const std::string statisticsOptionShortName; static const std::string bisimulationOptionName; static const std::string bisimulationOptionShortName; + +#ifdef STORM_HAVE_CARL static const std::string parametricOptionName; +#endif }; } // namespace modules diff --git a/src/storage/SparseMatrix.cpp b/src/storage/SparseMatrix.cpp index 9fcdb856e..1cbdaef68 100644 --- a/src/storage/SparseMatrix.cpp +++ b/src/storage/SparseMatrix.cpp @@ -720,14 +720,7 @@ namespace storm { return std::make_pair(std::move(resultLU), dInvBuilder.build()); } -#ifdef PARAMETRIC_SYSTEMS - template<> - typename std::pair, storm::storage::SparseMatrix> SparseMatrix::getJacobiDecomposition() const { - // NOT SUPPORTED - // TODO do whatever storm does in such cases. - assert(false); - } - +#ifdef STORM_HAVE_CARL template<> typename std::pair, storm::storage::SparseMatrix> SparseMatrix::getJacobiDecomposition() const { // NOT SUPPORTED @@ -992,12 +985,6 @@ namespace storm { template class SparseMatrixBuilder; template class SparseMatrix; template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); - - template class MatrixEntry::index_type, Polynomial>; - template std::ostream& operator<<(std::ostream& out, MatrixEntry const& entry); - template class SparseMatrixBuilder; - template class SparseMatrix; - template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); #endif diff --git a/src/storage/StronglyConnectedComponentDecomposition.cpp b/src/storage/StronglyConnectedComponentDecomposition.cpp index 692fdd9d7..2c7b0322b 100644 --- a/src/storage/StronglyConnectedComponentDecomposition.cpp +++ b/src/storage/StronglyConnectedComponentDecomposition.cpp @@ -212,7 +212,6 @@ namespace storm { // Explicitly instantiate the SCC decomposition. template class StronglyConnectedComponentDecomposition; #ifdef STORM_HAVE_CARL - template class StronglyConnectedComponentDecomposition; template class StronglyConnectedComponentDecomposition; #endif } // namespace storage diff --git a/src/storage/expressions/ExpressionEvaluator.cpp b/src/storage/expressions/ExpressionEvaluator.cpp index cf927a0ff..46ef54c24 100644 --- a/src/storage/expressions/ExpressionEvaluator.cpp +++ b/src/storage/expressions/ExpressionEvaluator.cpp @@ -7,7 +7,7 @@ namespace storm { // Intentionally left empty. } -#ifdef PARAMETRIC_SYSTEMS +#ifdef STORM_HAVE_CARL ExpressionEvaluator::ExpressionEvaluator(storm::expressions::ExpressionManager const& manager) : ExprtkExpressionEvaluatorBase(manager) { // Intentionally left empty. } diff --git a/src/utility/ConstantsComparator.h b/src/utility/ConstantsComparator.h index 358b217c9..f31774468 100644 --- a/src/utility/ConstantsComparator.h +++ b/src/utility/ConstantsComparator.h @@ -41,7 +41,7 @@ namespace storm { template ValueType pow(ValueType const& value, uint_fast64_t exponent); -#ifdef PARAMETRIC_SYSTEMS +#ifdef STORM_HAVE_CARL template<> RationalFunction pow(RationalFunction const& value, uint_fast64_t exponent); #endif diff --git a/src/utility/cli.h b/src/utility/cli.h index cae78c1a8..6427f7dd9 100644 --- a/src/utility/cli.h +++ b/src/utility/cli.h @@ -332,10 +332,12 @@ namespace storm { } } +#ifdef STORM_HAVE_CARL template<> void generateCounterexample(storm::prism::Program const& program, std::shared_ptr> model, std::shared_ptr formula) { STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Unable to generate counterexample for parametric model."); } +#endif template void verifyModel(boost::optional const& program, std::shared_ptr> model, std::shared_ptr formula) { @@ -376,6 +378,7 @@ namespace storm { } } +#ifdef STORM_HAVE_CARL template<> void verifyModel(boost::optional const& program, std::shared_ptr> model, std::shared_ptr formula) { storm::settings::modules::GeneralSettings const& settings = storm::settings::generalSettings(); @@ -402,6 +405,7 @@ namespace storm { std::cout << " skipped, because the modelling formalism is currently unsupported." << std::endl; } } +#endif template void buildAndCheckSymbolicModel(boost::optional const& program, boost::optional> formula) { @@ -467,11 +471,15 @@ namespace storm { } if (settings.isSymbolicSet()) { +#ifdef STORM_HAVE_CARL if (settings.isParametricSet()) { buildAndCheckSymbolicModel(program.get(), formula); } else { +#endif buildAndCheckSymbolicModel(program.get(), formula); +#ifdef STORM_HAVE_CARL } +#endif } else if (settings.isExplicitSet()) { buildAndCheckExplicitModel(formula); } else {