Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TransientVariableInformation.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4#include <unordered_map>
5#include <vector>
6
12
14
15namespace storm {
16
17namespace jani {
18class Model;
19class Automaton;
20struct ArrayEliminatorData;
21class VariableSet;
22} // namespace jani
23
24namespace expressions {
25template<typename ValueType>
26class ExpressionEvaluator;
27}
28
29namespace generator {
30
31// A structure storing information about a transient variable
32
33template<typename VariableType>
35 TransientVariableData(storm::expressions::Variable const& variable, boost::optional<VariableType> const& lowerBound,
36 boost::optional<VariableType> const& upperBound, VariableType const& defaultValue, bool global = false);
37 TransientVariableData(storm::expressions::Variable const& variable, VariableType const& defaultValue, bool global = false);
38
39 // The integer variable.
41
42 // The lower bound of its range.
43 boost::optional<VariableType> lowerBound;
44
45 // The upper bound of its range.
46 boost::optional<VariableType> upperBound;
47
48 // Its default value
49 VariableType defaultValue;
50
51 // A flag indicating whether the variable is a global one.
52 bool global;
53};
54
55template<typename ValueType>
57 std::vector<std::pair<TransientVariableData<bool> const*, bool>> booleanValues;
58 std::vector<std::pair<TransientVariableData<int64_t> const*, int64_t>> integerValues;
59 std::vector<std::pair<TransientVariableData<ValueType> const*, ValueType>> rationalValues;
60
61 void clear() {
62 booleanValues.clear();
63 integerValues.clear();
64 rationalValues.clear();
65 }
66
67 bool empty() const {
68 return booleanValues.empty() && integerValues.empty() && rationalValues.empty();
69 }
70
71 void setInEvaluator(storm::expressions::ExpressionEvaluator<ValueType>& evaluator, bool explorationChecks) const {
72 for (auto const& varValue : booleanValues) {
73 evaluator.setBooleanValue(varValue.first->variable, varValue.second);
74 }
75 for (auto const& varValue : integerValues) {
76 if (explorationChecks) {
77 STORM_LOG_THROW(!varValue.first->lowerBound.is_initialized() || varValue.first->lowerBound.get() <= varValue.second,
78 storm::exceptions::OutOfRangeException,
79 "The assigned value for transient variable " << varValue.first->variable.getName() << " is smaller than its lower bound.");
80 STORM_LOG_THROW(!varValue.first->upperBound.is_initialized() || varValue.second <= varValue.first->upperBound.get(),
81 storm::exceptions::OutOfRangeException,
82 "The assigned value for transient variable " << varValue.first->variable.getName() << " is higher than its upper bound.");
83 }
84 evaluator.setIntegerValue(varValue.first->variable, varValue.second);
85 }
86 for (auto const& varValue : rationalValues) {
87 evaluator.setRationalValue(varValue.first->variable, varValue.second);
88 }
89 }
90};
91
92// A structure storing information about the used variables of the program.
93template<typename ValueType>
95 TransientVariableInformation(storm::jani::Model const& model, std::vector<std::reference_wrapper<storm::jani::Automaton const>> const& parallelAutomata);
96
98
101 std::vector<uint64_t> const& arrayIndexVector) const;
103 std::vector<uint64_t> const& arrayIndexVector) const;
105 std::vector<uint64_t> const& arrayIndexVector) const;
106
108
109 std::vector<TransientVariableData<bool>> booleanVariableInformation;
110 std::vector<TransientVariableData<int64_t>> integerVariableInformation;
111 std::vector<TransientVariableData<ValueType>> rationalVariableInformation;
112
114 std::unordered_map<storm::expressions::Variable, ArrayVariableReplacementInformation> arrayVariableToElementInformations;
115
116 private:
120 void sortVariables();
121
125 void createVariablesForAutomaton(storm::jani::Automaton const& automaton);
126
130 void createVariablesForVariableSet(storm::jani::VariableSet const& variableSet, bool global);
131};
132
133} // namespace generator
134} // namespace storm
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18
std::vector< TransientVariableData< bool > > booleanVariableInformation
void registerArrayVariableReplacements(storm::jani::ArrayEliminatorData const &arrayEliminatorData)
void setDefaultValuesInEvaluator(storm::expressions::ExpressionEvaluator< ValueType > &evaluator) const
std::vector< TransientVariableData< ValueType > > rationalVariableInformation
std::unordered_map< storm::expressions::Variable, ArrayVariableReplacementInformation > arrayVariableToElementInformations
Replacements for each array variable.
TransientVariableData< int64_t > const & getIntegerArrayVariableReplacement(storm::expressions::Variable const &arrayVariable, std::vector< uint64_t > const &arrayIndexVector) const
std::vector< TransientVariableData< int64_t > > integerVariableInformation
TransientVariableData< bool > const & getBooleanArrayVariableReplacement(storm::expressions::Variable const &arrayVariable, std::vector< uint64_t > const &arrayIndexVector) const
TransientVariableData< ValueType > const & getRationalArrayVariableReplacement(storm::expressions::Variable const &arrayVariable, std::vector< uint64_t > const &arrayIndexVector) const
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