Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MultiObjectiveModelChecking.cpp
Go to the documentation of this file.
2
23
24namespace storm {
25namespace modelchecker {
26namespace multiobjective {
27
28template<typename SparseModelType>
29std::unique_ptr<CheckResult> performMultiObjectiveModelChecking(Environment const& env, SparseModelType const& model,
30 storm::logic::MultiObjectiveFormula const& formula, bool produceScheduler) {
31 storm::utility::Stopwatch swTotal(true);
32 storm::utility::Stopwatch swPreprocessing(true);
33 STORM_LOG_ASSERT(model.getInitialStates().getNumberOfSetBits() == 1,
34 "Multi-objective Model checking on model with multiple initial states is not supported.");
35
36 // If we consider an MA, ensure that it is closed
39 storm::exceptions::InvalidArgumentException, "Unable to check multi-objective formula on non-closed Markov automaton.");
40 }
41
42 // Preprocess the model
43 auto preprocessorResult = preprocessing::SparseMultiObjectivePreprocessor<SparseModelType>::preprocess(env, model, formula, produceScheduler);
44 swPreprocessing.stop();
45 if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) {
46 STORM_PRINT_AND_LOG("Preprocessing done in " << swPreprocessing << " seconds.\n"
47 << " Result: " << preprocessorResult << '\n');
48 } else {
49 STORM_LOG_INFO("Preprocessing done in " << swPreprocessing << " seconds.\n"
50 << " Result: " << preprocessorResult << '\n');
51 }
52
53 // Invoke the analysis
54 storm::utility::Stopwatch swAnalysis(true);
55 std::unique_ptr<CheckResult> result;
56 MultiObjectiveMethod method = env.modelchecker().multi().getMethod();
57 switch (method) {
58 case MultiObjectiveMethod::Pcaa: {
60 STORM_LOG_THROW(!produceScheduler, storm::exceptions::NotImplementedException,
61 "Scheduler computation is not implement for queries with restricted scheduler classes.");
65 result = achChecker.check(env);
66 } else {
68 storm::exceptions::NotImplementedException, "The query type is not implemented with scheduler restrictions.");
70 result = explorer.check(env);
71 if (env.modelchecker().multi().isExportPlotSet()) {
72 explorer.exportPlotOfCurrentApproximation(env);
73 }
74 }
75 } else {
76 std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> query;
77 switch (preprocessorResult.queryType) {
79 query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>>(
81 break;
83 query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>>(
85 break;
87 query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>>(
89 break;
90 default:
91 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
92 "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'.");
93 break;
94 }
95
96 result = query->check(env, produceScheduler);
97 if (produceScheduler) {
98 STORM_LOG_THROW(result->isExplicitParetoCurveCheckResult(), storm::exceptions::UnexpectedException,
99 "Scheduler computation is not implement for the produced result type.");
100 auto& paretoRes = result->template asExplicitParetoCurveCheckResult<typename SparseModelType::ValueType>();
101 STORM_LOG_ASSERT(paretoRes.hasScheduler(), "Scheduler requested but none was produced.");
102 if (preprocessorResult.memoryIncorporationReverseData) {
103 // we have information to post-process schedulers
104 transformObjectiveSchedulersToOriginal(preprocessorResult.memoryIncorporationReverseData.value(), paretoRes.getSchedulers());
105 }
106 }
107
108 if (env.modelchecker().multi().isExportPlotSet()) {
109 query->exportPlotOfCurrentApproximation(env);
110 }
111 }
112 break;
113 }
114 case MultiObjectiveMethod::ConstraintBased: {
115 STORM_LOG_THROW(!env.modelchecker().multi().isSchedulerRestrictionSet(), storm::exceptions::InvalidEnvironmentException,
116 "The selected multi-objective model checking method does not support scheduler restrictions.");
117 STORM_LOG_THROW(!produceScheduler, storm::exceptions::NotImplementedException,
118 "Scheduler computation is not implement for constraint-based multi objective solving.");
119 std::unique_ptr<SparseCbQuery<SparseModelType>> query;
120 switch (preprocessorResult.queryType) {
122 query = std::unique_ptr<SparseCbQuery<SparseModelType>>(new SparseCbAchievabilityQuery<SparseModelType>(preprocessorResult));
123 break;
124 default:
125 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
126 "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'.");
127 break;
128 }
129
130 result = query->check(env);
131
132 if (env.modelchecker().multi().isExportPlotSet()) {
133 STORM_LOG_ERROR("Can not export plot for the constrained based solver.");
134 }
135 break;
136 }
137 default:
138 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
139 "The multi-objective solution method '" << toString(method) << "' is not supported.");
140 }
141 swAnalysis.stop();
142
143 swTotal.stop();
144 if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) {
145 STORM_PRINT_AND_LOG("Solving multi-objective query took " << swTotal << " seconds (consisting of " << swPreprocessing
146 << " seconds for preprocessing and " << swAnalysis
147 << " seconds for analyzing the preprocessed model).\n");
148 }
149
150 return result;
151}
152
153template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<double>>(Environment const& env,
156 bool produceScheduler);
157template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<double>>(
159 bool produceScheduler);
160template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<storm::RationalNumber>>(
162 bool produceScheduler);
163template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>(
165 bool produceScheduler);
166
167} // namespace multiobjective
168} // namespace modelchecker
169} // namespace storm
ModelCheckerEnvironment & modelchecker()
MultiObjectiveModelCheckerEnvironment & multi()
storm::modelchecker::multiobjective::MultiObjectiveMethod const & getMethod() const
static ReturnType preprocess(Environment const &env, SparseModelType const &originalModel, storm::logic::MultiObjectiveFormula const &originalFormula, bool produceScheduler)
Preprocesses the given model w.r.t.
This class represents a Markov automaton.
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:13
A class that provides convenience operations to display run times.
Definition Stopwatch.h:14
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_ERROR(message)
Definition logging.h:26
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
#define STORM_PRINT_AND_LOG(message)
Definition macros.h:68
void transformObjectiveSchedulersToOriginal(storm::storage::SparseModelMemoryProductReverseData const &reverseData, std::vector< storm::storage::Scheduler< ValueType > > &schedulers)
std::unique_ptr< CheckResult > performMultiObjectiveModelChecking(Environment const &env, SparseModelType const &model, storm::logic::MultiObjectiveFormula const &formula, bool produceScheduler)