Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TransformationSettings.cpp
Go to the documentation of this file.
2
9
10namespace storm {
11namespace settings {
12namespace modules {
13
14const std::string TransformationSettings::moduleName = "transformation";
15
16const std::string TransformationSettings::chainEliminationOptionName = "eliminate-chains";
17const std::string TransformationSettings::labelBehaviorOptionName = "ec-label-behavior";
18const std::string TransformationSettings::toNondetOptionName = "to-nondet";
19const std::string TransformationSettings::toDiscreteTimeOptionName = "to-discrete";
20const std::string TransformationSettings::permuteModelOptionName = "permute";
21
23 this->addOption(storm::settings::OptionBuilder(moduleName, chainEliminationOptionName, false,
24 "If set, chains of non-Markovian states are eliminated if the resulting model is a Markov Automaton.")
25 .setIsAdvanced()
26 .build());
27 std::vector<std::string> labelBehavior;
28 labelBehavior.push_back("keep");
29 labelBehavior.push_back("merge");
30 labelBehavior.push_back("delete");
31 this->addOption(
32 storm::settings::OptionBuilder(moduleName, labelBehaviorOptionName, false,
33 "Sets the behavior of labels for all non-Markovian states. Some options may cause wrong results.")
34 .setIsAdvanced()
36 "behavior",
37 "The behavior how the transformer handles labels of non-Markovian states. 'keep' does not eliminate states with different labels, "
38 "'merge' builds the union of labels of all eliminated states, 'delete' only keeps the labels of the last state.")
41 .build())
42 .build());
43 this->addOption(storm::settings::OptionBuilder(moduleName, toNondetOptionName, false,
44 "If set, DTMCs/CTMCs are converted to MDPs/MAs (without actual nondeterminism) before model checking.")
45 .setIsAdvanced()
46 .build());
47 this->addOption(storm::settings::OptionBuilder(moduleName, toDiscreteTimeOptionName, false,
48 "If set, CTMCs/MAs are converted to DTMCs/MDPs (which might or might not preserve the provided properties).")
49 .setIsAdvanced()
50 .build());
51
52 this->addOption(
53 storm::settings::OptionBuilder(moduleName, permuteModelOptionName, false, "Permutes the build model w.r.t. the given order.")
54 .setIsAdvanced()
55 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("order", "The order.")
58 .build())
59 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("seed", "An optional seed, makes random order deterministic.")
61 .makeOptional()
62 .build())
63 .build());
64}
65
67 return this->getOption(chainEliminationOptionName).getHasOptionBeenSet();
68}
69
71 std::string labelBehaviorAsString = this->getOption(labelBehaviorOptionName).getArgumentByName("behavior").getValueAsString();
72 if (labelBehaviorAsString == "keep") {
74 } else if (labelBehaviorAsString == "merge") {
76 } else if (labelBehaviorAsString == "delete") {
78 }
79 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
80 "Illegal value '" << labelBehaviorAsString << "' set as label behavior for the elimination.");
81}
82
84 return this->getOption(toNondetOptionName).getHasOptionBeenSet();
85}
86
88 return this->getOption(toDiscreteTimeOptionName).getHasOptionBeenSet();
89}
90
91std::optional<storm::utility::permutation::OrderKind> TransformationSettings::getModelPermutation() const {
92 if (this->getOption(permuteModelOptionName).getHasOptionBeenSet()) {
93 return storm::utility::permutation::orderKindFromString(this->getOption(permuteModelOptionName).getArgumentByName("order").getValueAsString());
94 }
95 return std::nullopt;
96}
97
98std::optional<uint64_t> TransformationSettings::getModelPermutationSeed() const {
99 if (this->getOption(permuteModelOptionName).getHasOptionBeenSet()) {
100 if (auto const& arg = this->getOption(permuteModelOptionName).getArgumentByName("seed"); arg.getHasBeenSet()) {
101 return arg.getValueAsUnsignedInteger();
102 }
103 }
104 return std::nullopt;
105}
106
108 // Ensure that labeling preservation is only set if chain elimination is set
109 STORM_LOG_THROW(isChainEliminationSet() || !this->getOption(labelBehaviorOptionName).getHasOptionBeenSet(), storm::exceptions::InvalidSettingsException,
110 "Label preservation can only be chosen if chain elimination is applied.");
111
112 // If there is a seed, the permutation order shall be random
114 "Random seed is given for permutation order, but the order is not random. Seed will be ignored.");
115
116 return true;
117}
118
120 // Intentionally left empty
121}
122
123} // namespace modules
124} // namespace settings
125} // namespace storm
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
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< 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
This is the base class of the settings for a particular module.
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.
bool isToNondeterministicModelSet() const
Retrieves whether a DTMC/CTMC should be converted to an MDP/MA.
bool check() const override
Checks whether the settings are consistent.
TransformationSettings()
Creates a new set of transformer settings.
storm::transformer::EliminationLabelBehavior getLabelBehavior() const
Retrieves how the transformer should deal with labels when non-Markovian states are eliminated.
bool isChainEliminationSet() const
Retrieves whether the option to eliminate chains of non-Markovian states was set.
std::optional< storm::utility::permutation::OrderKind > getModelPermutation() const
If the returned value is not empty, the model should be permuted according to the given order.
void finalize() override
Prepares the modules for further usage, should be called at the end of the initialization,...
std::optional< uint64_t > getModelPermutationSeed() const
Retrieves a random seed to be used in case the model shall be permuted randomly.
bool isToDiscreteTimeModelSet() const
Retrieves whether a CTMC/MA should be converted to a DTMC/MDP.
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
SettingsType const & getModule()
Get module.
EliminationLabelBehavior
Specify criteria whether a state can be eliminated and how its labels should be treated.
std::string orderKindtoString(OrderKind order)
Converts the given order to a string.
std::vector< std::string > orderKinds()
Returns a list of possible order kinds.
OrderKind orderKindFromString(std::string const &order)
Gets the order from the given string.
LabParser.cpp.
Definition cli.cpp:18