Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
UmbModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <iosfwd>
5#include <map>
6#include <memory>
7#include <string>
8
14
15namespace storm::umb {
21class UmbModel {
22 public:
23 // index
25 // states
31 // choices
33 // branches
36 // actions
37 struct ActionLabels {
41 auto static constexpr FileNames = {"values.bin", "string-mapping.bin", "strings.bin"};
42 };
43 std::optional<ActionLabels> choiceActions, branchActions;
44 // observations
45 struct Observations {
49 auto static constexpr FileNames = {"values.bin", "distribution-mapping.bin", "probabilities.bin"};
50 };
51 std::optional<Observations> stateObservations, branchObservations;
52 // annotations
53 template<typename Values>
55 std::optional<Values> states, choices, branches, observations, players;
56 auto static constexpr FileNames = {"states/", "choices/", "branches/", "observations/", "players/"};
57 };
64 auto static constexpr FileNames = {"values.bin", "string-mapping.bin", "strings.bin", "distribution-mapping.bin", "probabilities.bin"};
65 };
66 using Annotation = std::map<std::string, AppliesToEntity<AnnotationValues>>;
67 std::map<std::string, Annotation> annotations;
68 // valuations
69 struct Valuation {
74 auto static constexpr FileNames = {"valuation-to-class.bin", "valuations.bin", "string-mapping.bin", "strings.bin"};
75 };
78
79 // Collects non-standard files (for custom extensions)
80 // Note: As this field matches any file path, we need to make sure that it is the last field so that our importer tries the other fields first.
81 std::map<std::filesystem::path, std::vector<char>> nonStandardFiles;
82
83 auto static constexpr FileNames = {"index.json",
84 "state-to-choices.bin",
85 "state-to-player.bin",
86 "state-is-initial.bin",
87 "state-is-markovian.bin",
88 "state-to-exit-rate.bin",
89 "choice-to-branches.bin",
90 "branch-to-target.bin",
91 "branch-to-probability.bin",
92 "actions/choices/",
93 "actions/branches/",
94 "observations/states/",
95 "observations/branches/",
96 "annotations/",
97 "valuations/",
98 ""};
99
103 std::string getShortModelInformation() const;
104
108 std::string getModelInformation() const;
109
113 storm::OptionalRef<Annotation> annotation(std::string const& annotationType, bool createIfMissing = false);
114 storm::OptionalRef<Annotation const> annotation(std::string const& annotationType) const;
115 storm::OptionalRef<Annotation> aps(bool createIfMissing = false);
117 storm::OptionalRef<Annotation> rewards(bool createIfMissing = false);
119
124 bool validate(std::ostream& errors) const;
125
129 void validateOrThrow() const;
130
134 void encodeRationals();
135
139 void decodeRationals();
140};
141
142} // namespace storm::umb
Helper class that optionally holds a reference to an object of type T.
Definition OptionalRef.h:48
Represents a model in the UMB format.
Definition UmbModel.h:21
storm::OptionalRef< Annotation > annotation(std::string const &annotationType, bool createIfMissing=false)
Gets the annotation data with the given annotation type.
Definition UmbModel.cpp:61
std::map< std::filesystem::path, std::vector< char > > nonStandardFiles
Definition UmbModel.h:81
TO1< bool > stateIsMarkovian
Definition UmbModel.h:29
std::map< std::string, Annotation > annotations
Definition UmbModel.h:67
storm::OptionalRef< Annotation const > rewards() const
Definition UmbModel.cpp:92
storm::OptionalRef< Annotation const > aps() const
Definition UmbModel.cpp:84
std::string getShortModelInformation() const
Retrieves a short string that can be used to refer to the model in user output.
Definition UmbModel.cpp:11
void validateOrThrow() const
Validates the UmbModel.
Definition UmbModel.cpp:100
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< AnyValueType > branchToProbability
Definition UmbModel.h:35
std::string getModelInformation() const
Retrieves a string that describes the model in more detail.
Definition UmbModel.cpp:24
std::optional< ActionLabels > choiceActions
Definition UmbModel.h:43
TO1< bool > stateIsInitial
Definition UmbModel.h:28
AppliesToEntity< Valuation > Valuations
Definition UmbModel.h:76
void decodeRationals()
Decodes all rational values stored in the model from their UMB bit representation.
Definition UmbModel.cpp:181
TO1< AnyValueType > stateToExitRate
Definition UmbModel.h:30
static auto constexpr FileNames
Definition UmbModel.h:83
std::map< std::string, AppliesToEntity< AnnotationValues > > Annotation
Definition UmbModel.h:66
ModelIndex index
Definition UmbModel.h:24
TO1< uint32_t > stateToPlayer
Definition UmbModel.h:27
void encodeRationals()
Encodes all rational values stored in the model into their UMB bit representation.
Definition UmbModel.cpp:104
TO1< uint64_t > branchToTarget
Definition UmbModel.h:34
Valuations valuations
Definition UmbModel.h:77
std::optional< Observations > branchObservations
Definition UmbModel.h:51
std::optional< Observations > stateObservations
Definition UmbModel.h:51
std::optional< ActionLabels > branchActions
Definition UmbModel.h:43
std::conditional_t< std::is_same_v< T, AnyValueType >, GenericVector, OptionalVectorType< T > > TO1
Definition FileTypes.h:26
OptionalVectorType< uint64_t > CSR
Definition FileTypes.h:31
TO1< T > SEQ
Definition FileTypes.h:29
static auto constexpr FileNames
Definition UmbModel.h:41
TO1< AnyValueType > probabilities
Definition UmbModel.h:63
static auto constexpr FileNames
Definition UmbModel.h:64
TO1< AnyValueType > probabilities
Definition UmbModel.h:48
static auto constexpr FileNames
Definition UmbModel.h:49
static auto constexpr FileNames
Definition UmbModel.h:74
TO1< uint32_t > valuationToClass
Definition UmbModel.h:70