9#include <boost/functional/hash.hpp>
34 if (varDesc.
offset.value_or(0) == 0) {
37 }
else if (varDesc.
upper.has_value()) {
46 return varDesc.
offset.value() == std::numeric_limits<int64_t>::min();
55 if (varDesc.
offset.value_or(0) == 0) {
57 }
else if (varDesc.
offset.value() < 0) {
59 int64_t
const minValueStored =
60 varDesc.
type.
bitSize() == 64 ? std::numeric_limits<int64_t>::min() : -(
static_cast<int64_t
>(1) << (varDesc.
type.
bitSize() - 1));
61 return varDesc.
lower.has_value() || minValueStored >= std::numeric_limits<int64_t>::min() - varDesc.
offset.value();
64 int64_t
const maxValueStored =
65 varDesc.
type.
bitSize() == 64 ? std::numeric_limits<int64_t>::max() : (
static_cast<int64_t
>(1) << (varDesc.
type.
bitSize() - 1)) - 1;
66 return varDesc.
upper.has_value() || maxValueStored <= std::numeric_limits<int64_t>::max() - varDesc.
offset.value();
77 "ValuationsStorage for variable type '" << varDesc.
type.
toString() <<
"' are not supported.");
81template<
typename ManagerType>
83 std::vector<typename ValuationsStorage::VariableInformation> variables;
84 uint64_t currentOffset = 0;
85 for (
auto const& varVariant : description.
variables) {
86 if (std::holds_alternative<ValuationClassDescription::Variable>(varVariant)) {
87 auto const& varDesc = std::get<ValuationClassDescription::Variable>(varVariant);
89 if constexpr (std::is_const_v<ManagerType>) {
90 exprVar = expressionManager.getVariable(varDesc.name);
94 switch (varDesc.type.type) {
96 variableType = expressionManager.getBooleanType();
100 variableType = expressionManager.getIntegerType();
104 variableType = expressionManager.getRationalType();
107 variableType = expressionManager.getStringType();
111 "ValuationsStorage for variable type '" << varDesc.type.toString() <<
"' are not supported.");
113 exprVar = expressionManager.declareOrGetVariable(varDesc.name, variableType);
115 if (varDesc.isOptional.value_or(
false)) {
119 .expressionVariable = exprVar, .description = varDesc, .bitOffset = currentOffset, .fits64Bit =
fits64Bit(varDesc)});
120 currentOffset += variables.back().description.type.bitSize();
122 auto const& padding = std::get<ValuationClassDescription::Padding>(varVariant);
123 currentOffset += padding.padding;
127 STORM_LOG_ASSERT(currentOffset % 8 == 0,
"Invalid valuation description detected: size in bits must be a multiple of 8.");
129 .variables = std::move(variables), .expressionManager = expressionManager.shared_from_this(), .sizeInBytes = currentOffset / 8};
135 std::vector<uint64_t> stringMapping, std::vector<char> strings, std::optional<std::vector<uint32_t>> classes,
136 std::vector<std::shared_ptr<storm::expressions::ExpressionManager const>> expressionManagers)
137 : numEntities(numEntities), valuations(
std::move(valuations)), stringMapping(
std::move(stringMapping)), strings(
std::move(strings)) {
138 STORM_LOG_ASSERT(descriptions.size() == expressionManagers.size() || expressionManagers.size() <= 1,
139 "Mismatch between number of descriptions and expression managers.");
143 auto sharedManager = std::make_shared<storm::expressions::ExpressionManager>();
144 for (uint64_t
i = 0;
i < descriptions.size(); ++
i) {
145 if (expressionManagers.empty() || (expressionManagers.size() == 1 && expressionManagers.front() ==
nullptr)) {
148 }
else if (expressionManagers.size() == 1) {
151 }
else if (expressionManagers[
i] ==
nullptr) {
153 auto manager = std::make_shared<storm::expressions::ExpressionManager>();
161 bool const hasStringVariable = std::any_of(descriptions.begin(), descriptions.end(), [](
auto const& classDescr) { return classDescr.hasStringVariable(); });
162 if (hasStringVariable && this->stringMapping.empty()) {
163 this->stringMapping.push_back(0);
165 STORM_LOG_ASSERT(hasStringVariable || this->stringMapping.empty(),
"Non-empty string mapping given but there is no string variable.");
166 STORM_LOG_ASSERT(this->stringMapping.empty() || this->stringMapping.back() == this->strings.size(),
167 "String mapping should end with the total size of the string data.");
170 if (classes.has_value() && this->variableClasses.size() > 1) {
171 STORM_LOG_ASSERT(numEntities == classes->size(),
"Number of entities does not match class mapping size.");
172 this->entityClassMappings = {std::move(*classes), std::vector<uint64_t>({0ull})};
174 this->entityClassMappings->toValuationsMapping.reserve(this->entityClassMappings->toClassMapping.size() + 1);
175 for (uint64_t entity = 0; entity < this->entityClassMappings->toClassMapping.size(); ++entity) {
177 this->entityClassMappings->toClassMapping[entity] < this->variableClasses.size(),
178 "Class index " << this->entityClassMappings->toClassMapping[entity] <<
" out of bounds. Only " << descriptions.size() <<
"classes known.");
179 pos += this->variableClasses[this->entityClassMappings->toClassMapping[entity]].sizeInBytes;
180 this->entityClassMappings->toValuationsMapping.push_back(pos);
182 STORM_LOG_ASSERT(this->valuations.size() == pos,
"Valuation data size does not match class mapping.");
184 STORM_LOG_ASSERT(this->variableClasses.size() == 1,
"Valuation descriptions must be unique if no class mapping is given.");
185 STORM_LOG_ASSERT(!classes.has_value() || std::all_of(classes->begin(), classes->end(), [&](
auto classIndex) { return classIndex == 0; }),
186 "A single description is given but the class mapping is not unique.");
187 STORM_LOG_ASSERT(this->variableClasses.front().sizeInBytes == 0 || this->valuations.size() % this->variableClasses.front().sizeInBytes == 0,
188 "Valuation data size is not a multiple of the unique valuation size.");
189 STORM_LOG_ASSERT(numEntities * this->variableClasses.front().sizeInBytes == this->valuations.size(),
190 "Valuation data size (" << this->valuations.size() <<
") does not match number of entities (" << this->numEntities
191 <<
") times valuation size (" << this->variableClasses.front().sizeInBytes <<
").");
196 std::shared_ptr<storm::expressions::ExpressionManager const> expressionManager)
197 :
ValuationsStorage(numEntities, {description}, std::move(valuations), {}, {}, std::nullopt, {expressionManager}) {
198 STORM_LOG_ASSERT(!description.hasStringVariable(),
"String mapping must be given for descriptions with string variables.");
202 std::vector<std::shared_ptr<storm::expressions::ExpressionManager const>> expressionManagers)
203 :
ValuationsStorage(0, descriptions, {}, {}, {}, std::vector<uint32_t>{}, std::move(expressionManagers)) {}
206 std::shared_ptr<storm::expressions::ExpressionManager const> expressionManager)
207 :
ValuationsStorage(0, {description}, {}, {}, {}, std::nullopt, {expressionManager}) {}
216 return variableClasses.size();
220 return stringMapping.size() > 0 ? stringMapping.size() - 1 : 0;
224 return !stringMapping.empty();
229 if (entityClassMappings) {
230 return entityClassMappings->toClassMapping[entity];
232 STORM_LOG_ASSERT(variableClasses.size() == 1,
"No class mapping given but multiple classes exist.");
238 STORM_LOG_ASSERT(classIndex <
numClasses(),
"Class index " << classIndex <<
" out of bounds. Only " << variableClasses.size() <<
"classes known.");
240 uint64_t currBit = 0;
241 for (
auto const& varInfo : variableClasses[classIndex].variables) {
242 uint64_t padding = varInfo.bitOffset - currBit;
243 if (varInfo.description.isOptional.value_or(
false)) {
244 STORM_LOG_ASSERT(padding >= 1,
"Optional variables must have at least 1 bit preceding its offset.");
250 res.
variables.push_back(varInfo.description);
251 currBit = varInfo.bitOffset + varInfo.description.type.bitSize();
252 STORM_LOG_ASSERT(currBit == res.
sizeInBits(),
"Unexpected bit offset for variable " << varInfo.description.name <<
" in class " << classIndex
253 <<
". Expected " << res.
sizeInBits() <<
", got "
254 << varInfo.bitOffset <<
".");
256 if (uint64_t padding = currBit % 8; padding > 0) {
263 STORM_LOG_ASSERT(!variableClasses.empty(),
"No variable classes given, cannot determine expression manager.");
264 auto const& manager = variableClasses.front().expressionManager;
266 std::all_of(variableClasses.begin() + 1, variableClasses.end(), [&manager](
auto const& varClass) { return varClass.expressionManager == manager; }),
267 storm::exceptions::IllegalFunctionCallException,
"Expression manager is not unique.");
273 "Class index " << classIndex <<
" out of bounds. Only " << variableClasses.size() <<
"classes known.");
274 return *variableClasses[classIndex].expressionManager;
278 auto const& vars = info(entity).variables;
279 auto varInfoIt = std::find_if(vars.begin(), vars.end(), [&variable](
auto const& varInfo) { return varInfo.expressionVariable == variable; });
290 [[maybe_unused]]
auto const& manager =
getManager();
291 std::set<storm::expressions::Variable> result;
292 for (
auto const& varClass : variableClasses) {
293 for (
auto const& varInfo : varClass.variables) {
295 "Expression manager of variable " << varInfo.expressionVariable.getName() <<
" does not match the one of the valuation.");
296 result.insert(varInfo.expressionVariable);
303 auto const& vars = info(entity).variables;
304 return std::any_of(vars.begin(), vars.end(), [&variable](
auto const& varInfo) { return varInfo.expressionVariable == variable; });
309 if (entityClassMappings.has_value()) {
321 if (newEntityCount >
size()) {
323 uint64_t
const initializedEntity =
size();
326 if (newEntityCount >
size()) {
327 uint64_t
const classSize = variableClasses[classIndex].sizeInBytes;
328 valuations.resize(valuations.size() + (newEntityCount -
size()) * classSize);
329 if (entityClassMappings) {
330 entityClassMappings->toClassMapping.resize(newEntityCount, classIndex);
332 auto& toValuationsMapping = entityClassMappings->toValuationsMapping;
333 for (uint64_t valEnd = toValuationsMapping.back() + classSize; toValuationsMapping.size() < newEntityCount + 1; valEnd += classSize) {
334 toValuationsMapping.push_back(valEnd);
337 uint64_t
const firstCopiedEntity =
size();
338 numEntities = newEntityCount;
339 auto const srcBytes = getRawBytes(initializedEntity);
340 for (uint64_t newEntityIndex = firstCopiedEntity; newEntityIndex < newEntityCount; ++newEntityIndex) {
341 auto destBytes = getRawBytes(newEntityIndex);
342 std::copy(srcBytes.begin(), srcBytes.end(), destBytes.begin());
345 }
else if (newEntityCount <
size()) {
346 uint64_t
const newValuationsSize =
347 entityClassMappings.has_value() ? entityClassMappings->toValuationsMapping[newEntityCount] : newEntityCount * variableClasses.front().sizeInBytes;
348 valuations.resize(newValuationsSize);
349 if (entityClassMappings) {
350 entityClassMappings->toClassMapping.resize(newEntityCount);
351 entityClassMappings->toValuationsMapping.resize(newEntityCount + 1);
353 numEntities = newEntityCount;
357template<
typename RationalValueType>
359 readCallback(entity, [&evaluator](
auto,
auto const& var,
auto const& value) {
360 using ValueType = std::remove_cvref_t<
decltype(value)>;
361 if constexpr (std::is_same_v<ValueType, bool>) {
362 evaluator.setBooleanValue(var, value);
363 }
else if constexpr (std::is_same_v<ValueType, int64_t> || std::is_same_v<ValueType, uint64_t>) {
364 evaluator.setIntegerValue(var, value);
366 }
else if constexpr (std::is_same_v<ValueType, double> || std::is_same_v<ValueType, storm::RationalNumber>) {
370 (std::is_same_v<ValueType, std::string_view> || std::is_same_v<ValueType, std::string> || std::is_same_v<ValueType, std::nullopt_t>),
371 storm::exceptions::NotSupportedException,
"Unsupported variable value type when reading state values: " <<
typeid(ValueType).name() <<
".");
384template<
typename ValueType>
385 requires(std::is_same_v<ValueType, int64_t> || std::is_same_v<ValueType, uint64_t> || std::is_same_v<ValueType, ValuationsStorage::Integer>)
386bool ValuationsStorage::fitsIntoStoredType(ValueType
const& value, VariableInformation
const& varInfo)
const {
387 auto const bitSize = varInfo.description.type.bitSize();
388 STORM_LOG_ASSERT(bitSize > 0,
"Expected a positive bit size for variable " << varInfo.description.name <<
".");
391 if constexpr (std::is_same_v<ValueType, Integer>) {
394 return isSigned ? (value >= -limit && value < limit) : (value >= 0 && value < limit);
395 }
else if (isSigned) {
397 return std::cmp_less_equal(value, std::numeric_limits<int64_t>::max());
399 int64_t
const limit = int64_t(1) << (bitSize - 1);
400 return std::cmp_greater_equal(value, -limit) && std::cmp_less(value, limit);
405 return std::cmp_greater_equal(value, 0) && std::cmp_less(value, uint64_t(1) << bitSize);
409template bool ValuationsStorage::fitsIntoStoredType<int64_t>(int64_t
const&, VariableInformation
const&)
const;
410template bool ValuationsStorage::fitsIntoStoredType<uint64_t>(uint64_t
const&, VariableInformation
const&)
const;
411template bool ValuationsStorage::fitsIntoStoredType<ValuationsStorage::Integer>(Integer
const&, VariableInformation
const&)
const;
413std::span<char const> ValuationsStorage::getRawBytes(uint64_t entity)
const {
415 if (entityClassMappings) {
416 auto const start = entityClassMappings->toValuationsMapping[entity];
417 auto const end = entityClassMappings->toValuationsMapping[entity + 1];
418 return std::span<char const>(&valuations[start], end - start);
420 auto const start = entity * variableClasses.front().sizeInBytes;
421 return std::span<char const>(&valuations[start], variableClasses.front().sizeInBytes);
425std::span<char> ValuationsStorage::getRawBytes(uint64_t entity) {
426 if (entityClassMappings) {
427 auto const start = entityClassMappings->toValuationsMapping[entity];
428 auto const end = entityClassMappings->toValuationsMapping[entity + 1];
429 return std::span<char>(&valuations[start], end - start);
431 auto const start = entity * variableClasses.front().sizeInBytes;
432 return std::span<char>(&valuations[start], variableClasses.front().sizeInBytes);
436bool ValuationsStorage::readBit(std::span<char const> bytes, uint64_t
const position)
const {
437 STORM_LOG_ASSERT(position < bytes.size() * 8,
"Bit position exceeds valuation size.");
438 return bytes[position / 8] & (1 << (position % 8));
441void ValuationsStorage::writeBit(std::span<char> bytes, uint64_t
const position,
bool value)
const {
442 STORM_LOG_ASSERT(position < bytes.size() * 8,
"Bit position exceeds valuation size.");
443 char&
byte = bytes[position / 8];
444 char const pos = (1 << (position % 8));
452uint64_t ValuationsStorage::readUint64(std::span<char const> bytes, uint64_t
const bitOffset, uint64_t
const bitSize)
const {
453 STORM_LOG_ASSERT(bitOffset < bytes.size() * 8,
"Variable offset exceeds valuation size.");
455 auto const firstByte = bitOffset / 8;
456 auto const bitOffsetWithinByte = bitOffset % 8;
457 auto const numBytes = (bitOffsetWithinByte + bitSize + 7) / 8;
458 STORM_LOG_ASSERT(numBytes <= 9,
"Invalid number of bytes computed: " << numBytes);
461 std::memcpy(&result, &bytes[firstByte], std::min<uint64_t>(numBytes, 8ull));
462 result >>= bitOffsetWithinByte;
464 if (numBytes == 9ull) {
465 uint64_t upperBits = std::bit_cast<uint8_t>(bytes[firstByte + 8]);
466 upperBits <<= (64 - bitOffsetWithinByte);
471 uint64_t
const relevantBitMask = (1ull << bitSize) - 1;
472 result &= relevantBitMask;
477void ValuationsStorage::writeUint64(std::span<char> bytes, uint64_t
const bitOffset, uint64_t
const bitSize, uint64_t
const value)
const {
478 STORM_LOG_ASSERT(bitOffset < bytes.size() * 8,
"Variable offset exceeds valuation size.");
480 STORM_LOG_THROW(bitSize == 64 || value < (1ull << bitSize), storm::exceptions::OutOfRangeException,
481 "Invalid value " << value <<
" for bit size " << bitSize <<
".");
482 uint64_t
const firstByte = bitOffset / 8;
483 uint8_t
const bitOffsetWithinByte = bitOffset % 8;
484 uint8_t
const numBytes = (bitOffsetWithinByte + bitSize + 7) / 8;
485 uint8_t
const numFullBytes = (bitOffsetWithinByte + bitSize) / 8;
486 STORM_LOG_ASSERT(numBytes <= 9,
"Invalid number of bytes computed: " << numBytes);
487 if (numFullBytes == 0) {
489 char&
byte = bytes[firstByte];
490 uint8_t
const relevantBitsMask = ((1 << bitSize) - 1) << bitOffsetWithinByte;
491 byte &=
static_cast<char>(~relevantBitsMask);
492 byte |=
static_cast<char>((value << bitOffsetWithinByte) & relevantBitsMask);
495 if (bitOffsetWithinByte == 0) {
497 std::memcpy(&bytes[firstByte], &value, numFullBytes);
499 uint64_t
const shiftedValue = (
static_cast<uint64_t
>(bytes[firstByte]) & ((1ull << bitOffsetWithinByte) - 1)) | (value << bitOffsetWithinByte);
500 std::memcpy(&bytes[firstByte], &shiftedValue, numFullBytes);
503 if (numFullBytes != numBytes) {
505 char& lastByte = bytes[firstByte + numFullBytes];
506 uint8_t
const numBitsUsedInLastByte = (bitOffsetWithinByte + bitSize) % 8;
507 uint8_t
const relevantBitsMask =
static_cast<uint8_t
>((uint8_t(1) << numBitsUsedInLastByte) - 1);
508 uint8_t newLastByte = std::bit_cast<uint8_t>(lastByte);
509 newLastByte &=
static_cast<uint8_t
>(~relevantBitsMask);
510 newLastByte |=
static_cast<uint8_t
>(value >> (numFullBytes * 8 - bitOffsetWithinByte));
511 lastByte = std::bit_cast<char>(newLastByte);
517ValuationsStorage::Integer ValuationsStorage::readInteger(std::span<char const> bytes, uint64_t
const bitOffset, uint64_t
const bitSize)
const {
518 auto const num64BitChunks = (bitSize + 63) / 64;
519 auto chunksView = std::ranges::iota_view(0ull, num64BitChunks) | std::ranges::views::transform([
this, &bytes, &bitOffset, &bitSize](
auto i) -> uint64_t {
520 return readUint64(bytes, bitOffset +
i * 64, std::min<uint64_t>(64, bitSize -
i * 64));
523 if constexpr (Signed) {
536void ValuationsStorage::writeInteger(std::span<char> bytes, uint64_t bitOffset, uint64_t bitSize, Integer
const& value)
const {
538 "Value " << value <<
" cannot be encoded in " << bitSize <<
" bits.");
539 auto const num64BitChunks = (bitSize + 63) / 64;
540 std::vector<uint64_t> uint64Encoding;
542 STORM_LOG_ASSERT(uint64Encoding.size() == num64BitChunks,
"Encoding does not fit into the specified bit size.");
543 for (
auto v : uint64Encoding) {
545 writeUint64(bytes, bitOffset, 64, v);
549 uint64_t
const relevantBitMask = (1ull << bitSize) - 1;
551 if (Signed && ((v & (1ull << (bitSize - 1))) != 0)) {
552 STORM_LOG_ASSERT(value < 0,
"Value " << value <<
" is non-negative but the sign bit is set.");
555 "Value " << value <<
" does not fit into the specified bit size of " << bitSize <<
" bits.");
559 v &= relevantBitMask;
562 STORM_LOG_ASSERT((~relevantBitMask & v) == 0,
"Value " << value <<
" does not fit into the specified bit size of " << bitSize <<
" bits.");
564 writeUint64(bytes, bitOffset, bitSize, v);
569 STORM_LOG_ASSERT(bitSize == 0,
"Unexpected integer encoding. Not all bits were written.");
572template void ValuationsStorage::writeInteger<false>(std::span<char>, uint64_t, uint64_t, Integer
const&)
const;
573template void ValuationsStorage::writeInteger<true>(std::span<char>, uint64_t, uint64_t, Integer
const&)
const;
575template<
typename ValueType>
577 if constexpr (std::is_same_v<ValueType, bool>) {
578 writeUint64(bytes, bitOffset, bitSize, value ? 1ul : 0ul);
579 }
else if constexpr (std::is_same_v<ValueType, uint64_t>) {
580 writeUint64(bytes, bitOffset, bitSize, value);
581 }
else if constexpr (std::is_same_v<ValueType, int64_t>) {
584 uint64_t v = ~static_cast<uint64_t>(-(value + 1));
587 v &= (1ull << bitSize) - 1;
589 writeUint64(bytes, bitOffset, bitSize, v);
592 writeUint64(bytes, bitOffset, bitSize,
static_cast<uint64_t
>(value));
594 }
else if constexpr (std::is_same_v<ValueType, double>) {
595 writeUint64(bytes, bitOffset, bitSize, std::bit_cast<uint64_t>(value));
596 }
else if constexpr (std::is_same_v<ValueType, Integer>) {
598 writeInteger<true>(bytes, bitOffset, bitSize, value);
600 writeInteger<false>(bytes, bitOffset, bitSize, value);
602 }
else if constexpr (std::is_same_v<ValueType, storm::RationalNumber>) {
603 STORM_LOG_ASSERT(bitSize % 2 == 0,
"Uneven bitsize for rational number not expected.");
604 auto const numDenSize = bitSize / 2;
606 static_assert(storm::RationalNumberDenominatorAlwaysPositive);
610 static_assert(std::is_same_v<ValueType, std::string_view> || std::is_same_v<ValueType, std::string>);
611 uint64_t
const index = storm::umb::StringsBuilder(strings, stringMapping).findOrPushBack(value);
612 writeUint64(bytes, bitOffset, bitSize, index);
628 result.numEntities = [&selectedEntities]() {
629 if constexpr (std::is_same_v<T, storm::storage::BitVector>) {
630 return selectedEntities.getNumberOfSetBits();
632 return std::ranges::distance(selectedEntities);
635 result.stringMapping = stringMapping;
636 result.strings = strings;
638 if (entityClassMappings) {
639 result.entityClassMappings.emplace();
640 result.entityClassMappings->toValuationsMapping.reserve(result.numEntities + 1);
641 result.entityClassMappings->toValuationsMapping.push_back(0);
642 result.entityClassMappings->toClassMapping.reserve(result.numEntities);
644 result.valuations.reserve(result.numEntities * result.variableClasses.front().sizeInBytes);
646 for (
auto const oldEntityIndex : selectedEntities) {
647 STORM_LOG_ASSERT(oldEntityIndex <
size(),
"Selected entity index " << oldEntityIndex <<
" out of bounds. Only " <<
size() <<
" entities known.");
648 auto const bytes = getRawBytes(oldEntityIndex);
649 result.valuations.insert(result.valuations.end(), bytes.begin(), bytes.end());
650 if (entityClassMappings) {
651 result.entityClassMappings->toValuationsMapping.push_back(result.valuations.size());
652 result.entityClassMappings->toClassMapping.push_back(entityClassMappings->toClassMapping[oldEntityIndex]);
663 auto const hashBytes = std::hash<std::string_view>{};
665 std::size_t seed = hashBytes(std::string_view(valuations.data(), valuations.size()));
666 boost::hash_combine(seed, hashBytes(std::string_view(strings.data(), strings.size())));
This class is responsible for managing a set of typed variables and all expressions using these varia...
std::string const & getName() const
Retrieves the name of the variable.
A bit vector that is internally represented as a vector of 64-bit values.
Stores valuations of variables for a set of entities (e.g.
ValuationsStorage(ValuationsStorage const &)=default
storm::umb::UmbModel::Valuation getRawUmbData() const
Exports a snapshot of the raw UMB model valuation data (packed bytes, optional class mapping,...
bool entityHasVariable(uint64_t entity, storm::expressions::Variable const &variable) const
Returns true iff the variable is relevant for the given entity's class, i.e.
ValuationsStorage selectEntities(T const &selectedEntities) const
Constructs a new ValuationsStorage containing only the selected entities, in the order they appear in...
void resize(uint64_t newEntityCount, uint64_t classIndex=0)
Resizes the entity count to newEntityCount.
std::set< storm::expressions::Variable > getAllVariables() const
Returns all expression variables that this valuation assigns values to for at least one class.
void readCallback(uint64_t entity, Callback const &callback) const
Reads all variables of the given entity and invokes callback for each one.
uint64_t numStrings() const
void writeValue(uint64_t entity, storm::expressions::Variable const &variable, ValueType const &value)
Directly writes value to the given variable of entity.
std::size_t hash() const
Computes a hash of the entire valuation data.
uint64_t getClassOfEntity(uint64_t entity) const
Returns the class index of the given entity.
storm::expressions::ExpressionManager const & getManager() const
Returns the expression manager shared by all classes.
void setValuesInEvaluator(uint64_t entity, storm::expressions::ExpressionEvaluator< RationalValueType > &evaluator) const
Reads the variable values for the given entity and sets them into the given expression evaluator.
VariableInformation const & getVariableInformation(uint64_t entity, storm::expressions::Variable const &variable) const
Looks up compiled variable information for the given entity and variable.
storm::NumberTraits< storm::RationalNumber >::IntegerType Integer
void emplaceBack(uint64_t classIndex, Callback const &callback)
Appends a new entity of the given class and populates its variables via callback.
ValuationClassDescription getClassDescription(uint64_t classIndex=0) const
Reconstructs the ValuationClassDescription for the given class from the stored compiled variable info...
uint64_t numClasses() const
static void appendEncodedInteger(std::vector< uint64_t > &result, typename storm::NumberTraits< storm::RationalNumber >::IntegerType const &value, uint64_t uint64BucketsPerInteger)
static storm::NumberTraits< storm::RationalNumber >::IntegerType decodeArbitraryPrecisionInteger(InputRange &&input)
static uint64_t getSizeOfIntegerEncoding(typename storm::NumberTraits< storm::RationalNumber >::IntegerType const &value)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
bool fits64Bit(ValuationClassDescription::Variable const &varDesc)
ValuationsStorage::VariablesInformation createVariablesInformation(ManagerType &expressionManager, ValuationClassDescription const &description)
NumberTraits< RationalType >::IntegerType denominator(RationalType const &number)
NumberTraits< RationalType >::IntegerType numerator(RationalType const &number)
ValueType pow(ValueType const &value, int_fast64_t exponent)
TargetType convertNumber(SourceType const &number)
std::optional< int64_t > offset
std::optional< int64_t > upper
storm::umb::SizedType type
std::optional< int64_t > lower
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
std::string toString() const
storm::SerializedEnum< storm::umb::TypeDeclaration > type
TO1< uint32_t > valuationToClass