15 : manager(expressionManager) {
16 STORM_LOG_ASSERT(this->manager !=
nullptr,
"Initilization with empty expression manager is not allowed.");
25 "Variable " << variable.
getName() <<
" has a different manager than previously specified for this valuation description.");
26 bool const inserted = addedVariables.insert(variable).second;
28 "Duplicate variable with name '" << variable.
getName() <<
"' has already been added to this valuation description.");
32 assertAndCollectVariable(variable);
34 .isOptional{optional ? std::optional<bool>(
true) : std::nullopt},
43 assertAndCollectVariable(variable);
44 STORM_LOG_ASSERT(lowerBound <= upperBound,
"Lower bound " << lowerBound <<
" must not be above upper bound" << upperBound <<
".");
46 uint64_t
const bitSize =
storm::utility::bitsize(
static_cast<uint64_t
>(upperBound) -
static_cast<uint64_t
>(lowerBound));
49 .isOptional{optional ? std::optional<bool>(
true) : std::nullopt},
53 .offset{lowerBound}});
58 assertAndCollectVariable(variable);
59 STORM_LOG_ASSERT(lowerBound <= upperBound,
"Lower bound " << lowerBound <<
" must not be above upper bound" << upperBound <<
".");
68 .name{variable.
getName()}, .isOptional{optional ? std::optional<bool>(
true) : std::nullopt}, .type{t}, .lower{}, .upper{}, .offset{}});
73 assertAndCollectVariable(variable);
75 .isOptional{optional ? std::optional<bool>(
true) : std::nullopt},
83 assertAndCollectVariable(variable);
84 STORM_LOG_ASSERT(bitSize % 2 == 0,
"Bit size for rational variables must be a multiple of 2.");
87 .name{variable.
getName()}, .isOptional{optional ? std::optional<bool>(
true) : std::nullopt}, .type{t}, .lower{}, .upper{}, .offset{}});
91 assertAndCollectVariable(variable);
93 .isOptional{optional ? std::optional<bool>(
true) : std::nullopt},
101 STORM_LOG_ASSERT(manager->hasVariable(variable.
name),
"Variable " << variable.
name <<
" is not declared in the expression manager.");
102 assertAndCollectVariable(manager->getVariable(variable.
name));
103 std::ostringstream errors;
105 "Invalid type declaration for variable " << variable.
name <<
": " << errors.str() <<
".");
106 descr.variables.push_back(variable);
110 for (
auto const& varVariant : description.
variables) {
111 if (std::holds_alternative<ValuationClassDescription::Variable>(varVariant)) {
112 addVariable(std::get<ValuationClassDescription::Variable>(varVariant));
113 }
else if (addPadding && std::holds_alternative<ValuationClassDescription::Padding>(varVariant)) {
114 descr.variables.push_back(varVariant);
119void ValuationDescriptionBuilder::finalize() {
120 if (uint64_t
const padding = descr.
sizeInBits() % 8; padding > 0) {
This class is responsible for managing a set of typed variables and all expressions using these varia...
ExpressionManager const & getManager() const
Retrieves the manager responsible for this variable.
std::string const & getName() const
Retrieves the name of the variable.
ValuationClassDescription buildClassDescription()
Creates the finalized state valuations object.
storm::expressions::ExpressionManager const & getManager() const
void addBooleanVariable(storm::expressions::Variable const &variable, bool optional=false)
Adds a new boolean variable to the builder.
storm::NumberTraits< storm::RationalNumber >::IntegerType Integer
ValuationDescriptionBuilder(std::shared_ptr< storm::expressions::ExpressionManager const > const &expressionManager)
void addRationalVariable(storm::expressions::Variable const &variable, uint64_t bitSize, bool optional=false)
Adds a new rational variable to the builder.
void addStringVariable(storm::expressions::Variable const &variable, bool optional=false)
Adds a new string variable to the builder.
void addIntegerVariable(storm::expressions::Variable const &variable, int64_t const lowerBound, int64_t const upperBound, bool optional=false)
Adds a new integer variable to the builder.
void addVariables(ValuationClassDescription const &description, bool addPadding=false)
Adds all variables from the given description.
void addVariable(ValuationClassDescription::Variable const &variable)
Adds the given variable.
void addDoubleVariable(storm::expressions::Variable const &variable, bool optional=false)
Adds a new double variable to the builder.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
bool validateTypeDeclaration(storm::umb::SizedType const &type, bool requireStandardSize, std::ostream &err)
Validates a single type declaration against the UMB specification, writing potential errors to the gi...
uint64_t bitsize(ValueType const &number)
Returns the minimum number of bits to represent the given number.
TargetType convertNumber(SourceType const &number)
storm::umb::SizedType type
Describes the layout of a class of valuations (e.g.
uint64_t sizeInBits() const
Computes the size in bits of a valuation.
std::vector< std::variant< Padding, Variable > > variables