20 "Variable " << var.
getName() <<
" and expression " << expr <<
" must have the same type.");
22 "Variable " << var.
getName() <<
" and expression " << expr <<
" must have the same manager.");
24 "Variable " << var.
getName() <<
" and old state valuations must have the same manager.");
26 "Unsupported variable type " << var.
getType() <<
" for variable " << var.
getName() <<
".");
27 variables.push_back(var);
28 expressions.push_back(expr);
32 STORM_LOG_THROW(oldValuations.getStorage().numClasses() == 1, storm::exceptions::NotSupportedException,
33 "Valuation transformation is only supported for valuations with a single class.");
37 descriptionBuilder.
addVariables(oldValuations.getStorage().getClassDescription());
39 for (
auto const& v : variables) {
40 if (v.hasBooleanType()) {
42 }
else if (v.hasIntegerType()) {
43 descriptionBuilder.
addIntegerVariable(v, std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max());
44 }
else if (v.hasRationalType()) {
48 "Variable " << v.getName() <<
" has unsupported type " << v.getType() <<
".");
53 result.
resize(oldValuations.getNumberOfEntities());
56 for (uint64_t entity = 0; entity < oldValuations.getNumberOfEntities(); ++entity) {
59 oldValuations.getStorage().readCallback(entity, [&result](
auto const e,
auto const& var,
auto const& value) { result.
writeValue(e, var, value); });
63 oldValuations.setValuesInEvaluator(entity, evaluator);
65 for (uint64_t
i = 0;
i < variables.size(); ++
i) {
66 auto const& var = variables[
i];
67 auto const& expr = expressions[
i];
68 if (var.hasBooleanType()) {
69 result.
writeValue(entity, var, evaluator.asBool(expr));
70 }
else if (var.hasIntegerType()) {
71 result.
writeValue(entity, var, evaluator.asInt(expr));
72 }
else if (var.hasRationalType()) {
73 result.
writeValue(entity, var, evaluator.asRational(expr));
76 "Variable " << var.getName() <<
" has unsupported type " << var.getType() <<
".");
Type const & getType() const
Retrieves the type of the expression.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
bool hasBooleanType() const
Checks whether the variable is of boolean type.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this variable.
Type const & getType() const
Retrieves the type of the variable.
bool hasIntegerType() const
Checks whether the variable is of integral type.
bool hasRationalType() const
Checks whether the variable is of rational type.
std::string const & getName() const
Retrieves the name of the variable.
Helper to incrementally build a ValuationClassDescription, i.e.
ValuationClassDescription buildClassDescription()
Creates the finalized state valuations object.
void addBooleanVariable(storm::expressions::Variable const &variable, bool optional=false)
Adds a new boolean variable to the builder.
void addRationalVariable(storm::expressions::Variable const &variable, uint64_t bitSize, bool optional=false)
Adds a new rational 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.
Provides access to valuations of variables for a set of entities (e.g.
Stores valuations of variables for a set of entities (e.g.
void resize(uint64_t newEntityCount, uint64_t classIndex=0)
Resizes the entity count to newEntityCount.
void writeValue(uint64_t entity, storm::expressions::Variable const &variable, ValueType const &value)
Directly writes value to the given variable of entity.
#define STORM_LOG_THROW(cond, exception, message)