Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseModelToUmb.cpp
Go to the documentation of this file.
2
6
21
22namespace storm::umb {
23
24namespace detail {
25
26template<typename ValueType, typename TargetValueType>
28 if (!matrix.hasTrivialRowGrouping()) {
29 umb.stateToChoices = matrix.getRowGroupIndices();
30 }
31 umb.choiceToBranches = matrix.getRowIndices();
32 umb.branchToTarget.emplace().reserve(matrix.getEntryCount());
33 std::vector<TargetValueType> branchProbabilities;
34 branchProbabilities.reserve(matrix.getEntryCount());
35 for (uint64_t rowIndex = 0; rowIndex < matrix.getRowCount(); ++rowIndex) {
36 auto const& row = matrix.getRow(rowIndex);
37 for (auto const& entry : row) {
38 umb.branchToTarget->push_back(entry.getColumn());
39 branchProbabilities.push_back(storm::utility::convertNumber<TargetValueType>(entry.getValue()));
40 }
41 if (normalize) {
42 auto rowProbs = std::span<TargetValueType>(branchProbabilities.end() - row.getNumberOfEntries(), branchProbabilities.end());
43 TargetValueType const rowSum = std::accumulate(rowProbs.begin(), rowProbs.end(), storm::utility::zero<TargetValueType>());
44 if (!storm::utility::isOne(rowSum)) {
45 std::for_each(rowProbs.begin(), rowProbs.end(), [&rowSum](TargetValueType& entry) { entry /= rowSum; });
46 }
47 }
48 }
49 umb.branchToProbability.template set<TargetValueType>(std::move(branchProbabilities));
50}
51
53 for (auto const& labelName : labeling.getLabels()) {
54 if (labelName == "init") {
55 continue; // skip initial state labeling. Initial states are handled separately.
56 }
57 STORM_LOG_ASSERT(umb.index.aps(), "Model index must have annotations to store state labels.");
58 auto const name = umb.index.findAPName(labelName);
59 STORM_LOG_ASSERT(name.has_value(), "Label '" << labelName << "' not found in the model index.");
60 auto& aps = umb.aps(true).value();
61 STORM_LOG_ASSERT(!aps.contains(*name), "Annotation for label '" << labelName << "' already exists.");
62 auto& annotation = aps[*name];
63 annotation.states.emplace().values.template set<bool>(labeling.getStates(labelName));
64 }
65}
66
68 // choice to action
69 auto& choiceToAction = umb.choiceActions.emplace().values.emplace();
70 choiceToAction.reserve(choiceOrigins.getNumberOfChoices());
71 for (uint64_t c = 0; c < choiceOrigins.getNumberOfChoices(); ++c) {
72 choiceToAction.push_back(choiceOrigins.getIdentifier(c));
73 }
74
75 // action strings
76 // We always set a csr, even in cases where it could be omitted.
77 auto actionStrings = StringsBuilder(umb.choiceActions->strings.emplace(), umb.choiceActions->stringMapping.emplace());
78 // We use the empty action string for choices with no origin, which we want to be the first index.
79 auto const emptyStringIndex = actionStrings.push_back("");
80 STORM_LOG_ASSERT(emptyStringIndex == 0, "Action index for empty action string must be 0.");
81 // add to the action strings by initializing the csr with {0,0}
82 STORM_LOG_ASSERT(choiceOrigins.getIdentifierForChoicesWithNoOrigin() == 0, "Identifier for choices with no origin expected to be 0.");
83
84 for (uint64_t id = 1; id < choiceOrigins.getNumberOfIdentifiers(); ++id) { // intentionally start at 1, since we already added the empty action string
85 actionStrings.push_back(choiceOrigins.getIdentifierInfo(id));
86 }
87 actionStrings.finalize();
88 return actionStrings.size();
89}
90
92 // initialize umb data
93 // Action 0 must be the default action and is used for choices without any label (if present).
94 auto& choiceToAction = umb.choiceActions.emplace().values.emplace(labeling.getNumberOfItems(), 0);
95 auto actionStrings = StringsBuilder(umb.choiceActions->strings.emplace(), umb.choiceActions->stringMapping.emplace());
96
97 // Find out which choices have zero, at least one, or multiple labels. The former two cases can be handled more efficiently
98 auto const labels = labeling.getLabels();
99 storm::storage::BitVector choicesWithAtLeastOneLabel, choicesWithMultipleLabels;
100 for (auto const& labelName : labels) {
101 auto const& currentChoices = labeling.getChoices(labelName);
102 if (choicesWithAtLeastOneLabel.size() == 0) {
103 // first processed label
104 choicesWithAtLeastOneLabel = currentChoices;
105 } else if (choicesWithMultipleLabels.size() == 0) {
106 // second processed label
107 choicesWithMultipleLabels = choicesWithAtLeastOneLabel & currentChoices;
108 choicesWithAtLeastOneLabel |= currentChoices;
109 } else {
110 // third or later processed label
111 choicesWithMultipleLabels |= choicesWithAtLeastOneLabel & currentChoices;
112 choicesWithAtLeastOneLabel |= currentChoices;
113 }
114 }
115
116 // Handle choices without any labels.
117 if (!choicesWithAtLeastOneLabel.full()) {
118 // For consistency, unlabelled choices shall always have action index 0. So we add the empty action string.
119 auto const emptyStringIndex = actionStrings.push_back("");
120 STORM_LOG_ASSERT(emptyStringIndex == 0, "Action index for empty action string must be 0.");
121 // nothing else to do for unlabeled choices: we already initialized the choiceToAction mapping with 0s
122 }
123
124 // Handle choices with exactly one label.
125 auto setChoices = [&choiceToAction, &actionStrings](storm::storage::BitVector const& choices, std::string_view actionName) {
126 auto choiceIt = choices.begin();
127 auto const choiceItEnd = choices.end();
128 if (choiceIt != choiceItEnd) {
129 // there is at least one choice with this label
130 auto const actionIndex = actionStrings.findOrPushBack(actionName);
131 for (; choiceIt != choiceItEnd; ++choiceIt) {
132 choiceToAction[*choiceIt] = actionIndex; // set action index for this choice
133 }
134 }
135 };
136 if (choicesWithMultipleLabels.empty()) {
137 for (auto const& labelName : labels) {
138 setChoices(labeling.getChoices(labelName), labelName);
139 }
140 } else {
141 choicesWithMultipleLabels.complement(); // now contains the choices with at most one label
142 for (auto const& labelName : labels) {
143 setChoices(labeling.getChoices(labelName) & choicesWithMultipleLabels, labelName);
144 }
145 choicesWithMultipleLabels.complement(); // revert above complement operation
146 }
147
148 // Handle choices with multiple labels.
149 for (auto const& choice : choicesWithMultipleLabels) {
150 std::string action;
151 for (auto const& label : labeling.getLabelsOfChoice(choice)) {
152 if (!action.empty()) {
153 action += ","; // separate multiple labels with a comma
154 }
155 action += label;
156 }
157 choiceToAction[choice] = actionStrings.findOrPushBack(action);
158 }
159 return actionStrings.size();
160}
161
162template<typename TargetValueType>
163void setGenericVector(storm::umb::GenericVector& target, std::ranges::input_range auto&& values) {
164 using ValueType = std::ranges::range_value_t<decltype(values)>;
165 if constexpr (std::is_same_v<ValueType, TargetValueType>) {
166 target.template set<TargetValueType>(std::forward<decltype(values)>(values));
167 } else {
168 target.template set<TargetValueType>(storm::utility::vector::convertNumericVector<TargetValueType>(std::forward<decltype(values)>(values)));
169 }
170}
171
172template<typename ValueType, typename TargetValueType>
173void rewardToUmb(std::string const& rewardModelName, storm::models::sparse::StandardRewardModel<ValueType> const& rewardModel,
175 STORM_LOG_ASSERT(umb.index.rewards(), "Model index must have rewards to store state labels.");
176 auto const rewardIdentifier = umb.index.findRewardName(rewardModelName);
177 STORM_LOG_ASSERT(rewardIdentifier.has_value(), "Reward '" << rewardModelName << "' not found in the model index.");
178 auto& umbRewards = umb.rewards(true).value();
179 STORM_LOG_ASSERT(!umbRewards.contains(*rewardIdentifier), "Reward '" << *rewardIdentifier << "' already exists in the umb model.");
180 auto& rewardAnnotation = umbRewards[*rewardIdentifier];
181 if (rewardModel.hasStateRewards()) {
182 setGenericVector<TargetValueType>(rewardAnnotation.states.emplace().values, rewardModel.getStateRewardVector());
183 }
184 if (rewardModel.hasStateActionRewards()) {
185 setGenericVector<TargetValueType>(rewardAnnotation.choices.emplace().values, rewardModel.getStateActionRewardVector());
186 }
187 if (rewardModel.hasTransitionRewards()) {
188 std::vector<TargetValueType> branchRewards;
189 branchRewards.reserve(transitionMatrix.getEntryCount());
190 STORM_LOG_ASSERT(transitionMatrix.getRowCount() == rewardModel.getTransitionRewardMatrix().getRowCount(),
191 "The number of rows in the transition matrix and the reward model do not match.");
192 for (uint64_t rowIndex = 0; rowIndex < transitionMatrix.getRowCount(); ++rowIndex) {
193 auto const& transitionRow = transitionMatrix.getRow(rowIndex);
194 auto const& rewardRow = rewardModel.getTransitionRewardMatrix().getRow(rowIndex);
195 auto rewIt = rewardRow.begin();
196 // Match transition branch entries with entries in the transition reward matrix (which might not have the same entries at the same columns)
197 for (auto const& entry : transitionRow) {
198 while (rewIt != rewardRow.end() && rewIt->getColumn() < entry.getColumn()) {
199 ++rewIt;
200 }
201 if (rewIt == rewardRow.end() || rewIt->getColumn() > entry.getColumn()) {
202 branchRewards.push_back(storm::utility::zero<TargetValueType>());
203 } else {
204 STORM_LOG_ASSERT(rewIt->getColumn() == entry.getColumn(), "Unexpected column in reward model.");
205 branchRewards.push_back(storm::utility::convertNumber<TargetValueType>(rewIt->getValue()));
206 }
207 }
208 }
209 rewardAnnotation.branches.emplace().values.template set<TargetValueType>(std::move(branchRewards));
210 }
211}
212
213template<typename ValueType, typename TargetValueType>
214void playerIndicesToUmb(storm::models::sparse::Smg<ValueType> const& smg, auto& playerNames, auto& stateToPlayerIndices) {
215 STORM_LOG_ASSERT(playerNames.empty() && stateToPlayerIndices.empty(), "Expected initially empty player names and indices.");
216 auto const& origPlayerNamesToIndex = smg.getPlayerNamesToIndex();
217 playerNames.resize(smg.getNumberOfPlayers());
218 // We might have to insert names for unnamed players
219 storm::storage::BitVector unnamedIndices(playerNames.size(), true);
220 for (auto const& [name, index] : origPlayerNamesToIndex) {
221 playerNames[index] = name;
222 unnamedIndices.set(index, false);
223 }
224 auto freshPlayerName = [&origPlayerNamesToIndex](uint64_t i) {
225 std::string name = "unnamed_player" + std::to_string(i);
226 while (origPlayerNamesToIndex.contains(name)) {
227 name += "_";
228 }
229 return name;
230 };
231 for (auto const unnamedIndex : unnamedIndices) {
232 playerNames[unnamedIndex] = freshPlayerName(unnamedIndex);
233 }
234 stateToPlayerIndices.reserve(smg.getNumberOfStates());
235 // Some states might not have a player. For example, states that were not explored during model construction.
236 // These states are indicated by INVALID_PLAYER_INDEX. We assign these states to a fresh player at the end.
237 auto const invalPlayerIndex = smg.getNumberOfPlayers();
238 bool hasInvalidIndices = false;
239 for (auto const& index : smg.getStatePlayerIndications()) {
241 stateToPlayerIndices.push_back(invalPlayerIndex);
242 hasInvalidIndices = true;
243 } else {
244 STORM_LOG_ASSERT(index < smg.getNumberOfPlayers(), "Unexpected player index.");
245 stateToPlayerIndices.push_back(index);
246 }
247 }
248 if (hasInvalidIndices) {
249 playerNames.push_back(freshPlayerName(invalPlayerIndex));
250 }
251}
252
253template<typename ValueType>
255 using OptionType = ExportOptions::ValueType;
256 using ExportType = storm::umb::Type;
257 switch (options.valueType) {
258 case OptionType::Default:
259 if constexpr (std::is_same_v<ValueType, double>) {
260 return ExportType::Double;
261 } else if constexpr (std::is_same_v<ValueType, storm::RationalNumber>) {
262 return ExportType::Rational;
263 } else if constexpr (std::is_same_v<ValueType, storm::Interval>) {
264 return ExportType::DoubleInterval;
265 } else {
266 static_assert(std::is_same_v<ValueType, storm::RationalInterval>, "Unhandled value type");
267 return ExportType::RationalInterval;
268 }
269 case OptionType::Double:
270 return ExportType::Double;
271 case OptionType::Rational:
272 return ExportType::Rational;
273 case OptionType::DoubleInterval:
274 return ExportType::DoubleInterval;
275 case OptionType::RationalInterval:
276 return ExportType::RationalInterval;
277 }
278 STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Unexpected value type.");
279}
280
281template<typename ValueType>
283 // No model (meta-)data to set at this point.
284 // file-data:
285 index.fileData.emplace();
286 index.fileData->setCreationDateToNow();
287 index.fileData->tool = "Storm";
288 // Note: it's difficult to get the version of the tool because the storm library is not linked against storm-version-info
289
290 // transition-system:
291 auto& ts = index.transitionSystem;
292 switch (model.getType()) {
293 using enum storm::models::ModelType;
295 case Dtmc:
296 ts.time = Discrete;
297 ts.numPlayers = 0;
298 break;
299 case Ctmc:
300 ts.time = Stochastic;
301 ts.numPlayers = 0;
302 break;
303 case Mdp:
304 case Pomdp:
305 ts.time = Discrete;
306 ts.numPlayers = 1;
307 break;
308 case MarkovAutomaton:
309 ts.time = UrgentStochastic;
310 ts.numPlayers = 1;
311 break;
312 case Smg:
313 ts.time = Discrete;
315 break;
316 default:
317 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Unexpected model type.");
318 }
319 ts.numStates = model.getNumberOfStates();
320 ts.numInitialStates = model.getInitialStates().getNumberOfSetBits();
321 ts.numChoices = model.getNumberOfChoices();
322 ts.numChoiceActions = (model.hasChoiceLabeling() || model.hasChoiceOrigins()) ? ModelIndex::TransitionSystem::InvalidNumber
323 : 0; // action count is only known after processing choice labeling/origins.
324 ts.numBranches = model.getNumberOfTransitions();
325 ts.numBranchActions = 0;
326 ts.numObservations = model.isPartiallyObservable() ? ModelIndex::TransitionSystem::InvalidNumber : 0; // observation count set later
327
328 auto const exportType = getExportType<ValueType>(options);
329 ts.branchProbabilityType = {exportType, defaultBitSize(exportType)};
331 ts.exitRateType = ts.branchProbabilityType;
332 }
333
334 // annotations:
335 bool const hasRewards = model.hasRewardModel();
336 bool const hasAps = model.getStateLabeling().getNumberOfLabels() >= 2 ||
337 (model.getStateLabeling().getNumberOfLabels() == 1 && !model.getStateLabeling().containsLabel("init"));
338 if (hasRewards || hasAps) {
339 index.annotations.emplace();
340 }
341
342 // rewards:
343 if (hasRewards) {
344 auto& rewards = index.rewards(true).value();
345 for (auto const& [rewardModelName, rewardModel] : model.getRewardModels()) {
346 auto identifier = umb::ModelIndex::Annotation::getValidIdentifierFromAlias(rewardModelName);
347 STORM_LOG_THROW(!rewards.contains(identifier), storm::exceptions::WrongFormatException, "Reward id '" << identifier << "' already exists.");
348 auto& rewardIndex = rewards[identifier];
349 if (!rewardModelName.empty()) {
350 rewardIndex.alias = rewardModelName; // Don't introduce an alias for unnamed rewards. They don't have a nice name.
351 }
352 if (rewardModel.hasNegativeRewards()) {
353 if (!rewardModel.hasPositiveRewards()) {
354 rewardIndex.upper = 0;
355 }
356 } else {
357 rewardIndex.lower = 0;
358 }
360 if (rewardModel.hasStateRewards()) {
361 rewardIndex.appliesTo.push_back(States);
362 }
363 if (rewardModel.hasStateActionRewards()) {
364 rewardIndex.appliesTo.push_back(Choices);
365 }
366 if (rewardModel.hasTransitionRewards()) {
367 rewardIndex.appliesTo.push_back(Branches);
368 }
369 rewardIndex.type = {exportType, defaultBitSize(exportType)};
370 }
371 }
372
373 // aps:
374 if (hasAps) {
375 auto& aps = index.aps(true).value();
376 for (auto const& label : model.getStateLabeling().getLabels()) {
377 if (label == "init") {
378 continue;
379 }
381 STORM_LOG_THROW(!aps.contains(identifier), storm::exceptions::WrongFormatException, "AP with identifier '" << identifier << "' already exists.");
382 auto& apIndex = aps[identifier];
383 apIndex.alias = label;
386 }
387 }
388}
389
390template<typename ValueType, typename TargetValueType>
392 // Possibly canonicize POMDP
393 if (options.canonicizePomdp && model.isPartiallyObservable()) {
394 STORM_LOG_ASSERT(model.isOfType(storm::models::ModelType::Pomdp), "Only POMDPs are supported as partially observable models.");
395 auto pomdp = model.template as<storm::models::sparse::Pomdp<ValueType>>();
396 if (!pomdp->isCanonic()) {
397 STORM_LOG_INFO("Canonicizing POMDP before UMB export.");
399 auto newOptions = options;
400 newOptions.canonicizePomdp = false; // avoid infinite recursion
401 sparseModelToUmb<ValueType, TargetValueType>(*makeCanonic.transform(), umbModel, newOptions);
402 return;
403 }
404 }
405
406 // index
407 setIndexInformation<ValueType>(model, umbModel.index, options);
408
409 // initial states and APs
410 umbModel.stateIsInitial = model.getInitialStates();
411 stateLabelingToUmb(model.getStateLabeling(), umbModel);
412
413 // Choice Actions
414 if (options.allowChoiceOriginsAsActions && model.hasChoiceOrigins()) {
416 "Choice origins and choice labeling are both present but only choice origins will be used as actions for UMB export.");
417 uint64_t const numActions = choiceOriginsToUmb(*model.getChoiceOrigins(), umbModel);
418 umbModel.index.transitionSystem.numChoiceActions = numActions;
419 } else if (options.allowChoiceLabelingAsActions && model.hasChoiceLabeling()) {
420 uint64_t const numActions = choiceLabelingToUmb(model.getChoiceLabeling(), umbModel);
421 umbModel.index.transitionSystem.numChoiceActions = numActions;
422 }
423
424 // State valuations
425 if (model.hasStateValuations()) {
426 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "State valuations are not yet supported for UMB export.");
427 }
428
429 // Transition matrix
430 using enum storm::models::ModelType;
431 bool normalize = model.isOfType(Ctmc);
433 STORM_LOG_WARN("Translating from non-exact to exact model representation. This may lead to rounding errors.");
434 normalize = true;
435 }
437
438 // rewards
439 for (auto const& [name, rewardModel] : model.getRewardModels()) {
440 rewardToUmb<ValueType, TargetValueType>(name, rewardModel, model.getTransitionMatrix(), umbModel);
441 }
442
443 // Model type specific components
444 if (model.isOfType(Ctmc)) {
445 auto const& ctmc = *model.template as<storm::models::sparse::Ctmc<ValueType>>();
446 setGenericVector<TargetValueType>(umbModel.stateToExitRate, ctmc.getExitRateVector());
447 } else if (model.isOfType(MarkovAutomaton)) {
448 auto const& ma = *model.template as<storm::models::sparse::MarkovAutomaton<ValueType>>();
449 umbModel.stateIsMarkovian = ma.getMarkovianStates();
450 setGenericVector<TargetValueType>(umbModel.stateToExitRate, ma.getExitRates());
451 } else if (model.isOfType(Pomdp)) {
452 auto const& pomdp = *model.template as<storm::models::sparse::Pomdp<ValueType>>();
453 umbModel.index.transitionSystem.numObservations = pomdp.getNrObservations();
455 umbModel.stateObservations.emplace().values.emplace(pomdp.getObservations().begin(), pomdp.getObservations().end());
456 } else if (model.isOfType(Smg)) {
457 auto const& smg = *model.template as<storm::models::sparse::Smg<ValueType>>();
461 "Exporting SMG to UMB with zero or one players. The model will be recognized as MDP or DTMC on import.");
462 } else {
463 STORM_LOG_THROW(model.isOfType(Dtmc) || model.isOfType(Mdp), storm::exceptions::NotSupportedException,
464 "Unexpected model type for UMB export: " << model.getType());
465 }
466}
467
468} // namespace detail
469
470template<typename ValueType>
472 storm::umb::UmbModel umbModel;
473 using enum ExportOptions::ValueType;
474 switch (options.valueType) {
475 case Default:
476 detail::sparseModelToUmb<ValueType, ValueType>(model, umbModel, options);
477 break;
478 case Double:
479 detail::sparseModelToUmb<ValueType, double>(model, umbModel, options);
480 break;
481 case Rational:
483 break;
484 case DoubleInterval:
486 break;
487 case RationalInterval:
489 break;
490 default:
491 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Unexpected value type.");
492 }
493 STORM_LOG_ASSERT(umbModel.validate(std::cout), "Created umb model is not valid.");
494 return umbModel;
495}
496
499 ExportOptions const& options);
502 ExportOptions const& options);
503} // namespace storm::umb
storm::models::sparse::Dtmc< double > Dtmc
storm::models::sparse::Mdp< double > Mdp
virtual ModelType getType() const
Return the actual type of the model.
Definition ModelBase.cpp:7
bool isOfType(storm::models::ModelType const &modelType) const
Checks whether the model is of the given type.
Definition ModelBase.cpp:27
virtual bool isPartiallyObservable() const
Definition ModelBase.cpp:50
This class manages the labeling of the choice space with a number of (atomic) labels.
storm::storage::BitVector const & getChoices(std::string const &label) const
Returns the labeling of choices associated with the given label.
std::set< std::string > getLabelsOfChoice(uint64_t choice) const
Retrieves the set of labels attached to the given choice.
std::set< std::string > getLabels() const
Retrieves the set of labels contained in this labeling.
bool containsLabel(std::string const &label) const
Checks whether a label is registered within this labeling.
std::size_t getNumberOfItems() const
Returns the number of items managed by this object.
std::size_t getNumberOfLabels() const
Returns the number of labels managed by this object.
Base class for all sparse models.
Definition Model.h:30
storm::models::sparse::ChoiceLabeling const & getChoiceLabeling() const
Retrieves the labels for the choices of the model.
Definition Model.cpp:335
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
Definition Model.cpp:198
std::unordered_map< std::string, RewardModelType > const & getRewardModels() const
Retrieves the reward models.
Definition Model.cpp:690
bool hasStateValuations() const
Retrieves whether this model was build with state valuations.
Definition Model.cpp:350
virtual uint_fast64_t getNumberOfChoices() const override
Returns the number of choices ine the model.
Definition Model.cpp:173
std::shared_ptr< storm::storage::sparse::ChoiceOrigins > const & getChoiceOrigins() const
Retrieves the origins of the choices of the model.
Definition Model.cpp:375
bool hasChoiceLabeling() const
Retrieves whether this model has a labeling of the choices.
Definition Model.cpp:330
virtual bool hasRewardModel(std::string const &rewardModelName) const override
Retrieves whether the model has a reward model with the given name.
Definition Model.cpp:208
storm::models::sparse::StateLabeling const & getStateLabeling() const
Returns the state labeling associated with this model.
Definition Model.cpp:320
virtual uint_fast64_t getNumberOfTransitions() const override
Returns the number of (non-zero) transitions of the model.
Definition Model.cpp:168
bool hasChoiceOrigins() const
Retrieves whether this model was build with choice origins.
Definition Model.cpp:370
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
Definition Model.cpp:163
storm::storage::BitVector const & getInitialStates() const
Retrieves the initial states of the model.
Definition Model.cpp:178
This class represents a stochastic multiplayer game.
Definition Smg.h:16
std::vector< storm::storage::PlayerIndex > const & getStatePlayerIndications() const
Definition Smg.cpp:34
std::map< std::string, storm::storage::PlayerIndex > const & getPlayerNamesToIndex() const
Definition Smg.cpp:52
uint64_t getNumberOfPlayers() const
Definition Smg.cpp:57
storm::storage::SparseMatrix< ValueType > const & getTransitionRewardMatrix() const
Retrieves the transition rewards of the reward model.
bool hasTransitionRewards() const
Retrieves whether the reward model has transition rewards.
std::vector< ValueType > const & getStateActionRewardVector() const
Retrieves the state-action rewards of the reward model.
std::vector< ValueType > const & getStateRewardVector() const
Retrieves the state rewards of the reward model.
bool hasStateRewards() const
Retrieves whether the reward model has state rewards.
bool hasStateActionRewards() const
Retrieves whether the reward model has state-action rewards.
This class manages the labeling of the state space with a number of (atomic) labels.
storm::storage::BitVector const & getStates(std::string const &label) const
Returns the labeling of states associated with the given label.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
void complement()
Negates all bits in the bit vector.
bool full() const
Retrieves whether all bits are set in this bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
size_t size() const
Retrieves the number of bits this bit vector can store.
A class that holds a possibly non-square matrix in the compressed row storage format.
const_rows getRow(index_type row) const
Returns an object representing the given row.
index_type getEntryCount() const
Returns the number of entries in the matrix.
std::vector< index_type > const & getRowIndices() const
Returns the entry indices within the given row.
bool hasTrivialRowGrouping() const
Retrieves whether the matrix has a trivial row grouping.
std::vector< index_type > const & getRowGroupIndices() const
Returns the grouping of rows of this matrix.
index_type getRowCount() const
Returns the number of rows of the matrix.
This class represents the origin of the choices of a model in terms of the input model specification ...
virtual uint_fast64_t getNumberOfIdentifiers() const =0
uint_fast64_t getIdentifier(uint_fast64_t choiceIndex) const
static uint_fast64_t getIdentifierForChoicesWithNoOrigin()
std::string const & getIdentifierInfo(uint_fast64_t identifier) const
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform() const
Represents a model in the UMB format.
Definition UmbModel.h:21
TO1< bool > stateIsMarkovian
Definition UmbModel.h:29
bool validate(std::ostream &errors) const
Validates the given UMB model and writes potential errors to the given output stream.
Definition UmbModel.cpp:96
TO1< bool > stateIsInitial
Definition UmbModel.h:28
TO1< AnyValueType > stateToExitRate
Definition UmbModel.h:30
ModelIndex index
Definition UmbModel.h:24
TO1< uint32_t > stateToPlayer
Definition UmbModel.h:27
std::optional< Observations > stateObservations
Definition UmbModel.h:51
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_WARN(message)
Definition logging.h:25
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
PlayerIndex const INVALID_PLAYER_INDEX
Definition PlayerIndex.h:8
void rewardToUmb(std::string const &rewardModelName, storm::models::sparse::StandardRewardModel< ValueType > const &rewardModel, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::umb::UmbModel &umb)
storm::umb::Type getExportType(ExportOptions const &options)
void setIndexInformation(storm::models::sparse::Model< ValueType > const &model, storm::umb::ModelIndex &index, ExportOptions const &options)
uint64_t choiceLabelingToUmb(storm::models::sparse::ChoiceLabeling const &labeling, storm::umb::UmbModel &umb)
void setGenericVector(storm::umb::GenericVector &target, std::ranges::input_range auto &&values)
uint64_t choiceOriginsToUmb(storm::storage::sparse::ChoiceOrigins const &choiceOrigins, storm::umb::UmbModel &umb)
void playerIndicesToUmb(storm::models::sparse::Smg< ValueType > const &smg, auto &playerNames, auto &stateToPlayerIndices)
void transitionMatrixToUmb(storm::storage::SparseMatrix< ValueType > const &matrix, storm::umb::UmbModel &umb, bool const normalize)
void stateLabelingToUmb(storm::models::sparse::StateLabeling const &labeling, storm::umb::UmbModel &umb)
void sparseModelToUmb(storm::models::sparse::Model< ValueType > const &model, UmbModel &umbModel, ExportOptions const &options)
storm::umb::UmbModel sparseModelToUmb(storm::models::sparse::Model< ValueType > const &model, ExportOptions const &options)
template storm::umb::UmbModel sparseModelToUmb< storm::RationalInterval >(storm::models::sparse::Model< storm::RationalInterval > const &model, ExportOptions const &options)
uint64_t defaultBitSize(Type const type)
Returns the default size (in bits) of a type, if available.
Definition Type.cpp:59
template storm::umb::UmbModel sparseModelToUmb< double >(storm::models::sparse::Model< double > const &model, ExportOptions const &options)
template storm::umb::UmbModel sparseModelToUmb< storm::Interval >(storm::models::sparse::Model< storm::Interval > const &model, ExportOptions const &options)
template storm::umb::UmbModel sparseModelToUmb< storm::RationalNumber >(storm::models::sparse::Model< storm::RationalNumber > const &model, ExportOptions const &options)
std::vector< TargetType > convertNumericVector(std::vector< SourceType > const &oldVector)
Converts the given vector to the given ValueType Assumes that both, TargetType and SourceType are num...
Definition vector.h:966
bool isOne(ValueType const &a)
Definition constants.cpp:34
ValueType zero()
Definition constants.cpp:24
TargetType convertNumber(SourceType const &number)
carl::Interval< storm::RationalNumber > RationalInterval
static const bool IsExact
bool allowChoiceLabelingAsActions
Whether export of choice origins is enabled.
bool allowChoiceOriginsAsActions
Whether export of choice origins is enabled.
ValueType
The type that is used for all kinds of values.
bool canonicizePomdp
Whether to canonicize POMDPs before export.
static std::string getValidIdentifierFromAlias(std::string const &alias)
Takes an alias (which can be an arbitrary string) and converts it to a valid identifier in [0-9a-z_-]...
std::optional< storm::SerializedEnum< ObservationsApplyToDeclaration > > observationsApplyTo
Definition ModelIndex.h:56
std::optional< std::vector< std::string > > playerNames
Definition ModelIndex.h:60
storm::OptionalRef< AnnotationMap > rewards(bool createIfMissing=false)
struct storm::umb::ModelIndex::TransitionSystem transitionSystem
std::optional< std::map< std::string, AnnotationMap > > annotations
Definition ModelIndex.h:109
storm::OptionalRef< AnnotationMap > aps(bool createIfMissing=false)
std::optional< FileData > fileData
Definition ModelIndex.h:37