Browse Source
build infrastructure for switching between multi objective model checking methods
main
build infrastructure for switching between multi objective model checking methods
main
19 changed files with 506 additions and 143 deletions
-
4src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp
-
19src/storm/modelchecker/multiobjective/MultiObjectiveModelCheckingMethod.cpp
-
13src/storm/modelchecker/multiobjective/MultiObjectiveModelCheckingMethod.h
-
50src/storm/modelchecker/multiobjective/constraintBased/SparseCbAchievabilityQuery.cpp
-
36src/storm/modelchecker/multiobjective/constraintBased/SparseCbAchievabilityQuery.h
-
36src/storm/modelchecker/multiobjective/constraintBased/SparseCbQuery.cpp
-
39src/storm/modelchecker/multiobjective/constraintBased/SparseCbQuery.h
-
122src/storm/modelchecker/multiobjective/multiObjectiveModelChecking.cpp
-
19src/storm/modelchecker/multiobjective/multiObjectiveModelChecking.h
-
88src/storm/modelchecker/multiobjective/pcaa.cpp
-
20src/storm/modelchecker/multiobjective/pcaa.h
-
2src/storm/modelchecker/multiobjective/pcaa/SparsePcaaQuery.h
-
4src/storm/modelchecker/prctl/HybridMdpPrctlModelChecker.cpp
-
4src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp
-
19src/storm/settings/modules/MultiObjectiveSettings.cpp
-
7src/storm/settings/modules/MultiObjectiveSettings.h
-
28src/test/modelchecker/SparseMaPcaaMultiObjectiveModelCheckerTest.cpp
-
113src/test/modelchecker/SparseMdpCbMultiObjectiveModelCheckerTest
-
26src/test/modelchecker/SparseMdpPcaaMultiObjectiveModelCheckerTest.cpp
@ -0,0 +1,19 @@ |
|||
#include "storm/modelchecker/multiobjective/MultiObjectiveModelCheckingMethod.h"
|
|||
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
std::string toString(MultiObjectiveMethod m) { |
|||
switch (m) { |
|||
case MultiObjectiveMethod::Pcaa: |
|||
return "Pareto Curve Approximation Algorithm"; |
|||
case MultiObjectiveMethod::ConstraintBased: |
|||
return "Constraint Based Algorithm"; |
|||
} |
|||
return "invalid"; |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/utility/ExtendSettingEnumWithSelectionField.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
ExtendEnumsWithSelectionField(MultiObjectiveMethod, Pcaa, ConstraintBased) |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
@ -0,0 +1,50 @@ |
|||
#include "storm/modelchecker/multiobjective/constraintbased/SparseCbAchievabilityQuery.h"
|
|||
|
|||
#include "storm/adapters/CarlAdapter.h"
|
|||
#include "storm/models/sparse/Mdp.h"
|
|||
#include "storm/models/sparse/MarkovAutomaton.h"
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
#include "storm/modelchecker/results/ExplicitQualitativeCheckResult.h"
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/utility/vector.h"
|
|||
#include "storm/settings/SettingsManager.h"
|
|||
#include "storm/settings/modules/GeneralSettings.h"
|
|||
#include "storm/settings/modules/MultiObjectiveSettings.h"
|
|||
|
|||
#include "storm/exceptions/InvalidOperationException.h"
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
|
|||
template <class SparseModelType> |
|||
SparseCbAchievabilityQuery<SparseModelType>::SparseCbAchievabilityQuery(SparseMultiObjectivePreprocessorReturnType<SparseModelType>& preprocessorResult) : SparseCbQuery<SparseModelType>(preprocessorResult) { |
|||
STORM_LOG_ASSERT(preprocessorResult.queryType==SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Achievability, "Invalid query Type"); |
|||
|
|||
} |
|||
|
|||
template <class SparseModelType> |
|||
std::unique_ptr<CheckResult> SparseCbAchievabilityQuery<SparseModelType>::check() { |
|||
|
|||
bool result = this->checkAchievability(); |
|||
|
|||
return std::unique_ptr<CheckResult>(new ExplicitQualitativeCheckResult(this->originalModel.getInitialStates().getNextSetIndex(0), result)); |
|||
|
|||
} |
|||
|
|||
template <class SparseModelType> |
|||
bool SparseCbAchievabilityQuery<SparseModelType>::checkAchievability() { |
|||
return false; |
|||
} |
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
template class SparseCbAchievabilityQuery<storm::models::sparse::Mdp<double>>; |
|||
template class SparseCbAchievabilityQuery<storm::models::sparse::MarkovAutomaton<double>>; |
|||
|
|||
template class SparseCbAchievabilityQuery<storm::models::sparse::Mdp<storm::RationalNumber>>; |
|||
// template class SparseCbAchievabilityQuery<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>;
|
|||
#endif
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/modelchecker/multiobjective/constraintbased/SparseCbQuery.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
/* |
|||
* This class represents an achievability query for the constraint based approach (using SMT or LP solvers). |
|||
*/ |
|||
template <class SparseModelType> |
|||
class SparseCbAchievabilityQuery : public SparseCbQuery<SparseModelType> { |
|||
public: |
|||
|
|||
SparseCbAchievabilityQuery(SparseMultiObjectivePreprocessorReturnType<SparseModelType>& preprocessorResult); |
|||
|
|||
virtual ~SparseCbAchievabilityQuery() = default; |
|||
|
|||
/* |
|||
* Invokes the computation and retrieves the result |
|||
*/ |
|||
virtual std::unique_ptr<CheckResult> check() override; |
|||
|
|||
private: |
|||
|
|||
/* |
|||
* Returns whether the given thresholds are achievable. |
|||
*/ |
|||
bool checkAchievability(); |
|||
|
|||
}; |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
#include "storm/modelchecker/multiobjective/constraintbased/SparseCbQuery.h"
|
|||
|
|||
#include "storm/adapters/CarlAdapter.h"
|
|||
#include "storm/models/sparse/Mdp.h"
|
|||
#include "storm/models/sparse/MarkovAutomaton.h"
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
#include "storm/modelchecker/multiobjective/Objective.h"
|
|||
#include "storm/settings/SettingsManager.h"
|
|||
#include "storm/settings/modules/MultiObjectiveSettings.h"
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/utility/vector.h"
|
|||
|
|||
#include "storm/exceptions/UnexpectedException.h"
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
|
|||
template <class SparseModelType> |
|||
SparseCbQuery<SparseModelType>::SparseCbQuery(SparseMultiObjectivePreprocessorReturnType<SparseModelType>& preprocessorResult) : |
|||
originalModel(preprocessorResult.originalModel), originalFormula(preprocessorResult.originalFormula), |
|||
preprocessedModel(std::move(*preprocessorResult.preprocessedModel)), objectives(std::move(preprocessorResult.objectives)) { |
|||
|
|||
} |
|||
|
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
template class SparseCbQuery<storm::models::sparse::Mdp<double>>; |
|||
template class SparseCbQuery<storm::models::sparse::MarkovAutomaton<double>>; |
|||
|
|||
template class SparseCbQuery<storm::models::sparse::Mdp<storm::RationalNumber>>; |
|||
#endif
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,39 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/modelchecker/results/CheckResult.h" |
|||
#include "storm/modelchecker/multiobjective/SparseMultiObjectivePreprocessorReturnType.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
/* |
|||
* This class represents a multi-objective query for the constraint based approach (using SMT or LP solvers). |
|||
*/ |
|||
template <class SparseModelType> |
|||
class SparseCbQuery { |
|||
public: |
|||
|
|||
|
|||
virtual ~SparseCbQuery() = default; |
|||
|
|||
/* |
|||
* Invokes the computation and retrieves the result |
|||
*/ |
|||
virtual std::unique_ptr<CheckResult> check() = 0; |
|||
|
|||
protected: |
|||
|
|||
SparseCbQuery(SparseMultiObjectivePreprocessorReturnType<SparseModelType>& preprocessorResult); |
|||
|
|||
SparseModelType const& originalModel; |
|||
storm::logic::MultiObjectiveFormula const& originalFormula; |
|||
|
|||
SparseModelType preprocessedModel; |
|||
std::vector<Objective<typename SparseModelType::ValueType>> objectives; |
|||
|
|||
}; |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,122 @@ |
|||
#include "storm/modelchecker/multiobjective/multiObjectiveModelChecking.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
#include "storm/models/sparse/Mdp.h"
|
|||
#include "storm/models/sparse/MarkovAutomaton.h"
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
#include "storm/modelchecker/multiobjective/SparseMultiObjectivePreprocessor.h"
|
|||
#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaAchievabilityQuery.h"
|
|||
#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaQuantitativeQuery.h"
|
|||
#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaParetoQuery.h"
|
|||
#include "storm/modelchecker/multiobjective/constraintbased/SparseCbAchievabilityQuery.h"
|
|||
#include "storm/settings/SettingsManager.h"
|
|||
#include "storm/settings/modules/MultiObjectiveSettings.h"
|
|||
#include "storm/settings/modules/CoreSettings.h"
|
|||
#include "storm/utility/Stopwatch.h"
|
|||
|
|||
#include "storm/exceptions/InvalidArgumentException.h"
|
|||
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
template<typename SparseModelType> |
|||
std::unique_ptr<CheckResult> performMultiObjectiveModelChecking(SparseModelType const& model, storm::logic::MultiObjectiveFormula const& formula, MultiObjectiveMethodSelection methodSelection) { |
|||
storm::utility::Stopwatch swTotal(true); |
|||
storm::utility::Stopwatch swPreprocessing(true); |
|||
STORM_LOG_ASSERT(model.getInitialStates().getNumberOfSetBits() == 1, "Multi-objective Model checking on model with multiple initial states is not supported."); |
|||
|
|||
// If we consider an MA, ensure that it is closed
|
|||
if(model.isOfType(storm::models::ModelType::MarkovAutomaton)) { |
|||
STORM_LOG_THROW(dynamic_cast<storm::models::sparse::MarkovAutomaton<typename SparseModelType::ValueType> const *>(&model)->isClosed(), storm::exceptions::InvalidArgumentException, "Unable to check multi-objective formula on non-closed Markov automaton."); |
|||
} |
|||
|
|||
// Preprocess the model
|
|||
auto preprocessorResult = SparseMultiObjectivePreprocessor<SparseModelType>::preprocess(model, formula); |
|||
swPreprocessing.stop(); |
|||
if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) { |
|||
STORM_PRINT_AND_LOG("Preprocessing done in " << swPreprocessing << " seconds." << std::endl << " Result: " << preprocessorResult << std::endl); |
|||
} else { |
|||
STORM_LOG_INFO("Preprocessing done in " << swPreprocessing << " seconds." << std::endl << " Result: " << preprocessorResult << std::endl); |
|||
} |
|||
|
|||
// Get the solution method
|
|||
MultiObjectiveMethod method; |
|||
if (methodSelection == MultiObjectiveMethodSelection::FROMSETTINGS) { |
|||
method = storm::settings::getModule<storm::settings::modules::MultiObjectiveSettings>().getMultiObjectiveMethod(); |
|||
} else { |
|||
method = convert(methodSelection); |
|||
} |
|||
|
|||
// Invoke the analysis
|
|||
storm::utility::Stopwatch swAnalysis(true); |
|||
std::unique_ptr<CheckResult> result; |
|||
switch (method) { |
|||
case MultiObjectiveMethod::Pcaa: |
|||
{ |
|||
std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> query; |
|||
switch (preprocessorResult.queryType) { |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Achievability: |
|||
query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> (new SparsePcaaAchievabilityQuery<SparseModelType, storm::RationalNumber>(preprocessorResult)); |
|||
break; |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Quantitative: |
|||
query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> (new SparsePcaaQuantitativeQuery<SparseModelType, storm::RationalNumber>(preprocessorResult)); |
|||
break; |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Pareto: |
|||
query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> (new SparsePcaaParetoQuery<SparseModelType, storm::RationalNumber>(preprocessorResult)); |
|||
break; |
|||
default: |
|||
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'."); |
|||
break; |
|||
} |
|||
|
|||
result = query->check(); |
|||
|
|||
if(storm::settings::getModule<storm::settings::modules::MultiObjectiveSettings>().isExportPlotSet()) { |
|||
query->exportPlotOfCurrentApproximation(storm::settings::getModule<storm::settings::modules::MultiObjectiveSettings>().getExportPlotDirectory()); |
|||
} |
|||
break; |
|||
} |
|||
case MultiObjectiveMethod::ConstraintBased: |
|||
{ |
|||
std::unique_ptr<SparseCbQuery<SparseModelType>> query; |
|||
switch (preprocessorResult.queryType) { |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Achievability: |
|||
query = std::unique_ptr<SparseCbQuery<SparseModelType>> (new SparseCbAchievabilityQuery<SparseModelType>(preprocessorResult)); |
|||
break; |
|||
default: |
|||
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'."); |
|||
break; |
|||
} |
|||
|
|||
result = query->check(); |
|||
|
|||
if(storm::settings::getModule<storm::settings::modules::MultiObjectiveSettings>().isExportPlotSet()) { |
|||
STORM_LOG_ERROR("Can not export plot for the constrained based solver."); |
|||
} |
|||
break; |
|||
} |
|||
default: |
|||
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The multi-objective solution method '" << toString(method) << "' is not supported."); |
|||
} |
|||
swAnalysis.stop(); |
|||
|
|||
swTotal.stop(); |
|||
if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) { |
|||
STORM_PRINT_AND_LOG("Solving multi-objective query took " << swTotal << " seconds (consisting of " << swPreprocessing << " seconds for preprocessing and " << swAnalysis << " seconds for analyzing the preprocessed model)." << std::endl); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<double>>(storm::models::sparse::Mdp<double> const& model, storm::logic::MultiObjectiveFormula const& formula, MultiObjectiveMethodSelection methodSelection); |
|||
template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<double>>(storm::models::sparse::MarkovAutomaton<double> const& model, storm::logic::MultiObjectiveFormula const& formula, MultiObjectiveMethodSelection methodSelection); |
|||
template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<storm::RationalNumber>>(storm::models::sparse::Mdp<storm::RationalNumber> const& model, storm::logic::MultiObjectiveFormula const& formula, MultiObjectiveMethodSelection methodSelection); |
|||
// template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>(storm::models::sparse::MarkovAutomaton<storm::RationalNumber> const& model, storm::logic::MultiObjectiveFormula const& formula, MultiObjectiveMethodSelection methodSelection);
|
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
|
|||
#include "storm/modelchecker/results/CheckResult.h" |
|||
#include "storm/modelchecker/multiobjective/MultiObjectiveModelCheckingMethod.h" |
|||
#include "storm/logic/Formulas.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
|
|||
template<typename SparseModelType> |
|||
std::unique_ptr<CheckResult> performMultiObjectiveModelChecking(SparseModelType const& model, storm::logic::MultiObjectiveFormula const& formula, MultiObjectiveMethodSelection methodSelection = MultiObjectiveMethodSelection::FROMSETTINGS); |
|||
|
|||
} |
|||
} |
|||
} |
@ -1,88 +0,0 @@ |
|||
#include "storm/modelchecker/multiobjective/pcaa.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
#include "storm/models/sparse/Mdp.h"
|
|||
#include "storm/models/sparse/MarkovAutomaton.h"
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
#include "storm/modelchecker/multiobjective/SparseMultiObjectivePreprocessor.h"
|
|||
#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaAchievabilityQuery.h"
|
|||
#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaQuantitativeQuery.h"
|
|||
#include "storm/modelchecker/multiobjective/pcaa/SparsePcaaParetoQuery.h"
|
|||
#include "storm/settings/SettingsManager.h"
|
|||
#include "storm/settings/modules/MultiObjectiveSettings.h"
|
|||
#include "storm/settings/modules/CoreSettings.h"
|
|||
#include "storm/utility/Stopwatch.h"
|
|||
|
|||
#include "storm/exceptions/InvalidArgumentException.h"
|
|||
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
template<typename SparseModelType> |
|||
std::unique_ptr<CheckResult> performPcaa(SparseModelType const& model, storm::logic::MultiObjectiveFormula const& formula) { |
|||
storm::utility::Stopwatch swTotal(true); |
|||
storm::utility::Stopwatch swPreprocessing(true); |
|||
STORM_LOG_ASSERT(model.getInitialStates().getNumberOfSetBits() == 1, "Multi-objective Model checking on model with multiple initial states is not supported."); |
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
|
|||
// If we consider an MA, ensure that it is closed
|
|||
if(model.isOfType(storm::models::ModelType::MarkovAutomaton)) { |
|||
STORM_LOG_THROW(dynamic_cast<storm::models::sparse::MarkovAutomaton<typename SparseModelType::ValueType> const *>(&model)->isClosed(), storm::exceptions::InvalidArgumentException, "Unable to check multi-objective formula on non-closed Markov automaton."); |
|||
} |
|||
|
|||
auto preprocessorResult = SparseMultiObjectivePreprocessor<SparseModelType>::preprocess(model, formula); |
|||
swPreprocessing.stop(); |
|||
if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) { |
|||
STORM_PRINT_AND_LOG("Preprocessing done in " << swPreprocessing << " seconds." << std::endl << " Result: " << preprocessorResult << std::endl); |
|||
} else { |
|||
STORM_LOG_INFO("Preprocessing done in " << swPreprocessing << " seconds." << std::endl << " Result: " << preprocessorResult << std::endl); |
|||
} |
|||
storm::utility::Stopwatch swValueIterations(true); |
|||
std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> query; |
|||
switch (preprocessorResult.queryType) { |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Achievability: |
|||
query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> (new SparsePcaaAchievabilityQuery<SparseModelType, storm::RationalNumber>(preprocessorResult)); |
|||
break; |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Quantitative: |
|||
query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> (new SparsePcaaQuantitativeQuery<SparseModelType, storm::RationalNumber>(preprocessorResult)); |
|||
break; |
|||
case SparseMultiObjectivePreprocessorReturnType<SparseModelType>::QueryType::Pareto: |
|||
query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> (new SparsePcaaParetoQuery<SparseModelType, storm::RationalNumber>(preprocessorResult)); |
|||
break; |
|||
default: |
|||
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Unsupported multi-objective Query Type."); |
|||
break; |
|||
} |
|||
|
|||
auto result = query->check(); |
|||
swValueIterations.stop(); |
|||
swTotal.stop(); |
|||
if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) { |
|||
STORM_PRINT_AND_LOG("Solving multi-objective query took " << swTotal << " seconds (consisting of " << swPreprocessing << " seconds for preprocessing and " << swValueIterations << " seconds for value iteration-based exploration of achievable points)." << std::endl); |
|||
} |
|||
|
|||
|
|||
if(storm::settings::getModule<storm::settings::modules::MultiObjectiveSettings>().isExportPlotSet()) { |
|||
query->exportPlotOfCurrentApproximation(storm::settings::getModule<storm::settings::modules::MultiObjectiveSettings>().getExportPlotDirectory()); |
|||
} |
|||
return result; |
|||
#else
|
|||
STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Multi-objective model checking requires carl."); |
|||
return nullptr; |
|||
#endif
|
|||
} |
|||
|
|||
template std::unique_ptr<CheckResult> performPcaa<storm::models::sparse::Mdp<double>>(storm::models::sparse::Mdp<double> const& model, storm::logic::MultiObjectiveFormula const& formula); |
|||
template std::unique_ptr<CheckResult> performPcaa<storm::models::sparse::MarkovAutomaton<double>>(storm::models::sparse::MarkovAutomaton<double> const& model, storm::logic::MultiObjectiveFormula const& formula); |
|||
#ifdef STORM_HAVE_CARL
|
|||
template std::unique_ptr<CheckResult> performPcaa<storm::models::sparse::Mdp<storm::RationalNumber>>(storm::models::sparse::Mdp<storm::RationalNumber> const& model, storm::logic::MultiObjectiveFormula const& formula); |
|||
// template std::unique_ptr<CheckResult> performPcaa<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>(storm::models::sparse::MarkovAutomaton<storm::RationalNumber> const& model, storm::logic::MultiObjectiveFormula const& formula);
|
|||
#endif
|
|||
|
|||
} |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
#ifndef STORM_MODELCHECKER_MULTIOBJECTIVE_PCAA_H_ |
|||
#define STORM_MODELCHECKER_MULTIOBJECTIVE_PCAA_H_ |
|||
|
|||
#include <memory> |
|||
|
|||
#include "storm/modelchecker/results/CheckResult.h" |
|||
#include "storm/logic/Formulas.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace multiobjective { |
|||
|
|||
template<typename SparseModelType> |
|||
std::unique_ptr<CheckResult> performPcaa(SparseModelType const& model, storm::logic::MultiObjectiveFormula const& formula); |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_MODELCHECKER_MULTIOBJECTIVE_PCAA_H_ */ |
@ -0,0 +1,113 @@ |
|||
#include "gtest/gtest.h" |
|||
#include "storm-config.h" |
|||
|
|||
#if defined STORM_HAVE_HYPRO || defined STORM_HAVE_Z3_OPTIMIZE |
|||
|
|||
#include "storm/modelchecker/multiobjective/multiObjectiveModelChecking.h" |
|||
#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h" |
|||
#include "storm/modelchecker/results/ExplicitQualitativeCheckResult.h" |
|||
#include "storm/models/sparse/Mdp.h" |
|||
#include "storm/settings/modules/GeneralSettings.h" |
|||
#include "storm/settings/SettingsManager.h" |
|||
#include "storm/utility/storm.h" |
|||
|
|||
|
|||
TEST(SparseMdpCbMultiObjectiveModelCheckerTest, consensus) { |
|||
|
|||
std::string programFile = STORM_TEST_RESOURCES_DIR "/mdp/multiobj_consensus2_3_2.nm"; |
|||
std::string formulasAsString = "multi(Pmax=? [ F \"one_proc_err\" ], P>=0.8916673903 [ G \"one_coin_ok\" ]) "; // numerical |
|||
formulasAsString += "; \n multi(P>=0.1 [ F \"one_proc_err\" ], P>=0.8916673903 [ G \"one_coin_ok\" ])"; // achievability (true) |
|||
formulasAsString += "; \n multi(P>=0.11 [ F \"one_proc_err\" ], P>=0.8916673903 [ G \"one_coin_ok\" ])"; // achievability (false) |
|||
|
|||
// programm, model, formula |
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
program = storm::utility::prism::preprocess(program, ""); |
|||
std::vector<std::shared_ptr<storm::logic::Formula const>> formulas = storm::extractFormulasFromProperties(storm::parsePropertiesForPrismProgram(formulasAsString, program)); |
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::buildSparseModel<double>(program, formulas)->as<storm::models::sparse::Mdp<double>>(); |
|||
uint_fast64_t const initState = *mdp->getInitialStates().begin();; |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[0]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
ASSERT_TRUE(result->isExplicitQuantitativeCheckResult()); |
|||
EXPECT_NEAR(0.10833260970000025, result->asExplicitQuantitativeCheckResult<double>()[initState], storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision()); |
|||
|
|||
result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[1]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
ASSERT_TRUE(result->isExplicitQualitativeCheckResult()); |
|||
EXPECT_TRUE(result->asExplicitQualitativeCheckResult()[initState]); |
|||
|
|||
result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[2]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
ASSERT_TRUE(result->isExplicitQualitativeCheckResult()); |
|||
EXPECT_FALSE(result->asExplicitQualitativeCheckResult()[initState]); |
|||
|
|||
} |
|||
|
|||
TEST(SparseMdpCbMultiObjectiveModelCheckerTest, zeroconf) { |
|||
|
|||
std::string programFile = STORM_TEST_RESOURCES_DIR "/mdp/multiobj_zeroconf4.nm"; |
|||
std::string formulasAsString = "multi(Pmax=? [ F l=4 & ip=1 ] , P>=0.993141[ G (error=0) ]) "; // numerical |
|||
|
|||
// programm, model, formula |
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
program = storm::utility::prism::preprocess(program, ""); |
|||
std::vector<std::shared_ptr<storm::logic::Formula const>> formulas = storm::extractFormulasFromProperties(storm::parsePropertiesForPrismProgram(formulasAsString, program)); |
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::buildSparseModel<double>(program, formulas)->as<storm::models::sparse::Mdp<double>>(); |
|||
uint_fast64_t const initState = *mdp->getInitialStates().begin(); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[0]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
ASSERT_TRUE(result->isExplicitQuantitativeCheckResult()); |
|||
EXPECT_NEAR(0.0003075787401574803, result->asExplicitQuantitativeCheckResult<double>()[initState], storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(SparseMdpCbMultiObjectiveModelCheckerTest, team3with3objectives) { |
|||
|
|||
std::string programFile = STORM_TEST_RESOURCES_DIR "/mdp/multiobj_team3.nm"; |
|||
std::string formulasAsString = "multi(Pmax=? [ F \"task1_compl\" ], R{\"w_1_total\"}>=2.210204082 [ C ], P>=0.5 [ F \"task2_compl\" ])"; // numerical |
|||
|
|||
// programm, model, formula |
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
program = storm::utility::prism::preprocess(program, ""); |
|||
std::vector<std::shared_ptr<storm::logic::Formula const>> formulas = storm::extractFormulasFromProperties(storm::parsePropertiesForPrismProgram(formulasAsString, program)); |
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::buildSparseModel<double>(program, formulas)->as<storm::models::sparse::Mdp<double>>(); |
|||
uint_fast64_t const initState = *mdp->getInitialStates().begin(); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[0]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
ASSERT_TRUE(result->isExplicitQuantitativeCheckResult()); |
|||
EXPECT_NEAR(0.7448979591841851, result->asExplicitQuantitativeCheckResult<double>()[initState], storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(SparseMdpCbMultiObjectiveModelCheckerTest, scheduler) { |
|||
|
|||
std::string programFile = STORM_TEST_RESOURCES_DIR "/mdp/multiobj_scheduler05.nm"; |
|||
std::string formulasAsString = "multi(R{\"time\"}<= 11.778[ F \"tasks_complete\" ], R{\"energy\"}<=1.45 [ F \"tasks_complete\" ]) "; |
|||
|
|||
// programm, model, formula |
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
program = storm::utility::prism::preprocess(program, ""); |
|||
std::vector<std::shared_ptr<storm::logic::Formula const>> formulas = storm::extractFormulasFromProperties(storm::parsePropertiesForPrismProgram(formulasAsString, program)); |
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::buildSparseModel<double>(program, formulas)->as<storm::models::sparse::Mdp<double>>(); |
|||
uint_fast64_t const initState = *mdp->getInitialStates().begin(); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[0]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
EXPECT_TRUE(result->asExplicitQualitativeCheckResult()[initState]); |
|||
} |
|||
|
|||
TEST(SparseMdpCbMultiObjectiveModelCheckerTest, dpm) { |
|||
|
|||
std::string programFile = STORM_TEST_RESOURCES_DIR "/mdp/multiobj_dpm100.nm"; |
|||
std::string formulasAsString = "multi(R{\"power\"}min=? [ C<=100 ], R{\"queue\"}<=70 [ C<=100 ])"; // numerical |
|||
|
|||
// programm, model, formula |
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
program = storm::utility::prism::preprocess(program, ""); |
|||
std::vector<std::shared_ptr<storm::logic::Formula const>> formulas = storm::extractFormulasFromProperties(storm::parsePropertiesForPrismProgram(formulasAsString, program)); |
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::buildSparseModel<double>(program, formulas)->as<storm::models::sparse::Mdp<double>>(); |
|||
uint_fast64_t const initState = *mdp->getInitialStates().begin(); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = storm::modelchecker::multiobjective::performMultiObjectiveModelChecking(*mdp, formulas[0]->asMultiObjectiveFormula(), storm::modelchecker::multiobjective::MultiObjectiveMethodSelection::ConstraintBased); |
|||
ASSERT_TRUE(result->isExplicitQuantitativeCheckResult()); |
|||
EXPECT_NEAR(121.6128842, result->asExplicitQuantitativeCheckResult<double>()[initState], storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
#endif /* STORM_HAVE_HYPRO || defined STORM_HAVE_Z3_OPTIMIZE */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue