23 : variable(variable), bitOffset(bitOffset), global(global), observable(observable) {
28 uint_fast64_t bitOffset, uint_fast64_t bitWidth,
bool global,
bool observable,
29 bool forceOutOfBoundsCheck)
31 lowerBound(lowerBound),
32 upperBound(upperBound),
36 observable(observable),
37 forceOutOfBoundsCheck(forceOutOfBoundsCheck) {
42 uint_fast64_t bitWidth,
bool observable)
43 : variable(variable), highestValue(highestValue), bitOffset(bitOffset), bitWidth(bitWidth), observable(observable) {
64 uint64_t
const& reservedBitsForUnboundedVariables) {
67 STORM_LOG_THROW(lowerBound <= upperBound, storm::exceptions::WrongFormatException,
"Lower bound must not be above upper bound");
70 return static_cast<uint64_t
>(std::ceil(std::log2(upperBound - lowerBound + 1)));
73 upperBound = lowerBound + ((1ll << reservedBitsForUnboundedVariables) - 1);
78 lowerBound = upperBound - ((1ll << reservedBitsForUnboundedVariables) - 1);
81 lowerBound = -(1ll << (reservedBitsForUnboundedVariables - 1));
82 upperBound = (1ll << (reservedBitsForUnboundedVariables - 1)) - 1;
87 STORM_LOG_THROW(lowerBound <= upperBound, storm::exceptions::WrongFormatException,
88 "Lower bound must not be above upper bound. Has there been an integer over-/underflow?");
90 STORM_LOG_ASSERT(reservedBitsForUnboundedVariables ==
static_cast<uint64_t
>(std::ceil(std::log2(upperBound - lowerBound + 1))),
91 "Unexpected bitwidth for unbounded variable.");
92 return reservedBitsForUnboundedVariables;
97 if (outOfBoundsState) {
101 outOfBoundsBit = boost::none;
109 int64_t lowerBound, upperBound;
110 if (integerVariable.hasLowerBoundExpression()) {
111 lowerBound = integerVariable.getLowerBoundExpression().evaluateAsInt();
113 if (integerVariable.hasUpperBoundExpression()) {
114 upperBound = integerVariable.getUpperBoundExpression().evaluateAsInt();
116 uint64_t bitwidth =
getBitWidthLowerUpperBound(integerVariable.hasLowerBoundExpression(), lowerBound, integerVariable.hasUpperBoundExpression(),
117 upperBound, reservedBitsForUnboundedVariables);
119 integerVariable.isObservable(), !integerVariable.hasLowerBoundExpression() || !integerVariable.hasUpperBoundExpression());
122 for (
auto const& module : program.
getModules()) {
123 for (
auto const& booleanVariable :
module.getBooleanVariables()) {
124 booleanVariables.emplace_back(booleanVariable.getExpressionVariable(), totalBitOffset, false, booleanVariable.isObservable());
127 for (
auto const& integerVariable :
module.getIntegerVariables()) {
128 int64_t lowerBound, upperBound;
129 if (integerVariable.hasLowerBoundExpression()) {
130 lowerBound = integerVariable.getLowerBoundExpression().evaluateAsInt();
132 if (integerVariable.hasUpperBoundExpression()) {
133 upperBound = integerVariable.getUpperBoundExpression().evaluateAsInt();
135 uint64_t bitwidth =
getBitWidthLowerUpperBound(integerVariable.hasLowerBoundExpression(), lowerBound, integerVariable.hasUpperBoundExpression(),
136 upperBound, reservedBitsForUnboundedVariables);
138 integerVariable.isObservable(),
139 !integerVariable.hasLowerBoundExpression() || !integerVariable.hasUpperBoundExpression());
143 for (
auto const& oblab : program.getObservationLabels()) {
144 observationLabels.emplace_back(oblab.getName());
151 std::vector<std::reference_wrapper<storm::jani::Automaton const>>
const& parallelAutomata,
152 uint64_t reservedBitsForUnboundedVariables,
bool outOfBoundsState)
153 : totalBitOffset(0) {
156 "Cannot build model from JANI model that contains global non-transient real variables.");
157 for (
auto const& automaton : model.
getAutomata()) {
158 STORM_LOG_THROW(!automaton.getVariables().containsNonTransientRealVariables(), storm::exceptions::InvalidArgumentException,
159 "Cannot build model from JANI model that contains non-transient real variables in automaton '" << automaton.getName() <<
"'.");
162 if (outOfBoundsState) {
166 outOfBoundsBit = boost::none;
169 createVariablesForVariableSet(model.
getGlobalVariables(), reservedBitsForUnboundedVariables,
true);
171 for (
auto const& automatonRef : parallelAutomata) {
172 createVariablesForAutomaton(automatonRef.get(), reservedBitsForUnboundedVariables);
182 if (!arrayVariable->isTransient()) {
183 auto findRes = arrayEliminatorData.
replacements.find(arrayVariable->getExpressionVariable());
185 auto const& replacements = findRes->second;
186 auto const& innerType = arrayVariable->getType().asArrayType().getBaseTypeRecursive();
187 if (innerType.isBasicType() && innerType.asBasicType().isBooleanType()) {
190 }
else if ((innerType.isBasicType() && innerType.asBasicType().isIntegerType()) ||
191 (innerType.isBoundedType() && innerType.asBoundedType().isIntegerType())) {
195 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unhandled type of base variable.");
202 std::vector<uint64_t>
const& arrayIndexVector)
const {
207 std::vector<uint64_t>
const& arrayIndexVector)
const {
211void VariableInformation::createVariablesForAutomaton(
storm::jani::Automaton const& automaton, uint64_t reservedBitsForUnboundedVariables) {
212 uint_fast64_t bitwidth =
static_cast<uint_fast64_t
>(std::ceil(std::log2(automaton.
getNumberOfLocations())));
216 createVariablesForVariableSet(automaton.
getVariables(), reservedBitsForUnboundedVariables,
false);
219void VariableInformation::createVariablesForVariableSet(
storm::jani::VariableSet const& variableSet, uint64_t reservedBitsForUnboundedVariables,
bool global) {
220 for (
auto const& variable : variableSet.getBooleanVariables()) {
221 if (!variable.isTransient()) {
226 for (
auto const& variable : variableSet.getBoundedIntegerVariables()) {
227 if (!variable.isTransient()) {
228 int64_t lowerBound, upperBound;
229 auto const& type = variable.getType().asBoundedType();
230 STORM_LOG_ASSERT(type.hasLowerBound() || type.hasUpperBound(),
"Bounded integer variable has neither a lower nor an upper bound.");
231 if (type.hasLowerBound()) {
232 lowerBound = type.getLowerBound().evaluateAsInt();
234 if (type.hasUpperBound()) {
235 upperBound = type.getUpperBound().evaluateAsInt();
238 getBitWidthLowerUpperBound(type.hasLowerBound(), lowerBound, type.hasUpperBound(), upperBound, reservedBitsForUnboundedVariables);
240 !type.hasLowerBound() || !type.hasUpperBound());
244 for (
auto const& variable : variableSet.getUnboundedIntegerVariables()) {
245 if (!variable.isTransient()) {
246 int64_t lowerBound, upperBound;
256 if (roundTo64Bit & ((result & ((1ull << 6) - 1)) != 0)) {
257 result = ((result >> 6) + 1) << 6;
263 return outOfBoundsBit != boost::none;
268 return outOfBoundsBit.get();
271void VariableInformation::sortVariables() {
VariableSet & getVariables()
Retrieves the variables of this automaton.
storm::expressions::Variable const & getLocationExpressionVariable() const
Retrieves the expression variable that represents the location of this automaton.
uint64_t getNumberOfLocations() const
Retrieves the number of locations.
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
std::vector< Automaton > & getAutomata()
Retrieves the automata of the model.
bool containsNonTransientRealVariables() const
Retrieves whether the set of variables contains a non-transient real variable.
std::vector< BooleanVariable > const & getGlobalBooleanVariables() const
Retrieves the global boolean variables of the program.
std::vector< Module > const & getModules() const
Retrieves all modules of the program.
std::vector< IntegerVariable > const & getGlobalIntegerVariables() const
Retrieves the global integer variables of the program.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
uint64_t getBitWidthLowerUpperBound(bool const &hasLowerBound, int64_t &lowerBound, bool const &hasUpperBound, int64_t &upperBound, uint64_t const &reservedBitsForUnboundedVariables)
Small helper function that sets unspecified lower/upper bounds for an integer variable based on the p...
ArrayVariableReplacementInformation convertArrayReplacement(typename storm::jani::ArrayEliminatorData::Replacement const &replacement, InfoType const &relevantVariableInfo)
std::unordered_map< storm::expressions::Variable, Replacement > replacements
std::vector< std::shared_ptr< Variable > > eliminatedArrayVariables