Storm 1.14.0.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_THROW(model.getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::NotSupportedException,
33 "Multi-objective Model checking on model with multiple initial states is not supported.");
34 STORM_LOG_THROW(formula.isTradeoff(), storm::exceptions::IllegalFunctionCallException,
35 "Invoked multi-objective model checking with a non-tradeoff formula " << formula << ".");
36
37 // If we consider an MA, ensure that it is closed
40 storm::exceptions::InvalidArgumentException, "Unable to check multi-objective formula on non-closed Markov automaton.");
41 }
42
43 // Preprocess the model
44 auto preprocessorResult = preprocessing::SparseMultiObjectivePreprocessor<SparseModelType>::preprocess(env, model, formula, produceScheduler);
45 swPreprocessing.stop();
46 STORM_LOG_INFO("Preprocessing done in " << swPreprocessing << " seconds.\n"
47 << " Result: " << preprocessorResult << '\n');
48
49 // Invoke the analysis
50 storm::utility::Stopwatch swAnalysis(true);
51 std::unique_ptr<CheckResult> result;
52 MultiObjectiveMethod method = env.modelchecker().multi().getMethod();
53 switch (method) {
54 case MultiObjectiveMethod::Pcaa: {
56 STORM_LOG_THROW(!produceScheduler, storm::exceptions::NotImplementedException,
57 "Scheduler computation is not implement for queries with restricted scheduler classes.");
61 result = achChecker.check(env);
62 } else {
64 storm::exceptions::NotImplementedException, "The query type is not implemented with scheduler restrictions.");
66 result = explorer.check(env);
67 if (env.modelchecker().multi().isExportPlotSet()) {
68 explorer.exportPlotOfCurrentApproximation(env);
69 }
70 }
71 } else {
73 // Adapt environment for the query
74 auto subEnv = env;
76 subEnv.solver().setForceExact(true);
77 }
78 // Solve the query
79 result = query.check(subEnv, produceScheduler);
80 if (produceScheduler) {
81 STORM_LOG_THROW(result->isExplicitParetoCurveCheckResult(), storm::exceptions::UnexpectedException,
82 "Scheduler computation is not implement for the produced result type.");
83 auto& paretoRes = result->template asExplicitParetoCurveCheckResult<typename SparseModelType::ValueType>();
84 STORM_LOG_ASSERT(paretoRes.hasScheduler(), "Scheduler requested but none was produced.");
85 if (preprocessorResult.memoryIncorporationReverseData) {
86 // we have information to post-process schedulers
87 transformObjectiveSchedulersToOriginal(preprocessorResult.memoryIncorporationReverseData.value(), paretoRes.getSchedulers());
88 }
89 }
90 }
91 break;
92 }
93 case MultiObjectiveMethod::ConstraintBased: {
94 STORM_LOG_THROW(!env.modelchecker().multi().isSchedulerRestrictionSet(), storm::exceptions::InvalidEnvironmentException,
95 "The selected multi-objective model checking method does not support scheduler restrictions.");
96 STORM_LOG_THROW(!produceScheduler, storm::exceptions::NotImplementedException,
97 "Scheduler computation is not implement for constraint-based multi objective solving.");
98 std::unique_ptr<SparseCbQuery<SparseModelType>> query;
99 switch (preprocessorResult.queryType) {
101 query = std::unique_ptr<SparseCbQuery<SparseModelType>>(new SparseCbAchievabilityQuery<SparseModelType>(preprocessorResult));
102 break;
103 default:
104 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
105 "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'.");
106 break;
107 }
108
109 result = query->check(env);
110
111 if (env.modelchecker().multi().isExportPlotSet()) {
112 STORM_LOG_ERROR("Can not export plot for the constrained based solver.");
113 }
114 break;
115 }
116 default:
117 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
118 "The multi-objective solution method '" << toString(method) << "' is not supported.");
119 }
120 swAnalysis.stop();
121
122 swTotal.stop();
123 STORM_LOG_STATISTICS("Solving multi-objective query took " << swTotal << " seconds (consisting of " << swPreprocessing << " seconds for preprocessing and "
124 << swAnalysis << " seconds for analyzing the preprocessed model).\n");
125
126 return result;
127}
128
132 bool produceScheduler);
135 bool produceScheduler);
138 bool produceScheduler);
141 bool produceScheduler);
142
143} // namespace multiobjective
144} // namespace modelchecker
145} // namespace storm
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:13
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
#define STORM_LOG_INFO(message)
Definition logging.h:27
#define STORM_LOG_STATISTICS(message)
Definition logging.h:41
#define STORM_LOG_ERROR(message)
Definition logging.h:29
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
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)
static const bool IsExact