Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
EdgeContainer.cpp
Go to the documentation of this file.
6
7namespace storm {
8namespace jani {
9namespace detail {
10Edges::Edges(iterator it, iterator ite) : it(it), ite(ite) {
11 // Intentionally left empty.
12}
13
15 return it;
16}
17
19 return ite;
20}
21
22bool Edges::empty() const {
23 return it == ite;
24}
25
26std::size_t Edges::size() const {
27 return std::distance(it, ite);
28}
29
31 // Intentionally left empty.
32}
33
37
39 return ite;
40}
41
42bool ConstEdges::empty() const {
43 return it == ite;
44}
45
46std::size_t ConstEdges::size() const {
47 return std::distance(it, ite);
48}
49} // namespace detail
50
52 edges = other.getConcreteEdges();
53 // templates = other.templates;
54 std::map<std::shared_ptr<TemplateEdge>, std::shared_ptr<TemplateEdge>> map;
55 for (auto const& te : other.templates) {
56 auto newTe = std::make_shared<TemplateEdge>(*te);
57 this->templates.insert(newTe);
58 map[te] = newTe;
59 }
60
61 for (auto& e : edges) {
62 if (map.count(e.getTemplateEdge()) == 0) {
63 e.setTemplateEdge(std::make_shared<TemplateEdge>(*(e.getTemplateEdge())));
64 } else {
65 e.setTemplateEdge(map[e.getTemplateEdge()]);
66 }
67 }
68}
69
71 EdgeContainer otherCpy(other);
72 this->templates = std::move(otherCpy.templates);
73 this->edges = std::move(otherCpy.edges);
74 return *this;
75}
76
77void EdgeContainer::finalize(Model const& containingModel) {
78 templates.clear();
79 for (auto& edge : edges) {
80 templates.insert(edge.getTemplateEdge());
81 }
82 for (auto& templateEdge : templates) {
83 templateEdge->finalize(containingModel);
84 }
85}
86
88 edges.clear();
89}
90
92 for (auto& templateEdge : templates) {
93 templateEdge->liftTransientDestinationAssignments(maxLevel);
94 }
95}
96
97void EdgeContainer::substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution,
98 bool const substituteTranscendentalNumbers) {
99 for (auto& templateEdge : templates) {
100 templateEdge->substitute(substitution, substituteTranscendentalNumbers);
101 }
102 for (auto& edge : edges) {
103 edge.substitute(substitution, substituteTranscendentalNumbers);
104 }
105}
106
108 for (auto const& templateEdge : templates) {
109 if (!templateEdge->isLinear()) {
110 return false;
111 }
112 }
113 return true;
114}
115
116bool EdgeContainer::usesAssignmentLevels(bool onlyTransient) const {
117 for (auto const& edge : edges) {
118 if (edge.usesAssignmentLevels(onlyTransient)) {
119 return true;
120 }
121 }
122 return false;
123}
124
126 return edges;
127}
128
129std::vector<Edge> const& EdgeContainer::getConcreteEdges() const {
130 return edges;
131}
132
134 return templates;
135}
136
137std::set<uint64_t> EdgeContainer::getActionIndices() const {
138 std::set<uint64_t> result;
139 for (auto const& edge : edges) {
140 result.insert(edge.getActionIndex());
141 }
142 return result;
143}
144
151void EdgeContainer::insertEdge(Edge const& e, uint64_t locStart, uint64_t locEnd) {
152 assert(locStart <= locEnd);
153 // Find the right position for the edge and insert it properly.
154 auto posIt = edges.begin();
155 std::advance(posIt, locEnd);
156 edges.insert(posIt, e);
157
158 // Sort all edges form the source location of the newly introduced edge by their action indices.
159 auto it = edges.begin();
160 std::advance(it, locStart);
161 auto ite = edges.begin();
162 std::advance(ite, locEnd + 1);
163 std::sort(it, ite, [](Edge const& a, Edge const& b) { return a.getActionIndex() < b.getActionIndex(); });
164}
165
166void EdgeContainer::insertTemplateEdge(std::shared_ptr<TemplateEdge> const& te) {
167 templates.insert(te);
168}
169
171 for (auto& templateEdge : templates) {
172 templateEdge->pushAssignmentsToDestinations();
173 }
174}
175
176void EdgeContainer::changeAssignmentVariables(std::map<Variable const*, std::reference_wrapper<Variable const>> const& remapping) {
177 for (auto& templateEdge : templates) {
178 templateEdge->changeAssignmentVariables(remapping);
179 }
180}
181
182size_t EdgeContainer::size() const {
183 return edges.size();
184}
185
187 return edges.begin();
188}
190 return edges.end();
191}
193 return edges.begin();
194}
196 return edges.end();
197}
198
199} // namespace jani
200} // namespace storm
EdgeContainer & operator=(EdgeContainer const &other)
void changeAssignmentVariables(std::map< Variable const *, std::reference_wrapper< Variable const > > const &remapping)
std::set< uint64_t > getActionIndices() const
TemplateEdgeContainer const & getTemplateEdges() const
void insertEdge(Edge const &e, uint64_t locStart, uint64_t locEnd)
Insert an edge, then sort the range between locstart and locend according to the action index.
void finalize(Model const &containingModel)
std::vector< Edge >::iterator iterator
std::vector< Edge > const & getConcreteEdges() const
void insertTemplateEdge(std::shared_ptr< TemplateEdge > const &te)
std::vector< Edge >::const_iterator const_iterator
bool usesAssignmentLevels(bool onlyTransient=false) const
void liftTransientDestinationAssignments(int64_t maxLevel=0)
void substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution, bool const substituteTranscendentalNumbers)
uint64_t getActionIndex() const
Retrieves the id of the action with which this edge is labeled.
Definition Edge.cpp:45
bool empty() const
Determines whether this set of edges is empty.
const_iterator end() const
Retrieves an end iterator to the edges.
std::vector< Edge >::const_iterator const_iterator
ConstEdges(const_iterator it, const_iterator ite)
const_iterator begin() const
Retrieves an iterator to the edges.
std::size_t size() const
Retrieves the number of edges.
Edges(iterator it, iterator ite)
iterator begin() const
Retrieves an iterator to the edges.
std::vector< Edge >::iterator iterator
bool empty() const
Determines whether this set of edges is empty.
iterator end() const
Retrieves an end iterator to the edges.
std::size_t size() const
Retrieves the number of edges.
LabParser.cpp.
Definition cli.cpp:18