Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
POMDPSettings.cpp
Go to the documentation of this file.
2
3#include <charconv>
4#include <limits>
5#include <ranges>
6
11
13
14namespace storm {
15namespace settings {
16namespace modules {
17
18const std::string POMDPSettings::moduleName = "pomdp";
19const std::string noCanonicOption = "nocanonic";
20const std::string exportAsParametricModelOption = "parametric-drn";
21const std::string beliefExplorationOption = "belief-exploration";
22const std::vector<std::string> beliefExplorationModes = {"both", "discretize", "unfold"};
23const std::string qualitativeReductionOption = "qualitativereduction";
24const std::string analyzeUniqueObservationsOption = "uniqueobservations";
25const std::string selfloopReductionOption = "selfloopreduction";
26const std::string memoryBoundOption = "memorybound";
27const std::string memoryPatternOption = "memorypattern";
28const std::vector<std::string> memoryPatterns = {"trivial", "fixedcounter", "selectivecounter", "ring", "fixedring", "settablebits", "full"};
29const std::string checkFullyObservableOption = "check-fully-observable";
30const std::string isQualitativeOption = "qualitative-analysis";
31const std::string isBoundedToUnboundedReachabilityTransformationOption = "unfold-reward-bound";
32const std::string isRewardObservableOption = "reward-aware";
33
36 "If this is set, actions will not be ordered canonically. Could yield incorrect results.")
37 .build());
38 this->addOption(
39 storm::settings::OptionBuilder(moduleName, exportAsParametricModelOption, false, "Export the parametric file.")
40 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file to which to write the model.").build())
41 .build());
43 "Reduces the model size by performing qualitative analysis (E.g. merge states with prob. 1.")
44 .build());
45 this->addOption(
46 storm::settings::OptionBuilder(moduleName, analyzeUniqueObservationsOption, false, "Computes the states with a unique observation").build());
47 this->addOption(storm::settings::OptionBuilder(moduleName, selfloopReductionOption, false, "Reduces the model size by removing self loop actions").build());
49 "Sets the maximal number of allowed memory states (1 means memoryless schedulers).")
50 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("bound", "The maximal number of memory states.")
51 .setDefaultValueUnsignedInteger(1)
53 .build())
54 .build());
55 this->addOption(storm::settings::OptionBuilder(moduleName, memoryPatternOption, false, "Sets the pattern of the considered memory structure")
56 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "Pattern name.")
58 .setDefaultValueString("full")
59 .build())
60 .build());
61 this->addOption(storm::settings::OptionBuilder(moduleName, beliefExplorationOption, false, "Analyze the POMDP by exploring the belief space.")
63 "mode", "Sets whether lower bounds, upper bounds, or interval bounds are computed.")
65 .setDefaultValueString("both")
66 .makeOptional()
67 .build())
68 .build());
69 this->addOption(
70 storm::settings::OptionBuilder(moduleName, checkFullyObservableOption, false, "Performs standard model checking on the underlying MDP").build());
71 this->addOption(storm::settings::OptionBuilder(moduleName, isQualitativeOption, false, "Sets the option qualitative analysis").build());
73 "Transforms reward-bounded reachability properties to an unbounded problem on an unfolded POMDP.")
74 .build());
75 this->addOption(storm::settings::OptionBuilder(moduleName, isRewardObservableOption, false, "Makes rewards observable for bounded reachability properties.")
77 "levelwidths", "Comma-separated reward level widths (integers from 0 to INT64_MAX).")
78 .setDefaultValueString("")
79 .makeOptional()
80 .build())
81 .build());
82}
83
85 return this->getOption(noCanonicOption).getHasOptionBeenSet();
86}
87
89 return this->getOption(exportAsParametricModelOption).getHasOptionBeenSet();
90}
91
93 return this->getOption(exportAsParametricModelOption).getArgumentByName("filename").getValueAsString();
94}
95
97 return this->getOption(qualitativeReductionOption).getHasOptionBeenSet();
98}
99
101 return this->getOption(analyzeUniqueObservationsOption).getHasOptionBeenSet();
102}
103
105 return this->getOption(selfloopReductionOption).getHasOptionBeenSet();
106}
107
109 return this->getOption(beliefExplorationOption).getHasOptionBeenSet();
110}
111
113 std::string arg = this->getOption(beliefExplorationOption).getArgumentByName("mode").getValueAsString();
114 return isBeliefExplorationSet() && (arg == "discretize" || arg == "both");
115}
116
118 std::string arg = this->getOption(beliefExplorationOption).getArgumentByName("mode").getValueAsString();
119 return isBeliefExplorationSet() && (arg == "unfold" || arg == "both");
120}
121
123 return this->getOption(checkFullyObservableOption).getHasOptionBeenSet();
124}
125
127 return this->getOption(isQualitativeOption).getHasOptionBeenSet();
128}
129
131 return this->getOption(isBoundedToUnboundedReachabilityTransformationOption).getHasOptionBeenSet();
132}
133
135 return this->getOption(isRewardObservableOption).getHasOptionBeenSet();
136}
137
139 auto const input = this->getOption(isRewardObservableOption).getArgumentByName("levelwidths").getValueAsString();
140 if (input.empty()) {
141 return {};
142 }
143 std::vector<uint64_t> result;
144 for (auto&& range : input | std::ranges::views::split(',')) {
145 std::string const token(range.begin(), range.end());
146 uint64_t width = 0;
147 auto const [end, error] = std::from_chars(token.data(), token.data() + token.size(), width);
148 STORM_LOG_THROW(error == std::errc{} && end == token.data() + token.size() && width <= std::numeric_limits<int64_t>::max(),
149 storm::exceptions::InvalidArgumentException,
150 "Invalid reward level width '" << token << "'. Expected an unsigned integer fitting in int64_t.");
151 result.push_back(width);
152 }
153 return result;
154}
155
157 return this->getOption(memoryBoundOption).getArgumentByName("bound").getValueAsUnsignedInteger();
158}
159
161 auto pattern = this->getOption(memoryPatternOption).getArgumentByName("name").getValueAsString();
162 if (pattern == "trivial") {
164 } else if (pattern == "fixedcounter") {
166 } else if (pattern == "selectivecounter") {
168 } else if (pattern == "ring") {
170 } else if (pattern == "fixedring") {
172 } else if (pattern == "settablebits") {
174 } else if (pattern == "full") {
176 }
177 STORM_LOG_THROW_UNCONDITIONALLY(storm::exceptions::InvalidArgumentException, "The name of the memory pattern is unknown.");
178}
179
181
183 STORM_LOG_THROW(getMemoryPattern() != storm::storage::PomdpMemoryPattern::Trivial || getMemoryBound() == 1, storm::exceptions::InvalidArgumentException,
184 "Memory bound greater one is not possible with the trivial memory pattern.");
185 return true;
186}
187
188} // namespace modules
189} // namespace settings
190} // namespace storm
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual uint_fast64_t getValueAsUnsignedInteger() const =0
Retrieves the value of this argument as an unsigned integer.
static ArgumentBuilder createUnsignedIntegerArgument(std::string const &name, std::string const &description)
Creates an unsigned integer argument with the given parameters.
static ArgumentBuilder createStringArgument(std::string const &name, std::string const &description)
Creates a string argument with the given parameters.
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedGreaterValidator(uint64_t lowerBound)
static std::shared_ptr< ArgumentValidator< std::string > > createMultipleChoiceValidator(std::vector< std::string > const &choices)
This class provides the interface to create an option...
ArgumentBase const & getArgumentByName(std::string const &argumentName) const
Returns a reference to the argument with the specified long name.
Definition Option.cpp:79
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
Definition Option.cpp:125
ModuleSettings(std::string const &moduleName)
Constructs a new settings object.
void addOption(std::shared_ptr< Option > const &option)
Adds and registers the given option.
Option & getOption(std::string const &longName)
Retrieves the option with the given long name.
void finalize() override
Prepares the modules for further usage, should be called at the end of the initialization,...
POMDPSettings()
Creates a new set of POMDP settings.
bool check() const override
Checks whether the settings are consistent.
std::string getExportToParametricFilename() const
storm::storage::PomdpMemoryPattern getMemoryPattern() const
static const std::string moduleName
std::vector< uint64_t > getLevelWidthForBoundedReachability() const
#define STORM_LOG_THROW_UNCONDITIONALLY(exception, message)
Definition macros.h:48
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
const std::string memoryPatternOption
const std::string beliefExplorationOption
const std::string isQualitativeOption
const std::string analyzeUniqueObservationsOption
const std::string isBoundedToUnboundedReachabilityTransformationOption
const std::string memoryBoundOption
const std::string isRewardObservableOption
const std::string noCanonicOption
const std::string checkFullyObservableOption
const std::string exportAsParametricModelOption
const std::vector< std::string > beliefExplorationModes
const std::string selfloopReductionOption
const std::string qualitativeReductionOption
const std::vector< std::string > memoryPatterns