3#include <boost/any.hpp>
24 bool* result = boost::any_cast<bool*>(data);
30 STORM_LOG_TRACE(
"The expression " << expression <<
" 'contains' a variable in the variable set.");
34 virtual void traverse(
LValue const& lValue, boost::any
const& data)
override {
35 bool* result = boost::any_cast<bool*>(data);
43 std::set<storm::expressions::Variable> varSet;
47 std::set<uint64_t> res;
54 bool varAccessed =
false;
67 uint64_t automatonIndex = 0;
73 std::map<Variable const*, std::reference_wrapper<Variable const>> remapping;
75 remapping.emplace(oldJaniVar.get(), model.
addVariable(*oldJaniVar));
82 std::map<Variable const*, std::reference_wrapper<Variable const>> remapping;
96 bool foundVar =
false;
98 if (aut.hasVariable(variable.
getName())) {
110 std::optional<uint64_t> automatonIndex)
const {
116 return {
false, index};
120 if (accessingAutomata.size() > 1 || (automatonIndex.has_value() && accessingAutomata.count(automatonIndex.value()) == 0)) {
123 return {
false, index};
126 STORM_LOG_TRACE(
".. no!, initial states restriction contains variable");
127 return {
false, index};
130 if (rewExp.second.containsVariable({variable})) {
132 return {
false, index};
136 if (funDef.second.getFunctionBody().containsVariable({variable})) {
138 return {
false, index};
142 for (
auto const& p : *properties) {
143 if (p.getUsedVariablesAndConstants().count(variable) > 0) {
145 return {
false, index};
147 if (p.getUsedLabels().count(variable.
getName()) > 0) {
149 return {
false, index};
154 if (accessingAutomata.empty()) {
155 index = automatonIndex.has_value() ? automatonIndex.value() : 0;
157 index = *accessingAutomata.begin();
158 assert(!automatonIndex.has_value() || index == automatonIndex.value());
160 STORM_LOG_TRACE(
".. Yes, made local in automaton with index " << index);
161 return {
true, index};
167 std::set<storm::expressions::Variable> varsToMakeGlobal;
170 varsToMakeGlobal.insert(v.getExpressionVariable());
173 for (
auto const& v : varsToMakeGlobal) {
181 std::map<storm::expressions::Variable, uint64_t> varsToMakeLocal;
184 if (makeLocal.first) {
185 varsToMakeLocal[v.getExpressionVariable()] = makeLocal.second;
188 for (
auto const& v : varsToMakeLocal) {
Helper class that optionally holds a reference to an object of type T.
bool containsVariable(std::set< storm::expressions::Variable > const &variables) const
Retrieves whether the expression contains any of the given variables.
std::string const & getName() const
Retrieves the name of the variable.
VariableSet & getVariables()
Retrieves the variables of this automaton.
Variable const & addVariable(Variable const &variable)
Adds the given variable to this automaton.
void changeAssignmentVariables(std::map< Variable const *, std::reference_wrapper< Variable const > > const &remapping)
Changes all variables in assignments based on the given mapping.
std::string const & getName() const
Retrieves the name of the automaton.
virtual void traverse(Model const &model, boost::any const &data)
void makeVariablesGlobal(Model &model) const
Moves as many variables to the global scope as possible.
void makeVariablesLocal(Model &model, storm::OptionalRef< std::vector< Property > const > properties=storm::NullRef) const
Moves as many variables to a local scope as possible.
void makeVariableGlobal(storm::expressions::Variable const &variable, Model &model) const
Moves the given variable to the global scope.
bool canMakeVariableGlobal(storm::expressions::Variable const &variable, Model const &model) const
Checks whether this variable can be made global without introducing name clashes.
void makeVariableLocal(storm::expressions::Variable const &variable, Model &model, uint64_t automatonIndex) const
Moves the given variable into the local scope of the automaton with the given index.
std::pair< bool, uint64_t > canMakeVariableLocal(storm::expressions::Variable const &variable, Model const &model, storm::OptionalRef< std::vector< Property > const > properties=storm::NullRef, std::optional< uint64_t > automatonIndex=std::nullopt) const
Checks whether this variable can be made local without introducing out-of-scope accesses.
storm::jani::Variable const & getVariable() const
To check if the array is fully accessed, so result will be of the most inner child Type....
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
std::unordered_map< std::string, storm::expressions::Expression > const & getNonTrivialRewardExpressions() const
Retrieves all available non-trivial reward model names and expressions of the model.
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the global variables.
std::vector< Automaton > & getAutomata()
Retrieves the automata of the model.
Variable const & addVariable(Variable const &variable)
Adds the given variable to this model.
std::size_t getNumberOfAutomata() const
Retrieves the number of automata in this model.
bool hasGlobalVariable(std::string const &name) const
Retrieves whether this model has a global variable with the given name.
Automaton & getAutomaton(std::string const &name)
Retrieves the automaton with the given name.
std::unordered_map< std::string, FunctionDefinition > const & getGlobalFunctionDefinitions() const
Retrieves all global function definitions.
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the associated expression variable.
bool hasVariable(std::string const &name) const
Retrieves whether this variable set contains a variable with the given name.
std::shared_ptr< Variable > eraseVariable(storm::expressions::Variable const &variable)
Erases the given variable from this set.
virtual void traverse(LValue const &lValue, boost::any const &data) override
VariableAccessedTraverser(std::set< storm::expressions::Variable > const &varSet)
virtual void traverse(storm::expressions::Expression const &expression, boost::any const &data) override
#define STORM_LOG_TRACE(message)
std::set< uint64_t > getAutomataAccessingVariable(storm::expressions::Variable const &variable, Model const &model)