Merge lp:~verifypn-cpn/verifypn/partitioning into lp:verifypn
- partitioning
- Merge into new-trunk
Proposed by
Thomas Pedersen
Status: | Merged |
---|---|
Approved by: | Jiri Srba |
Approved revision: | 277 |
Merged at revision: | 234 |
Proposed branch: | lp:~verifypn-cpn/verifypn/partitioning |
Merge into: | lp:verifypn |
Diff against target: |
473 lines (+183/-41) 9 files modified
include/PetriEngine/Colored/Colors.h (+15/-0) include/PetriEngine/Colored/Expressions.h (+13/-7) include/PetriEngine/Colored/Intervals.h (+1/-7) include/PetriEngine/Colored/PartitionBuilder.h (+11/-1) include/PetriParse/PNMLParser.h (+4/-0) src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp (+17/-13) src/PetriEngine/Colored/PartitionBuilder.cpp (+14/-0) src/PetriParse/PNMLParser.cpp (+107/-13) src/VerifyPN.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~verifypn-cpn/verifypn/partitioning |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Approve | ||
Peter Gjøl Jensen | Pending | ||
Review via email: mp+401702@code.launchpad.net |
Commit message
Merge in parsing of vehicularWifi (Untested)
Description of the change
To post a comment you must log in.
Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote : | # |
Revision history for this message
Jiri Srba (srba) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'include/PetriEngine/Colored/Colors.h' |
2 | --- include/PetriEngine/Colored/Colors.h 2021-04-14 10:41:18 +0000 |
3 | +++ include/PetriEngine/Colored/Colors.h 2021-04-26 08:36:24 +0000 |
4 | @@ -207,6 +207,10 @@ |
5 | virtual void getColortypes(std::vector<ColorType *> &colorTypes){ |
6 | colorTypes.push_back(this); |
7 | } |
8 | + |
9 | + virtual void printConstituents(){ |
10 | + std::cout << _name << std::endl; |
11 | + } |
12 | |
13 | virtual const Color& operator[] (size_t index) { |
14 | return _colors[index]; |
15 | @@ -322,6 +326,12 @@ |
16 | return true; |
17 | } |
18 | |
19 | + void printConstituents() override{ |
20 | + for(auto ct : constituents){ |
21 | + ct->printConstituents(); |
22 | + } |
23 | + } |
24 | + |
25 | const ColorType* getNestedColorType(size_t index) { |
26 | return constituents[index]; |
27 | } |
28 | @@ -377,6 +387,11 @@ |
29 | return true; |
30 | } |
31 | }; |
32 | + |
33 | + struct ColorTypePartition { |
34 | + std::vector<const Color *> colors; |
35 | + std::string name; |
36 | + }; |
37 | } |
38 | } |
39 | |
40 | |
41 | === modified file 'include/PetriEngine/Colored/Expressions.h' |
42 | --- include/PetriEngine/Colored/Expressions.h 2021-04-14 11:51:52 +0000 |
43 | +++ include/PetriEngine/Colored/Expressions.h 2021-04-26 08:36:24 +0000 |
44 | @@ -62,6 +62,7 @@ |
45 | ProductType* findProductColorType(const std::vector<const ColorType*>& types) const { |
46 | for (auto& elem : colorTypes) { |
47 | auto* pt = dynamic_cast<ProductType*>(elem.second); |
48 | + |
49 | if (pt && pt->containsTypes(types)) { |
50 | return pt; |
51 | } |
52 | @@ -490,7 +491,7 @@ |
53 | types.push_back(colors.back()->getColorType()); |
54 | } |
55 | ProductType* pt = context.findProductColorType(types); |
56 | - |
57 | + assert(pt != nullptr); |
58 | const Color* col = pt->getColor(colors); |
59 | assert(col != nullptr); |
60 | return col; |
61 | @@ -548,17 +549,24 @@ |
62 | } |
63 | |
64 | ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{ |
65 | + |
66 | std::vector<const ColorType*> types; |
67 | + if(_colorType != nullptr){ |
68 | + return _colorType; |
69 | + } |
70 | + |
71 | for (auto color : _colors) { |
72 | types.push_back(color->getColorType(colorTypes)); |
73 | } |
74 | - for (auto& elem : colorTypes) { |
75 | + |
76 | + for (auto elem : colorTypes) { |
77 | auto* pt = dynamic_cast<ProductType*>(elem.second); |
78 | if (pt && pt->containsTypes(types)) { |
79 | return pt; |
80 | } |
81 | } |
82 | std::cout << "COULD NOT FIND PRODUCT TYPE" << std::endl; |
83 | + assert(false); |
84 | return nullptr; |
85 | } |
86 | |
87 | @@ -1160,7 +1168,6 @@ |
88 | for (auto elem : _color) { |
89 | //TODO: can there be more than one element in a number of expression? |
90 | elem->getVariables(variables, varPositions, varModifierMap, index); |
91 | - //(*index)++; |
92 | } |
93 | } |
94 | |
95 | @@ -1168,13 +1175,13 @@ |
96 | if (_all != nullptr) { |
97 | return _all->getArcIntervals(arcIntervals, cfp, index, modifier); |
98 | } |
99 | - uint32_t i = 0; |
100 | + //uint32_t i = 0; |
101 | for (auto elem : _color) { |
102 | - (*index) += i; |
103 | + //(*index) += i; |
104 | if(!elem->getArcIntervals(arcIntervals, cfp, index, modifier)){ |
105 | return false; |
106 | } |
107 | - i++; |
108 | + //i++; |
109 | } |
110 | return true; |
111 | } |
112 | @@ -1210,7 +1217,6 @@ |
113 | for(auto pair : elemMap){ |
114 | constantMap[pair.first].push_back(pair.second); |
115 | } |
116 | - index++;//not sure if index should be increased here, but no number expression have multiple elements |
117 | } |
118 | } |
119 | |
120 | |
121 | === modified file 'include/PetriEngine/Colored/Intervals.h' |
122 | --- include/PetriEngine/Colored/Intervals.h 2021-04-14 10:41:18 +0000 |
123 | +++ include/PetriEngine/Colored/Intervals.h 2021-04-26 08:36:24 +0000 |
124 | @@ -360,15 +360,9 @@ |
125 | enum FoundPlace {undecided, greater, lower}; |
126 | FoundPlace foundPlace = undecided; |
127 | |
128 | - //uint32_t allowedDist = 1; |
129 | - |
130 | for(uint32_t k = 0; k < interval.size(); k++){ |
131 | if(interval[k]._lower > localInterval[k]._upper || localInterval[k]._lower > interval[k]._upper){ |
132 | - //if(interval[k]._lower > localInterval[k]._upper + allowedDist || localInterval[k]._lower > interval[k]._upper + allowedDist){ |
133 | - extendsInterval = false; |
134 | - // } else { |
135 | - // allowedDist = 0; |
136 | - // } |
137 | + extendsInterval = false; |
138 | } |
139 | if(interval[k]._lower < localInterval[k]._lower){ |
140 | if(foundPlace == undecided){ |
141 | |
142 | === modified file 'include/PetriEngine/Colored/PartitionBuilder.h' |
143 | --- include/PetriEngine/Colored/PartitionBuilder.h 2021-04-07 08:41:47 +0000 |
144 | +++ include/PetriEngine/Colored/PartitionBuilder.h 2021-04-26 08:36:24 +0000 |
145 | @@ -6,7 +6,17 @@ |
146 | namespace Colored { |
147 | class PartitionBuilder { |
148 | public: |
149 | - PartitionBuilder(std::vector<Transition> *transitions, std::vector<Place> *places, std::unordered_map<uint32_t,std::vector<uint32_t>> *placePostTransitionMap, std::unordered_map<uint32_t,std::vector<uint32_t>> *placePreTransitionMap); |
150 | + PartitionBuilder(std::vector<Transition> *transitions, |
151 | + std::vector<Place> *places, |
152 | + std::unordered_map<uint32_t,std::vector<uint32_t>> *placePostTransitionMap, |
153 | + std::unordered_map<uint32_t,std::vector<uint32_t>> *placePreTransitionMap); |
154 | + |
155 | + PartitionBuilder(std::vector<Transition> *transitions, |
156 | + std::vector<Place> *places, |
157 | + std::unordered_map<uint32_t,std::vector<uint32_t>> *placePostTransitionMap, |
158 | + std::unordered_map<uint32_t,std::vector<uint32_t>> *placePreTransitionMap, |
159 | + std::vector<Colored::ColorFixpoint> *placeColorFixpoints); |
160 | + |
161 | ~PartitionBuilder() {} |
162 | |
163 | //void initPartition(); |
164 | |
165 | === modified file 'include/PetriParse/PNMLParser.h' |
166 | --- include/PetriParse/PNMLParser.h 2021-04-14 10:41:18 +0000 |
167 | +++ include/PetriParse/PNMLParser.h 2021-04-26 08:36:24 +0000 |
168 | @@ -83,6 +83,7 @@ |
169 | void parseArc(rapidxml::xml_node<>* element, bool inhibitor = false); |
170 | void parseTransition(rapidxml::xml_node<>* element); |
171 | void parseDeclarations(rapidxml::xml_node<>* element); |
172 | + void parsePartitions(rapidxml::xml_node<>* element); |
173 | void parseNamedSort(rapidxml::xml_node<>* element); |
174 | PetriEngine::Colored::ArcExpression_ptr parseArcExpression(rapidxml::xml_node<>* element); |
175 | PetriEngine::Colored::GuardExpression_ptr parseGuardExpression(rapidxml::xml_node<>* element, bool notFlag); |
176 | @@ -99,6 +100,7 @@ |
177 | void parseQueries(rapidxml::xml_node<>* element); |
178 | const PetriEngine::Colored::Color* findColor(const char* name) const; |
179 | const PetriEngine::Colored::Color* findColorForIntRange(const char* value, uint32_t start, uint32_t end) const; |
180 | + std::vector<PetriEngine::Colored::ColorExpression_ptr> findPartitionColors(rapidxml::xml_node<>* element) const; |
181 | std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> cartesianProduct(std::vector<PetriEngine::Colored::ColorExpression_ptr> rightVector, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftVector); |
182 | std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> cartesianProduct(std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> rightVector, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftVector); |
183 | PetriEngine::AbstractPetriNetBuilder* builder; |
184 | @@ -110,6 +112,8 @@ |
185 | VariableMap variables; |
186 | bool isColored; |
187 | std::vector<Query> queries; |
188 | + std::vector<PetriEngine::Colored::ColorTypePartition> partitions; |
189 | + std::vector<std::pair<char *, PetriEngine::Colored::ProductType*>> missingCTs; |
190 | }; |
191 | |
192 | #endif // PNMLPARSER_H |
193 | \ No newline at end of file |
194 | |
195 | === modified file 'src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp' |
196 | --- src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp 2021-04-14 11:51:52 +0000 |
197 | +++ src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp 2021-04-26 08:36:24 +0000 |
198 | @@ -138,6 +138,21 @@ |
199 | void ColoredPetriNetBuilder::sort() { |
200 | } |
201 | |
202 | + //----------------------- Partitioning -----------------------// |
203 | + |
204 | + void ColoredPetriNetBuilder::computePartition(){ |
205 | + auto partitionStart = std::chrono::high_resolution_clock::now(); |
206 | + Colored::PartitionBuilder pBuilder = _fixpointDone? Colored::PartitionBuilder(&_transitions, &_places, &_placePostTransitionMap, &_placePreTransitionMap, &_placeColorFixpoints) : Colored::PartitionBuilder(&_transitions, &_places, &_placePostTransitionMap, &_placePreTransitionMap); |
207 | + |
208 | + pBuilder.partitionNet(); |
209 | + //pBuilder.printPartion(); |
210 | + _partition = pBuilder.getPartition(); |
211 | + pBuilder.assignColorMap(_partition); |
212 | + _partitionComputed = true; |
213 | + auto partitionEnd = std::chrono::high_resolution_clock::now(); |
214 | + _partitionTimer = (std::chrono::duration_cast<std::chrono::microseconds>(partitionEnd - partitionStart).count())*0.000001; |
215 | + } |
216 | + |
217 | //----------------------- Color fixpoint -----------------------// |
218 | |
219 | void ColoredPetriNetBuilder::printPlaceTable() { |
220 | @@ -157,17 +172,7 @@ |
221 | } |
222 | } |
223 | |
224 | - void ColoredPetriNetBuilder::computePartition(){ |
225 | - auto partitionStart = std::chrono::high_resolution_clock::now(); |
226 | - Colored::PartitionBuilder pBuilder = Colored::PartitionBuilder(&_transitions, &_places, &_placePostTransitionMap, &_placePreTransitionMap); |
227 | - pBuilder.partitionNet(); |
228 | - //pBuilder.printPartion(); |
229 | - _partition = pBuilder.getPartition(); |
230 | - pBuilder.assignColorMap(_partition); |
231 | - _partitionComputed = true; |
232 | - auto partitionEnd = std::chrono::high_resolution_clock::now(); |
233 | - _partitionTimer = (std::chrono::duration_cast<std::chrono::microseconds>(partitionEnd - partitionStart).count())*0.000001; |
234 | - } |
235 | + |
236 | |
237 | void ColoredPetriNetBuilder::computePlaceColorFixpoint(uint32_t maxIntervals, uint32_t maxIntervalsReduced, int32_t timeout) { |
238 | //Start timers for timing color fixpoint creation and max interval reduction steps |
239 | @@ -334,7 +339,6 @@ |
240 | |
241 | void ColoredPetriNetBuilder::processOutputArcs(Colored::Transition& transition) { |
242 | bool transitionHasVarOutArcs = false; |
243 | - |
244 | for (auto& arc : transition.output_arcs) { |
245 | Colored::ColorFixpoint& placeFixpoint = _placeColorFixpoints[arc.place]; |
246 | //used to check if colors are added to the place. The total distance between upper and |
247 | @@ -351,7 +355,7 @@ |
248 | |
249 | //Apply partitioning to unbound outgoing variables such that |
250 | // bindings are only created for colors used in the rest of the net |
251 | - if(!_partition[arc.place].diagonal){ |
252 | + if(_partitionComputed && !_partition[arc.place].diagonal){ |
253 | for(auto outVar : variables){ |
254 | for(auto& varMap : transition.variableMaps){ |
255 | if(varMap.count(outVar) == 0){ |
256 | |
257 | === modified file 'src/PetriEngine/Colored/PartitionBuilder.cpp' |
258 | --- src/PetriEngine/Colored/PartitionBuilder.cpp 2021-04-14 10:41:18 +0000 |
259 | +++ src/PetriEngine/Colored/PartitionBuilder.cpp 2021-04-26 08:36:24 +0000 |
260 | @@ -22,6 +22,20 @@ |
261 | } |
262 | } |
263 | |
264 | + PartitionBuilder::PartitionBuilder(std::vector<Transition> *transitions, std::vector<Place> *places, std::unordered_map<uint32_t,std::vector<uint32_t>> *placePostTransitionMap, std::unordered_map<uint32_t,std::vector<uint32_t>> *placePreTransitionMap, std::vector<Colored::ColorFixpoint> *placeColorFixpoints) |
265 | + : _transitions(transitions), _places(places), _placePostTransitionMap(placePostTransitionMap), _placePreTransitionMap(placePreTransitionMap) { |
266 | + |
267 | + //Instantiate partitions |
268 | + for(uint32_t i = 0; i < _places->size(); i++){ |
269 | + auto place = _places->operator[](i); |
270 | + EquivalenceClass fullClass = EquivalenceClass(place.type); |
271 | + fullClass._colorIntervals = placeColorFixpoints->operator[](i).constraints; |
272 | + _partition[i]._equivalenceClasses.push_back(fullClass); |
273 | + _placeQueue.push_back(i); |
274 | + _inQueue[i] = true; |
275 | + } |
276 | + } |
277 | + |
278 | void PartitionBuilder::printPartion() { |
279 | for(auto equivalenceVec : _partition){ |
280 | std::cout << "Partition for place " << _places->operator[](equivalenceVec.first).name << std::endl; |
281 | |
282 | === modified file 'src/PetriParse/PNMLParser.cpp' |
283 | --- src/PetriParse/PNMLParser.cpp 2021-04-14 10:41:18 +0000 |
284 | +++ src/PetriParse/PNMLParser.cpp 2021-04-26 08:36:24 +0000 |
285 | @@ -154,8 +154,33 @@ |
286 | parseUserSort(it) |
287 | }; |
288 | variables[it->first_attribute("id")->value()] = var; |
289 | + } else if (strcmp(it->name(), "partition") == 0) { |
290 | + parsePartitions(it); |
291 | } else { |
292 | - parseDeclarations(element->first_node()); |
293 | + parseDeclarations(it); |
294 | + } |
295 | + } |
296 | + |
297 | + for(auto missingCTPair : missingCTs){ |
298 | + if(colorTypes.count(missingCTPair.first) == 0){ |
299 | + std::cerr << "Unable to find colortype " << missingCTPair.first << " used in product type " << missingCTPair.second->getName() << std::endl; |
300 | + exit(ErrorCode); |
301 | + } |
302 | + missingCTPair.second->addType(colorTypes[missingCTPair.first]); |
303 | + } |
304 | + missingCTs.clear(); |
305 | +} |
306 | + |
307 | +void PNMLParser::parsePartitions(rapidxml::xml_node<>* element){ |
308 | + auto partitionCT = parseUserSort(element); |
309 | + for (auto it = element->first_node(); it; it = it->next_sibling()) { |
310 | + if (strcmp(it->name(), "partitionelement") == 0) { |
311 | + auto id = it->first_attribute("id")->value(); |
312 | + std::vector<const PetriEngine::Colored::Color *> colors; |
313 | + for(auto partitionElement = it->first_node(); partitionElement; partitionElement = partitionElement->next_sibling()){ |
314 | + colors.push_back(partitionCT->operator[](partitionElement->first_attribute("declaration")->value())); |
315 | + } |
316 | + partitions.push_back({colors, id}); |
317 | } |
318 | } |
319 | } |
320 | @@ -177,9 +202,16 @@ |
321 | if (strcmp(type->name(), "dot") == 0) { |
322 | ct->addDot(); |
323 | } else if (strcmp(type->name(), "productsort") == 0) { |
324 | + bool missingType = false; |
325 | for (auto it = type->first_node(); it; it = it->next_sibling()) { |
326 | if (strcmp(it->name(), "usersort") == 0) { |
327 | - ((PetriEngine::Colored::ProductType*)ct)->addType(colorTypes[it->first_attribute("declaration")->value()]); |
328 | + auto ctName = it->first_attribute("declaration")->value(); |
329 | + if(!missingType && colorTypes.count(ctName)){ |
330 | + ((PetriEngine::Colored::ProductType*)ct)->addType(colorTypes[ctName]); |
331 | + } else { |
332 | + missingType = true; |
333 | + missingCTs.push_back(std::make_pair(ctName, (PetriEngine::Colored::ProductType*)ct)); |
334 | + } |
335 | } |
336 | } |
337 | } else if (strcmp(type->name(), "finiteintrange") == 0) { |
338 | @@ -232,7 +264,6 @@ |
339 | std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> collectedColors; |
340 | collectColorsInTuple(element, collectedColors); |
341 | auto expr = constructAddExpressionFromTupleExpression(element, collectedColors, 1); |
342 | - std::cout << expr->toString() << std::endl; |
343 | return expr; |
344 | } |
345 | printf("Could not parse '%s' as an arc expression\n", element->name()); |
346 | @@ -280,8 +311,9 @@ |
347 | std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> returnSet; |
348 | for(auto set : rightSet){ |
349 | for(auto expr2 : leftSet){ |
350 | - set.push_back(expr2); |
351 | - returnSet.push_back(set); |
352 | + auto setCopy = set; |
353 | + setCopy.push_back(expr2); |
354 | + returnSet.push_back(std::move(setCopy)); |
355 | } |
356 | } |
357 | return returnSet; |
358 | @@ -304,19 +336,43 @@ |
359 | } |
360 | } |
361 | collectedColors.push_back(expressionsToAdd); |
362 | - return; |
363 | + } else if (strcmp(element->name(), "add") == 0) { |
364 | + std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> intermediateColors; |
365 | + std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> intermediateColors2; |
366 | + for(auto it = element->first_node(); it; it = it->next_sibling()){ |
367 | + collectColorsInTuple(it, intermediateColors2); |
368 | + if(intermediateColors.empty()){ |
369 | + intermediateColors = intermediateColors2; |
370 | + } else { |
371 | + for(uint32_t i = 0; i < intermediateColors.size(); i++){ |
372 | + intermediateColors[i].insert(intermediateColors[i].end(), intermediateColors2[i].begin(), intermediateColors2[i].end()); |
373 | + } |
374 | + } |
375 | + |
376 | + } |
377 | + for(auto &colorVec : intermediateColors){ |
378 | + collectedColors.push_back(std::move(colorVec)); |
379 | + } |
380 | } else if (strcmp(element->name(), "subterm") == 0 || strcmp(element->name(), "structure") == 0) { |
381 | collectColorsInTuple(element->first_node(), collectedColors); |
382 | - } else if (strcmp(element->name(), "userOperator") == 0 || strcmp(element->name(), "dotconstant") == 0 || strcmp(element->name(), "variable") == 0 |
383 | + } else if (strcmp(element->name(), "finiteintrangeconstant") == 0){ |
384 | + std::vector<PetriEngine::Colored::ColorExpression_ptr> expressionsToAdd; |
385 | + auto value = element->first_attribute("value")->value(); |
386 | + auto intRangeElement = element->first_node("finiteintrange"); |
387 | + uint32_t start = (uint32_t)atoll(intRangeElement->first_attribute("start")->value()); |
388 | + uint32_t end = (uint32_t)atoll(intRangeElement->first_attribute("end")->value()); |
389 | + expressionsToAdd.push_back(std::make_shared<PetriEngine::Colored::UserOperatorExpression>(findColorForIntRange(value, start,end))); |
390 | + collectedColors.push_back(expressionsToAdd); |
391 | + } else if (strcmp(element->name(), "useroperator") == 0 || strcmp(element->name(), "dotconstant") == 0 || strcmp(element->name(), "variable") == 0 |
392 | || strcmp(element->name(), "successor") == 0 || strcmp(element->name(), "predecessor") == 0) { |
393 | - std::vector<PetriEngine::Colored::ColorExpression_ptr> expressionsToAdd; |
394 | - auto color = parseColorExpression(element); |
395 | - expressionsToAdd.push_back(color); |
396 | + std::vector<PetriEngine::Colored::ColorExpression_ptr> expressionsToAdd = findPartitionColors(element); |
397 | + if(expressionsToAdd.empty()){ |
398 | + auto color = parseColorExpression(element); |
399 | + expressionsToAdd.push_back(color); |
400 | + } |
401 | collectedColors.push_back(expressionsToAdd); |
402 | - return; |
403 | } else{ |
404 | - printf("Could not parse '%s' as an arc expression\n", element->name()); |
405 | - return; |
406 | + printf("Could not parse '%s' as an arc expression when collecting tuple colors\n", element->name()); |
407 | } |
408 | } |
409 | |
410 | @@ -563,6 +619,8 @@ |
411 | std::unordered_map<const PetriEngine::Colored::Variable*, const PetriEngine::Colored::Color*> binding; |
412 | PetriEngine::Colored::EquivalenceVec placePartition; |
413 | PetriEngine::Colored::ExpressionContext context {binding, colorTypes, placePartition}; |
414 | + for(auto ct : colorTypes){ |
415 | + } |
416 | hlinitialMarking = parseArcExpression(it->first_node("structure"))->eval(context); |
417 | } else if (strcmp(it->name(), "type") == 0) { |
418 | type = parseUserSort(it); |
419 | @@ -769,6 +827,42 @@ |
420 | exit(ErrorCode); |
421 | } |
422 | |
423 | +std::vector<PetriEngine::Colored::ColorExpression_ptr> PNMLParser::findPartitionColors(rapidxml::xml_node<>* element) const { |
424 | + std::vector<PetriEngine::Colored::ColorExpression_ptr> colorExpressions; |
425 | + char *name; |
426 | + if (strcmp(element->name(), "useroperator") == 0) { |
427 | + name = element->first_attribute("declaration")->value(); |
428 | + } else if (strcmp(element->name(), "successor") == 0) { |
429 | + auto colorExpressionVec = findPartitionColors(element->first_node()); |
430 | + for(auto &colorExpression : colorExpressionVec){ |
431 | + colorExpressions.push_back(std::make_shared<PetriEngine::Colored::SuccessorExpression>(std::move(colorExpression))); |
432 | + } |
433 | + return colorExpressions; |
434 | + } else if (strcmp(element->name(), "predecessor") == 0) { |
435 | + auto colorExpressionVec = findPartitionColors(element->first_node()); |
436 | + for(auto &colorExpression : colorExpressionVec){ |
437 | + colorExpressions.push_back(std::make_shared<PetriEngine::Colored::PredecessorExpression>(std::move(colorExpression))); |
438 | + } |
439 | + return colorExpressions; |
440 | + } else if (strcmp(element->name(), "variable") == 0 || strcmp(element->name(), "dotconstant") == 0 || strcmp(element->name(), "finiteintrangeconstant") == 0) { |
441 | + return colorExpressions; |
442 | + } else if (strcmp(element->name(), "subterm") == 0) { |
443 | + return findPartitionColors(element->first_node()); |
444 | + } else { |
445 | + printf("Could not find color expression in expression: %s\nCANNOT_COMPUTE\n", element->name()); |
446 | + exit(ErrorCode); |
447 | + } |
448 | + |
449 | + for (auto partition : partitions) { |
450 | + if (strcmp(partition.name.c_str(), name) == 0){ |
451 | + for(auto color : partition.colors){ |
452 | + colorExpressions.push_back(std::make_shared<PetriEngine::Colored::UserOperatorExpression>(color)); |
453 | + } |
454 | + } |
455 | + } |
456 | + return colorExpressions; |
457 | +} |
458 | + |
459 | const PetriEngine::Colored::Color* PNMLParser::findColorForIntRange(const char* value, uint32_t start, uint32_t end) const{ |
460 | for (const auto& elem : colorTypes) { |
461 | auto col = (*elem.second)[value]; |
462 | |
463 | === modified file 'src/VerifyPN.cpp' |
464 | --- src/VerifyPN.cpp 2021-04-16 18:53:36 +0000 |
465 | +++ src/VerifyPN.cpp 2021-04-26 08:36:24 +0000 |
466 | @@ -191,6 +191,7 @@ |
467 | } |
468 | } else if (strcmp(argv[i], "-e") == 0 || strcmp(argv[i], "--state-space-exploration") == 0) { |
469 | options.statespaceexploration = true; |
470 | + options.computePartition = false; |
471 | } else if (strcmp(argv[i], "-n") == 0 || strcmp(argv[i], "--no-statistics") == 0) { |
472 | options.printstatistics = false; |
473 | } else if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--trace") == 0) { |
passes all tests on the competition script