Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseModelFromUmb.cpp
Go to the documentation of this file.
2
3#include <ranges>
4#include <utility>
5
21
22namespace storm::umb {
23
24namespace detail {
25
26auto csrRange(auto&& csr, uint64_t i) {
27 if (csr) {
28 STORM_LOG_ASSERT(i + 1 < csr->size(), "CSR index out of bounds: " << (i + 1) << " >= " << csr->size());
29 return std::ranges::iota_view(csr.value()[i], csr.value()[i + 1]);
30 } else {
31 // assume 1:1 mapping
32 return std::ranges::iota_view(i, i + 1);
33 }
34}
35
36template<typename ValueType>
38
44template<typename ValueType>
45storm::storage::SparseMatrix<ValueType> createBranchMatrix(storm::umb::UmbModel const& umbModel, std::ranges::input_range auto&& branchValues,
46 AccumulationMode<ValueType> accumulationMode) {
47 auto const& tsIndex = umbModel.index.transitionSystem;
48 bool const hasRowGroups = tsIndex.numPlayers >= 1;
49 // We can not force the number of entries since branches with the same source and target are merged into one entry.
50 storm::storage::SparseMatrixBuilder<ValueType> builder(tsIndex.numChoices, tsIndex.numStates, tsIndex.numBranches, false, hasRowGroups,
51 hasRowGroups ? tsIndex.numStates : 0u);
52 builder.setAccumulationMode(accumulationMode);
53 for (uint64_t stateIndex{0}; stateIndex < tsIndex.numStates; ++stateIndex) {
54 auto choices = csrRange(umbModel.stateToChoices, stateIndex);
55 if (hasRowGroups) {
56 builder.newRowGroup(*choices.begin());
57 }
58 for (auto const choiceIndex : choices) {
59 STORM_LOG_ASSERT(choiceIndex < tsIndex.numChoices, "Choice index out of bounds.");
60 for (auto const branchIndex : csrRange(umbModel.choiceToBranches, choiceIndex)) {
61 auto const branchTarget = umbModel.branchToTarget.has_value() ? umbModel.branchToTarget.value()[branchIndex] : 0ul;
62 STORM_LOG_ASSERT(branchTarget < tsIndex.numStates, "Branch target index out of bounds: " << branchTarget << " >= " << tsIndex.numStates);
63 builder.addNextValue(choiceIndex, branchTarget, branchValues[branchIndex]);
64 }
65 }
66 }
67 return builder.build(tsIndex.numChoices, tsIndex.numStates, hasRowGroups ? tsIndex.numStates : 0u);
68}
69
70template<typename ValueType>
72 storm::umb::SizedType const& sourceType, AccumulationMode<ValueType> accumulationMode) {
74 [&umbModel, accumulationMode](auto&& input) { return createBranchMatrix<ValueType>(umbModel, input, accumulationMode); }, branchValues, sourceType);
75}
76
77template<typename ValueType>
79 AccumulationMode<ValueType> accumulationMode) {
80 auto const defaultView = std::ranges::iota_view(0ull, umbModel.index.transitionSystem.numBranches) |
81 std::ranges::views::transform([&defaultValue](auto) -> ValueType { return defaultValue; });
82 return createBranchMatrix<ValueType>(umbModel, defaultView, accumulationMode);
83}
84
86 STORM_LOG_THROW(umbBitVector.size() >= size, storm::exceptions::WrongFormatException,
87 "Bit vector has unexpected size: " << umbBitVector.size() << " < " << size << ".");
88 storm::storage::BitVector result(umbBitVector);
89 result.resize(size);
90 return result;
91}
92
94 STORM_LOG_THROW(umbBitVector.has_value(), storm::exceptions::WrongFormatException, "BitVector is not given but expected.");
95 return createBitVector(umbBitVector.value(), size);
96}
97
99 auto const& numStates = umbModel.index.transitionSystem.numStates;
100 storm::models::sparse::StateLabeling stateLabelling(numStates);
101 if (umbModel.stateIsInitial) {
102 stateLabelling.addLabel("init", createBitVector(umbModel.stateIsInitial, numStates));
103 }
104 if (umbModel.index.aps().has_value()) {
105 auto aps = umbModel.index.aps();
106 for (auto const& [apName, apIndex] : aps.value()) {
107 STORM_LOG_THROW(umbModel.aps().has_value() && umbModel.aps()->contains(apName), storm::exceptions::WrongFormatException,
108 "Atomic proposition '" << apName << "' mentioned in index but no files were found.");
109 STORM_LOG_THROW(isBooleanType(apIndex.type.type), storm::exceptions::WrongFormatException,
110 "Atomic proposition '" << apName << "' must be of boolean type.");
111 STORM_LOG_THROW(apIndex.appliesTo.size() == 1 && apIndex.appliesToStates(), storm::exceptions::WrongFormatException,
112 "Atomic proposition '" << apName << "' must apply only to states.");
113 auto const& ap = umbModel.aps()->at(apName);
114 auto labelName = apIndex.alias.value_or(apName); // prefer alias as label name if it exists
115 STORM_LOG_THROW(ap.states.has_value(), storm::exceptions::WrongFormatException, "Atomic proposition '" << apName << "' has no states values.");
116 auto labeledStates = createBitVector(ap.states->values.template get<bool>(), numStates);
117 if (stateLabelling.containsLabel(labelName)) {
118 STORM_LOG_THROW(stateLabelling.getStates(labelName) == labeledStates, storm::exceptions::WrongFormatException,
119 "Label '" << labelName << "' is declared multiple times with different labellings.");
120 STORM_LOG_WARN("Ignoring additional declaration of label '" << labelName << "' as it is already defined with the same labelling.");
121 } else {
122 stateLabelling.addLabel(labelName, std::move(labeledStates));
123 }
124 }
125 }
126 if (!stateLabelling.containsLabel("init")) {
127 STORM_LOG_WARN("No initial states given in UMB model.");
128 stateLabelling.addLabel("init", storm::storage::BitVector(numStates, false)); // default to all states not being initial
129 }
130 return stateLabelling;
131}
132
134 auto const& numChoices = umbModel.index.transitionSystem.numChoices;
135 auto const& numActions = umbModel.index.transitionSystem.numChoiceActions;
136
137 storm::models::sparse::ChoiceLabeling choiceLabeling(numChoices);
138
139 auto const actionStrings = storm::umb::stringVectorView(umbModel.choiceActions->strings, umbModel.choiceActions->stringMapping);
140 bool const hasActionStrings = !actionStrings.empty();
141 STORM_LOG_THROW(!hasActionStrings || actionStrings.size() == numActions, storm::exceptions::WrongFormatException,
142 "Number of action strings does not match number of actions.");
143
144 // choices where the action has the empty label will not be labeled at all. If there are no string labels, this case is not relevant.
145 uint64_t const emptyActionIndex = hasActionStrings ? std::ranges::find(actionStrings, "") - actionStrings.begin() : numActions;
146
147 // for each choice, find the corresponding action index and set the bit accordingly
148 auto const& choiceToChoiceAction = umbModel.choiceActions->values.value();
149 std::vector<storm::storage::BitVector> actionToLabels(numActions, storm::storage::BitVector(numChoices, false));
150 for (uint64_t choiceIndex = 0; choiceIndex < numChoices; ++choiceIndex) {
151 auto const actionIndex = choiceToChoiceAction[choiceIndex];
152 STORM_LOG_ASSERT(actionIndex < numActions, "Choice to action mapping out of bounds.");
153 if (hasActionStrings && actionIndex == emptyActionIndex) {
154 continue; // skip choices with empty action. They will not be labeled.
155 }
156 actionToLabels[actionIndex].set(choiceIndex);
157 }
158
159 // add the action labels to the labeling
160 if (hasActionStrings) {
161 for (uint64_t actionIndex = 0; actionIndex < numActions; ++actionIndex) {
162 if (actionIndex == emptyActionIndex) {
163 continue;
164 }
165 choiceLabeling.addLabel(std::string(actionStrings[actionIndex]), std::move(actionToLabels[actionIndex]));
166 }
167 } else {
168 // use generic action names
169 for (uint64_t actionIndex = 0; actionIndex < numActions; ++actionIndex) {
170 choiceLabeling.addLabel("a" + std::to_string(actionIndex), std::move(actionToLabels[actionIndex]));
171 }
172 }
173 return choiceLabeling;
174}
175
176template<typename ValueType>
179 std::unordered_map<std::string, RewardModel> rewardModels;
180 if (umbModel.index.rewards().has_value()) {
181 auto rewards = umbModel.index.rewards();
182 for (auto const& [rewName, rewIndex] : rewards.value()) {
183 STORM_LOG_THROW(umbModel.rewards().has_value() && umbModel.rewards()->contains(rewName), storm::exceptions::WrongFormatException,
184 "Reward " << rewName << "' mentioned in index but no files were found.");
185 auto const& rew = umbModel.rewards()->at(rewName);
186 auto usedRewName = rewIndex.alias.value_or(rewName); // prefer alias as reward name if it exists
187 STORM_LOG_THROW(!rewardModels.contains(usedRewName), storm::exceptions::WrongFormatException,
188 "Reward '" << usedRewName << "' already exists in reward models.");
189 STORM_LOG_THROW(isNumericType(rewIndex.type.type), storm::exceptions::WrongFormatException,
190 "Reward type for reward '" << rewName << "' must be numeric.");
191 std::optional<std::vector<ValueType>> stateRewards, stateActionRewards;
192 std::optional<storm::storage::SparseMatrix<ValueType>> transitionRewards;
193 if (rewIndex.appliesToStates() && rew.states.has_value()) {
194 stateRewards = ValueEncoding::createDecodedVector<ValueType>(rew.states->values, rewIndex.type);
195 }
196 if (rewIndex.appliesToChoices() && rew.choices.has_value()) {
197 stateActionRewards = ValueEncoding::createDecodedVector<ValueType>(rew.choices->values, rewIndex.type);
198 }
199 if (rewIndex.appliesToBranches() && rew.branches.has_value()) {
200 // Rewards of branches that are merged into one matrix entry (same source choice and target state) must coincide.
201 try {
202 transitionRewards = createBranchMatrix<ValueType>(umbModel, rew.branches->values, rewIndex.type, AccumulationMode<ValueType>::ExpectSame);
203 } catch (storm::exceptions::InvalidArgumentException const& e) {
204 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException,
205 "Branch rewards of reward '"
206 << rewName
207 << "' can not be imported, possibly due to multiple branches with the same source choice and the same target "
208 "state but distinct rewards, which is not supported. ("
209 << e.what() << ")");
210 }
211 }
212 STORM_LOG_THROW(!rewIndex.appliesToObservations(), storm::exceptions::NotSupportedException,
213 "Observation rewards are not supported for reward '" << rewName << "'.");
214 STORM_LOG_THROW(!rewIndex.appliesToPlayers(), storm::exceptions::NotSupportedException,
215 "Player rewards are not supported for reward '" << rewName << "'.");
216 rewardModels.emplace(std::move(usedRewName), RewardModel(std::move(stateRewards), std::move(stateActionRewards), std::move(transitionRewards)));
217 }
218 }
219 return rewardModels;
220}
221
222template<typename ValueType>
224 if (umbModel.branchToProbability.hasValue()) {
225 auto const probType = umbModel.index.transitionSystem.branchProbabilityType.value();
226 // Probabilities of branches that are merged into one matrix entry (same source choice and target state) are summed up.
229 if (umbModel.branchToProbability.isType<double>() || umbModel.branchToProbability.isType<storm::Interval>()) {
230 // If the branch probabilities are imprecise, we might need to adapt the matrix rows to ensure they sum up to 1.
231 uint64_t numNormalized{0};
233 auto updateNormStats = [&numNormalized, &maxDiff](auto const& rowSum) {
234 maxDiff = std::max(
236 ++numNormalized;
237 };
238
239 for (uint64_t rowIndex = 0; rowIndex < result.getRowCount(); ++rowIndex) {
240 auto const rowSum = result.getRowSum(rowIndex);
241 if constexpr (storm::IsIntervalType<ValueType>) {
242 if (rowSum.lower() > storm::utility::one<ValueType>()) {
243 updateNormStats(rowSum.lower());
244 for (auto& entry : result.getRow(rowIndex)) {
245 entry.setValue({entry.getValue().lower() / rowSum.lower(), entry.getValue().upper()});
246 }
247 } else if (rowSum.upper() < storm::utility::one<ValueType>()) {
248 updateNormStats(rowSum.upper());
249 for (auto& entry : result.getRow(rowIndex)) {
250 entry.setValue({entry.getValue().lower(), entry.getValue().upper() / rowSum.upper()});
251 }
252 }
253 } else {
254 if (!storm::utility::isOne(rowSum)) {
255 updateNormStats(rowSum);
256 for (auto& entry : result.getRow(rowIndex)) {
257 entry.setValue(entry.getValue() / rowSum);
258 }
259 }
260 }
261 }
262 STORM_LOG_WARN_COND(numNormalized == 0,
263 "Branch probabilities are given in an imprecise type but an exact model was requested. Probabilities for "
264 << numNormalized << " choices were normalized to ensure they sum up to 1. Maximum diff to 1 was " << maxDiff << ".");
265 }
266 }
267 return result;
268 } else {
270 }
271}
272
273template<typename ValueType>
274std::shared_ptr<storm::models::sparse::Model<ValueType>> constructSparseModel(storm::umb::UmbModel const& umbModel, ImportOptions const& options) {
275 umbModel.validateOrThrow();
276
277 // transitions, labelings, rewards
278 auto stateLabelling = constructStateLabeling(umbModel);
279 STORM_LOG_THROW(umbModel.index.transitionSystem.branchProbabilityType.has_value(), storm::exceptions::WrongFormatException,
280 "Branch probability type must be given in the UMB model index.");
281 auto transitionMatrix = constructTransitionMatrix<ValueType>(umbModel);
282 storm::storage::sparse::ModelComponents<ValueType> components(std::move(transitionMatrix), std::move(stateLabelling),
284 // choice labeling
285 if (options.buildChoiceLabeling && umbModel.index.transitionSystem.numChoiceActions > 0) {
286 STORM_LOG_THROW(umbModel.choiceActions.has_value() && umbModel.choiceActions->values.has_value(), storm::exceptions::WrongFormatException,
287 "Choice actions mentioned in the index but no files given.");
288 components.choiceLabeling = constructChoiceLabeling(umbModel);
289 }
290 // state valuations
291 if (options.buildStateValuations && umbModel.index.valuations.has_value() && umbModel.index.valuations->states.has_value()) {
292 STORM_LOG_THROW(umbModel.valuations.states.has_value() && umbModel.valuations.states->valuations.has_value(), storm::exceptions::WrongFormatException,
293 "State valuations mentioned in the index but no files given.");
294 auto const& svIndex = umbModel.index.valuations->states.value();
295 auto const& svData = umbModel.valuations.states.value();
296 STORM_LOG_ASSERT(svIndex.numStrings.has_value() == svData.stringMapping.has_value() && svIndex.numStrings.has_value() == svData.strings.has_value(),
297 "String mapping and strings must be given iff there are #strings mentioned in index.");
298 storm::storage::sparse::ValuationsStorage val(umbModel.index.transitionSystem.numStates, svIndex.classes, svData.valuations.value(),
299 svData.stringMapping.value_or(std::vector<uint64_t>()), svData.strings.value_or(std::vector<char>()),
300 svData.valuationToClass);
301 components.stateValuations.emplace(std::move(val));
302 } else {
303 STORM_LOG_WARN_COND(!options.buildStateValuations, "State valuations requested but the UMB model does not have any.");
304 }
305
306 // model type-specific components
307 using enum storm::models::ModelType;
308 auto const modelType = deriveModelType(umbModel.index);
309 if (modelType == Ctmc || modelType == MarkovAutomaton) {
310 STORM_LOG_THROW(umbModel.stateToExitRate.hasValue(), storm::exceptions::WrongFormatException,
311 "Exit rates are required for CTMC and Markov automaton models but not present in the UMB model.");
313 if (modelType == MarkovAutomaton) {
314 if (umbModel.stateIsMarkovian) {
316 } else {
317 // Default to no Markovian state
318 components.markovianStates.emplace(umbModel.index.transitionSystem.numStates, false);
319 }
320 }
321 } else if (modelType == Pomdp) {
323 storm::exceptions::NotSupportedException, "Only state observations are currently supported for POMDP models.");
324 STORM_LOG_THROW(!umbModel.index.transitionSystem.observationProbabilityType.has_value(), storm::exceptions::NotSupportedException,
325 "Only deterministic state observations are currently supported for POMDP models.");
326 STORM_LOG_THROW(umbModel.stateObservations.has_value(), storm::exceptions::WrongFormatException,
327 "State observations are required for POMDP models but not present in the UMB model.");
328 components.observabilityClasses.emplace(umbModel.stateObservations->values->begin(), umbModel.stateObservations->values->end());
329 // observation valuations
330 if (options.buildObservationValuations && umbModel.index.valuations.has_value() && umbModel.index.valuations->observations.has_value()) {
331 STORM_LOG_THROW(umbModel.valuations.observations.has_value() && umbModel.valuations.observations->valuations.has_value(),
332 storm::exceptions::WrongFormatException, "Observation valuations mentioned in the index but no files given.");
333 auto const& ovIndex = umbModel.index.valuations->observations.value();
334 auto const& ovData = umbModel.valuations.observations.value();
335 STORM_LOG_ASSERT(ovIndex.numStrings.has_value() == ovData.stringMapping.has_value() && ovIndex.numStrings.has_value() == ovData.strings.has_value(),
336 "String mapping and strings must be given iff there are #strings mentioned in index.");
337 storm::storage::sparse::ValuationsStorage val(umbModel.index.transitionSystem.numObservations, ovIndex.classes, ovData.valuations.value(),
338 ovData.stringMapping.value_or(std::vector<uint64_t>()), ovData.strings.value_or(std::vector<char>()),
339 ovData.valuationToClass);
340 components.observationValuations.emplace(std::move(val));
341 } else {
342 STORM_LOG_WARN_COND(!options.buildStateValuations, "State valuations requested but the UMB model does not have any.");
343 }
344 } else if (modelType == Smg) {
345 if (umbModel.stateToPlayer.has_value()) {
346 auto const& stateToPlayer = umbModel.stateToPlayer.value();
347 components.statePlayerIndications.emplace(stateToPlayer.begin(), stateToPlayer.end());
348 } else {
349 // Default to all states belonging to player 0
350 components.statePlayerIndications.emplace(umbModel.index.transitionSystem.numStates, 0);
351 }
352 if (umbModel.index.transitionSystem.playerNames.has_value()) {
353 auto const& names = umbModel.index.transitionSystem.playerNames.value();
354 STORM_LOG_THROW(names.size() == umbModel.index.transitionSystem.numPlayers, storm::exceptions::WrongFormatException,
355 "Number of player names does not match number of players in the UMB model index.");
356 components.playerNameToIndexMap.emplace();
357 for (uint64_t i = 0; i < names.size(); ++i) {
358 components.playerNameToIndexMap->emplace(names[i], i);
359 }
360 }
361 } else {
362 STORM_LOG_THROW(modelType == Dtmc || modelType == Mdp, storm::exceptions::NotSupportedException,
363 "Unexpected model type for UMB import: " << modelType << ".");
364 }
365 return storm::utility::builder::buildModelFromComponents(deriveModelType(umbModel.index), std::move(components));
366}
367
368} // namespace detail
369
371 using enum storm::models::ModelType;
372
373 auto const& ts = index.transitionSystem;
374
375 STORM_LOG_THROW(ts.branchProbabilityType.has_value(), storm::exceptions::NotSupportedException, "Models without branch values are not supported.");
378 case Discrete:
379 switch (ts.numPlayers) {
380 case 0:
381 return Dtmc;
382 case 1:
383 return ts.numObservations == 0 ? Mdp : Pomdp;
384 default:
385 STORM_LOG_THROW(ts.numObservations == 0, storm::exceptions::NotSupportedException,
386 "Multiplayer partially observable models are not supported.");
387 return Smg;
388 }
389 case Stochastic:
390 STORM_LOG_THROW(ts.numPlayers == 0, storm::exceptions::NotSupportedException, "Stochastic time models with multiple players are not supported.");
391 return Ctmc;
392 case UrgentStochastic:
393 STORM_LOG_THROW(ts.numPlayers == 1, storm::exceptions::NotSupportedException,
394 "Urgent stochastic time models with multiple or no players are not supported.");
395 return MarkovAutomaton;
396 }
397 STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Unexpected transition system time type" << ts.time << ".");
398}
399
400template<typename ValueType>
401bool deriveValueType(storm::umb::ModelIndex const& index, ImportOptions const& options) {
402 STORM_LOG_THROW(index.transitionSystem.branchProbabilityType.has_value(), storm::exceptions::NotSupportedException,
403 "Models without branch values are not supported.");
404 bool const haveDouble = index.transitionSystem.branchProbabilityType->type == storm::umb::Type::Double;
405 bool const haveRational = index.transitionSystem.branchProbabilityType->type == storm::umb::Type::Rational;
406 bool const haveDoubleInterval = index.transitionSystem.branchProbabilityType->type == storm::umb::Type::DoubleInterval;
407 bool const haveRationalInterval = index.transitionSystem.branchProbabilityType->type == storm::umb::Type::RationalInterval;
408 bool const haveInterval = haveDoubleInterval || haveRationalInterval;
409 bool const useDefault = options.valueType == ImportOptions::ValueType::Default;
410 bool const useDouble = options.valueType == ImportOptions::ValueType::Double;
411 bool const useRational = options.valueType == ImportOptions::ValueType::Rational;
412
413 STORM_LOG_ASSERT(useDefault || useDouble || useRational, "Unexpected value type option: " << static_cast<int>(options.valueType) << ".");
414
415 if (!haveInterval) {
416 if constexpr (std::is_same_v<ValueType, double>) {
417 return useDouble || (useDefault && haveDouble);
418 } else if constexpr (std::is_same_v<ValueType, storm::RationalNumber>) {
419 return useRational || (useDefault && haveRational);
420 } else {
421 return false;
422 }
423 } else {
424 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
425 return useDouble || (useDefault && haveDoubleInterval);
426 } else if constexpr (std::is_same_v<ValueType, storm::RationalInterval>) {
427 return useRational || (useDefault && haveRationalInterval);
428 } else {
429 return false;
430 }
431 }
432}
433
434template<typename ValueType>
435std::shared_ptr<storm::models::sparse::Model<ValueType>> sparseModelFromUmb(storm::umb::UmbModel const& umbModel, ImportOptions const& options) {
436 return detail::constructSparseModel<ValueType>(umbModel, options);
437}
438
439std::shared_ptr<storm::models::ModelBase> sparseModelFromUmb(storm::umb::UmbModel const& umbModel, ImportOptions const& options) {
440 if (deriveValueType<double>(umbModel.index, options)) {
441 return detail::constructSparseModel<double>(umbModel, options);
442 } else if (deriveValueType<storm::RationalNumber>(umbModel.index, options)) {
444 } else if (deriveValueType<storm::Interval>(umbModel.index, options)) {
445 return detail::constructSparseModel<storm::Interval>(umbModel, options);
446 } else if (deriveValueType<storm::RationalInterval>(umbModel.index, options)) {
448 } else {
449 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException,
450 "Could not derive a supported value type for the UMB model with branch probabilities of type "
451 << umbModel.index.transitionSystem.branchProbabilityType->toString() << ".");
452 }
453}
454
455template std::shared_ptr<storm::models::sparse::Model<double>> sparseModelFromUmb<double>(storm::umb::UmbModel const& umbModel, ImportOptions const& options);
456template std::shared_ptr<storm::models::sparse::Model<storm::RationalNumber>> sparseModelFromUmb<storm::RationalNumber>(storm::umb::UmbModel const& umbModel,
457 ImportOptions const& options);
458template std::shared_ptr<storm::models::sparse::Model<storm::Interval>> sparseModelFromUmb<storm::Interval>(storm::umb::UmbModel const& umbModel,
459 ImportOptions const& options);
460template std::shared_ptr<storm::models::sparse::Model<storm::RationalInterval>> sparseModelFromUmb<storm::RationalInterval>(
461 storm::umb::UmbModel const& umbModel, ImportOptions const& options);
462
463} // namespace storm::umb
storm::models::sparse::Dtmc< double > Dtmc
storm::models::sparse::Mdp< double > Mdp
This class manages the labeling of the choice space with a number of (atomic) labels.
void addLabel(std::string const &label)
Adds a new label to the labelings.
bool containsLabel(std::string const &label) const
Checks whether a label is registered within this labeling.
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 resize(uint64_t newLength, bool init=false)
Resizes the bit vector to hold the given new number of bits.
A class that can be used to build a sparse matrix by adding value by value.
AccumulationMode
Specifies how values that are added for the same row and column are combined.
A class that holds a possibly non-square matrix in the compressed row storage format.
Stores valuations of variables for a set of entities (e.g.
Represents a model in the UMB format.
Definition UmbModel.h:21
TO1< bool > stateIsMarkovian
Definition UmbModel.h:29
void validateOrThrow() const
Validates the UmbModel.
Definition UmbModel.cpp:100
storm::OptionalRef< Annotation > rewards(bool createIfMissing=false)
Definition UmbModel.cpp:88
TO1< AnyValueType > branchToProbability
Definition UmbModel.h:35
std::optional< ActionLabels > choiceActions
Definition UmbModel.h:43
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
TO1< uint64_t > branchToTarget
Definition UmbModel.h:34
Valuations valuations
Definition UmbModel.h:77
std::optional< Observations > stateObservations
Definition UmbModel.h:51
storm::OptionalRef< Annotation > aps(bool createIfMissing=false)
Definition UmbModel.cpp:80
static auto applyDecodedVector(auto &&func, storm::umb::GenericVector const &input, storm::umb::SizedType const &sourceType)
returns func(<decoded_input>) where <decoded_input> is a range that (if necessary) decodes and conver...
static std::vector< ValueType > createDecodedVector(storm::umb::GenericVector const &input, storm::umb::SizedType const &sourceType)
#define STORM_LOG_WARN(message)
Definition logging.h:35
#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
std::shared_ptr< storm::models::sparse::Model< ValueType > > constructSparseModel(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
auto csrRange(auto &&csr, uint64_t i)
storm::models::sparse::StateLabeling constructStateLabeling(storm::umb::UmbModel const &umbModel)
auto constructRewardModels(storm::umb::UmbModel const &umbModel)
typename storm::storage::SparseMatrixBuilder< ValueType >::AccumulationMode AccumulationMode
storm::storage::SparseMatrix< ValueType > constructTransitionMatrix(storm::umb::UmbModel const &umbModel)
storm::storage::BitVector createBitVector(storm::umb::VectorType< bool > const &umbBitVector, uint64_t size)
storm::models::sparse::ChoiceLabeling constructChoiceLabeling(storm::umb::UmbModel const &umbModel)
storm::storage::SparseMatrix< ValueType > createBranchMatrix(storm::umb::UmbModel const &umbModel, std::ranges::input_range auto &&branchValues, AccumulationMode< ValueType > accumulationMode)
Creates a matrix with one row per choice and one column per state, where the entry at (choice,...
Import and export of umb files.
std::optional< VectorType< T > > OptionalVectorType
Definition FileTypes.h:22
template std::shared_ptr< storm::models::sparse::Model< storm::RationalNumber > > sparseModelFromUmb< storm::RationalNumber >(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
bool isNumericType(Type const type)
Definition Type.cpp:38
template std::shared_ptr< storm::models::sparse::Model< storm::Interval > > sparseModelFromUmb< storm::Interval >(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
std::conditional_t< std::is_same_v< T, bool >, storm::storage::BitVector, std::vector< T > > VectorType
Definition FileTypes.h:19
bool deriveValueType(storm::umb::ModelIndex const &index, ImportOptions const &options)
Returns true iff the given umb model with the given options should have ValueType as its ValueType.
bool isBooleanType(Type const type)
Definition Type.cpp:8
std::shared_ptr< storm::models::sparse::Model< ValueType > > sparseModelFromUmb(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
Constructs a sparse model from the given UMB model.
template std::shared_ptr< storm::models::sparse::Model< storm::RationalInterval > > sparseModelFromUmb< storm::RationalInterval >(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
auto stringVectorView(SEQ< char >::value_type const &strings, CSR::value_type const &stringMapping)
template std::shared_ptr< storm::models::sparse::Model< double > > sparseModelFromUmb< double >(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
@ RationalInterval
Definition Type.h:11
storm::models::ModelType deriveModelType(storm::umb::ModelIndex const &index)
Derives the model type from the given UMB model index.
std::shared_ptr< storm::models::sparse::Model< ValueType, RewardModelType > > buildModelFromComponents(storm::models::ModelType modelType, storm::storage::sparse::ModelComponents< ValueType, RewardModelType > &&components)
Definition builder.cpp:20
bool isOne(ValueType const &a)
Definition constants.cpp:39
ValueType abs(ValueType const &number)
ValueType zero()
Definition constants.cpp:26
ValueType one()
Definition constants.cpp:21
carl::Interval< double > Interval
Interval type.
constexpr bool IsIntervalType
Helper to check if a type is an interval.
typename detail::IntervalMetaProgrammingHelper< ValueType >::BaseType IntervalBaseType
Helper to access the type in which interval boundaries are stored.
static const bool IsExact
boost::optional< storm::storage::BitVector > markovianStates
boost::optional< std::vector< storm::storage::PlayerIndex > > statePlayerIndications
std::optional< storm::storage::sparse::Valuations > observationValuations
std::optional< storm::models::sparse::ChoiceLabeling > choiceLabeling
boost::optional< std::map< std::string, storm::storage::PlayerIndex > > playerNameToIndexMap
std::optional< storm::storage::sparse::Valuations > stateValuations
std::optional< std::vector< uint32_t > > observabilityClasses
boost::optional< std::vector< ValueType > > exitRates
bool buildChoiceLabeling
Controls building of choice labelings.
bool buildObservationValuations
Controls building of observation valuations.
bool buildStateValuations
Controls building of state valuations.
std::optional< SizedType > exitRateType
Definition ModelIndex.h:58
std::optional< SizedType > branchProbabilityType
Definition ModelIndex.h:58
std::optional< storm::SerializedEnum< ObservationsApplyToDeclaration > > observationsApplyTo
Definition ModelIndex.h:56
std::optional< std::vector< std::string > > playerNames
Definition ModelIndex.h:60
std::optional< SizedType > observationProbabilityType
Definition ModelIndex.h:58
storm::OptionalRef< AnnotationMap > rewards(bool createIfMissing=false)
struct storm::umb::ModelIndex::TransitionSystem transitionSystem
std::optional< Valuations > valuations
Definition ModelIndex.h:116
storm::OptionalRef< AnnotationMap > aps(bool createIfMissing=false)
std::optional< Values > observations
Definition UmbModel.h:55
std::optional< Values > states
Definition UmbModel.h:55