25 boost::optional<storm::RationalFunction>
const&
lowerBound,
26 boost::optional<storm::RationalFunction>
const&
upperBound,
32template<
typename VariableType>
37 "The default value for transient variable " <<
variable.getName() <<
" is smaller than its lower bound.");
39 "The default value for transient variable " <<
variable.getName() <<
" is higher than its upper bound.");
42template<
typename VariableType>
48template<
typename ValueType>
55template<
typename ValueType>
60template<
typename ValueType>
63 evaluator.setBooleanValue(varValue.first->variable, varValue.second);
66 if (explorationChecks) {
67 STORM_LOG_THROW(!varValue.first->lowerBound.is_initialized() || varValue.first->lowerBound.get() <= varValue.second,
68 storm::exceptions::OutOfRangeException,
69 "The assigned value for transient variable " << varValue.first->variable.getName() <<
" is smaller than its lower bound.");
70 STORM_LOG_THROW(!varValue.first->upperBound.is_initialized() || varValue.second <= varValue.first->upperBound.get(),
71 storm::exceptions::OutOfRangeException,
72 "The assigned value for transient variable " << varValue.first->variable.getName() <<
" is higher than its upper bound.");
74 evaluator.setIntegerValue(varValue.first->variable, varValue.second);
77 evaluator.setRationalValue(varValue.first->variable, varValue.second);
81template<
typename ValueType>
84 auto writeValues = [stateIndex, &valuations](
auto const& varInfos,
auto const& varValues) {
85 auto varIt = varValues.begin();
86 auto const varIte = varValues.end();
87 for (
auto const& varInfo : varInfos) {
88 bool const hasValue = varIt != varIte && varIt->first->variable == varInfo.variable;
89 auto const& value = hasValue ? varIt->second : varInfo.defaultValue;
96 "Non-constant variable valuations are not supported. Got value " << value <<
" for variable " << varInfo.variable.getName() <<
".");
99 valuations.
writeValue(stateIndex, varInfo.variable, value);
108template<
typename ValueType>
110 storm::jani::Model const& model, std::vector<std::reference_wrapper<storm::jani::Automaton const>>
const& parallelAutomata) {
113 for (
auto const& automatonRef : parallelAutomata) {
114 createVariablesForAutomaton(automatonRef.get());
120template<
typename ValueType>
125 if (arrayVariable->isTransient()) {
126 auto findRes = arrayEliminatorData.
replacements.find(arrayVariable->getExpressionVariable());
128 auto const& replacements = findRes->second;
129 auto const& innerType = arrayVariable->getType().asArrayType().getBaseTypeRecursive();
130 if (innerType.isBasicType() && innerType.asBasicType().isBooleanType()) {
133 }
else if ((innerType.isBasicType() && innerType.asBasicType().isIntegerType()) ||
134 (innerType.isBoundedType() && innerType.asBoundedType().isIntegerType())) {
137 }
else if ((innerType.isBasicType() && innerType.asBasicType().isRealType()) ||
138 (innerType.isBoundedType() && innerType.asBoundedType().isRealType())) {
142 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unhandled type of base variable.");
148template<
typename ValueType>
154template<
typename ValueType>
160template<
typename ValueType>
166template<
typename ValueType>
167void TransientVariableInformation<ValueType>::createVariablesForAutomaton(
storm::jani::Automaton const& automaton) {
168 createVariablesForVariableSet(automaton.
getVariables(),
false);
171template<
typename ValueType>
172void TransientVariableInformation<ValueType>::createVariablesForVariableSet(
storm::jani::VariableSet const& variableSet,
bool global) {
174 if (variable.isTransient()) {
175 booleanVariableInformation.emplace_back(variable.getExpressionVariable(), variable.getInitExpression().evaluateAsBool(), global);
179 if (variable.isTransient()) {
180 boost::optional<int64_t> lowerBound;
181 boost::optional<int64_t> upperBound;
182 auto const& type = variable.getType().asBoundedType();
183 if (type.hasLowerBound()) {
184 lowerBound = type.getLowerBound().evaluateAsInt();
186 if (type.hasUpperBound()) {
187 upperBound = type.getUpperBound().evaluateAsInt();
189 integerVariableInformation.emplace_back(variable.getExpressionVariable(), lowerBound, upperBound, variable.getInitExpression().evaluateAsInt(),
194 if (variable.isTransient()) {
195 integerVariableInformation.emplace_back(variable.getExpressionVariable(), variable.getInitExpression().evaluateAsInt(), global);
199 if (variable.isTransient()) {
200 rationalVariableInformation.emplace_back(variable.getExpressionVariable(),
206template<
typename ValueType>
207void TransientVariableInformation<ValueType>::sortVariables() {
209 std::sort(booleanVariableInformation.begin(), booleanVariableInformation.end(),
211 std::sort(integerVariableInformation.begin(), integerVariableInformation.end(),
213 std::sort(rationalVariableInformation.begin(), rationalVariableInformation.end(),
217template<
typename ValueType>
220 evaluator.setBooleanValue(variableData.variable, variableData.defaultValue);
223 evaluator.setIntegerValue(variableData.variable, variableData.defaultValue);
226 evaluator.setRationalValue(variableData.variable, variableData.defaultValue);
VariableSet & getVariables()
Retrieves the variables of this automaton.
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
detail::Variables< Variable > getBoundedIntegerVariables()
Retrieves the bounded integer variables in this set.
detail::Variables< Variable > getUnboundedIntegerVariables()
Retrieves the unbounded integer variables in this set.
detail::Variables< Variable > getRealVariables()
Retrieves the real variables in this set.
detail::Variables< Variable > getBooleanVariables()
Retrieves the boolean variables in this set.
Stores valuations of variables for a set of entities (e.g.
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_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
ArrayVariableReplacementInformation convertArrayReplacement(typename storm::jani::ArrayEliminatorData::Replacement const &replacement, InfoType const &relevantVariableInfo)
bool isConstant(ValueType const &)
TargetType convertNumber(SourceType const &number)
carl::RationalFunction< Polynomial, true > RationalFunction
boost::optional< VariableType > lowerBound
TransientVariableData(storm::expressions::Variable const &variable, boost::optional< VariableType > const &lowerBound, boost::optional< VariableType > const &upperBound, VariableType const &defaultValue, bool global=false)
boost::optional< VariableType > upperBound
VariableType defaultValue
storm::expressions::Variable variable
std::vector< std::pair< TransientVariableData< ValueType > const *, ValueType > > rationalValues
std::vector< std::pair< TransientVariableData< bool > const *, bool > > booleanValues
void setInEvaluator(storm::expressions::ExpressionEvaluator< ValueType > &evaluator, bool explorationChecks) const
std::vector< std::pair< TransientVariableData< int64_t > const *, int64_t > > integerValues
void setInValuations(uint64_t const stateIndex, TransientVariableInformation< ValueType > const &info, storm::storage::sparse::ValuationsStorage &valuations) const
std::unordered_map< storm::expressions::Variable, Replacement > replacements
std::vector< std::shared_ptr< Variable > > eliminatedArrayVariables