Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
storm-pomdp.cpp
Go to the documentation of this file.
1#include <filesystem>
2#include <optional>
3#include <type_traits>
4
12
34#include "storm/api/storm.h"
47#include "storm/utility/graph.h"
48
49namespace storm {
50namespace pomdp {
51namespace cli {
52
54template<typename ValueType>
56 storm::logic::Formula const& formula) {
58 bool preprocessingPerformed = false;
59 if (pomdpSettings.isSelfloopReductionSet()) {
61 if (selfLoopEliminator.preservesFormula(formula)) {
62 STORM_PRINT_AND_LOG("Eliminating self-loop choices ...");
63 uint64_t oldChoiceCount = pomdp->getNumberOfChoices();
64 pomdp = selfLoopEliminator.transform();
65 STORM_PRINT_AND_LOG(oldChoiceCount - pomdp->getNumberOfChoices() << " choices eliminated through self-loop elimination.\n");
66 preprocessingPerformed = true;
67 } else {
68 STORM_PRINT_AND_LOG("Not eliminating self-loop choices as it does not preserve the formula.\n");
69 }
70 }
71 if (pomdpSettings.isQualitativeReductionSet() && formulaInfo.isNonNestedReachabilityProbability() && !formulaInfo.isBounded()) {
73 STORM_PRINT_AND_LOG("Computing states with probability 0 ...");
74 storm::storage::BitVector prob0States = qualitativeAnalysis.analyseProb0(formula.asProbabilityOperatorFormula());
75 STORM_PRINT_AND_LOG(" done. " << prob0States.getNumberOfSetBits() << " states found.\n");
76 STORM_PRINT_AND_LOG("Computing states with probability 1 ...");
77 storm::storage::BitVector prob1States = qualitativeAnalysis.analyseProb1(formula.asProbabilityOperatorFormula());
78 STORM_PRINT_AND_LOG(" done. " << prob1States.getNumberOfSetBits() << " states found.\n");
80 pomdp = kpt.transform(*pomdp, prob0States, prob1States);
81 // Update formulaInfo to changes from Preprocessing
82 formulaInfo.updateTargetStates(*pomdp, std::move(prob1States));
83 formulaInfo.updateSinkStates(*pomdp, std::move(prob0States));
84 preprocessingPerformed = true;
85 }
86 return preprocessingPerformed;
87}
88
89template<typename ValueType>
90void printResult(std::optional<ValueType> const& lowerBound, std::optional<ValueType> const& upperBound) {
91 if (lowerBound.has_value() && upperBound.has_value()) {
92 if (*lowerBound == *upperBound) {
93 if (storm::utility::isInfinity(*lowerBound)) {
95 } else {
96 STORM_PRINT_AND_LOG(*lowerBound);
97 }
98 } else if (storm::utility::isInfinity(ValueType(-*lowerBound))) {
99 if (storm::utility::isInfinity(*upperBound)) {
100 STORM_PRINT_AND_LOG("[-inf, inf] (width=inf)");
101 }
102 } else {
103 STORM_PRINT_AND_LOG("[" << *lowerBound << ", " << *upperBound << "] (width=" << ValueType(*upperBound - *lowerBound) << ")");
104 }
105 } else if (lowerBound.has_value()) {
106 STORM_PRINT_AND_LOG("≥ " << *lowerBound);
107 } else if (upperBound.has_value()) {
108 STORM_PRINT_AND_LOG("≤ " << *upperBound);
109 }
111 STORM_PRINT_AND_LOG(" (approx. ");
112 std::optional<double> roundedLowerBound = std::nullopt;
113 std::optional<double> roundedUpperBound = std::nullopt;
114 if (lowerBound.has_value()) {
115 roundedLowerBound = storm::utility::convertNumber<double>(*lowerBound);
116 }
117 if (upperBound.has_value()) {
118 roundedUpperBound = storm::utility::convertNumber<double>(*upperBound);
119 }
120 printResult(roundedLowerBound, roundedUpperBound);
122 }
123}
124
125template<typename Statistics>
126void printBeliefExplorationStatistics(Statistics const& statistics) {
127 STORM_PRINT_AND_LOG("Belief exploration " << (statistics.completedExploration ? "completed" : "stopped early") << ": " << statistics.discoveredBeliefs
128 << " beliefs discovered, " << statistics.exploredBeliefs << " beliefs explored.\n");
129 STORM_PRINT_AND_LOG("Constructed belief MDP: " << statistics.beliefMdpStates << " states, " << statistics.beliefMdpChoices << " choices, "
130 << statistics.beliefMdpTransitions << " transitions.\n");
131 if (statistics.processedMdpStates && statistics.processedMdpChoices && statistics.processedMdpTransitions) {
132 STORM_PRINT_AND_LOG("Processed belief MDP: " << *statistics.processedMdpStates << " states, " << *statistics.processedMdpChoices << " choices, "
133 << *statistics.processedMdpTransitions << " transitions.\n");
134 }
135 STORM_PRINT_AND_LOG("Time for exploring beliefs: " << statistics.explorationTimeMilliseconds << "ms.\n");
136 STORM_PRINT_AND_LOG("Time for building the belief MDP: " << statistics.beliefMdpBuildTimeMilliseconds << "ms.\n");
137 STORM_PRINT_AND_LOG("Time for analyzing the belief MDP: " << statistics.beliefMdpAnalysisTimeMilliseconds << "ms.\n");
138}
139
141
142PolicyExportFormat getPolicyExportFormat(std::string const& filename) {
143 auto const extension = std::filesystem::path(filename).extension().string();
144 STORM_LOG_THROW(extension.empty() || extension == ".json" || extension == ".dot", storm::exceptions::InvalidSettingsException,
145 "Unsupported policy export extension '" << extension << "'. Use '.json', '.dot', or no extension for JSON output.");
146 return extension == ".dot" ? PolicyExportFormat::Dot : PolicyExportFormat::Json;
147}
148
152
153 options.onlyDeterministicStrategies = qualSettings.isOnlyDeterministicSet();
154 uint64_t loglevel = 0;
155 // TODO a big ugly, but we have our own loglevels (for technical reasons)
156 if (storm::utility::getLogLevel() == l3pp::LogLevel::INFO) {
157 loglevel = 1;
158 } else if (storm::utility::getLogLevel() == l3pp::LogLevel::DEBUG) {
159 loglevel = 2;
160 } else if (storm::utility::getLogLevel() == l3pp::LogLevel::TRACE) {
161 loglevel = 3;
162 }
163 options.setDebugLevel(loglevel);
164 options.validateEveryStep = qualSettings.validateIntermediateSteps();
165 options.validateResult = qualSettings.validateFinalResult();
166
167 options.pathVariableType = storm::pomdp::pathVariableTypeFromString(qualSettings.getLookaheadType());
168
169 if (qualSettings.isExportSATCallsSet()) {
170 options.setExportSATCalls(qualSettings.getExportSATCallsPath());
171 }
172
173 return options;
174}
175
176template<typename ValueType>
178 storm::pomdp::analysis::FormulaInformation const& formulaInfo, storm::logic::Formula const& formula) {
181 std::stringstream sstr;
182 origpomdp->printModelInformationToStream(sstr);
183 STORM_LOG_INFO(sstr.str());
184 STORM_LOG_THROW(formulaInfo.isNonNestedReachabilityProbability() && !formulaInfo.isBounded(), storm::exceptions::NotSupportedException,
185 "Qualitative memoryless scheduler search is not implemented for this property type.");
186 STORM_LOG_TRACE("Run qualitative preprocessing...");
189 // After preprocessing, this might be done cheaper.
190 storm::storage::BitVector surelyNotAlmostSurelyReachTarget = qualitativeAnalysis.analyseProbSmaller1(formula.asProbabilityOperatorFormula());
191 pomdp.getTransitionMatrix().makeRowGroupsAbsorbing(surelyNotAlmostSurelyReachTarget);
192 storm::storage::BitVector targetStates = qualitativeAnalysis.analyseProb1(formula.asProbabilityOperatorFormula());
193 bool computedSomething = false;
194 if (qualSettings.isMemlessSearchSet()) {
195 computedSomething = true;
196 std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::SmtSolverFactory>();
197 uint64_t lookahead = qualSettings.getLookahead();
198 if (lookahead == 0) {
199 lookahead = pomdp.getNumberOfStates();
200 }
201 if (qualSettings.getMemlessSearchMethod() == "one-shot") {
202 storm::pomdp::OneShotPolicySearch<ValueType> memlessSearch(env, pomdp, targetStates, surelyNotAlmostSurelyReachTarget, smtSolverFactory);
203 if (qualSettings.isWinningRegionSet()) {
204 STORM_LOG_ERROR("Computing winning regions is not supported by the one-shot method.");
205 } else {
206 bool result = memlessSearch.analyzeForInitialStates(lookahead);
207 if (result) {
208 STORM_PRINT_AND_LOG("From initial state, one can almost-surely reach the target.\n");
209 } else {
210 STORM_PRINT_AND_LOG("From initial state, one may not almost-surely reach the target .\n");
211 }
212 }
213 } else if (qualSettings.getMemlessSearchMethod() == "iterative") {
215 storm::pomdp::IterativePolicySearch<ValueType> search(env, pomdp, targetStates, surelyNotAlmostSurelyReachTarget, smtSolverFactory, options);
216 if (qualSettings.isWinningRegionSet()) {
217 search.computeWinningRegion(lookahead);
218 } else {
219 bool result = search.analyzeForInitialStates(lookahead);
220 if (result) {
221 STORM_PRINT_AND_LOG("From initial state, one can almost-surely reach the target.");
222 } else {
223 // TODO consider adding check for end components to improve this message.
224 STORM_PRINT_AND_LOG("From initial state, one may not almost-surely reach the target.");
225 }
226 }
227
228 if (qualSettings.isPrintWinningRegionSet()) {
229 search.getLastWinningRegion().print();
230 std::cout << '\n';
231 }
232 if (qualSettings.isExportWinningRegionSet()) {
233 std::size_t hash = pomdp.hash();
234 search.getLastWinningRegion().storeToFile(qualSettings.exportWinningRegionPath(), "model hash: " + std::to_string(hash));
235 }
236
237 search.finalizeStatistics();
238 if (pomdp.getInitialStates().getNumberOfSetBits() == 1) {
239 uint64_t initialState = pomdp.getInitialStates().getNextSetIndex(0);
240 uint64_t initialObservation = pomdp.getObservation(initialState);
241 // TODO this is inefficient.
242 uint64_t offset = 0;
243 for (uint64_t state = 0; state < pomdp.getNumberOfStates(); ++state) {
244 if (state == initialState) {
245 break;
246 }
247 if (pomdp.getObservation(state) == initialObservation) {
248 ++offset;
249 }
250 }
251
252 if (search.getLastWinningRegion().isWinning(initialObservation, offset)) {
253 STORM_PRINT_AND_LOG("Initial state is safe!\n");
254 } else {
255 STORM_PRINT_AND_LOG("Initial state may not be safe.\n");
256 }
257 } else {
258 STORM_LOG_WARN("Output for multiple initial states is incomplete");
259 }
260
261 if (coreSettings.isShowStatisticsSet()) {
262 STORM_PRINT_AND_LOG("#STATS Number of belief support states: " << search.getLastWinningRegion().beliefSupportStates() << '\n');
263 if (qualSettings.computeExpensiveStats()) {
264 auto wbss = search.getLastWinningRegion().computeNrWinningBeliefs();
265 STORM_PRINT_AND_LOG("#STATS Number of winning belief support states: [" << wbss.first << "," << wbss.second << "]");
266 }
267 search.getStatistics().print();
268 }
269
270 } else {
271 STORM_LOG_ERROR("This method is not implemented.");
272 }
273 }
274 if (qualSettings.isComputeOnBeliefSupportSet()) {
275 computedSomething = true;
277 janicreator.generate(targetStates, surelyNotAlmostSurelyReachTarget);
278 bool initialOnly = !qualSettings.isWinningRegionSet();
279 janicreator.verifySymbolic(env, initialOnly);
280 STORM_PRINT_AND_LOG("Initial state is safe: " << janicreator.isInitialWinning() << "\n");
281 }
282 STORM_LOG_THROW(computedSomething, storm::exceptions::InvalidSettingsException, "Nothing to be done, did you forget to set a method?");
283}
284
285template<typename ValueType, typename BeliefType, typename BeliefMDPType>
287 storm::pomdp::analysis::FormulaInformation const& formulaInfo, storm::logic::Formula const& formula) {
290 STORM_LOG_THROW(!formulaInfo.isBounded() || !belExplSettings.isUseClippingSet(), storm::exceptions::NotSupportedException,
291 "Grid clipping is not supported for reward-bounded POMDP properties.");
292
293 bool const policyExportRequested = pomdpSettings.isExportPolicySet();
294 STORM_LOG_THROW(!policyExportRequested || !belExplSettings.isCutZeroGapSet(), storm::exceptions::InvalidSettingsException,
295 "Policy export does not support zero-gap cutting because cut-off beliefs do not retain a continuation policy. Remove --cut-zero-gap to "
296 "allow policy export.");
297 std::optional<PolicyExportFormat> policyExportFormat;
298 if (policyExportRequested) {
299 policyExportFormat = getPolicyExportFormat(pomdpSettings.getExportPolicyFilename());
300 }
301
303 // We hard-code this to FIFO for now to mimic the legacy behaviour
305 if (belExplSettings.getExplorationTimeLimit() != 0) {
306 revisedOptions.maxExplorationTime = belExplSettings.getExplorationTimeLimit();
307 }
308 revisedOptions.cutZeroGap = belExplSettings.isCutZeroGapSet();
309
310 std::shared_ptr<storm::models::sparse::Pomdp<ValueType>> preprocessedPomdpPtr = pomdp;
311
312 std::optional<std::string> rewardModelName;
313 std::set<uint32_t> targetObservations;
314 if (formulaInfo.isNonNestedReachabilityProbability() || formulaInfo.isNonNestedExpectedRewardFormula()) {
315 if (formulaInfo.getTargetStates().observationClosed) {
316 targetObservations = formulaInfo.getTargetStates().observations;
317 } else {
319 std::tie(preprocessedPomdpPtr, targetObservations) = obsCloser.transform(formulaInfo.getTargetStates().states);
320 }
321 if (formulaInfo.isNonNestedReachabilityProbability()) {
322 if (!formulaInfo.getSinkStates().empty()) {
324 components.stateLabeling = preprocessedPomdpPtr->getStateLabeling();
325 components.rewardModels = preprocessedPomdpPtr->getRewardModels();
326 auto matrix = preprocessedPomdpPtr->getTransitionMatrix();
327 matrix.makeRowGroupsAbsorbing(formulaInfo.getSinkStates().states, true);
328 STORM_LOG_ASSERT(matrix.isProbabilistic(storm::utility::zero<ValueType>()), "Resulting transition matrix is not a probability matrix.");
329 STORM_LOG_ASSERT(matrix.hasOnlyPositiveEntries(), "Resulting transition matrix has non-positive entries.");
330 components.transitionMatrix = matrix;
331 components.observabilityClasses = preprocessedPomdpPtr->getObservations();
332 if (preprocessedPomdpPtr->hasChoiceLabeling()) {
333 components.choiceLabeling = preprocessedPomdpPtr->getChoiceLabeling();
334 }
335 if (preprocessedPomdpPtr->hasObservationValuations()) {
336 components.observationValuations = preprocessedPomdpPtr->getObservationValuations();
337 }
338 preprocessedPomdpPtr = std::make_shared<storm::models::sparse::Pomdp<ValueType>>(std::move(components), true);
339 auto reachableFromSinkStates =
340 storm::utility::graph::getReachableStates(preprocessedPomdpPtr->getTransitionMatrix(), formulaInfo.getSinkStates().states,
341 formulaInfo.getSinkStates().states, ~formulaInfo.getSinkStates().states);
342 reachableFromSinkStates &= ~formulaInfo.getSinkStates().states;
343 STORM_LOG_THROW(reachableFromSinkStates.empty(), storm::exceptions::NotSupportedException,
344 "There are sink states that can reach non-sink states. This is currently not supported");
345 }
346 } else {
347 // Expected reward formula!
348 rewardModelName = formulaInfo.getRewardModelName();
349 }
350 } else {
351 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Unsupported formula '" << formula << "'.");
352 }
353 std::optional<storm::storage::BitVector> optionalTargetStates;
354 optionalTargetStates = formulaInfo.getTargetStates().states;
355 if (storm::pomdp::detectFiniteBeliefMdp(*preprocessedPomdpPtr, optionalTargetStates)) {
356 STORM_LOG_INFO("Detected that the belief MDP is finite.");
357 }
358
360
361 if (!formulaInfo.isBounded()) {
362 // Precompute initial bounds used for cut-offs and clipping
363 if (belExplSettings.isInexactPreprocessingSet()) {
364 STORM_LOG_WARN("Using inexact preprocessing for belief exploration can lead to inaccurate results.");
365 std::shared_ptr<storm::models::sparse::Pomdp<double>> preprocessedPomdpDouble;
366 if constexpr (std::is_same_v<ValueType, storm::RationalNumber>) {
367 preprocessedPomdpDouble = storm::transformer::sparseRationalModelToDouble(
369 ->template as<storm::models::sparse::Pomdp<double>>();
370 } else {
371 STORM_LOG_WARN("Inexact preprocessing option has no effect for floating-point models.");
372 preprocessedPomdpDouble = preprocessedPomdpPtr;
373 }
374 auto inExactPreProcessingMC =
376 beliefExplorationBounds.preprocessingBounds = inExactPreProcessingMC.getValueBounds(env, formula).template toValueType<ValueType>();
377 if (belExplSettings.isUseClippingSet() && rewardModelName) {
378 beliefExplorationBounds.extremeBounds = inExactPreProcessingMC.getExtremeValueBound(env, formula).template toValueType<ValueType>();
379 }
380 } else {
382 beliefExplorationBounds.preprocessingBounds = preProcessingMC.getValueBounds(env, formula);
383 if (belExplSettings.isUseClippingSet() && rewardModelName) {
384 beliefExplorationBounds.extremeBounds = preProcessingMC.getExtremeValueBound(env, formula);
385 }
386 }
387 } else {
388 // We only consider bounded probability formulae, so we can use 0-1 bounds
390 zeroOneValueBound.lower.push_back(std::vector<ValueType>(preprocessedPomdpPtr->getNumberOfStates(), storm::utility::zero<ValueType>()));
391 zeroOneValueBound.upper.push_back(std::vector<ValueType>(preprocessedPomdpPtr->getNumberOfStates(), storm::utility::one<ValueType>()));
392
393 beliefExplorationBounds.preprocessingBounds = zeroOneValueBound;
394 }
395
396 uint64_t initialPomdpState = preprocessedPomdpPtr->getInitialStates().getNextSetIndex(0);
397 using ExtendedBeliefMDPType = storm::utility::ExtendedValueType<BeliefMDPType>;
398 std::optional<ExtendedBeliefMDPType> lowerBound =
399 storm::utility::fromSentinel(beliefExplorationBounds.preprocessingBounds->template getHighestLowerBound<BeliefMDPType>(initialPomdpState));
400 std::optional<ExtendedBeliefMDPType> upperBound =
401 storm::utility::fromSentinel(beliefExplorationBounds.preprocessingBounds->template getSmallestUpperBound<BeliefMDPType>(initialPomdpState));
402 STORM_LOG_INFO("Initial value bounds are [" << *lowerBound << ", " << *upperBound << "]");
403
404 auto updateLowerBound = [&lowerBound](ExtendedBeliefMDPType const& value) {
405 if (!lowerBound || value > *lowerBound) {
406 lowerBound = value;
407 }
408 };
409 auto updateUpperBound = [&upperBound](ExtendedBeliefMDPType const& value) {
410 if (!upperBound || value < *upperBound) {
411 upperBound = value;
412 }
413 };
414
416 if (rewardModelName) {
418 propertyInfo.rewardModelName = rewardModelName;
419 } else if (formulaInfo.isBounded()) {
421 // Collect reward bounds from bounded formula
422 auto boundedFormula = formula.asProbabilityOperatorFormula().getSubformula().asBoundedUntilFormula();
423 for (uint64_t i = 0; i < boundedFormula.getDimension(); ++i) {
424 const auto& tbRef = boundedFormula.getTimeBoundReference(i);
425 if (tbRef.isRewardBound()) {
426 propertyInfo.rewardBounds.push_back({.rewardModelName = tbRef.getOptionalRewardModelName().get_value_or(""),
427 .lowerBound = boundedFormula.getLowerBoundAsOptionalTimeBound(i),
428 .upperBound = boundedFormula.getUpperBoundAsOptionalTimeBound(i)});
429 }
430 }
431 } else {
433 }
434 propertyInfo.dir = formulaInfo.getOptimizationDirection();
435 propertyInfo.targetObservations = targetObservations;
437 storm::exceptions::InvalidSettingsException, "Policy export is not supported for reward-aware belief exploration.");
438
439 storm::pomdp::beliefs::BeliefBasedModelChecker<storm::models::sparse::Pomdp<ValueType>, BeliefType, BeliefMDPType> checker(*preprocessedPomdpPtr);
440 ExtendedBeliefMDPType overResultValue;
441 ExtendedBeliefMDPType underResultValue;
442 bool isOverApproximation{false};
443 bool isUnderApproximation{false};
444 bool completedExploration{false};
445 if (pomdpSettings.isBeliefExplorationDiscretizeSet()) {
446 isOverApproximation = true;
447 STORM_PRINT_AND_LOG("Computing an over-approximation via belief MDP discretization...\n");
448 STORM_LOG_WARN_COND(belExplSettings.getSizeThresholdInit() == 0,
449 "The size threshold is ignored for discretization, which requires complete exploration.");
450 STORM_LOG_WARN_COND(belExplSettings.getExplorationTimeLimit() == 0,
451 "The exploration time threshold is ignored for discretization, which requires complete exploration.");
452 revisedOptions.maxExplorationSize.reset();
453 revisedOptions.maxExplorationTime.reset();
454
456 std::vector<std::string> relevantRewardModelNames;
457 for (auto const& rewardBound : propertyInfo.rewardBounds) {
458 relevantRewardModelNames.push_back(rewardBound.rewardModelName);
459 }
460 auto checkResult =
461 checker.checkRewardAwareDiscretize(env, propertyInfo, revisedOptions, belExplSettings.getResolutionInit(),
462 belExplSettings.isDynamicTriangulationModeSet(), beliefExplorationBounds, relevantRewardModelNames);
463 overResultValue = checkResult.value;
464 printBeliefExplorationStatistics(checkResult.statistics);
465 } else {
466 auto checkResult = checker.checkDiscretize(env, propertyInfo, revisedOptions, belExplSettings.getResolutionInit(),
467 belExplSettings.isDynamicTriangulationModeSet(), beliefExplorationBounds);
468 overResultValue = checkResult.value;
469 printBeliefExplorationStatistics(checkResult.statistics);
470 }
471 }
472
473 if (pomdpSettings.isBeliefExplorationUnfoldSet()) {
474 STORM_PRINT_AND_LOG("Computing an under-approximation via belief MDP unfolding...\n");
475 revisedOptions.generatePolicy = policyExportRequested;
476 if (belExplSettings.getExplorationTimeLimit() != 0) {
477 revisedOptions.maxExplorationTime = belExplSettings.getExplorationTimeLimit();
478 }
479 if (belExplSettings.getSizeThresholdInit() == 0) {
480 revisedOptions.maxExplorationSize = preprocessedPomdpPtr->getNumberOfStates() * preprocessedPomdpPtr->getMaxNrStatesWithSameObservation();
481 STORM_PRINT_AND_LOG("Heuristically selected an under-approximation MDP size threshold of " << revisedOptions.maxExplorationSize.value() << ".\n");
482 } else {
483 revisedOptions.maxExplorationSize = belExplSettings.getSizeThresholdInit();
484 }
485 if (belExplSettings.isUseClippingSet()) {
486 revisedOptions.useClipping = true;
487 revisedOptions.clippingResolutions = std::vector<uint64_t>(preprocessedPomdpPtr->getNrObservations(), belExplSettings.getClippingGridResolution());
488 }
489 isUnderApproximation = true;
492 std::vector<std::string> relevantRewardModelNames;
493 for (auto const& rewardBound : propertyInfo.rewardBounds) {
494 relevantRewardModelNames.push_back(rewardBound.rewardModelName);
495 }
496 return checker.checkRewardAwareUnfold(env, propertyInfo, revisedOptions, beliefExplorationBounds, relevantRewardModelNames);
497 }
498 return checker.checkUnfold(env, propertyInfo, revisedOptions, beliefExplorationBounds);
499 }();
500 underResultValue = checkResult.value;
501 completedExploration = checkResult.completedExploration;
502 printBeliefExplorationStatistics(checkResult.statistics);
503 if (policyExportRequested) {
504 STORM_LOG_THROW(checkResult.policy.has_value(), storm::exceptions::UnexpectedException,
505 "Policy generation was requested, but belief-space unfolding did not produce a policy.");
506 auto const& filename = pomdpSettings.getExportPolicyFilename();
507 if (*policyExportFormat == PolicyExportFormat::Dot) {
508 storm::pomdp::api::exportPolicyAsDot(*checkResult.policy, filename);
509 } else {
510 storm::pomdp::api::exportPolicyAsJson(*checkResult.policy, filename);
511 }
512 STORM_PRINT_AND_LOG("Exported policy to '" << filename << "'.\n");
513 if (belExplSettings.isUseClippingSet()) {
515 "The reported result includes the clipping approximation and may differ from the value achieved by the exported policy "
516 "on the original POMDP.");
517 }
518 }
519 isOverApproximation = (completedExploration && !belExplSettings.isUseClippingSet()) || isOverApproximation;
520 }
521
522 if (completedExploration && !belExplSettings.isUseClippingSet()) {
523 updateLowerBound(underResultValue);
524 updateUpperBound(underResultValue);
525 } else {
526 if (isOverApproximation) {
527 if (storm::solver::maximize(propertyInfo.dir)) {
528 updateUpperBound(overResultValue);
529 if (!isUnderApproximation) {
530 lowerBound.reset();
531 }
532 } else {
533 updateLowerBound(overResultValue);
534 if (!isUnderApproximation) {
535 upperBound.reset();
536 }
537 }
538 }
539 if (isUnderApproximation) {
540 if (storm::solver::maximize(propertyInfo.dir)) {
541 updateLowerBound(underResultValue);
542 if (!isOverApproximation) {
543 upperBound.reset();
544 }
545 } else {
546 updateUpperBound(underResultValue);
547 if (!isOverApproximation) {
548 lowerBound.reset();
549 }
550 }
551 }
552 }
553
555 STORM_PRINT_AND_LOG("\nResult till abort: ");
556 } else {
557 STORM_PRINT_AND_LOG("\nResult: ");
558 }
559 printResult(lowerBound, upperBound);
561 return true;
562}
563
564template<typename ValueType, typename BeliefType = ValueType>
566 storm::pomdp::analysis::FormulaInformation const& formulaInfo, storm::logic::Formula const& formula) {
568 bool analysisPerformed = false;
569 if (pomdpSettings.isBeliefExplorationSet()) {
571 if (beliefExplorationSettings.isBeliefMDPNumberTypeDouble()) {
573 } else if (beliefExplorationSettings.isBeliefMDPNumberTypeRational()) {
575 } else if (beliefExplorationSettings.isBeliefMDPNumberTypeMatch()) {
576 STORM_LOG_ASSERT(beliefExplorationSettings.isBeliefMDPNumberTypeMatch(),
577 "Expected belief MDP number type to be set to match the POMDP, but it is not.");
579 }
580 analysisPerformed = true;
581 }
582 if (pomdpSettings.isQualitativeAnalysisSet()) {
583 performQualitativeAnalysis(env, pomdp, formulaInfo, formula);
584 analysisPerformed = true;
585 }
586 if (pomdpSettings.isCheckFullyObservableSet()) {
587 STORM_PRINT_AND_LOG("Analyzing the formula on the fully observable MDP ... ");
590 if (resultPtr) {
591 auto result = resultPtr->template asExplicitQuantitativeCheckResult<ValueType>();
594 STORM_PRINT_AND_LOG("\nResult till abort: ");
595 } else {
596 STORM_PRINT_AND_LOG("\nResult: ");
597 }
598 printResult(std::optional{result.getMin()}, std::optional{result.getMax()});
600 } else {
601 STORM_PRINT_AND_LOG("\nResult: Not available.\n");
602 }
603 analysisPerformed = true;
604 }
605 return analysisPerformed;
606}
607
608template<typename ValueType>
613 bool transformationPerformed = false;
614 bool memoryUnfolded = false;
615 if (pomdpSettings.getMemoryBound() > 1) {
616 STORM_PRINT_AND_LOG("Computing the unfolding for memory bound " << pomdpSettings.getMemoryBound() << " and memory pattern '"
617 << storm::storage::toString(pomdpSettings.getMemoryPattern()) << "' ...");
618 storm::storage::PomdpMemory memory = storm::storage::PomdpMemoryBuilder().build(pomdpSettings.getMemoryPattern(), pomdpSettings.getMemoryBound());
619 std::cout << memory.toString() << '\n';
621 pomdp = memoryUnfolder.transform();
622 STORM_PRINT_AND_LOG(" done.\n");
623 pomdp->printModelInformationToStream(std::cout);
624 transformationPerformed = true;
625 memoryUnfolded = true;
626 }
627
628 // From now on the POMDP is considered memoryless
629
630 if (transformSettings.isMecReductionSet()) {
631 STORM_PRINT_AND_LOG("Eliminating mec choices ...");
632 // Note: Elimination of mec choices only preserves memoryless schedulers.
633 uint64_t oldChoiceCount = pomdp->getNumberOfChoices();
635 pomdp = mecChoiceEliminator.transform(formula);
636 STORM_PRINT_AND_LOG(" done.\n");
637 STORM_PRINT_AND_LOG(oldChoiceCount - pomdp->getNumberOfChoices() << " choices eliminated through MEC choice elimination.\n");
638 pomdp->printModelInformationToStream(std::cout);
639 transformationPerformed = true;
640 }
641
642 if (transformSettings.isTransformBinarySet() || transformSettings.isTransformSimpleSet()) {
643 if (transformSettings.isTransformSimpleSet()) {
644 STORM_PRINT_AND_LOG("Transforming the POMDP to a simple POMDP.");
646 } else {
647 STORM_PRINT_AND_LOG("Transforming the POMDP to a binary POMDP.");
649 }
650 pomdp->printModelInformationToStream(std::cout);
651 STORM_PRINT_AND_LOG(" done.\n");
652 transformationPerformed = true;
653 }
654
655 if (pomdpSettings.isExportToParametricSet()) {
656 STORM_PRINT_AND_LOG("Transforming memoryless POMDP to pMC...");
658 std::string transformMode = transformSettings.getFscApplicationTypeString();
659 auto pmc = toPMCTransformer.transform(storm::transformer::parsePomdpFscApplicationMode(transformMode));
660 STORM_PRINT_AND_LOG(" done.\n");
661 if (transformSettings.allowPostSimplifications()) {
662 STORM_PRINT_AND_LOG("Simplifying pMC...");
664 {formula.asSharedPointer()})
665 ->template as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
666 STORM_PRINT_AND_LOG(" done.\n");
667 pmc->printModelInformationToStream(std::cout);
668 }
669 STORM_PRINT_AND_LOG("Exporting pMC...");
671 auto const& parameterSet = constraints.getVariables();
672 std::vector<storm::RationalFunctionVariable> parameters(parameterSet.begin(), parameterSet.end());
673 std::vector<std::string> parameterNames;
674 for (auto const& parameter : parameters) {
675 parameterNames.push_back(parameter.name());
676 }
677 storm::api::exportSparseModelAsDrn(pmc, pomdpSettings.getExportToParametricFilename(), parameterNames,
678 !ioSettings.isExplicitExportPlaceholdersDisabled());
679 STORM_PRINT_AND_LOG(" done.\n");
680 transformationPerformed = true;
681 }
682 if (transformationPerformed && !memoryUnfolded) {
683 STORM_PRINT_AND_LOG("Implicitly assumed restriction to memoryless schedulers for at least one transformation.\n");
684 }
685 return transformationPerformed;
686}
687
688template<typename ValueType>
691
692 if (!pomdpSettings.isNoCanonicSet()) {
694 pomdp = makeCanonic.transform();
695 }
696
697 if (pomdpSettings.isAnalyzeUniqueObservationsSet()) {
698 STORM_PRINT_AND_LOG("Analyzing states with unique observation ...\n");
700 std::cout << uniqueAnalysis.analyse() << '\n';
701 }
702}
703
704template<typename ValueType>
706 std::shared_ptr<storm::logic::Formula const> formula) {
707 if (formula->asOperatorFormula().getSubformula().isBoundedUntilFormula()) {
708 // TODO: allow for more general reward-bounded until properties than reachability
709
710 auto const& boundedUntilFormula = formula->asOperatorFormula().getSubformula().asBoundedUntilFormula();
711 for (uint64_t i = 0; i < boundedUntilFormula.getDimension(); ++i) {
712 STORM_LOG_THROW(boundedUntilFormula.getLeftSubformula(i).isTrueFormula(), storm::exceptions::NotSupportedException,
713 "Reward-bounded until properties for POMDPs currently require 'true' as the left-hand side, i.e., they must be reward-bounded "
714 "reachability properties.");
715 }
717 // Process bounded until formulas
718 // If level widths are given, unfold the levels and make sure that the level rewards (and only those) are made observable
719 // If explicit unfolding is requested, unfold all reward bounds (if levels were unfolded before, this means a second round of unfolding)
720 // If reward observability is set and no level widths are given, make all rewards occurring in the formula observable. This also happens if no
721 // unfolding was requested.
722 storm::utility::Stopwatch boundedUntilProcessingWatch(true);
723 auto const levelWidths = pomdpSettings.getLevelWidthForBoundedReachability();
724 if (!levelWidths.empty()) {
725 STORM_PRINT_AND_LOG("Perform unfolding for observation levels.\n");
726 // Unfold the levels (includes dimensions with level-width 0)
728 options.levelWidths = levelWidths;
729 auto const unfoldingResult = transformer::RewardBoundUnfolder<ValueType>::transform(*pomdp, *formula, options);
730 pomdp = unfoldingResult.model->template as<storm::models::sparse::Pomdp<ValueType>>();
731 formula = unfoldingResult.formula;
732 // make sure the levels are observable
733 std::set<std::string> levelRewardModels;
734 formula->gatherReferencedRewardModels(levelRewardModels);
736 }
737 std::set<std::string> rewardModelsToObserve;
738 if (pomdpSettings.isRewardObservableSet() && levelWidths.empty()) {
739 formula->gatherReferencedRewardModels(rewardModelsToObserve); // keep rewards to make them observable later
740 }
741 if (pomdpSettings.isBoundedToUnboundedReachabilityTransformationSet() && formula->asOperatorFormula().getSubformula().isBoundedUntilFormula()) {
742 STORM_PRINT_AND_LOG("Perform explicit unfolding of reward bounds.\n");
744 options.preservedRewardModels = rewardModelsToObserve;
745 auto const unfoldingResult = transformer::RewardBoundUnfolder<ValueType>::transform(*pomdp, *formula, options);
746 pomdp = unfoldingResult.model->template as<storm::models::sparse::Pomdp<ValueType>>();
747 formula = unfoldingResult.formula;
748 }
749 if (pomdpSettings.isRewardObservableSet() && levelWidths.empty()) {
750 STORM_PRINT_AND_LOG("Extend observation function to become reward aware.\n");
752 }
753 STORM_LOG_THROW(!levelWidths.empty() || pomdpSettings.isRewardObservableSet() || pomdpSettings.isBoundedToUnboundedReachabilityTransformationSet(),
754 storm::exceptions::InvalidSettingsException,
755 "No handling of bounded until formulas specified. Consider setting --unfold-reward-bound and/or --reward-aware.");
756 STORM_PRINT_AND_LOG("bounded reachability processing done. POMDP Information:\n");
757 pomdp->printModelInformationToStream(std::cout);
758 STORM_PRINT_AND_LOG("Transformed formula: " << *formula << "\n");
759 boundedUntilProcessingWatch.stop();
760 STORM_PRINT_AND_LOG("Time for pre-processing: " << boundedUntilProcessingWatch << ".\n");
761 }
762 auto formulaInfo = storm::pomdp::analysis::getFormulaInformation(*pomdp, *formula);
763 STORM_LOG_THROW(!formulaInfo.isUnsupported(), storm::exceptions::InvalidPropertyException,
764 "The formula '" << *formula << "' is not supported by storm-pomdp.");
765
767 // Note that formulaInfo contains state-based information which potentially needs to be updated during preprocessing
768 if (performPreprocessing(pomdp, formulaInfo, *formula)) {
769 sw.stop();
770 STORM_PRINT_AND_LOG("Time for graph-based POMDP (pre-)processing: " << sw << ".\n");
771 pomdp->printModelInformationToStream(std::cout);
772 }
773
774 sw.restart();
775 if (performTransformation(pomdp, *formula)) {
776 sw.stop();
777 STORM_PRINT_AND_LOG("Time for POMDP transformation(s): " << sw << ".\n");
778 }
779
780 sw.restart();
781 if (performAnalysis(env, pomdp, formulaInfo, *formula)) {
782 sw.stop();
783 STORM_PRINT_AND_LOG("Time for POMDP analysis: " << sw << ".\n");
784 }
785}
786
787template<typename ValueType>
789 std::shared_ptr<storm::logic::Formula const> const& formula) {
790 STORM_LOG_ASSERT(pomdp, "No POMDP given or input POMDP is of unexpected type.");
792
793 if (formula) {
794 processFormula(env, std::move(pomdp), formula);
795 } else {
796 STORM_LOG_WARN("Nothing to be done. Did you forget to specify a formula?");
797 }
798}
799
801 auto symbolicInput = storm::cli::parseSymbolicInput();
803 std::tie(symbolicInput, mpi) = storm::cli::preprocessSymbolicInput(symbolicInput);
804 if (!symbolicInput.properties.empty()) {
806 bool const qualitativeOnly =
807 pomdpSettings.isQualitativeAnalysisSet() && !pomdpSettings.isBeliefExplorationSet() && !pomdpSettings.isCheckFullyObservableSet();
808 auto const& formula = *symbolicInput.properties.front().getRawFormula();
809 if (formula.isProbabilityOperatorFormula() || formula.isRewardOperatorFormula()) {
810 auto const& operatorFormula = formula.asOperatorFormula();
811 if (operatorFormula.hasBound()) {
813 qualitativeOnly && formula.isProbabilityOperatorFormula(), storm::exceptions::InvalidPropertyException,
814 "The threshold in '" << formula << "' is not supported by this POMDP analysis. Use a Pmin=?/Pmax=? or Rmin=?/Rmax=? query instead.");
815 auto const threshold = operatorFormula.getThresholdAs<storm::RationalNumber>();
816 STORM_LOG_THROW(threshold == 0 || threshold == 1, storm::exceptions::InvalidPropertyException,
817 "The probability threshold in '" << formula
818 << "' is not supported by storm-pomdp. Only thresholds of exactly 0 or 1 are supported for "
819 "qualitative analysis; use a Pmin=? or Pmax=? query for quantitative analysis.");
820 }
821 }
822 }
825 storm::exceptions::UnexpectedException, "Unexpected ValueType for model building.");
826
827 auto model = storm::cli::buildPreprocessExportModel(symbolicInput, mpi);
828 if (!model) {
829 STORM_PRINT_AND_LOG("No input model given.\n");
830 return;
831 }
832 STORM_LOG_THROW(model->getType() == storm::models::ModelType::Pomdp && model->isSparseModel(), storm::exceptions::WrongFormatException,
833 "Expected a POMDP in sparse representation.");
834
835 std::shared_ptr<storm::logic::Formula const> formula;
836 if (!symbolicInput.properties.empty()) {
837 formula = symbolicInput.properties.front().getRawFormula();
838 STORM_PRINT_AND_LOG("Analyzing property '" << *formula << "'\n");
839 STORM_LOG_WARN_COND(symbolicInput.properties.size() == 1,
840 "There is currently no support for multiple properties. All other properties will be ignored.");
841 }
842
843 if (model->isExact()) {
845 } else {
846 processPomdpFormula(mpi.env, model->template as<storm::models::sparse::Pomdp<double>>(), formula);
847 }
848}
849
850} // namespace cli
851} // namespace pomdp
852} // namespace storm
853
861int main(const int argc, const char** argv) {
862 try {
864 } catch (storm::exceptions::BaseException const& exception) {
865 STORM_LOG_ERROR("An exception caused Storm-pomdp to terminate. The message of the exception is: " << exception.what());
866 return 1;
867 } catch (std::exception const& exception) {
868 STORM_LOG_ERROR("An unexpected exception occurred and caused Storm-pomdp to terminate. The message of this exception is: " << exception.what());
869 return 2;
870 }
871}
storm::storage::BitVector analyseProb0(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyseProbSmaller1(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyseProb1(storm::logic::ProbabilityOperatorFormula const &formula) const
This class represents the base class of all exception classes.
virtual const char * what() const noexcept override
Retrieves the message associated with this exception.
BoundedUntilFormula & asBoundedUntilFormula()
Definition Formula.cpp:363
ProbabilityOperatorFormula & asProbabilityOperatorFormula()
Definition Formula.cpp:506
std::shared_ptr< Formula const > asSharedPointer()
Definition Formula.cpp:601
Formula const & getSubformula() const
A qualitative check result over the states of a sparse model.
This class represents a discrete-time Markov chain.
Definition Dtmc.h:16
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:16
This class represents a partially observable Markov decision process.
Definition Pomdp.h:13
Class to collect constraints on parametric Markov chains.
std::set< storm::RationalFunctionVariable > const & getVariables() const
Returns the set of variables in the model.
WinningRegion const & getLastWinningRegion() const
void setExportSATCalls(std::string const &path)
MemlessSearchPathVariables pathVariableType
bool analyzeForInitialStates(uint64_t k)
Check if you can find a memoryless policy from the initial states.
std::pair< storm::RationalNumber, storm::RationalNumber > computeNrWinningBeliefs() const
storm::RationalNumber beliefSupportStates() const
bool isWinning(uint64_t observation, uint64_t offset) const
void storeToFile(std::string const &path, std::string const &preamble="", bool append=false) const
void updateSinkStates(PomdpType const &pomdp, storm::storage::BitVector &&newSinkStates)
storm::solver::OptimizationDirection const & getOptimizationDirection() const
void updateTargetStates(PomdpType const &pomdp, storm::storage::BitVector &&newTargetStates)
Builds and checks a finite belief MDP approximation of a POMDP.
BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > checkDiscretize(storm::Environment const &env, PropertyInformation const &propertyInformation, storm::pomdp::beliefs::BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options, uint64_t resolution, bool useDynamic, storage::BeliefExplorationBounds< PomdpValueType > const &valueBounds)
Explores the belief space and discretises beliefs using the Freudenthal triangualtion approximation.
BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > checkRewardAwareUnfold(storm::Environment const &env, PropertyInformation const &propertyInformation, storm::pomdp::beliefs::BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options, storage::BeliefExplorationBounds< typename PomdpModelType::ValueType > const &valueBounds, std::vector< std::string > const &relevantRewardModelNames)
Explores a reward-aware belief MDP, splitting beliefs before successor generation by their reward vec...
BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > checkRewardAwareDiscretize(storm::Environment const &env, PropertyInformation const &propertyInformation, storm::pomdp::beliefs::BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options, uint64_t resolution, bool useDynamic, storage::BeliefExplorationBounds< typename PomdpModelType::ValueType > const &valueBounds, std::vector< std::string > const &relevantRewardModelNames)
Combines reward-aware exploration with Freudenthal triangulation discretization.
BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > checkUnfold(storm::Environment const &env, PropertyInformation const &propertyInformation, BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options, storage::BeliefExplorationBounds< PomdpValueType > const &valueBounds)
Explores the belief MDP by unfolding the belief space.
void generate(storm::storage::BitVector const &targetStates, storm::storage::BitVector const &badStates)
void verifySymbolic(storm::Environment const &env, bool onlyInitial=true)
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform(storm::models::sparse::Pomdp< ValueType > const &pomdp, storm::storage::BitVector &prob0States, storm::storage::BitVector &prob1States)
static ReturnType transform(storm::models::sparse::Model< ValueType > const &model, storm::logic::Formula const &formula, UnfoldingOptions const &options={})
Unfolds reward-bounded dimensions into the model state space and returns an equivalent formula.
static std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transformRewardAware(storm::models::sparse::Pomdp< ValueType > const &pomdp, std::set< std::string > const &observableRewardModels, bool dropUnreachableStates=true)
Makes rewards observable by extending observations with the state and state-action reward values of t...
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
PomdpMemory build(PomdpMemoryPattern pattern, uint64_t numStates) const
std::string toString() const
std::shared_ptr< storm::models::sparse::Model< storm::RationalFunction > > transform(PomdpFscApplicationMode applicationMode=PomdpFscApplicationMode::SIMPLE_LINEAR) const
PomdpTransformationResult< ValueType > transform(storm::models::sparse::Pomdp< ValueType > const &pomdp, bool transformSimple, bool keepStateValuations=false) const
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform() const
bool preservesFormula(storm::logic::Formula const &formula) const
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform(storm::logic::Formula const &formula) const
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform() const
std::pair< std::shared_ptr< storm::models::sparse::Pomdp< ValueType > >, std::set< uint32_t > > transform(storm::storage::BitVector const &stateSet) const
Ensures that the given set of states is observation closed, potentially, adding new observation(s) A ...
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform(bool dropUnreachableStates=true) const
A class that provides convenience operations to display run times.
Definition Stopwatch.h:13
void restart()
Reset the stopwatch and immediately start it.
Definition Stopwatch.cpp:59
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
#define STORM_LOG_INFO(message)
Definition logging.h:34
#define STORM_LOG_WARN(message)
Definition logging.h:35
#define STORM_LOG_TRACE(message)
Definition logging.h:22
#define STORM_LOG_ERROR(message)
Definition logging.h:36
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:54
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
storm::modelchecker::CheckTask< storm::logic::Formula, ValueType > createTask(std::shared_ptr< const storm::logic::Formula > const &formula, bool onlyInitialStatesRelevant=false)
void exportSparseModelAsDrn(std::shared_ptr< storm::models::sparse::Model< ValueType > > const &model, std::string const &filename, std::vector< std::string > const &parameterNames={}, bool allowPlaceholders=true)
Definition export.h:32
std::shared_ptr< storm::models::sparse::Model< ValueType > > performBisimulationMinimization(std::shared_ptr< storm::models::sparse::Model< ValueType > > const &model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas={}, storm::bisimulation::Options const &options={})
std::unique_ptr< storm::modelchecker::CheckResult > verifyWithSparseEngine(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Dtmc< ValueType > > const &dtmc, storm::modelchecker::CheckTask< storm::logic::Formula, ValueType > const &task, bool preferEliminationChecker=false)
std::shared_ptr< storm::models::ModelBase > buildPreprocessExportModel(SymbolicInput const &input, ModelProcessingInformation const &mpi)
SymbolicInput parseSymbolicInput()
int process(std::string const &name, std::string const &executableName, std::function< void(std::string const &, std::string const &)> initSettingsFunc, std::function< void(void)> processOptionsFunc, const int argc, const char **argv)
Processes the options and returns the exit code.
Definition cli.cpp:96
std::pair< SymbolicInput, ModelProcessingInformation > preprocessSymbolicInput(SymbolicInput const &input)
FormulaInformation getFormulaInformation(PomdpType const &pomdp, storm::logic::ProbabilityOperatorFormula const &formula)
void exportPolicyAsDot(storm::pomdp::policy::ObservationBasedFiniteStateController< ValueType > const &policy, std::string const &filename)
Exports an observation-based finite-state controller to a Graphviz DOT file.
Definition export.cpp:20
void exportPolicyAsJson(storm::pomdp::policy::ObservationBasedFiniteStateController< ValueType > const &policy, std::string const &filename)
Exports an observation-based finite-state controller to a JSON file.
Definition export.cpp:12
bool performPreprocessing(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &pomdp, storm::pomdp::analysis::FormulaInformation &formulaInfo, storm::logic::Formula const &formula)
Perform preprocessings based on the graph structure (if requested or necessary). Return true,...
void processPomdp(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &pomdp)
PolicyExportFormat getPolicyExportFormat(std::string const &filename)
void processPomdpFormula(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &&pomdp, std::shared_ptr< storm::logic::Formula const > const &formula)
bool performTransformation(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &pomdp, storm::logic::Formula const &formula)
MemlessSearchOptions fillMemlessSearchOptionsFromSettings()
bool performAnalysis(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > const &pomdp, storm::pomdp::analysis::FormulaInformation const &formulaInfo, storm::logic::Formula const &formula)
void performQualitativeAnalysis(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > const &origpomdp, storm::pomdp::analysis::FormulaInformation const &formulaInfo, storm::logic::Formula const &formula)
bool performBeliefExploration(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > const &pomdp, storm::pomdp::analysis::FormulaInformation const &formulaInfo, storm::logic::Formula const &formula)
void printResult(std::optional< ValueType > const &lowerBound, std::optional< ValueType > const &upperBound)
void processFormula(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &&pomdp, std::shared_ptr< storm::logic::Formula const > formula)
void printBeliefExplorationStatistics(Statistics const &statistics)
MemlessSearchPathVariables pathVariableTypeFromString(std::string const &in)
bool detectFiniteBeliefMdp(storm::models::sparse::Pomdp< ValueType > const &pomdp, std::optional< storm::storage::BitVector > const &targetStates)
This method tries to detect that the beliefmdp is finite.
void initializePomdpSettings(std::string const &name, std::string const &executableName)
Initialize the settings manager.
SettingsType const & getModule()
Get module.
bool constexpr maximize(OptimizationDirection d)
std::string toString(PomdpMemoryPattern const &pattern)
std::shared_ptr< storm::models::sparse::Model< double > > sparseRationalModelToDouble(std::shared_ptr< storm::models::sparse::Model< storm::RationalNumber > > const &inputModel, double precision)
PomdpFscApplicationMode parsePomdpFscApplicationMode(std::string const &mode)
storm::storage::BitVector getReachableStates(storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::BitVector const &initialStates, storm::storage::BitVector const &constraintStates, storm::storage::BitVector const &targetStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceFilter)
Performs a forward depth-first search through the underlying graph structure to identify the states t...
Definition graph.cpp:42
bool isTerminate()
Check whether the program should terminate (due to some abort signal).
ExtendedValueType< ValueType > fromSentinel(ValueType &&value)
Recognises the value that storm::utility::infinity still yields for the value types that have no infi...
ValueType zero()
Definition constants.cpp:26
std::conditional_t< storm::NumberTraits< ValueType >::HasInfinity, ValueType, ExtendedNumber< ValueType > > ExtendedValueType
The type to use for values that may be infinite.
ValueType one()
Definition constants.cpp:21
bool isInfinity(ValueType const &a)
TargetType convertNumber(SourceType const &number)
l3pp::LogLevel getLogLevel()
Gets the global log level.
The contract of a DD backend.
#define STORM_PRINT_AND_LOG(message)
Definition print.h:20
int main(const int argc, const char **argv)
Entry point for the pomdp backend.
static const bool IsExact
bool cutZeroGap
Cut non-target beliefs only when their preprocessing lower and upper bounds have exactly zero gap....
storm::utility::ExtendedValueType< BeliefMdpValueType > value
Property data consumed by the belief MDP construction.
std::set< BeliefObservationType > targetObservations
Struct for storing precomputed values bounding the actual values on the POMDP.
std::optional< ExtremePOMDPValueBound< POMDPValueType > > extremeBounds
std::optional< PreprocessingPomdpValueBounds< POMDPValueType > > preprocessingBounds
Struct for storing precomputed values bounding the actual values on the POMDP.
std::vector< std::vector< POMDPValueType > > lower
std::vector< std::vector< POMDPValueType > > upper
std::vector< uint64_t > levelWidths
Allows to define a levelWidth for each dimension.
std::set< std::string > preservedRewardModels
The reward models that will be preserved in the unfolding.
std::unordered_map< std::string, RewardModelType > rewardModels
storm::storage::SparseMatrix< ValueType > transitionMatrix
std::optional< storm::storage::sparse::Valuations > observationValuations
std::optional< storm::models::sparse::ChoiceLabeling > choiceLabeling
storm::models::sparse::StateLabeling stateLabeling
std::optional< std::vector< uint32_t > > observabilityClasses