13 : guard(guard), lowestAssignmentLevel(
std::numeric_limits<int64_t>::max()), highestAssignmentLevel(
std::numeric_limits<int64_t>::min()) {
18 std::vector<TemplateEdgeDestination>
const& destinations)
20 destinations(destinations),
21 assignments(assignments),
22 lowestAssignmentLevel(
std::numeric_limits<int64_t>::max()),
23 highestAssignmentLevel(
std::numeric_limits<int64_t>::min()) {
28 destinations.emplace_back(destination);
32 return assignments.
add(assignment, addToExisting);
36 lowestAssignmentLevel = std::numeric_limits<int64_t>::max();
37 highestAssignmentLevel = std::numeric_limits<int64_t>::min();
39 if (!destination.getOrderedAssignments().empty()) {
40 lowestAssignmentLevel = std::min(lowestAssignmentLevel, destination.getOrderedAssignments().getLowestLevel());
41 highestAssignmentLevel = std::max(highestAssignmentLevel, destination.getOrderedAssignments().getHighestLevel());
43 for (
auto const& assignment : destination.getOrderedAssignments().getAllAssignments()) {
44 Variable const& var = assignment.getVariable();
53 return writtenGlobalVariables;
65 return destinations.size();
77 return destinations[index];
89 bool const substituteTranscendentalNumbers) {
92 for (
auto& assignment : assignments) {
93 assignment.substitute(substitution, substituteTranscendentalNumbers);
96 for (
auto& destination : destinations) {
97 destination.substitute(substitution, substituteTranscendentalNumbers);
102 for (
auto& destination : destinations) {
103 destination.changeAssignmentVariables(remapping);
109 if (!destinations.empty()) {
110 auto const& destination = *destinations.begin();
112 std::vector<std::shared_ptr<Assignment>> assignmentsToLift;
114 for (
auto const& assignment : destination.getOrderedAssignments().getTransientAssignments()) {
116 bool canBeLifted = assignment.getLevel() <= maxLevel;
118 for (
auto const& destination : destinations) {
119 if (!destination.hasAssignment(assignment)) {
129 assignmentsToLift.push_back(std::make_shared<Assignment>(assignment));
134 for (
auto const& assignment : assignmentsToLift) {
136 for (
auto& destination : destinations) {
137 destination.removeAssignment(*assignment);
144 STORM_LOG_ASSERT(!destinations.empty(),
"Need non-empty destinations for this transformation.");
146 for (
auto& destination : destinations) {
147 destination.addAssignment(assignment,
true);
150 this->assignments.
clear();
154 for (
auto const& destination : destinations) {
155 for (
auto const& assignment : destination.getOrderedAssignments().getNonTransientAssignments()) {
156 if (assignment.getAssignedExpression().containsVariable(variables)) {
166 if (destination.hasTransientAssignment()) {
178 if (destination.usesAssignmentLevels(onlyTransient)) {
186 return lowestAssignmentLevel;
190 return highestAssignmentLevel;
194 for (
auto const& destination : destinations) {
195 if (destination.hasAssignments()) {
205 bool result = linearityChecker.
check(this->
getGuard(),
true);
206 for (
auto const& destination : destinations) {
207 result &= destination.isLinear();
214 if (assignments.
empty()) {
217 for (
auto const& dest : destinations) {
218 simplifiedTemplateEdge.
addDestination(dest.simplifyIndexedAssignments(syncronized, localVars));
220 return simplifiedTemplateEdge;
bool check(Expression const &expression, bool booleanIsLinear=false)
Checks that the given expression is linear.
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
bool hasMultipleLevels(bool onlyTransient=false) const
Checks whether the assignments have several levels.
void changeAssignmentVariables(std::map< Variable const *, std::reference_wrapper< Variable const > > const &remapping)
Changes all variables in assignments based on the given mapping.
bool empty(bool onlyTransient=false) const
Retrieves whether this set of assignments is empty.
OrderedAssignments simplifyLevels(bool synchronous, VariableSet const &localVars, bool first=true) const
Produces a new OrderedAssignments object with simplified leveling.
void clear()
Removes all assignments from this set.
bool add(Assignment const &assignment, bool addToExisting=false)
Adds the given assignment to the set of assignments.
bool hasTransientEdgeDestinationAssignments() const
Retrieves whether there is any transient edge destination assignment in the edge.
void finalize(Model const &containingModel)
Finalizes the building of this edge.
storm::expressions::Expression const & getGuard() const
bool usesVariablesInNonTransientAssignments(std::set< storm::expressions::Variable > const &variables) const
Checks whether the provided variables appear on the right-hand side of non-transient assignments.
std::vector< TemplateEdgeDestination > const & getDestinations() const
int64_t const & getLowestAssignmentLevel() const
Retrieves the lowest assignment level occurring in a destination assignment.
bool isLinear() const
Checks the template edge for linearity.
bool usesAssignmentLevels(bool onlyTransient=false) const
Retrieves whether the edge uses an assignment level other than zero.
void setGuard(storm::expressions::Expression const &newGuard)
void liftTransientDestinationAssignments(int64_t maxLevel=0)
Finds the transient assignments common to all destinations and lifts them to the edge.
OrderedAssignments const & getAssignments() const
std::size_t getNumberOfDestinations() const
int64_t const & getHighestAssignmentLevel() const
Retrieves the highest assignment level occurring in a destination assignment If no assignment exists,...
void pushAssignmentsToDestinations()
Shifts the assingments from the edges to the destinations.
bool hasEdgeDestinationAssignments() const
void substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution, bool const substituteTranscendentalNumbers)
Substitutes all variables in all expressions according to the given substitution.
bool addTransientAssignment(Assignment const &assignment, bool addToExisting=false)
Adds a transient assignment to this edge.
void changeAssignmentVariables(std::map< Variable const *, std::reference_wrapper< Variable const > > const &remapping)
Changes all variables in assignments based on the given mapping.
TemplateEdge simplifyIndexedAssignments(bool syncronized, VariableSet const &localVars) const
Simplify Indexed Assignments.
TemplateEdgeDestination const & getDestination(uint64_t index) const
storm::storage::FlatSet< storm::expressions::Variable > const & getWrittenGlobalVariables() const
Retrieves a set of (global) variables that are written by at least one of the edge's destinations.
void addDestination(TemplateEdgeDestination const &destination)
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.
#define STORM_LOG_ASSERT(cond, message)
storm::expressions::Expression substituteJaniExpression(storm::expressions::Expression const &expression, std::map< storm::expressions::Variable, storm::expressions::Expression > const &identifierToExpressionMap, bool const substituteTranscendentalNumbers)
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.