24 boost::optional<storm::RationalFunction>
const& lowerBound,
25 boost::optional<storm::RationalFunction>
const& upperBound,
27 : variable(variable), lowerBound(lowerBound), upperBound(upperBound), defaultValue(defaultValue), global(global) {
31template<
typename VariableType>
33 boost::optional<VariableType>
const& upperBound, VariableType
const& defaultValue,
bool global)
34 : variable(variable), lowerBound(lowerBound), upperBound(upperBound), defaultValue(defaultValue), global(global) {
36 "The default value for transient variable " <<
variable.
getName() <<
" is smaller than its lower bound.");
38 "The default value for transient variable " <<
variable.
getName() <<
" is higher than its upper bound.");
41template<
typename VariableType>
43 : variable(variable), defaultValue(defaultValue), global(global) {
47template<
typename ValueType>
49 storm::jani::Model const& model, std::vector<std::reference_wrapper<storm::jani::Automaton const>>
const& parallelAutomata) {
52 for (
auto const& automatonRef : parallelAutomata) {
53 createVariablesForAutomaton(automatonRef.get());
59template<
typename ValueType>
61 arrayVariableToElementInformations.clear();
64 if (arrayVariable->isTransient()) {
65 auto findRes = arrayEliminatorData.
replacements.find(arrayVariable->getExpressionVariable());
67 auto const& replacements = findRes->second;
68 auto const& innerType = arrayVariable->getType().asArrayType().getBaseTypeRecursive();
69 if (innerType.isBasicType() && innerType.asBasicType().isBooleanType()) {
71 this->arrayVariableToElementInformations.emplace(arrayVariable->getExpressionVariable(), std::move(replInfo));
72 }
else if ((innerType.isBasicType() && innerType.asBasicType().isIntegerType()) ||
73 (innerType.isBoundedType() && innerType.asBoundedType().isIntegerType())) {
75 this->arrayVariableToElementInformations.emplace(arrayVariable->getExpressionVariable(), std::move(replInfo));
76 }
else if ((innerType.isBasicType() && innerType.asBasicType().isRealType()) ||
77 (innerType.isBoundedType() && innerType.asBoundedType().isRealType())) {
79 this->arrayVariableToElementInformations.emplace(arrayVariable->getExpressionVariable(), std::move(replInfo));
81 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unhandled type of base variable.");
87template<
typename ValueType>
90 return booleanVariableInformation[arrayVariableToElementInformations.at(arrayVariable).getVariableInformationIndex(arrayIndexVector)];
93template<
typename ValueType>
96 return integerVariableInformation[arrayVariableToElementInformations.at(arrayVariable).getVariableInformationIndex(arrayIndexVector)];
99template<
typename ValueType>
102 return rationalVariableInformation[arrayVariableToElementInformations.at(arrayVariable).getVariableInformationIndex(arrayIndexVector)];
105template<
typename ValueType>
107 createVariablesForVariableSet(automaton.
getVariables(),
false);
110template<
typename ValueType>
111void TransientVariableInformation<ValueType>::createVariablesForVariableSet(
storm::jani::VariableSet const& variableSet,
bool global) {
112 for (
auto const& variable : variableSet.getBooleanVariables()) {
113 if (variable.isTransient()) {
114 booleanVariableInformation.emplace_back(variable.getExpressionVariable(), variable.getInitExpression().evaluateAsBool(), global);
117 for (
auto const& variable : variableSet.getBoundedIntegerVariables()) {
118 if (variable.isTransient()) {
119 boost::optional<int64_t> lowerBound;
120 boost::optional<int64_t> upperBound;
121 auto const& type = variable.getType().asBoundedType();
122 if (type.hasLowerBound()) {
123 lowerBound = type.getLowerBound().evaluateAsInt();
125 if (type.hasUpperBound()) {
126 upperBound = type.getUpperBound().evaluateAsInt();
128 integerVariableInformation.emplace_back(variable.getExpressionVariable(), lowerBound, upperBound, variable.getInitExpression().evaluateAsInt(),
132 for (
auto const& variable : variableSet.getUnboundedIntegerVariables()) {
133 if (variable.isTransient()) {
134 integerVariableInformation.emplace_back(variable.getExpressionVariable(), variable.getInitExpression().evaluateAsInt(), global);
137 for (
auto const& variable : variableSet.getRealVariables()) {
138 if (variable.isTransient()) {
139 rationalVariableInformation.emplace_back(variable.getExpressionVariable(),
140 storm::utility::convertNumber<ValueType>(variable.getInitExpression().evaluateAsRational()), global);
145template<
typename ValueType>
146void TransientVariableInformation<ValueType>::sortVariables() {
148 std::sort(booleanVariableInformation.begin(), booleanVariableInformation.end(),
149 [](TransientVariableData<bool>
const& a, TransientVariableData<bool>
const& b) { return a.variable < b.variable; });
150 std::sort(integerVariableInformation.begin(), integerVariableInformation.end(),
151 [](TransientVariableData<int64_t>
const& a, TransientVariableData<int64_t>
const& b) { return a.variable < b.variable; });
152 std::sort(rationalVariableInformation.begin(), rationalVariableInformation.end(),
153 [](TransientVariableData<ValueType>
const& a, TransientVariableData<ValueType>
const& b) { return a.variable < b.variable; });
156template<
typename ValueType>
158 for (
auto const& variableData : booleanVariableInformation) {
159 evaluator.setBooleanValue(variableData.variable, variableData.defaultValue);
161 for (
auto const& variableData : integerVariableInformation) {
162 evaluator.setIntegerValue(variableData.variable, variableData.defaultValue);
164 for (
auto const& variableData : rationalVariableInformation) {
165 evaluator.setRationalValue(variableData.variable, variableData.defaultValue);
std::string const & getName() const
Retrieves the name of the variable.
VariableSet & getVariables()
Retrieves the variables of this automaton.
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
#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)
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::unordered_map< storm::expressions::Variable, Replacement > replacements
std::vector< std::shared_ptr< Variable > > eliminatedArrayVariables