Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MultiObjectiveModelChecking.cpp
Go to the documentation of this file.
2
22
23namespace storm {
24namespace modelchecker {
25namespace multiobjective {
26
27template<typename SparseModelType>
28std::unique_ptr<CheckResult> performMultiObjectiveModelChecking(Environment const& env, SparseModelType const& model,
29 storm::logic::MultiObjectiveFormula const& formula, bool produceScheduler) {
30 storm::utility::Stopwatch swTotal(true);
31 storm::utility::Stopwatch swPreprocessing(true);
32 STORM_LOG_ASSERT(model.getInitialStates().getNumberOfSetBits() == 1,
33 "Multi-objective Model checking on model with multiple initial states is not supported.");
34
35 // If we consider an MA, ensure that it is closed
38 storm::exceptions::InvalidArgumentException, "Unable to check multi-objective formula on non-closed Markov automaton.");
39 }
40
41 // Preprocess the model
42 auto preprocessorResult = preprocessing::SparseMultiObjectivePreprocessor<SparseModelType>::preprocess(env, model, formula, produceScheduler);
43 swPreprocessing.stop();
44 STORM_LOG_INFO("Preprocessing done in " << swPreprocessing << " seconds.\n"
45 << " Result: " << preprocessorResult << '\n');
46
47 // Invoke the analysis
48 storm::utility::Stopwatch swAnalysis(true);
49 std::unique_ptr<CheckResult> result;
50 MultiObjectiveMethod method = env.modelchecker().multi().getMethod();
51 switch (method) {
52 case MultiObjectiveMethod::Pcaa: {
54 STORM_LOG_THROW(!produceScheduler, storm::exceptions::NotImplementedException,
55 "Scheduler computation is not implement for queries with restricted scheduler classes.");
59 result = achChecker.check(env);
60 } else {
62 storm::exceptions::NotImplementedException, "The query type is not implemented with scheduler restrictions.");
64 result = explorer.check(env);
65 if (env.modelchecker().multi().isExportPlotSet()) {
66 explorer.exportPlotOfCurrentApproximation(env);
67 }
68 }
69 } else {
71 // Adapt environment for the query
72 auto subEnv = env;
74 subEnv.solver().setForceExact(true);
75 }
76 // Solve the query
77 result = query.check(subEnv, produceScheduler);
78 if (produceScheduler) {
79 STORM_LOG_THROW(result->isExplicitParetoCurveCheckResult(), storm::exceptions::UnexpectedException,
80 "Scheduler computation is not implement for the produced result type.");
81 auto& paretoRes = result->template asExplicitParetoCurveCheckResult<typename SparseModelType::ValueType>();
82 STORM_LOG_ASSERT(paretoRes.hasScheduler(), "Scheduler requested but none was produced.");
83 if (preprocessorResult.memoryIncorporationReverseData) {
84 // we have information to post-process schedulers
85 transformObjectiveSchedulersToOriginal(preprocessorResult.memoryIncorporationReverseData.value(), paretoRes.getSchedulers());
86 }
87 }
88 }
89 break;
90 }
91 case MultiObjectiveMethod::ConstraintBased: {
92 STORM_LOG_THROW(!env.modelchecker().multi().isSchedulerRestrictionSet(), storm::exceptions::InvalidEnvironmentException,
93 "The selected multi-objective model checking method does not support scheduler restrictions.");
94 STORM_LOG_THROW(!produceScheduler, storm::exceptions::NotImplementedException,
95 "Scheduler computation is not implement for constraint-based multi objective solving.");
96 std::unique_ptr<SparseCbQuery<SparseModelType>> query;
97 switch (preprocessorResult.queryType) {
99 query = std::unique_ptr<SparseCbQuery<SparseModelType>>(new SparseCbAchievabilityQuery<SparseModelType>(preprocessorResult));
100 break;
101 default:
102 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
103 "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'.");
104 break;
105 }
106
107 result = query->check(env);
108
109 if (env.modelchecker().multi().isExportPlotSet()) {
110 STORM_LOG_ERROR("Can not export plot for the constrained based solver.");
111 }
112 break;
113 }
114 default:
115 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
116 "The multi-objective solution method '" << toString(method) << "' is not supported.");
117 }
118 swAnalysis.stop();
119
120 swTotal.stop();
121 if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) {
122 STORM_PRINT_AND_LOG("Solving multi-objective query took " << swTotal << " seconds (consisting of " << swPreprocessing
123 << " seconds for preprocessing and " << swAnalysis
124 << " seconds for analyzing the preprocessed model).\n");
125 }
126
127 return result;
128}
129
130template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<double>>(Environment const& env,
133 bool produceScheduler);
134template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<double>>(
136 bool produceScheduler);
137template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<storm::RationalNumber>>(
139 bool produceScheduler);
140template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>(
142 bool produceScheduler);
143
144} // namespace multiobjective
145} // namespace modelchecker
146} // namespace storm
SolverEnvironment & solver()
ModelCheckerEnvironment & modelchecker()
MultiObjectiveModelCheckerEnvironment & multi()
storm::modelchecker::multiobjective::MultiObjectiveMethod const & getMethod() const
std::unique_ptr< CheckResult > check(Environment const &env, bool produceScheduler)
Invokes the computation and retrieves the result.
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)