Merge lp:~tapaal-contributor/verifypn/unfoldTACPN into lp:verifypn

Proposed by Thomas Pedersen
Status: Needs review
Proposed branch: lp:~tapaal-contributor/verifypn/unfoldTACPN
Merge into: lp:verifypn
Diff against target: 3617 lines (+2252/-127) (has conflicts)
23 files modified
CMakeLists.txt (+4/-0)
include/PetriEngine/AbstractPetriNetBuilder.h (+92/-2)
include/PetriEngine/Colored/ColoredNetStructures.h (+23/-0)
include/PetriEngine/Colored/ColoredPetriNetBuilder.h (+97/-8)
include/PetriEngine/Colored/Colors.h (+34/-0)
include/PetriEngine/Colored/Expressions.h (+151/-8)
include/PetriEngine/Colored/TimeInterval.h (+118/-0)
include/PetriEngine/Colored/TimeInvariant.h (+87/-0)
include/PetriEngine/NetStructures.h (+15/-1)
include/PetriEngine/PetriNet.h (+27/-1)
include/PetriEngine/PetriNetBuilder.h (+25/-1)
include/PetriEngine/options.h (+10/-0)
include/PetriParse/PNMLParser.h (+31/-2)
src/PetriEngine/Colored/CMakeLists.txt (+6/-0)
src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp (+477/-9)
src/PetriEngine/Colored/Colors.cpp (+9/-0)
src/PetriEngine/Colored/TimeInterval.cpp (+91/-0)
src/PetriEngine/Colored/TimeInvariant.cpp (+71/-0)
src/PetriEngine/PQL/Expressions.cpp (+167/-0)
src/PetriEngine/PetriNet.cpp (+178/-32)
src/PetriEngine/PetriNetBuilder.cpp (+110/-6)
src/PetriParse/PNMLParser.cpp (+357/-51)
src/VerifyPN.cpp (+72/-6)
Text conflict in CMakeLists.txt
Text conflict in include/PetriEngine/Colored/ColoredNetStructures.h
Text conflict in include/PetriEngine/Colored/ColoredPetriNetBuilder.h
Text conflict in include/PetriEngine/Colored/Colors.h
Text conflict in include/PetriEngine/Colored/Expressions.h
Text conflict in include/PetriEngine/PetriNet.h
Text conflict in include/PetriEngine/options.h
Text conflict in include/PetriParse/PNMLParser.h
Text conflict in src/PetriEngine/Colored/CMakeLists.txt
Text conflict in src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp
Text conflict in src/PetriEngine/PQL/Expressions.cpp
Text conflict in src/PetriEngine/PetriNet.cpp
Text conflict in src/PetriEngine/PetriNetBuilder.cpp
Text conflict in src/PetriParse/PNMLParser.cpp
Text conflict in src/VerifyPN.cpp
To merge this branch: bzr merge lp:~tapaal-contributor/verifypn/unfoldTACPN
Reviewer Review Type Date Requested Status
Peter Gjøl Jensen Pending
Jiri Srba Pending
Review via email: mp+395537@code.launchpad.net

Commit message

Merge in unfolding of TACPNs and adjust output of unfolded model and queries to fit with GUI

To post a comment you must log in.
235. By Thomas Pedersen <email address hidden>

Add colortype to dot colors and fix writing of arc weights

236. By Thomas Pedersen <email address hidden>

Expand timed net detection and handle missing invariants

237. By Thomas Pedersen <email address hidden>

Use same query writing method

238. By Thomas Pedersen <email address hidden>

Handle inhibitor arcs in CPNs

239. By Thomas Pedersen <email address hidden>

Remove expressions from inhibitor arcs and handle .all in tuples

240. By Thomas Pedersen <email address hidden>

Fix parsing of useroperators

Unmerged revisions

240. By Thomas Pedersen <email address hidden>

Fix parsing of useroperators

239. By Thomas Pedersen <email address hidden>

Remove expressions from inhibitor arcs and handle .all in tuples

238. By Thomas Pedersen <email address hidden>

Handle inhibitor arcs in CPNs

237. By Thomas Pedersen <email address hidden>

Use same query writing method

236. By Thomas Pedersen <email address hidden>

Expand timed net detection and handle missing invariants

235. By Thomas Pedersen <email address hidden>

Add colortype to dot colors and fix writing of arc weights

234. By Thomas Pedersen <email address hidden>

Merge with trunk

233. By Thomas Pedersen <email address hidden>

Adjust model and query output to work with gui

232. By Thomas Pedersen <email address hidden>

Fix some errors when passing colored net from GUI and creating reduced query

231. By Thomas Pedersen <email address hidden>

Fix parser check for time

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2021-04-16 19:23:03 +0000
3+++ CMakeLists.txt 2021-04-19 13:50:22 +0000
4@@ -15,7 +15,11 @@
5 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
6
7
8+<<<<<<< TREE
9 set(VERIFYPN_VERSION 4.1.0)
10+=======
11+set(VERIFYPN_VERSION 4.0.0)
12+>>>>>>> MERGE-SOURCE
13 add_compile_definitions(VERIFYPN_VERSION=\"${VERIFYPN_VERSION}\")
14
15 project(verifypn VERSION ${VERIFYPN_VERSION} LANGUAGES CXX C)
16
17=== modified file 'include/PetriEngine/AbstractPetriNetBuilder.h'
18--- include/PetriEngine/AbstractPetriNetBuilder.h 2020-03-02 21:03:24 +0000
19+++ include/PetriEngine/AbstractPetriNetBuilder.h 2021-04-19 13:50:22 +0000
20@@ -25,6 +25,8 @@
21 #include "PQL/PQL.h"
22 #include "Colored/Multiset.h"
23 #include "Colored/Expressions.h"
24+#include "Colored/TimeInvariant.h"
25+#include "Colored/TimeInterval.h"
26
27 namespace PetriEngine {
28
29@@ -32,6 +34,7 @@
30 class AbstractPetriNetBuilder {
31 protected:
32 bool _isColored = false;
33+ bool _isTimed = false;
34
35 public:
36 /** Add a new place with a unique name */
37@@ -49,6 +52,35 @@
38 std::cerr << "Colored places are not supported in standard P/T nets" << std::endl;
39 exit(ErrorCode);
40 }
41+
42+ virtual void addPlace(const std::string& name,
43+ Colored::Multiset&& tokens,
44+ Colored::ColorType* type,
45+ std::vector<Colored::TimeInvariant>& invariant,
46+ double x = 0,
47+ double y = 0)
48+ {
49+ std::cerr << "Colored timed places are not supported in standard P/T nets" << std::endl;
50+ exit(ErrorCode);
51+ }
52+ /** Adds a new colored and timed place with a unique name */
53+ virtual void addPlace(const std::string& name,
54+ int tokens,
55+ Colored::TimeInvariant invariant,
56+ double x = 0,
57+ double y = 0)
58+ {
59+ std::cerr << "Colored timed places are not supported in standard P/T nets" << std::endl;
60+ exit(ErrorCode);
61+ }
62+
63+ // add a time transition with a unique name
64+ virtual void addTransition(const std::string &name, bool urgent,
65+ double, double)
66+ {
67+ std::cerr << "Timed transitions are not supported in standard P/T nets" << std::endl;
68+ exit(ErrorCode);
69+ }
70 /** Add a new transition with a unique name */
71 virtual void addTransition(const std::string& name,
72 double x = 0,
73@@ -62,6 +94,15 @@
74 std::cerr << "Colored transitions are not supported in standard P/T nets" << std::endl;
75 exit(ErrorCode);
76 }
77+ virtual void addTransition(const std::string& name,
78+ const Colored::GuardExpression_ptr& guard,
79+ bool urgent,
80+ double x,
81+ double y)
82+ {
83+ std::cerr << "Colored timed transitions are not supported in standard P/T nets" << std::endl;
84+ exit(ErrorCode);
85+ }
86 /** Add input arc with given weight */
87 virtual void addInputArc(const std::string& place,
88 const std::string& transition,
89@@ -70,15 +111,36 @@
90 /** Add colored input arc with given arc expression */
91 virtual void addInputArc(const std::string& place,
92 const std::string& transition,
93- const Colored::ArcExpression_ptr& expr)
94+ const Colored::ArcExpression_ptr& expr,
95+ bool inhibitor,
96+ int weight)
97 {
98 std::cerr << "Colored input arcs are not supported in standard P/T nets" << std::endl;
99 exit(ErrorCode);
100 }
101+ /* Add timed colored input arc with given arc expression*/
102+ virtual void addInputArc(const std::string &place,
103+ const std::string &transition,
104+ bool inhibitor, bool transport,
105+ int weight,
106+ PetriEngine::Colored::TimeInterval &interval, std::string transportID)
107+ {
108+ std::cerr << "Timed colored input arc are not supported in standard P/T nets" << std::endl;
109+ exit(ErrorCode);
110+ }
111+ virtual void addInputArc(const std::string &place,
112+ const std::string &transition,
113+ bool inhibitor, bool transport,
114+ const Colored::ArcExpression_ptr& expr,
115+ std::vector<PetriEngine::Colored::TimeInterval> &interval, int weight, std::string transportID)
116+ {
117+ std::cerr << "Timed colored input arc are not supported in standard P/T nets" << std::endl;
118+ exit(ErrorCode);
119+ }
120 /** Add output arc with given weight */
121 virtual void addOutputArc(const std::string& transition,
122 const std::string& place,
123- int weight = 1) = 0;
124+ int weight = 1, bool transport = false, std::string transportID = "") = 0;
125 /** Add output arc with given arc expression */
126 virtual void addOutputArc(const std::string& transition,
127 const std::string& place,
128@@ -87,6 +149,25 @@
129 std::cerr << "Colored output arcs are not supported in standard P/T nets" << std::endl;
130 exit(ErrorCode);
131 }
132+ virtual void addOutputArc(const std::string& transition,
133+ const std::string& place,
134+ const Colored::ArcExpression_ptr& expr, bool transport, std::string transportID)
135+ {
136+ std::cerr << "Colored output arcs are not supported in standard P/T nets" << std::endl;
137+ exit(ErrorCode);
138+ }
139+
140+ /* Add transport arc with given arc expression */
141+ virtual void addTransportArc(const std::string& source,
142+ const std::string& transition,
143+ const std::string& destination,
144+ const Colored::ArcExpression_ptr& expr,
145+ std::vector<Colored::TimeInterval>& interval)
146+ {
147+ std::cerr << "Transport arcs are not supported in standard P/T nets" << std::endl;
148+ exit(ErrorCode);
149+ }
150+
151 /** Add color types with id */
152 virtual void addColorType(const std::string& id,
153 Colored::ColorType* type)
154@@ -103,6 +184,14 @@
155 return _isColored;
156 }
157
158+ virtual void enableTimed() {
159+ _isTimed = true;
160+ }
161+
162+ virtual bool isTimed() const {
163+ return _isTimed;
164+ }
165+
166 virtual void sort() = 0;
167
168 virtual ~AbstractPetriNetBuilder() {
169@@ -112,3 +201,4 @@
170 }
171
172 #endif // ABSTRACTPETRINETBUILDER_H
173+
174
175=== modified file 'include/PetriEngine/Colored/ColoredNetStructures.h'
176--- include/PetriEngine/Colored/ColoredNetStructures.h 2021-03-15 10:04:47 +0000
177+++ include/PetriEngine/Colored/ColoredNetStructures.h 2021-04-19 13:50:22 +0000
178@@ -26,6 +26,8 @@
179 #include "Colors.h"
180 #include "Expressions.h"
181 #include "Multiset.h"
182+#include "TimeInterval.h"
183+#include "TimeInvariant.h"
184
185 namespace PetriEngine {
186 namespace Colored {
187@@ -35,21 +37,42 @@
188 uint32_t transition;
189 ArcExpression_ptr expr;
190 bool input;
191+ bool inhibitor = false;
192+ bool transport;
193+ int weight;
194+ std::vector<Colored::TimeInterval> interval;
195+ std::string transportID;
196+ };
197+
198+ struct TransportArc {
199+ uint32_t source;
200+ uint32_t transition;
201+ uint32_t destination;
202+ ArcExpression_ptr expr;
203+ std::vector<Colored::TimeInterval> interval;
204 };
205
206 struct Transition {
207 std::string name;
208 GuardExpression_ptr guard;
209+<<<<<<< TREE
210 std::vector<Arc> input_arcs;
211 std::vector<Arc> output_arcs;
212 std::vector<std::unordered_map<const Colored::Variable *, Colored::intervalTuple_t>> variableMaps;
213 bool considered;
214+=======
215+ bool urgent;
216+ std::vector<Arc> arcs;
217+ //bool inhibitor = false;
218+>>>>>>> MERGE-SOURCE
219 };
220
221 struct Place {
222 std::string name;
223 ColorType* type;
224 Multiset marking;
225+ std::vector<Colored::TimeInvariant> invariants;
226+ //bool inhibitor = false;
227 };
228 }
229 }
230
231=== modified file 'include/PetriEngine/Colored/ColoredPetriNetBuilder.h'
232--- include/PetriEngine/Colored/ColoredPetriNetBuilder.h 2021-04-14 10:41:18 +0000
233+++ include/PetriEngine/Colored/ColoredPetriNetBuilder.h 2021-04-19 13:50:22 +0000
234@@ -51,6 +51,12 @@
235 Colored::Multiset&& tokens,
236 double x = 0,
237 double y = 0) override;
238+ void addPlace(const std::string& name,
239+ Colored::Multiset&& tokens,
240+ Colored::ColorType* type,
241+ std::vector<Colored::TimeInvariant>& invariant,
242+ double x = 0,
243+ double y = 0) override;
244 void addTransition(const std::string& name,
245 double x = 0,
246 double y = 0) override;
247@@ -58,22 +64,49 @@
248 const Colored::GuardExpression_ptr& guard,
249 double x = 0,
250 double y = 0) override;
251+ void addTransition(const std::string& name,
252+ const Colored::GuardExpression_ptr& guard,
253+ bool urgent,
254+ double x,
255+ double y) override;
256 void addInputArc(const std::string& place,
257 const std::string& transition,
258 bool inhibitor,
259 int) override;
260+ void addInputArc(const std::string &place,
261+ const std::string &transition,
262+ bool inhibitor, bool transport,
263+ const Colored::ArcExpression_ptr& expr,
264+ std::vector<PetriEngine::Colored::TimeInterval> &interval,
265+ int weight,
266+ std::string transportID) override;
267 void addInputArc(const std::string& place,
268 const std::string& transition,
269- const Colored::ArcExpression_ptr& expr) override;
270- void addOutputArc(const std::string& transition,
271- const std::string& place,
272- int weight = 1) override;
273- void addOutputArc(const std::string& transition,
274- const std::string& place,
275- const Colored::ArcExpression_ptr& expr) override;
276+ const Colored::ArcExpression_ptr& expr,
277+ bool inhibitor,
278+ int weight) override;
279+
280+ void addOutputArc(const std::string& transition,
281+ const std::string& place,
282+ const Colored::ArcExpression_ptr& expr,
283+ bool transport,
284+ std::string transportID) override;
285+ void addOutputArc(const std::string& transition,
286+ const std::string& place,
287+ const Colored::ArcExpression_ptr& expr) override;
288+ void addOutputArc(const std::string& transition,
289+ const std::string& place,
290+ int weight = 1, bool transport = false, std::string transportID = "") override;
291 void addColorType(const std::string& id,
292 Colored::ColorType* type) override;
293
294+ void addTransportArc(const std::string& source,
295+ const std::string& transition,
296+ const std::string& destination,
297+ const Colored::ArcExpression_ptr& expr,
298+ std::vector<Colored::TimeInterval>& interval) override;
299+
300+
301
302 void sort() override;
303
304@@ -139,12 +172,15 @@
305 return _pttransitionnames;
306 }
307
308+ std::map<std::string, std::string> getInvariants() {return _invariantStrings;}
309+
310 PetriNetBuilder& unfold();
311 PetriNetBuilder& stripColors();
312 void computePlaceColorFixpoint(uint32_t max_intervals, uint32_t max_intervals_reduced, int32_t timeout);
313 void computePartition();
314
315 private:
316+ std::map<std::string, std::string> _invariantStrings;
317 std::unordered_map<std::string,uint32_t> _placenames;
318 std::unordered_map<std::string,uint32_t> _transitionnames;
319 std::unordered_map<uint32_t, std::unordered_map<uint32_t, Colored::ArcIntervals>> _arcIntervals;
320@@ -152,17 +188,24 @@
321 std::unordered_map<uint32_t,std::vector<uint32_t>> _placePreTransitionMap;
322 std::unordered_map<uint32_t,FixpointBindingGenerator> _bindings;
323 PTPlaceMap _ptplacenames;
324+ std::unordered_map<std::string, std::string> _shadowPlacesNames;
325 PTTransitionMap _pttransitionnames;
326+ std::vector< std::tuple<double, double> > _placelocations;
327+ std::vector< std::tuple<double, double> > _transitionlocations;
328 uint32_t _nptplaces = 0;
329 uint32_t _npttransitions = 0;
330 uint32_t _nptarcs = 0;
331 uint32_t _maxIntervals = 0;
332 PetriEngine::IntervalGenerator intervalGenerator;
333
334+ std::vector<Colored::Transition> _transitions;
335 std::vector<Colored::Place> _places;
336- std::vector<Colored::Transition> _transitions;
337 std::vector<Colored::Arc> _arcs;
338+<<<<<<< TREE
339 std::vector<Colored::ColorFixpoint> _placeColorFixpoints;
340+=======
341+ std::vector<Colored::Arc> inhibitorArcs;
342+>>>>>>> MERGE-SOURCE
343 ColorTypeMap _colors;
344 PetriNetBuilder _ptBuilder;
345 bool _unfolded = false;
346@@ -191,21 +234,40 @@
347 void addArc(const std::string& place,
348 const std::string& transition,
349 const Colored::ArcExpression_ptr& expr,
350+<<<<<<< TREE
351 bool input);
352
353
354 void getArcIntervals(Colored::Transition& transition, bool &transitionActivated, uint32_t max_intervals, uint32_t transitionId);
355 void processInputArcs(Colored::Transition& transition, uint32_t currentPlaceId, uint32_t transitionId, bool &transitionActivated, uint32_t max_intervals);
356 void processOutputArcs(Colored::Transition& transition);
357+=======
358+ bool input, bool inhibitor, int weight);
359+
360+ void addTimedArc(const std::string& place,
361+ const std::string& transition,
362+ const Colored::ArcExpression_ptr& expr,
363+ std::vector<Colored::TimeInterval>& interval,
364+ bool inhibitor, bool transport,
365+ bool input, int weight, std::string transportID);
366+>>>>>>> MERGE-SOURCE
367
368+<<<<<<< TREE
369 void unfoldPlace(const Colored::Place* place, const PetriEngine::Colored::Color *color, uint32_t unfoldPlace, uint32_t id);
370+=======
371+ Colored::TimeInterval getTimeIntervalForArc(std::vector< Colored::TimeInterval> timeIntervals,const Colored::Color* color);
372+ void unfoldPlace(Colored::Place& place);
373+ Colored::TimeInvariant getTimeInvariantForPlace(std::vector< Colored::TimeInvariant> TimeInvariants, const Colored::Color* color);
374+>>>>>>> MERGE-SOURCE
375 void unfoldTransition(Colored::Transition& transition);
376 void handleOrphanPlace(Colored::Place& place, std::unordered_map<std::string, uint32_t> unfoldedPlaceMap);
377 void createPartionVarmaps();
378
379 void unfoldArc(Colored::Arc& arc, Colored::ExpressionContext::BindingMap& binding, std::string& name);
380+ void unfoldInhibitorArc(std::string &oldname, std::string &newname);
381 };
382
383+<<<<<<< TREE
384 //Used for checking if a variable is inside either a succ or pred expression
385 enum ExpressionType {
386 None,
387@@ -213,6 +275,33 @@
388 Succ
389 };
390
391+=======
392+ class BindingGenerator {
393+ public:
394+ class Iterator {
395+ private:
396+ BindingGenerator* _generator;
397+
398+ public:
399+ Iterator(BindingGenerator* generator);
400+
401+ bool operator==(Iterator& other);
402+ bool operator!=(Iterator& other);
403+ Iterator& operator++();
404+ const Colored::ExpressionContext::BindingMap operator++(int);
405+ Colored::ExpressionContext::BindingMap& operator*();
406+ };
407+ private:
408+ Colored::GuardExpression_ptr _expr;
409+ Colored::ExpressionContext::BindingMap _bindings;
410+ ColoredPetriNetBuilder::ColorTypeMap& _colorTypes;
411+
412+ bool eval();
413+
414+ public:
415+ BindingGenerator(Colored::Transition& transition,
416+ ColoredPetriNetBuilder::ColorTypeMap& colorTypes);
417+>>>>>>> MERGE-SOURCE
418
419 }
420
421
422=== modified file 'include/PetriEngine/Colored/Colors.h'
423--- include/PetriEngine/Colored/Colors.h 2021-04-14 10:41:18 +0000
424+++ include/PetriEngine/Colored/Colors.h 2021-04-19 13:50:22 +0000
425@@ -35,6 +35,7 @@
426 namespace PetriEngine {
427 namespace Colored {
428 class ColorType;
429+ class TimeInvariant;
430
431 class Color {
432 public:
433@@ -47,6 +48,7 @@
434 uint32_t _id;
435
436 public:
437+ Color();
438 Color(ColorType* colorType, uint32_t id, std::vector<const Color*>& colors);
439 Color(ColorType* colorType, uint32_t id, const char* color);
440 ~Color() {}
441@@ -54,8 +56,15 @@
442 bool isTuple() const {
443 return _tuple.size() > 1;
444 }
445+<<<<<<< TREE
446
447 void getColorConstraints(Colored::interval_t *constraintsVector, uint32_t *index) const;
448+=======
449+
450+ const std::vector<const Color*> getTuple() const {
451+ return _tuple;
452+ }
453+>>>>>>> MERGE-SOURCE
454
455 std::vector<const Color*> getTupleColors() const {
456 return _tuple;
457@@ -110,9 +119,15 @@
458 public:
459 static const Color* dotConstant(ColorType *ct) {
460 static DotConstant _instance;
461+<<<<<<< TREE
462 if(ct != nullptr){
463 _instance._colorType = ct;
464 }
465+=======
466+ if(ct != nullptr){
467+ _instance._colorType = ct;
468+ }
469+>>>>>>> MERGE-SOURCE
470 return &_instance;
471 }
472
473@@ -253,6 +268,25 @@
474 }
475 };
476
477+ class StarColorType : public ColorType {
478+ private:
479+ StarColorType();
480+
481+ public:
482+ static const ColorType* starColorType() {
483+ static StarColorType _instance;
484+
485+ return &_instance;
486+ }
487+
488+ StarColorType(StarColorType const&) = delete;
489+ void operator=(StarColorType const&) = delete;
490+
491+ bool operator== (const StarColorType& other) {
492+ return true;
493+ }
494+ };
495+
496 class ProductType : public ColorType {
497 private:
498 std::vector<ColorType*> constituents;
499
500=== modified file 'include/PetriEngine/Colored/Expressions.h'
501--- include/PetriEngine/Colored/Expressions.h 2021-04-14 11:51:52 +0000
502+++ include/PetriEngine/Colored/Expressions.h 2021-04-19 13:50:22 +0000
503@@ -124,6 +124,7 @@
504 virtual ~ColorExpression() {}
505
506 virtual const Color* eval(ExpressionContext& context) const = 0;
507+<<<<<<< TREE
508
509 virtual void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const = 0;
510
511@@ -135,11 +136,18 @@
512 return Colored::intervalTuple_t();
513 }
514
515+=======
516+
517+ virtual ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const = 0;
518+
519+ virtual void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const = 0;
520+>>>>>>> MERGE-SOURCE
521 };
522
523 class DotConstantExpression : public ColorExpression {
524 public:
525 const Color* eval(ExpressionContext& context) const override {
526+<<<<<<< TREE
527 return DotConstant::dotConstant(nullptr);
528 }
529
530@@ -173,6 +181,18 @@
531
532 std::string toString() const override {
533 return "dot";
534+=======
535+ return DotConstant::dotConstant(nullptr);
536+ }
537+
538+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
539+ return DotConstant::dotConstant(nullptr)->getColorType();
540+ }
541+
542+ void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
543+ const Color *dotColor = DotConstant::dotConstant(nullptr);
544+ constantMap[index] = dotColor;
545+>>>>>>> MERGE-SOURCE
546 }
547 };
548
549@@ -244,14 +264,24 @@
550 void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
551 }
552
553+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
554+ return _variable->colorType;
555+ }
556+
557 std::string toString() const override {
558 return _variable->name;
559 }
560
561+<<<<<<< TREE
562 ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
563 return _variable->colorType;
564 }
565
566+=======
567+ void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
568+ }
569+
570+>>>>>>> MERGE-SOURCE
571 VariableExpression(Variable* variable)
572 : _variable(variable) {}
573 };
574@@ -304,6 +334,7 @@
575 return _userOperator->toString();
576 }
577
578+<<<<<<< TREE
579 void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
580 constantMap[index] = _userOperator;
581 }
582@@ -322,6 +353,16 @@
583 return tupleInterval;
584 }
585
586+=======
587+ void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
588+ constantMap[index] = _userOperator;
589+ }
590+
591+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
592+ return _userOperator->getColorType();
593+ }
594+
595+>>>>>>> MERGE-SOURCE
596 UserOperatorExpression(const Color* userOperator)
597 : _userOperator(userOperator) {}
598 };
599@@ -410,10 +451,24 @@
600 return _color->toString() + "++";
601 }
602
603- ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
604- return _color->getColorType(colorTypes);
605- }
606-
607+<<<<<<< TREE
608+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
609+ return _color->getColorType(colorTypes);
610+ }
611+
612+=======
613+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
614+ return _color->getColorType(colorTypes);
615+ }
616+
617+ void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
618+ _color->getConstants(constantMap, index);
619+ for(auto& constIndexPair : constantMap){
620+ constIndexPair.second = &constIndexPair.second->operator++();
621+ }
622+ }
623+
624+>>>>>>> MERGE-SOURCE
625 SuccessorExpression(ColorExpression_ptr&& color)
626 : _color(std::move(color)) {}
627 };
628@@ -468,10 +523,24 @@
629 return _color->toString() + "--";
630 }
631
632- ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
633- return _color->getColorType(colorTypes);
634- }
635-
636+<<<<<<< TREE
637+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
638+ return _color->getColorType(colorTypes);
639+ }
640+
641+=======
642+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
643+ return _color->getColorType(colorTypes);
644+ }
645+
646+ void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
647+ _color->getConstants(constantMap, index);
648+ for(auto& constIndexPair : constantMap){
649+ constIndexPair.second = &constIndexPair.second->operator--();
650+ }
651+ }
652+
653+>>>>>>> MERGE-SOURCE
654 PredecessorExpression(ColorExpression_ptr&& color)
655 : _color(std::move(color)) {}
656 };
657@@ -489,12 +558,14 @@
658 colors.push_back(color->eval(context));
659 types.push_back(colors.back()->getColorType());
660 }
661+
662 ProductType* pt = context.findProductColorType(types);
663
664 const Color* col = pt->getColor(colors);
665 assert(col != nullptr);
666 return col;
667 }
668+<<<<<<< TREE
669
670 bool isTuple() const override {
671 return true;
672@@ -539,6 +610,34 @@
673 }
674 return true;
675 }
676+=======
677+
678+ void setColorType(ColorType* ct){
679+ _colorType = ct;
680+ }
681+
682+ ColorType* getColorType(std::unordered_map<std::string, Colored::ColorType*>& colorTypes) const override{
683+ std::vector<const ColorType*> types;
684+ for (auto color : _colors) {
685+ types.push_back(color->getColorType(colorTypes));
686+ }
687+ for (auto& elem : colorTypes) {
688+ auto* pt = dynamic_cast<ProductType*>(elem.second);
689+ if (pt && pt->containsTypes(types)) {
690+ return pt;
691+ }
692+ }
693+ std::cout << "COULD NOT FIND PRODUCT TYPE" << std::endl;
694+ return nullptr;
695+ }
696+
697+ void getConstants(std::unordered_map<uint32_t, const Color*> &constantMap, uint32_t &index) const override {
698+ for (auto elem : _colors) {
699+ elem->getConstants(constantMap, index);
700+ index++;
701+ }
702+ }
703+>>>>>>> MERGE-SOURCE
704
705 void getVariables(std::set<const Colored::Variable*>& variables, std::unordered_map<uint32_t, const Colored::Variable *>& varPositions, std::unordered_map<const Colored::Variable *, std::vector<std::unordered_map<uint32_t, int32_t>>>& varModifierMap, uint32_t *index) const override {
706 for (auto elem : _colors) {
707@@ -1016,6 +1115,8 @@
708 public:
709 ArcExpression() {}
710 virtual ~ArcExpression() {}
711+
712+ virtual void getConstants(std::unordered_map<uint32_t, std::vector<const Color*>> &constantMap, uint32_t &index) const = 0;
713
714 virtual Multiset eval(ExpressionContext& context) const = 0;
715
716@@ -1110,6 +1211,12 @@
717 return _sort->size();
718 }
719
720+ void getConstants(std::unordered_map<uint32_t, std::vector<const Color*>> &constantMap, uint32_t &index) const {
721+ for (size_t i = 0; i < _sort->size(); i++) {
722+ constantMap[index].push_back(&(*_sort)[i]);
723+ }
724+ }
725+
726 std::string toString() const override {
727 return _sort->getName() + ".all";
728 }
729@@ -1144,6 +1251,7 @@
730
731 return Multiset(col);
732 }
733+<<<<<<< TREE
734
735 bool isTuple() const override {
736 for(auto colorExpr : _color){
737@@ -1155,6 +1263,23 @@
738 }
739
740 void getVariables(std::set<const Colored::Variable*>& variables, std::unordered_map<uint32_t, const Colored::Variable *>& varPositions, std::unordered_map<const Colored::Variable *, std::vector<std::unordered_map<uint32_t, int32_t>>>& varModifierMap, uint32_t *index) const override {
741+=======
742+
743+ void getConstants(std::unordered_map<uint32_t, std::vector<const Color*>> &constantMap, uint32_t &index) const override {
744+ if (_all != nullptr)
745+ _all->getConstants(constantMap, index);
746+ else for (auto elem : _color) {
747+ std::unordered_map<uint32_t, const Color*> elemMap;
748+ elem->getConstants(elemMap, index);
749+ for(auto pair : elemMap){
750+ constantMap[pair.first].push_back(pair.second);
751+ }
752+ index++;//not sure if index should be increased here, but no number expression have multiple elements
753+ }
754+ }
755+
756+ void getVariables(std::set<Variable*>& variables) const override {
757+>>>>>>> MERGE-SOURCE
758 if (_all != nullptr)
759 return;
760 for (auto elem : _color) {
761@@ -1264,6 +1389,14 @@
762 }
763 return ms;
764 }
765+
766+ void getConstants(std::unordered_map<uint32_t, std::vector<const Color*>> &constantMap, uint32_t &index) const override {
767+ uint32_t indexCopy = index;
768+ for (auto elem : _constituents) {
769+ uint32_t localIndex = indexCopy;
770+ elem->getConstants(constantMap, localIndex);
771+ }
772+ }
773
774 void getVariables(std::set<const Colored::Variable*>& variables, std::unordered_map<uint32_t, const Colored::Variable *>& varPositions, std::unordered_map<const Colored::Variable *, std::vector<std::unordered_map<uint32_t, int32_t>>>& varModifierMap, uint32_t *index) const override {
775 for (auto elem : _constituents) {
776@@ -1357,6 +1490,12 @@
777 Multiset eval(ExpressionContext& context) const override {
778 return _left->eval(context) - _right->eval(context);
779 }
780+
781+ void getConstants(std::unordered_map<uint32_t, std::vector<const Color*>> &constantMap, uint32_t &index) const override {
782+ uint32_t rIndex = index;
783+ _left->getConstants(constantMap, index);
784+ _right->getConstants(constantMap, rIndex);
785+ }
786
787 void getVariables(std::set<const Colored::Variable*>& variables, std::unordered_map<uint32_t, const Colored::Variable *>& varPositions, std::unordered_map<const Colored::Variable *, std::vector<std::unordered_map<uint32_t, int32_t>>>& varModifierMap, uint32_t *index) const override {
788 _left->getVariables(variables, varPositions, varModifierMap);
789@@ -1418,6 +1557,10 @@
790 Multiset eval(ExpressionContext& context) const override {
791 return _expr->eval(context) * _scalar;
792 }
793+
794+ void getConstants(std::unordered_map<uint32_t, std::vector<const Color*>> &constantMap, uint32_t &index) const override {
795+ _expr->getConstants(constantMap, index);
796+ }
797
798 void getVariables(std::set<const Colored::Variable*>& variables, std::unordered_map<uint32_t, const Colored::Variable *>& varPositions, std::unordered_map<const Colored::Variable *, std::vector<std::unordered_map<uint32_t, int32_t>>>& varModifierMap, uint32_t *index) const override {
799 _expr->getVariables(variables, varPositions,varModifierMap);
800
801=== added file 'include/PetriEngine/Colored/TimeInterval.h'
802--- include/PetriEngine/Colored/TimeInterval.h 1970-01-01 00:00:00 +0000
803+++ include/PetriEngine/Colored/TimeInterval.h 2021-04-19 13:50:22 +0000
804@@ -0,0 +1,118 @@
805+//
806+// Created by niels on 3/20/19.
807+//
808+
809+#ifndef VERIFYPN_TIMEINTERVAL_H
810+#define VERIFYPN_TIMEINTERVAL_H
811+
812+#include <limits>
813+#include <iostream>
814+#include <algorithm>
815+#include <map>
816+#include <cassert>
817+#include <string>
818+#include <cctype>
819+#include <vector>
820+#include "Colors.h"
821+
822+namespace PetriEngine {
823+ namespace Colored{
824+ class TimeInterval
825+ {
826+ public: //Construter
827+ TimeInterval(Colored::Color color) : leftStrict(false), lowerBound(0), upperBound(std::numeric_limits<int>::max()), rightStrict(true), color(color){ };
828+ TimeInterval(bool leftStrict, uint32_t lowerBound, uint32_t upperBound, bool rightStrict, Colored::Color color) : leftStrict(leftStrict), lowerBound(lowerBound), upperBound(upperBound), rightStrict(rightStrict), color(color) { };
829+ TimeInterval(const TimeInterval& ti) : leftStrict(ti.leftStrict), lowerBound(ti.lowerBound), upperBound(ti.upperBound), rightStrict(ti.rightStrict), color(ti.color) {};
830+ TimeInterval& operator=(const TimeInterval& ti)
831+ {
832+ leftStrict = ti.leftStrict;
833+ lowerBound = ti.lowerBound;
834+ upperBound = ti.upperBound;
835+ rightStrict = ti.rightStrict;
836+ return *this;
837+ }
838+
839+ virtual ~TimeInterval() { /* empty */ }
840+ void divideBoundsBy(int divider);
841+ const Colored::Color& getColor() const{
842+ return color;
843+ }
844+
845+
846+ public: // inspectors
847+ void print(std::ostream& out) const;
848+ std::string toString();
849+
850+ inline const uint32_t getLowerBound() const { return lowerBound; }
851+ inline const uint32_t getUpperBound() const { return upperBound; }
852+ inline const bool isLowerBoundStrict() const { return leftStrict; }
853+ inline const bool isUpperBoundStrict() const { return rightStrict; }
854+ inline bool setUpperBound(uint32_t bound, bool isStrict)
855+ {
856+ if(upperBound == bound) rightStrict |= isStrict;
857+ else if(upperBound > bound){
858+ rightStrict = isStrict;
859+ upperBound = bound;
860+ }
861+ if(upperBound < lowerBound) return false;
862+ else return true;
863+ }
864+
865+ inline const bool isZeroInfinity() const { return !leftStrict && lowerBound == 0 && upperBound == std::numeric_limits<int>::max() && rightStrict; }
866+ inline const bool contains(uint32_t number) const
867+ {
868+ return number >= lowerBound && number <= upperBound;
869+ }
870+ inline bool intersects(const TimeInterval& other) const
871+ {
872+ assert(!leftStrict);
873+ assert(!other.leftStrict);
874+ assert(!rightStrict || upperBound == std::numeric_limits<int>().max());
875+ assert(!other.rightStrict || other.upperBound == std::numeric_limits<int>().max());
876+ if(other.lowerBound >= lowerBound &&
877+ other.lowerBound <= upperBound) return true;
878+ return false;
879+ }
880+
881+ public: // statics
882+
883+ static TimeInterval createFor(const std::string& interval,
884+ std::vector<const Colored::Color*> colors, std::unordered_map<std::string, uint32_t> constantValues);
885+ static inline void ltrim(std::string &s) {
886+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
887+ return !std::isspace(ch);
888+ }));
889+ }
890+ static Colored::Color createColor(std::vector<const Colored::Color*> colors);
891+
892+ // trim from end
893+ static inline void rtrim(std::string &s) {
894+ s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
895+ return !std::isspace(ch);
896+ }).base(), s.end());
897+ }
898+
899+ // trim from both ends
900+ static inline void trim(std::string &s) {
901+ ltrim(s);
902+ rtrim(s);
903+ }
904+
905+ private: // data
906+ bool leftStrict;
907+ uint32_t lowerBound;
908+ uint32_t upperBound;
909+ bool rightStrict;
910+ Colored::Color color;
911+ };
912+
913+ inline std::ostream& operator<<(std::ostream& out, const TimeInterval& interval)
914+ {
915+ interval.print(out);
916+ return out;
917+ }
918+ // trim from start
919+ }
920+}
921+
922+#endif //VERIFYPN_TIMEINTERVAL_H
923
924=== added file 'include/PetriEngine/Colored/TimeInvariant.h'
925--- include/PetriEngine/Colored/TimeInvariant.h 1970-01-01 00:00:00 +0000
926+++ include/PetriEngine/Colored/TimeInvariant.h 2021-04-19 13:50:22 +0000
927@@ -0,0 +1,87 @@
928+//
929+// Created by niels on 3/20/19.
930+//
931+
932+#ifndef VERIFYPN_TIMEINVARIANT_H
933+#define VERIFYPN_TIMEINVARIANT_H
934+
935+#include <string>
936+#include <map>
937+#include <limits>
938+#include <algorithm>
939+#include <cctype>
940+#include <locale>
941+#include "Colors.h"
942+
943+namespace PetriEngine {
944+ namespace Colored{
945+ class TimeInvariant{
946+
947+ public:
948+ TimeInvariant(Colored::Color color) : strictComparison(true), bound(std::numeric_limits<int>::max()), color(color) {};
949+ TimeInvariant(bool strictComparison, int bound, PetriEngine::Colored::Color color) : strictComparison(strictComparison), bound(bound), color(color) { };
950+ TimeInvariant(const TimeInvariant& ti) : strictComparison(ti.strictComparison), bound(ti.bound), color(ti.color) { };
951+ TimeInvariant& operator=(const TimeInvariant& ti)
952+ {
953+ strictComparison = ti.strictComparison;
954+ bound = ti.bound;
955+ return *this;
956+ }
957+
958+ virtual ~TimeInvariant(){ /*Left empty*/ };
959+
960+ public: // inspectors
961+ void print(std::ostream& out) const;
962+ std::string toString();
963+ inline const int getBound() const { return bound; }
964+ inline const bool isBoundStrict() const { return strictComparison; }
965+ inline const Colored::Color getColor() {return color;}
966+
967+ public: // statics
968+ static TimeInvariant createFor(const std::string& invariant, std::vector<const Colored::Color*> colors, std::unordered_map<std::string, uint32_t> constants);
969+ static Colored::Color createColor(std::vector<const Colored::Color*> colors);
970+
971+ private: // data
972+ bool strictComparison;
973+ int bound;
974+ Colored::Color color;
975+ };
976+
977+ inline bool operator==(const TimeInvariant& a, const TimeInvariant& b)
978+ {
979+ return a.getBound() == b.getBound() && a.isBoundStrict() == b.isBoundStrict();
980+ }
981+
982+ inline bool operator!=(const TimeInvariant& a, const TimeInvariant& b)
983+ {
984+ return !(a == b);
985+ }
986+
987+ inline std::ostream& operator<<(std::ostream& out, const TimeInvariant& invariant)
988+ {
989+ invariant.print(out);
990+ return out;
991+ }
992+ /*
993+ * Singleton pattern from:
994+ * https://stackoverflow.com/questions/1008019/c-singleton-design-pattern
995+ */
996+ class TimeInvariantConstant : public TimeInvariant {
997+ private:
998+ TimeInvariantConstant();
999+
1000+ public:
1001+ static const TimeInvariant* starColorDotConstant() {
1002+ static TimeInvariantConstant _instance;
1003+ return &_instance;
1004+ }
1005+ TimeInvariantConstant(TimeInvariant const&) = delete;
1006+ void operator=(TimeInvariant const&) = delete;
1007+ bool operator==(const TimeInvariant other) {
1008+ return true;
1009+ }
1010+ };
1011+ }
1012+}
1013+
1014+#endif //VERIFYPN_TIMEINVARIANT_H
1015
1016=== modified file 'include/PetriEngine/NetStructures.h'
1017--- include/PetriEngine/NetStructures.h 2020-03-02 21:03:24 +0000
1018+++ include/PetriEngine/NetStructures.h 2021-04-19 13:50:22 +0000
1019@@ -10,6 +10,7 @@
1020
1021 #include <limits>
1022 #include <vector>
1023+#include <iostream>
1024
1025 namespace PetriEngine {
1026
1027@@ -18,12 +19,23 @@
1028 uint32_t weight;
1029 bool skip = false;
1030 bool inhib = false;
1031+ bool transport = false;
1032+ uint32_t lowerBound;
1033+ uint32_t upperBound;
1034+ bool lowerStrict;
1035+ bool upperStrict;
1036+ std::string interval;
1037+ std::string transportID;
1038
1039 Arc() :
1040 place(std::numeric_limits<uint32_t>::max()),
1041 weight(std::numeric_limits<uint32_t>::max()),
1042 skip(false),
1043- inhib(false) {
1044+ inhib(false),
1045+ lowerBound(std::numeric_limits<uint32_t>::max()),
1046+ upperBound(std::numeric_limits<uint32_t> ::max()),
1047+ lowerStrict(false),
1048+ upperStrict(false) {
1049 };
1050
1051 bool operator < (const Arc& other) const
1052@@ -42,6 +54,7 @@
1053 std::vector<Arc> post;
1054 bool skip = false;
1055 bool inhib = false;
1056+ bool urgent = false;
1057
1058 void addPreArc(const Arc& arc)
1059 {
1060@@ -89,3 +102,4 @@
1061 }
1062 #endif /* NETSTRUCTURES_H */
1063
1064+
1065
1066=== modified file 'include/PetriEngine/PetriNet.h'
1067--- include/PetriEngine/PetriNet.h 2021-03-23 14:10:04 +0000
1068+++ include/PetriEngine/PetriNet.h 2021-04-19 13:50:22 +0000
1069@@ -25,6 +25,8 @@
1070 #include <climits>
1071 #include <limits>
1072 #include <iostream>
1073+#include <map>
1074+#include <unordered_map>
1075
1076 namespace PetriEngine {
1077
1078@@ -42,6 +44,7 @@
1079 struct TransPtr {
1080 uint32_t inputs;
1081 uint32_t outputs;
1082+ bool urgent;
1083 };
1084
1085 struct Invariant {
1086@@ -49,6 +52,9 @@
1087 uint32_t tokens;
1088 bool inhibitor;
1089 int8_t direction;
1090+ bool transport;
1091+ std::string interval;
1092+ std::string transportID;
1093 // we can pack things here, but might give slowdown
1094 } /*__attribute__((packed))*/;
1095
1096@@ -102,7 +108,13 @@
1097
1098 void sort();
1099
1100- void toXML(std::ostream& out);
1101+ void toXML(std::ostream& out, bool timed, std::map<std::string, std::string> _invariantStrings, bool verifydtapn);
1102+
1103+ bool isTimed() {return timed;}
1104+ void setTimed(bool timed) {this->timed = timed;}
1105+ void setInvariants(std::map<std::string, std::string> invariants) {
1106+ invariantStrings = invariants;
1107+ }
1108
1109 const MarkVal* initial() const {
1110 return _initialMarking;
1111@@ -122,12 +134,21 @@
1112 * @remarks We could also get this from the _places vector, but I don't see any
1113 * any complexity garentees for this type.
1114 */
1115+ std::string getType(std::pair<const Invariant*, const Invariant*> pair, bool pre);
1116+ std::string getArcIdentifier(std::string arcType);
1117+ inline const char * const BoolToString(bool b)
1118+ {
1119+ return b ? "true" : "false";
1120+ }
1121 uint32_t _ninvariants, _ntransitions, _nplaces;
1122
1123 std::vector<TransPtr> _transitions;
1124 std::vector<Invariant> _invariants;
1125+ std::map<std::string, std::string> invariantStrings;
1126 std::vector<uint32_t> _placeToPtrs;
1127+ std::vector<std::string> usedTransportIDs;
1128 MarkVal* _initialMarking;
1129+ bool timed = false;
1130
1131 std::vector<std::string> _transitionnames;
1132 std::vector<std::string> _placenames;
1133@@ -140,9 +161,14 @@
1134 friend class SuccessorGenerator;
1135 friend class ReducingSuccessorGenerator;
1136 friend class STSolver;
1137+<<<<<<< TREE
1138 friend class StubbornSet;
1139+=======
1140+ friend class Filter;
1141+>>>>>>> MERGE-SOURCE
1142 };
1143
1144 } // PetriEngine
1145
1146 #endif // PETRINET_H
1147+
1148
1149=== modified file 'include/PetriEngine/PetriNetBuilder.h'
1150--- include/PetriEngine/PetriNetBuilder.h 2021-03-05 16:43:31 +0000
1151+++ include/PetriEngine/PetriNetBuilder.h 2021-04-19 13:50:22 +0000
1152@@ -29,6 +29,7 @@
1153 #include "Reducer.h"
1154 #include "NetStructures.h"
1155 #include "Reachability/ReachabilityResult.h"
1156+#include "Colored/TimeInvariant.h"
1157 namespace PetriEngine {
1158 /** Builder for building engine representations of PetriNets */
1159 class PetriNetBuilder : public AbstractPetriNetBuilder {
1160@@ -39,14 +40,27 @@
1161 PetriNetBuilder();
1162 PetriNetBuilder(const PetriNetBuilder& other);
1163 void addPlace(const std::string& name, int tokens, double x, double y) override;
1164+ void addPlace(const std::string& name,
1165+ int tokens,
1166+ Colored::TimeInvariant invariant,
1167+ double x = 0,
1168+ double y = 0) override;
1169 void addTransition(const std::string& name,
1170 double x,
1171 double y) override;
1172+ void addTransition(const std::string &name, bool urgent,
1173+ double, double) override;
1174 void addInputArc(const std::string& place,
1175 const std::string& transition,
1176 bool inhibitor,
1177 int weight) override;
1178- void addOutputArc(const std::string& transition, const std::string& place, int weight) override;
1179+ void addInputArc(const std::string &place,
1180+ const std::string &transition,
1181+ bool inhibitor, bool transport,
1182+ int weight,
1183+ Colored::TimeInterval &interval, std::string transportID) override;
1184+
1185+ void addOutputArc(const std::string& transition, const std::string& place, int weight = 1, bool transport = false, std::string transportID = "") override;
1186
1187 virtual void sort() override;
1188 /** Make the resulting petri net, you take ownership */
1189@@ -123,15 +137,24 @@
1190 void startTimer() {
1191 _start = std::chrono::high_resolution_clock::now();
1192 }
1193+
1194+ bool isTimed() {return timed;}
1195+
1196+ void setTimed(bool timed) { this->timed = timed;}
1197+
1198+ std::map<std::string, std::string> getInvariants() {return _invariantStrings;}
1199
1200 private:
1201 uint32_t nextPlaceId(std::vector<uint32_t>& counts, std::vector<uint32_t>& pcounts, std::vector<uint32_t>& ids, bool reorder);
1202 std::chrono::high_resolution_clock::time_point _start;
1203+ bool timed = false;
1204
1205 protected:
1206 std::unordered_map<std::string, uint32_t> _placenames;
1207 std::unordered_map<std::string, uint32_t> _transitionnames;
1208
1209+ std::map<std::string, std::string> _invariantStrings;
1210+
1211 std::vector< std::tuple<double, double> > _placelocations;
1212 std::vector< std::tuple<double, double> > _transitionlocations;
1213
1214@@ -146,3 +169,4 @@
1215
1216 #endif // PETRINETBUILDER_H
1217
1218+
1219
1220=== modified file 'include/PetriEngine/options.h'
1221--- include/PetriEngine/options.h 2021-04-14 11:51:52 +0000
1222+++ include/PetriEngine/options.h 2021-04-19 13:50:22 +0000
1223@@ -5,7 +5,13 @@
1224 #include <stddef.h>
1225 #include <limits>
1226 #include <set>
1227+<<<<<<< TREE
1228 #include <sstream>
1229+=======
1230+#include <string.h>
1231+#include <cctype>
1232+#include <iostream>
1233+>>>>>>> MERGE-SOURCE
1234
1235 #include "Reachability/ReachabilitySearch.h"
1236 #include "../CTL/Algorithm/AlgorithmTypes.h"
1237@@ -81,6 +87,9 @@
1238
1239 size_t seed() { return ++seed_offset; }
1240
1241+ //TACPN options
1242+ bool outputVerifydtapnFormat = false;
1243+
1244 void print() {
1245 if (!printstatistics) {
1246 return;
1247@@ -175,3 +184,4 @@
1248 };
1249
1250 #endif
1251+
1252
1253=== modified file 'include/PetriParse/PNMLParser.h'
1254--- include/PetriParse/PNMLParser.h 2021-04-14 10:41:18 +0000
1255+++ include/PetriParse/PNMLParser.h 2021-04-19 13:50:22 +0000
1256@@ -39,7 +39,12 @@
1257 std::string source,
1258 target;
1259 int weight;
1260+ bool transport;
1261+ bool normal;
1262+ bool inhib;
1263 PetriEngine::Colored::ArcExpression_ptr expr;
1264+ std::vector<PetriEngine::Colored::TimeInterval> interval;
1265+ std::string transportID;
1266 };
1267 typedef std::vector<Arc> ArcList;
1268 typedef ArcList::iterator ArcIter;
1269@@ -48,6 +53,7 @@
1270 std::string id;
1271 double x, y;
1272 PetriEngine::Colored::GuardExpression_ptr expr;
1273+ bool urgent;
1274 };
1275 typedef std::vector<Transition> TransitionList;
1276 typedef TransitionList::iterator TransitionIter;
1277@@ -78,9 +84,15 @@
1278 }
1279
1280 private:
1281+ inline bool stringToBool(std::string b)
1282+ {
1283+ return b == "true" ? 1 : 0;
1284+ }
1285 void parseElement(rapidxml::xml_node<>* element);
1286 void parsePlace(rapidxml::xml_node<>* element);
1287+ std::pair<std::string, std::vector<const PetriEngine::Colored::Color*>> parseTimeConstraint(rapidxml::xml_node<> *element);
1288 void parseArc(rapidxml::xml_node<>* element, bool inhibitor = false);
1289+ void parseInterval(rapidxml::xml_node<>* element);
1290 void parseTransition(rapidxml::xml_node<>* element);
1291 void parseDeclarations(rapidxml::xml_node<>* element);
1292 void parseNamedSort(rapidxml::xml_node<>* element);
1293@@ -89,27 +101,44 @@
1294 PetriEngine::Colored::ColorExpression_ptr parseColorExpression(rapidxml::xml_node<>* element);
1295 PetriEngine::Colored::AllExpression_ptr parseAllExpression(rapidxml::xml_node<>* element);
1296 PetriEngine::Colored::ColorType* parseUserSort(rapidxml::xml_node<>* element);
1297+<<<<<<< TREE
1298 PetriEngine::Colored::ArcExpression_ptr parseNumberOfExpression(rapidxml::xml_node<>* element);
1299 void collectColorsInTuple(rapidxml::xml_node<>* element,std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>>& collectedColors);
1300 PetriEngine::Colored::ArcExpression_ptr constructAddExpressionFromTupleExpression(rapidxml::xml_node<>* element,std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> collectedColors, uint32_t numberof);
1301+=======
1302+ PetriEngine::Colored::ArcExpression_ptr parseNumberOfExpression(rapidxml::xml_node<>* element);
1303+ void collectColorsInTuple(rapidxml::xml_node<>* element, std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>>& collectedColors);
1304+ PetriEngine::Colored::ArcExpression_ptr constructAddExpressionFromTupleExpression(rapidxml::xml_node<>* element,std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> collectedColors, uint32_t numberof);
1305+ std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> cartesianProduct(std::vector<PetriEngine::Colored::ColorExpression_ptr> rightSet, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftSet);
1306+ std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> cartesianProduct(std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> rightSet, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftSet);
1307+>>>>>>> MERGE-SOURCE
1308 void parseTransportArc(rapidxml::xml_node<>* element);
1309 void parseValue(rapidxml::xml_node<>* element, std::string& text);
1310 uint32_t parseNumberConstant(rapidxml::xml_node<>* element);
1311 void parsePosition(rapidxml::xml_node<>* element, double& x, double& y);
1312 void parseQueries(rapidxml::xml_node<>* element);
1313 const PetriEngine::Colored::Color* findColor(const char* name) const;
1314+<<<<<<< TREE
1315 const PetriEngine::Colored::Color* findColorForIntRange(const char* value, uint32_t start, uint32_t end) const;
1316 std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> cartesianProduct(std::vector<PetriEngine::Colored::ColorExpression_ptr> rightVector, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftVector);
1317 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);
1318+=======
1319+ bool checkIsTimed(rapidxml::xml_node<> *netType);
1320+>>>>>>> MERGE-SOURCE
1321 PetriEngine::AbstractPetriNetBuilder* builder;
1322 NodeNameMap id2name;
1323 ArcList arcs;
1324- ArcList inhibarcs;
1325 TransitionList transitions;
1326 ColorTypeMap colorTypes;
1327 VariableMap variables;
1328 bool isColored;
1329+ bool isTimed;
1330 std::vector<Query> queries;
1331+ std::unordered_map<std::string, uint32_t> constantValues;
1332 };
1333
1334-#endif // PNMLPARSER_H
1335\ No newline at end of file
1336+<<<<<<< TREE
1337+#endif // PNMLPARSER_H=======
1338+#endif // PNMLPARSER_H
1339+
1340+>>>>>>> MERGE-SOURCE
1341
1342=== modified file 'src/PetriEngine/Colored/CMakeLists.txt'
1343--- src/PetriEngine/Colored/CMakeLists.txt 2021-04-14 10:41:18 +0000
1344+++ src/PetriEngine/Colored/CMakeLists.txt 2021-04-19 13:50:22 +0000
1345@@ -2,9 +2,15 @@
1346
1347 add_library(Colored ColoredPetriNetBuilder.cpp
1348 Colors.cpp
1349+<<<<<<< TREE
1350 Multiset.cpp
1351 BindingGenerator.cpp
1352 PartitionBuilder.cpp
1353 EquivalenceClass.cpp
1354 GuardRestrictor.cpp)
1355+=======
1356+Multiset.cpp
1357+TimeInterval.cpp
1358+TimeInvariant.cpp)
1359+>>>>>>> MERGE-SOURCE
1360 add_dependencies(Colored rapidxml-ext ptrie-ext glpk-ext)
1361
1362=== modified file 'src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp'
1363--- src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp 2021-04-14 11:51:52 +0000
1364+++ src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp 2021-04-19 13:50:22 +0000
1365@@ -24,13 +24,19 @@
1366 ColoredPetriNetBuilder::ColoredPetriNetBuilder() {
1367 }
1368
1369- ColoredPetriNetBuilder::ColoredPetriNetBuilder(const ColoredPetriNetBuilder& orig) {
1370+ ColoredPetriNetBuilder::ColoredPetriNetBuilder(const ColoredPetriNetBuilder& orig)
1371+ : _placenames(orig._placenames), _transitionnames(orig._transitionnames),
1372+ _placelocations(orig._placelocations), _transitionlocations(orig._transitionlocations),
1373+ _transitions(orig._transitions), _places(orig._places)
1374+ {
1375+
1376 }
1377
1378 ColoredPetriNetBuilder::~ColoredPetriNetBuilder() {
1379 }
1380
1381 void ColoredPetriNetBuilder::addPlace(const std::string& name, int tokens, double x, double y) {
1382+
1383 if (!_isColored) {
1384 _ptBuilder.addPlace(name, tokens, x, y);
1385 }
1386@@ -42,6 +48,7 @@
1387 uint32_t next = _placenames.size();
1388 _places.emplace_back(Colored::Place {name, type, tokens});
1389 _placenames[name] = next;
1390+<<<<<<< TREE
1391
1392 //set up place color fix points and initialize queue
1393 if (!tokens.empty()) {
1394@@ -65,6 +72,26 @@
1395 }
1396
1397 _placeColorFixpoints.push_back(colorFixpoint);
1398+=======
1399+
1400+ _invariantStrings[name] = "< inf";
1401+ _placelocations.push_back(std::tuple<double, double>(x,y));
1402+ }
1403+ }
1404+
1405+ void ColoredPetriNetBuilder::addPlace(const std::string &name,
1406+ PetriEngine::Colored::Multiset &&tokens,
1407+ Colored::ColorType* type,
1408+ std::vector<PetriEngine::Colored::TimeInvariant> &invariant, double x,
1409+ double y) {
1410+ if(_placenames.count(name) == 0){
1411+ uint32_t next = _placenames.size();
1412+ _places.emplace_back(Colored::Place{name, type, tokens, invariant});
1413+ _placenames[name] = next;
1414+
1415+ _invariantStrings[name] = invariant.size() ? invariant[0].toString(): "< inf";
1416+ _placelocations.push_back(std::tuple<double, double>(x,y));
1417+>>>>>>> MERGE-SOURCE
1418 }
1419 }
1420
1421@@ -80,6 +107,20 @@
1422 uint32_t next = _transitionnames.size();
1423 _transitions.emplace_back(Colored::Transition {name, guard});
1424 _transitionnames[name] = next;
1425+ _transitionlocations.push_back(std::tuple<double, double>(x,y));
1426+ }
1427+ }
1428+
1429+ void ColoredPetriNetBuilder::addTransition(const std::string& name,
1430+ const Colored::GuardExpression_ptr& guard,
1431+ bool urgent,
1432+ double x,
1433+ double y) {
1434+ if (_transitionnames.count(name) == 0) {
1435+ uint32_t next = _transitionnames.size();
1436+ _transitions.emplace_back(Colored::Transition {name, guard, urgent});
1437+ _transitionnames[name] = next;
1438+ _transitionlocations.push_back(std::tuple<double, double>(x,y));
1439 }
1440 }
1441
1442@@ -89,17 +130,27 @@
1443 }
1444 }
1445
1446- void ColoredPetriNetBuilder::addInputArc(const std::string& place, const std::string& transition, const Colored::ArcExpression_ptr& expr) {
1447- addArc(place, transition, expr, true);
1448- }
1449-
1450- void ColoredPetriNetBuilder::addOutputArc(const std::string& transition, const std::string& place, int weight) {
1451+ void ColoredPetriNetBuilder::addInputArc(const std::string& place, const std::string& transition, const Colored::ArcExpression_ptr& expr, bool inhibitor, int weight) {
1452+ addArc(place, transition, expr, true, inhibitor, weight);
1453+ }
1454+
1455+ void ColoredPetriNetBuilder::addInputArc(const std::string &place,
1456+ const std::string &transition,
1457+ bool inhibitor, bool transport,
1458+ const Colored::ArcExpression_ptr& expr,
1459+ std::vector<PetriEngine::Colored::TimeInterval> &interval, int weight, std::string transportID) {
1460+ addTimedArc(place,transition,expr,interval,inhibitor, transport, true, weight, transportID);
1461+
1462+ }
1463+
1464+ void ColoredPetriNetBuilder::addOutputArc(const std::string& transition, const std::string& place, int weight, bool transport, std::string transportID) {
1465 if (!_isColored) {
1466- _ptBuilder.addOutputArc(transition, place, weight);
1467+ _ptBuilder.addOutputArc(transition, place, weight, transport, transportID);
1468 }
1469 }
1470
1471 void ColoredPetriNetBuilder::addOutputArc(const std::string& transition, const std::string& place, const Colored::ArcExpression_ptr& expr) {
1472+<<<<<<< TREE
1473 addArc(place, transition, expr, false);
1474 }
1475
1476@@ -125,10 +176,130 @@
1477 Colored::Arc arc;
1478 arc.place = p;
1479 arc.transition = t;
1480+=======
1481+ addArc(place, transition, expr, false, false, 1);
1482+ }
1483+
1484+ void ColoredPetriNetBuilder::addOutputArc(const std::string& transition, const std::string& place, const Colored::ArcExpression_ptr& expr, bool transport, std::string transportID) {
1485+ std::vector<PetriEngine::Colored::TimeInterval> intervals;
1486+ addTimedArc(place, transition, expr, intervals, false, transport, false, 0, transportID);
1487+ }
1488+
1489+ void ColoredPetriNetBuilder::addArc(const std::string& place, const std::string& transition, const Colored::ArcExpression_ptr& expr, bool input, bool inhibitor, int weight) {
1490+ if(_transitionnames.count(transition) == 0)
1491+ {
1492+ std::cout << "Transition '" << transition << "' not found. Adding it." << std::endl;
1493+ addTransition(transition,0.0,0.0);
1494+ }
1495+ if(_placenames.count(place) == 0)
1496+ {
1497+ std::cout << "Place '" << place << "' not found. Adding it." << std::endl;
1498+ addPlace(place,0,0,0);
1499+ }
1500+ uint32_t p = _placenames[place];
1501+ uint32_t t = _transitionnames[transition];
1502+
1503+ assert(t < _transitions.size());
1504+ assert(p < _places.size());
1505+
1506+ Colored::Arc arc;
1507+ arc.place = p;
1508+ arc.transition = t;
1509+ if(!inhibitor)
1510+ assert(expr != nullptr);
1511+ arc.expr = std::move(expr);
1512+ arc.input = input;
1513+ if(inhibitor){
1514+ std::cout << "Adding inhib arc " << std::endl;
1515+ inhibitorArcs.push_back(std::move(arc));
1516+ } else {
1517+ _transitions[t].arcs.push_back(std::move(arc));
1518+ }
1519+
1520+
1521+ }
1522+
1523+ void ColoredPetriNetBuilder::addTimedArc(const std::string &place, const std::string &transition,
1524+ const PetriEngine::Colored::ArcExpression_ptr &expr,
1525+ std::vector<PetriEngine::Colored::TimeInterval> &interval, bool inhibitor, bool transport,
1526+ bool input, int weight, std::string transportID) {
1527+ if(_transitionnames.count(transition) == 0)
1528+ {
1529+ std::cout << "Transition '" << transition << "' not found. Adding it." << std::endl;
1530+ addTransition(transition,0.0,0.0);
1531+ }
1532+ if(_placenames.count(place) == 0)
1533+ {
1534+ std::cout << "Place '" << place << "' not found. Adding it." << std::endl;
1535+ addPlace(place,0,0,0);
1536+ }
1537+ uint32_t p = _placenames[place];
1538+ uint32_t t = _transitionnames[transition];
1539+
1540+ assert(t < _transitions.size());
1541+ assert(p < _places.size());
1542+
1543+ Colored::Arc arc;
1544+ arc.place = p;
1545+ arc.transition = t;
1546+ if(!inhibitor)
1547+ assert(expr != nullptr);
1548+ arc.expr = expr;
1549+ arc.input = input;
1550+ arc.weight = weight;
1551+ arc.interval = interval;
1552+ arc.inhibitor = inhibitor;
1553+ arc.transport = transport;
1554+ arc.transportID = transportID;
1555+ // _transitions[t].inhibitor |= inhibitor;
1556+ // _places[p].inhibitor |= inhibitor;
1557+ if(inhibitor){
1558+ std::cout << "Adding inhib arc " << std::endl;
1559+ inhibitorArcs.push_back(std::move(arc));
1560+ } else {
1561+ _transitions[t].arcs.push_back(std::move(arc));
1562+ }
1563+
1564+ }
1565+
1566+ void ColoredPetriNetBuilder::addTransportArc(const std::string &source, const std::string &transition,
1567+ const std::string &destination,
1568+ const PetriEngine::Colored::ArcExpression_ptr &expr,
1569+ std::vector<PetriEngine::Colored::TimeInterval> &interval) {
1570+ if(_transitionnames.count(transition) == 0)
1571+ {
1572+ std::cout << "Transition '" << transition << "' not found. Adding it." << std::endl;
1573+ addTransition(transition,0.0,0.0);
1574+ }
1575+ if(_placenames.count(source) == 0)
1576+ {
1577+ std::cout << "Place '" << source << "' not found. Adding it." << std::endl;
1578+ addPlace(source,0,0,0);
1579+ }
1580+ if(_placenames.count(destination) == 0)
1581+ {
1582+ std::cout << "Place '" << destination << "' not found. Adding it." << std::endl;
1583+ addPlace(destination,0,0,0);
1584+ }
1585+ uint32_t s = _placenames[source];
1586+ uint32_t t = _transitionnames[transition];
1587+
1588+ assert(t < _transitions.size());
1589+ assert(s < _places.size());
1590+
1591+ Colored::TransportArc transportArc;
1592+ transportArc.source = s;
1593+ transportArc.transition = t;
1594+>>>>>>> MERGE-SOURCE
1595 assert(expr != nullptr);
1596+<<<<<<< TREE
1597 arc.expr = std::move(expr);
1598 arc.input = input;
1599 input? _transitions[t].input_arcs.push_back(std::move(arc)): _transitions[t].output_arcs.push_back(std::move(arc));
1600+=======
1601+ transportArc.expr = expr;
1602+ transportArc.interval = interval;
1603+>>>>>>> MERGE-SOURCE
1604 }
1605
1606 void ColoredPetriNetBuilder::addColorType(const std::string& id, Colored::ColorType* type) {
1607@@ -413,9 +584,17 @@
1608 auto end = std::chrono::high_resolution_clock::now();
1609 _time = (std::chrono::duration_cast<std::chrono::microseconds>(end - start).count())*0.000001;
1610 }
1611+<<<<<<< TREE
1612+=======
1613+ if (isTimed()) {
1614+ _ptBuilder.setTimed(true);
1615+ }
1616+
1617+>>>>>>> MERGE-SOURCE
1618 return _ptBuilder;
1619 }
1620
1621+<<<<<<< TREE
1622 //Due to the way we unfold places, we only unfold palces connected to an arc (which makes sense)
1623 //However, in queries asking about orphan places it cannot find these, as they have not been unfolded
1624 //so we make a placeholder place which just has tokens equal to the number of colored tokens
1625@@ -460,9 +639,75 @@
1626 _ptBuilder.addPlace(name, tokenSize, 0.0, 0.0);
1627 _ptplacenames[place->name][id] = std::move(name);
1628 ++_nptplaces;
1629+=======
1630+ void ColoredPetriNetBuilder::unfoldPlace(Colored::Place& place) {
1631+ double xBuffer = 0;
1632+ double yBuffer = 0;
1633+ uint32_t index = _placenames[place.name];
1634+ auto placePos = _placelocations[index];
1635+ for (size_t i = 0; i < place.type->size(); ++i) {
1636+ double x = xBuffer + get<0>(placePos);
1637+ double y = yBuffer + get<1>(placePos);
1638+ std::string name = place.name + "Sub" + std::to_string(i);
1639+ const Colored::Color* color = &place.type->operator[](i);
1640+ if (isTimed()) {
1641+ Colored::TimeInvariant invariant = getTimeInvariantForPlace(place.invariants, color); //TODO:: this does not take the correct time invariant
1642+ _ptBuilder.addPlace(name, place.marking[color], invariant, x, y);
1643+ _invariantStrings[name] = invariant.toString();
1644+ } else {
1645+ _ptBuilder.addPlace(name, place.marking[color], x, y);
1646+ }
1647+
1648+ _ptplacenames[place.name][color->getId()] = std::move(name);
1649+ ++_nptplaces;
1650+ xBuffer += 50;
1651+ yBuffer += 0;
1652+
1653+ }
1654+ if (isTimed()) { // we add the shadow place p.sum
1655+ double x = xBuffer + get<0>(placePos);
1656+ double y = yBuffer + get<1>(placePos);
1657+ Colored::Color color;
1658+ std::string placeName = place.name + "Sum";
1659+ _ptBuilder.addPlace(placeName, place.marking.size(), Colored::TimeInvariant(color), x, y);
1660+ _invariantStrings[placeName] = Colored::TimeInvariant(color).toString();
1661+ //_ptplacenames[place.name][color.getId()] = std::move(placeName);
1662+ _shadowPlacesNames[place.name] = std::move(placeName);
1663+ ++_nptplaces;
1664+ }
1665+ }
1666+
1667+ Colored::TimeInvariant ColoredPetriNetBuilder::getTimeInvariantForPlace(std::vector< Colored::TimeInvariant> TimeInvariants, const Colored::Color* color) {
1668+ for (Colored::TimeInvariant element : TimeInvariants) {
1669+ if (!element.getColor().isTuple()) {
1670+ if (element.getColor().getId() == color->getId()) {
1671+ return element;
1672+ }
1673+ } else {
1674+ bool matches = true;
1675+ Colored::Color color = element.getColor();
1676+ std::vector<const Colored::Color*> colors = color.getTuple();
1677+ if (colors.size() == color.getTuple().size()) {
1678+ for(uint32_t i = 0;i < colors.size(); i++) {
1679+ if (colors[i]->getId() != color.getTuple()[i]->getId())
1680+ matches = false;
1681+ }
1682+ if (matches)
1683+ return element;
1684+ }
1685+ }
1686+ }
1687+ for (uint32_t j = 0; j < TimeInvariants.size(); ++j) {
1688+ if (TimeInvariants[j].getColor().getColorName() == "*") {
1689+ return TimeInvariants[j];
1690+ }
1691+ }
1692+ exit(ErrorCode);
1693+>>>>>>> MERGE-SOURCE
1694 }
1695
1696 void ColoredPetriNetBuilder::unfoldTransition(Colored::Transition& transition) {
1697+<<<<<<< TREE
1698 if(_fixpointDone || _partitionComputed){
1699 FixpointBindingGenerator gen(transition, _colors);
1700 size_t i = 0;
1701@@ -495,18 +740,60 @@
1702 for (auto& arc : transition.output_arcs) {
1703 unfoldArc(arc, b, name);
1704 }
1705- }
1706+=======
1707+ BindingGenerator gen(transition, _colors);
1708+ double buffer = 0;
1709+ uint32_t transitionId = _transitionnames[transition.name];
1710+ auto transitionPos = _transitionlocations[transitionId];
1711+ size_t i = 0;
1712+ for (auto& b : gen) {
1713+ std::string name = transition.name + "Sub" + std::to_string(i++);
1714+ if (isTimed()) {
1715+ _ptBuilder.addTransition(name, transition.urgent, get<0>(transitionPos) + buffer, get<1>(transitionPos));
1716+ } else {
1717+ _ptBuilder.addTransition(name, get<0>(transitionPos) + buffer, get<1>(transitionPos));
1718+ }
1719+ _pttransitionnames[transition.name].push_back(name);
1720+ ++_npttransitions;
1721+ for (auto& arc : transition.arcs) {
1722+ unfoldArc(arc, b, name);
1723+>>>>>>> MERGE-SOURCE
1724+ }
1725+<<<<<<< TREE
1726 }
1727+=======
1728+ unfoldInhibitorArc(transition.name, name);
1729+ buffer += 250;
1730+ }
1731+ }
1732+
1733+ void ColoredPetriNetBuilder::unfoldInhibitorArc(std::string &oldname, std::string &newname) {
1734+ for (uint32_t i = 0; i < inhibitorArcs.size(); ++i) {
1735+ if (_transitions[inhibitorArcs[i].transition].name.compare(oldname) == 0) {
1736+ Colored::Arc inhibArc = inhibitorArcs[i];
1737+ std::string place = _shadowPlacesNames[_places[inhibArc.place].name];
1738+ _ptBuilder.addInputArc(place, newname, inhibArc.inhibitor, inhibArc.weight);
1739+ }
1740+ }
1741+>>>>>>> MERGE-SOURCE
1742 }
1743
1744 void ColoredPetriNetBuilder::unfoldArc(Colored::Arc& arc, Colored::ExpressionContext::BindingMap& binding, std::string& tName) {
1745+<<<<<<< TREE
1746 Colored::ExpressionContext context {binding, _colors, _partition[arc.place]};
1747 auto ms = arc.expr->eval(context);
1748
1749+=======
1750+ Colored::ExpressionContext context {binding, _colors};
1751+ auto ms = arc.expr->eval(context);
1752+ int shadowWeight = 0;
1753+ std::vector<Colored::TimeInterval>& timeIntervals = arc.interval;
1754+>>>>>>> MERGE-SOURCE
1755 for (const auto& color : ms) {
1756 if (color.second == 0) {
1757 continue;
1758 }
1759+<<<<<<< TREE
1760
1761 const PetriEngine::Colored::Place& place = _places[arc.place];
1762 uint32_t id;
1763@@ -527,6 +814,74 @@
1764 }
1765 ++_nptarcs;
1766 }
1767+=======
1768+ shadowWeight += color.second;
1769+ const std::string& pName = _ptplacenames[_places[arc.place].name][color.first->getId()];
1770+ if(isTimed()){
1771+ if (!arc.input) {
1772+ _ptBuilder.addOutputArc(tName, pName, color.second, arc.transport, arc.transportID);
1773+ } else {
1774+ Colored::TimeInterval timeInterval = getTimeIntervalForArc(timeIntervals, color.first);
1775+ _ptBuilder.addInputArc(pName, tName, arc.inhibitor, arc.transport, color.second, timeInterval, arc.transportID);
1776+ }
1777+ } else {
1778+ if (!arc.input) {
1779+ _ptBuilder.addOutputArc(tName, pName, color.second);
1780+ } else {
1781+ _ptBuilder.addInputArc(pName, tName, arc.inhibitor, color.second);
1782+ }
1783+ }
1784+
1785+ ++_nptarcs;
1786+ }
1787+ if(isTimed() && shadowWeight > 0) {
1788+ std::string pName = _shadowPlacesNames[_places[arc.place].name];
1789+ if (!arc.input) {
1790+ _ptBuilder.addOutputArc(tName, pName, shadowWeight, false, arc.transportID);
1791+ } else {
1792+ Colored::Color color;
1793+ Colored::TimeInterval timeInterval(color);
1794+ _ptBuilder.addInputArc(pName, tName, arc.inhibitor, false, shadowWeight, timeInterval, arc.transportID);
1795+ }
1796+ ++_nptarcs;
1797+ /*
1798+ if(inhibitorArcs.find(_places[arc.place].name) != inhibitorArcs.end()) {
1799+ Colored::Arc inhibArc = inhibitorArcs[_places[arc.place].name];
1800+ _ptBuilder.addInputArc(pName, tName, inhibArc.inhibitor, inhibArc.weight);
1801+ ++_nptarcs;
1802+ }
1803+ */
1804+ }
1805+ }
1806+
1807+ Colored::TimeInterval ColoredPetriNetBuilder::getTimeIntervalForArc(std::vector< Colored::TimeInterval> timeIntervals,const Colored::Color* color) {
1808+ for (Colored::TimeInterval element : timeIntervals) {
1809+ if (!element.getColor().isTuple()) {
1810+ if (element.getColor().getId() == color->getId()) {
1811+ return element;
1812+ }
1813+ } else {
1814+ bool matches = true;
1815+ std::vector<const Colored::Color*> colors = element.getColor().getTuple();
1816+
1817+ if (colors.size() == color->getTuple().size()) {
1818+ for(uint32_t i = 0; i < colors.size(); i++) {
1819+ if (colors[i]->getId() != color->getTuple()[i]->getId())
1820+ matches = false;
1821+ }
1822+ if (matches)
1823+ return element;
1824+ }
1825+ }
1826+ }
1827+ for (uint32_t j = 0; j < timeIntervals.size(); ++j) { // If there is no timeinterval for the specific color, we use the default * interval
1828+ if (timeIntervals[j].getColor().getColorName() == "*") {
1829+ return timeIntervals[j];
1830+ }
1831+ }
1832+ std::cerr << "There is no matching time interval to an arc" << std::endl;;
1833+ exit(ErrorCode);
1834+>>>>>>> MERGE-SOURCE
1835 }
1836
1837 //----------------------- Strip Colors -----------------------//
1838@@ -535,11 +890,13 @@
1839 if (_unfolded) assert(false);
1840 if (_isColored && !_stripped) {
1841 for (auto& place : _places) {
1842- _ptBuilder.addPlace(place.name, place.marking.size(), 0.0, 0.0);
1843+ if (!isTimed())
1844+ _ptBuilder.addPlace(place.name, place.marking.size(), 0.0, 0.0);
1845 }
1846
1847 for (auto& transition : _transitions) {
1848 _ptBuilder.addTransition(transition.name, 0.0, 0.0);
1849+<<<<<<< TREE
1850 for (auto& arc : transition.input_arcs) {
1851 try {
1852 _ptBuilder.addInputArc(_places[arc.place].name, _transitions[arc.transition].name, false,
1853@@ -557,6 +914,19 @@
1854 arc.expr->weight());
1855 } catch (Colored::WeightException& e) {
1856 std::cerr << "Exception on output arc: " << arcToString(arc) << std::endl;
1857+=======
1858+ for (auto& arc : transition.arcs) {
1859+ try {
1860+ if (arc.input) {
1861+ _ptBuilder.addInputArc(_places[arc.place].name, _transitions[arc.transition].name, false,
1862+ arc.expr->weight());
1863+ } else {
1864+ _ptBuilder.addOutputArc(_transitions[arc.transition].name, _places[arc.place].name,
1865+ arc.expr->weight(), arc.transport, arc.transportID);
1866+ }
1867+ } catch (Colored::WeightException& e) {
1868+ std::cerr << "Exception on arc: " << arcToString(arc) << std::endl;
1869+>>>>>>> MERGE-SOURCE
1870 std::cerr << "In expression: " << arc.expr->toString() << std::endl;
1871 std::cerr << e.what() << std::endl;
1872 exit(ErrorCode);
1873@@ -575,6 +945,104 @@
1874 return !arc.input ? "(" + _transitions[arc.transition].name + ", " + _places[arc.place].name + ")" :
1875 "(" + _places[arc.place].name + ", " + _transitions[arc.transition].name + ")";
1876 }
1877+<<<<<<< TREE
1878+=======
1879+
1880+ BindingGenerator::Iterator::Iterator(BindingGenerator* generator)
1881+ : _generator(generator)
1882+ {
1883+ }
1884+
1885+ bool BindingGenerator::Iterator::operator==(Iterator& other) {
1886+ return _generator == other._generator;
1887+ }
1888+
1889+ bool BindingGenerator::Iterator::operator!=(Iterator& other) {
1890+ return _generator != other._generator;
1891+ }
1892+
1893+ BindingGenerator::Iterator& BindingGenerator::Iterator::operator++() {
1894+ _generator->nextBinding();
1895+ if (_generator->isInitial()) _generator = nullptr;
1896+ return *this;
1897+ }
1898+
1899+ const Colored::ExpressionContext::BindingMap BindingGenerator::Iterator::operator++(int) {
1900+ auto prev = _generator->currentBinding();
1901+ ++*this;
1902+ return prev;
1903+ }
1904+
1905+ Colored::ExpressionContext::BindingMap& BindingGenerator::Iterator::operator*() {
1906+ return _generator->currentBinding();
1907+ }
1908+
1909+ BindingGenerator::BindingGenerator(Colored::Transition& transition,
1910+ ColoredPetriNetBuilder::ColorTypeMap& colorTypes)
1911+ : _colorTypes(colorTypes)
1912+ {
1913+ _expr = transition.guard;
1914+ std::set<Colored::Variable*> variables;
1915+ if (_expr != nullptr) {
1916+ _expr->getVariables(variables);
1917+ }
1918+ for (auto arc : transition.arcs) {
1919+ assert(arc.expr != nullptr);
1920+ arc.expr->getVariables(variables);
1921+ }
1922+ for (auto var : variables) {
1923+ _bindings[var->name] = &var->colorType->operator[](0);
1924+ }
1925+
1926+ if (!eval())
1927+ nextBinding();
1928+ }
1929+
1930+ bool BindingGenerator::eval() {
1931+ if (_expr == nullptr)
1932+ return true;
1933+
1934+ Colored::ExpressionContext context {_bindings, _colorTypes};
1935+ return _expr->eval(context);
1936+ }
1937+
1938+ Colored::ExpressionContext::BindingMap& BindingGenerator::nextBinding() {
1939+ bool test = false;
1940+ while (!test) {
1941+ for (auto& _binding : _bindings) {
1942+ _binding.second = &_binding.second->operator++();
1943+ if (_binding.second->getId() != 0) {
1944+ break;
1945+ }
1946+ }
1947+
1948+ if (isInitial())
1949+ break;
1950+
1951+ test = eval();
1952+ }
1953+ return _bindings;
1954+ }
1955+
1956+ Colored::ExpressionContext::BindingMap& BindingGenerator::currentBinding() {
1957+ return _bindings;
1958+ }
1959+
1960+ bool BindingGenerator::isInitial() const {
1961+ for (auto& b : _bindings) {
1962+ if (b.second->getId() != 0) return false;
1963+ }
1964+ return true;
1965+ }
1966+
1967+ BindingGenerator::Iterator BindingGenerator::begin() {
1968+ return {this};
1969+ }
1970+
1971+ BindingGenerator::Iterator BindingGenerator::end() {
1972+ return {nullptr};
1973+ }
1974+>>>>>>> MERGE-SOURCE
1975 }
1976
1977
1978\ No newline at end of file
1979
1980=== modified file 'src/PetriEngine/Colored/Colors.cpp'
1981--- src/PetriEngine/Colored/Colors.cpp 2021-03-15 10:04:47 +0000
1982+++ src/PetriEngine/Colored/Colors.cpp 2021-04-19 13:50:22 +0000
1983@@ -49,6 +49,12 @@
1984 stream << color.toString();
1985 return stream;
1986 }
1987+
1988+ Color::Color() {
1989+ _id = 0;
1990+ _colorName = "*";
1991+ _colorType = new ColorType("*");
1992+ }
1993
1994 Color::Color(ColorType* colorType, uint32_t id, std::vector<const Color*>& colors)
1995 : _tuple(colors), _colorType(colorType), _colorName(""), _id(id)
1996@@ -191,6 +197,9 @@
1997 {
1998 }
1999
2000+ StarColorType::StarColorType() : ColorType("*") {
2001+
2002+ }
2003
2004 void ColorType::addColor(const char* colorName) {
2005 _colors.emplace_back(this, _colors.size(), colorName);
2006
2007=== modified file 'src/PetriEngine/Colored/Multiset.cpp'
2008=== added file 'src/PetriEngine/Colored/TimeInterval.cpp'
2009--- src/PetriEngine/Colored/TimeInterval.cpp 1970-01-01 00:00:00 +0000
2010+++ src/PetriEngine/Colored/TimeInterval.cpp 2021-04-19 13:50:22 +0000
2011@@ -0,0 +1,91 @@
2012+//
2013+// Created by niels on 3/20/19.
2014+//
2015+#include "PetriEngine/Colored/TimeInterval.h"
2016+#include "PetriEngine/Colored/Colors.h"
2017+#include "PetriEngine/Colored/TimeInvariant.h"
2018+#include <vector>
2019+
2020+namespace PetriEngine {
2021+ namespace Colored {
2022+ TimeInterval TimeInterval::createFor(const std::string &interval, std::vector<const Colored::Color*> colors, std::unordered_map<std::string, uint32_t> constantValues) {
2023+ Colored::Color color = Colored::TimeInvariant::createColor(colors);
2024+ bool leftStrict = false;
2025+ std::string leftParentheses = "(";
2026+ std::size_t foundLeft = interval.find(leftParentheses);
2027+ if(foundLeft != std::string::npos){
2028+ leftStrict = true;
2029+ }
2030+
2031+ bool rightStrict = false;
2032+ std::string rightParentheses = ")";
2033+ std::size_t foundRight = interval.find(rightParentheses);
2034+ if(foundRight != std::string::npos) {
2035+ rightStrict = true;
2036+ }
2037+
2038+ std::string strLoverBound = interval.substr(0, interval.find(","));
2039+ trim(strLoverBound);
2040+ strLoverBound = strLoverBound.substr(1, strLoverBound.size());
2041+ std::string strUpperBound = interval.substr(interval.find(","), interval.size()-1);
2042+ trim(strUpperBound);
2043+ if(rightStrict == true){
2044+ strUpperBound = strUpperBound.substr(1, strUpperBound.find(")")-1);
2045+ } else{
2046+ strUpperBound = strUpperBound.substr(1, strUpperBound.find("]")-1);
2047+ }
2048+
2049+ int lowerBound;
2050+ int upperBound;
2051+ if (constantValues.find(strLoverBound) == constantValues.end())
2052+ lowerBound = std::stoi(strLoverBound);
2053+ else
2054+ lowerBound = constantValues[strLoverBound];
2055+
2056+ if(strUpperBound.compare("inf") == 0 )
2057+ upperBound = std::numeric_limits<int>().max();
2058+ else {
2059+ if (constantValues.find(strUpperBound) == constantValues.end())
2060+ upperBound = std::stoi(strUpperBound);
2061+ else
2062+ upperBound = constantValues[strUpperBound];
2063+ }
2064+
2065+ return TimeInterval(leftStrict, lowerBound, upperBound, rightStrict, color);
2066+ }
2067+
2068+ void TimeInterval::print(std::ostream &out) const
2069+ {
2070+ std::string leftParenthesis = leftStrict ? "(" : "[";
2071+ std::string rightParenthesis = rightStrict ? ")" : "]";
2072+ std::string strLowerBound = std::to_string(lowerBound);
2073+ std::string strUpperBound = upperBound == std::numeric_limits<int>().max() ? "inf" : std::to_string(upperBound);
2074+
2075+ out << leftParenthesis << strLowerBound << "," << strUpperBound << rightParenthesis;
2076+ }
2077+
2078+ std::string TimeInterval::toString() {
2079+ std::string leftParenthesis = leftStrict ? "(" : "[";
2080+ std::string rightParenthesis = rightStrict ? ")" : "]";
2081+ std::string strLowerBound = std::to_string(lowerBound);
2082+ std::string strUpperBound = upperBound == std::numeric_limits<int>().max() ? "inf" : std::to_string(upperBound);
2083+
2084+ return leftParenthesis + strLowerBound + "," + strUpperBound + rightParenthesis;
2085+ }
2086+ void TimeInterval::divideBoundsBy(int divider) {
2087+ if(lowerBound != 0 )
2088+ lowerBound = lowerBound / divider;
2089+ if(upperBound != std::numeric_limits<int>().max() ) {
2090+ upperBound = upperBound / divider;
2091+ }
2092+ }
2093+ Colored::Color TimeInterval::createColor(std::vector<const Colored::Color*> colors) {
2094+ if (colors.size() == 1 ) {
2095+ return Color(colors.front()->getColorType(), colors.front()->getId(), colors.front()->getColorName().c_str());
2096+ } else {
2097+ return Color(colors.front()->getColorType(), colors.front()->getId(), colors);
2098+ }
2099+ }
2100+ }
2101+}
2102+
2103
2104=== added file 'src/PetriEngine/Colored/TimeInvariant.cpp'
2105--- src/PetriEngine/Colored/TimeInvariant.cpp 1970-01-01 00:00:00 +0000
2106+++ src/PetriEngine/Colored/TimeInvariant.cpp 2021-04-19 13:50:22 +0000
2107@@ -0,0 +1,71 @@
2108+//
2109+// Created by niels on 3/20/19.
2110+//
2111+
2112+#include "PetriEngine/Colored/TimeInvariant.h"
2113+#include "PetriEngine/Colored/TimeInterval.h"
2114+
2115+namespace PetriEngine {
2116+ namespace Colored {
2117+
2118+ TimeInvariant TimeInvariant::createFor(const std::string& invariant, std::vector<const Colored::Color*> colors, std::unordered_map<std::string, uint32_t> constants){
2119+ Colored::Color color = createColor(colors);
2120+ bool strict = false;
2121+
2122+ std::string leq = "<=";
2123+ bool found = invariant.find(leq) != std::string::npos;
2124+ if(!found) {
2125+ strict = true;
2126+ }
2127+ int bound = std::numeric_limits<int>().max();
2128+
2129+ int pos = strict ? 1 : 2;
2130+ std::string number = invariant.substr(pos);
2131+ TimeInterval::trim(number);
2132+
2133+ bool foundInf = false;
2134+ std::string inf = "inf";
2135+ std::size_t findInf = invariant.find(inf);
2136+ if(findInf != std::string::npos) {
2137+ foundInf = true;
2138+ }
2139+
2140+ if(foundInf == false) {
2141+ if (constants.find(number) == constants.end())
2142+ bound = std::stoi(number);
2143+ else
2144+ bound = constants[number];
2145+ }
2146+
2147+
2148+ if (bound == std::numeric_limits<int>().max())
2149+ return TimeInvariant(color);
2150+ else
2151+ return TimeInvariant(strict, bound, color);
2152+ }
2153+
2154+ Colored::Color TimeInvariant::createColor(std::vector<const Colored::Color*> colors) {
2155+ if (colors.size() == 1 ) {
2156+ return Color(colors.front()->getColorType(), colors.front()->getId(), colors.front()->getColorName().c_str());
2157+ } else {
2158+ std::cerr << colors.size() << " colors size";
2159+ return Color(colors.front()->getColorType(), colors.front()->getId(), colors);
2160+ }
2161+ }
2162+
2163+ void TimeInvariant::print(std::ostream& out) const
2164+ {
2165+ std::string comparison = strictComparison ? "<" : "<=";
2166+ std::string strBound = bound == std::numeric_limits<int>().max() ? "inf" : std::to_string(bound);
2167+ strBound = " " + strBound;
2168+ out << comparison << strBound;
2169+ }
2170+ std::string TimeInvariant::toString() {
2171+ std::string comparison = strictComparison ? "<" : "<=";
2172+ std::string strBound = bound == std::numeric_limits<int>().max() ? "inf" : std::to_string(bound);
2173+ strBound = " " + strBound;
2174+ comparison = comparison + strBound;
2175+ return comparison;
2176+ }
2177+ }
2178+}
2179\ No newline at end of file
2180
2181=== modified file 'src/PetriEngine/PQL/Expressions.cpp'
2182--- src/PetriEngine/PQL/Expressions.cpp 2021-04-14 11:51:52 +0000
2183+++ src/PetriEngine/PQL/Expressions.cpp 2021-04-19 13:50:22 +0000
2184@@ -171,6 +171,172 @@
2185 return FALSE_CONSTANT;
2186 }
2187 }
2188+<<<<<<< TREE
2189+=======
2190+
2191+ /******************** To String ********************/
2192+
2193+ void LiteralExpr::toString(std::ostream& out) const {
2194+ out << _value;
2195+ }
2196+
2197+ void UnfoldedIdentifierExpr::toString(std::ostream& out) const {
2198+ out << _name;
2199+ }
2200+
2201+ void NaryExpr::toString(std::ostream& ss) const {
2202+ ss << "(";
2203+ _exprs[0]->toString(ss);
2204+ for(size_t i = 1; i < _exprs.size(); ++i)
2205+ {
2206+ ss << " " << op() << " ";
2207+ _exprs[i]->toString(ss);
2208+ }
2209+ ss << ")";
2210+ }
2211+
2212+ void CommutativeExpr::toString(std::ostream& ss) const {
2213+ ss << "( " << _constant;
2214+ for(auto& i : _ids)
2215+ ss << " " << op() << " " << i.second;
2216+ for(auto& e : _exprs)
2217+ {
2218+ ss << " " << op() << " ";
2219+ e->toString(ss);
2220+ }
2221+ ss << ")";
2222+ }
2223+
2224+
2225+ void MinusExpr::toString(std::ostream& out) const {
2226+ out << "-";
2227+ _expr->toString(out);
2228+ }
2229+
2230+ void SimpleQuantifierCondition::toString(std::ostream& out) const {
2231+ out << op() << " ";
2232+ _cond->toString(out);
2233+ }
2234+
2235+ void UntilCondition::toString(std::ostream& out) const {
2236+ out << op() << " (";
2237+ _cond1->toString(out);
2238+ out << " U ";
2239+ _cond2->toString(out);
2240+ out << ")";
2241+ }
2242+
2243+ void LogicalCondition::toString(std::ostream& out) const {
2244+ out << "(";
2245+ _conds[0]->toString(out);
2246+ for(size_t i = 1; i < _conds.size(); ++i)
2247+ {
2248+ out << " " << op() << " ";
2249+ _conds[i]->toString(out);
2250+ }
2251+ out << ")";
2252+ }
2253+
2254+ void CompareConjunction::toString(std::ostream& out) const {
2255+ out << "(";
2256+ if(_negated) out << "not";
2257+ bool first = true;
2258+ for(auto& c : _constraints)
2259+ {
2260+ if(!first) out << " and ";
2261+ if(c._lower != 0)
2262+ out << "(" << c._lower << " <= " << c._name << ")";
2263+ if(c._lower != 0 && c._upper != std::numeric_limits<uint32_t>::max())
2264+ out << " and ";
2265+ if(c._upper != std::numeric_limits<uint32_t>::max())
2266+ out << "(" << c._upper << " >= " << c._name << ")";
2267+ first = false;
2268+ }
2269+ out << ")";
2270+ }
2271+
2272+ void CompareCondition::toString(std::ostream& out) const {
2273+ out << "(";
2274+ _expr1->toString(out);
2275+ out << " " << op() << " ";
2276+ _expr2->toString(out);
2277+ out <<")";
2278+ }
2279+
2280+ void NotCondition::toString(std::ostream& out) const {
2281+ out << "(not ";
2282+ _cond->toString(out);
2283+ out << ")";
2284+ }
2285+
2286+ void BooleanCondition::toString(std::ostream& out) const {
2287+ if (_value)
2288+ out << "true";
2289+ else
2290+ out << "false";
2291+ }
2292+
2293+ void DeadlockCondition::toString(std::ostream& out) const {
2294+ out << "deadlock";
2295+ }
2296+
2297+ void StableMarkingCondition::_toString(std::ostream &out) const {
2298+ if(_compiled) _compiled->toString(out);
2299+ else out << "stable-marking";
2300+ }
2301+
2302+ void LivenessCondition::_toString(std::ostream &out) const {
2303+ if(_compiled) _compiled->toString(out);
2304+ else out << "liveness";
2305+ }
2306+
2307+ void QuasiLivenessCondition::_toString(std::ostream &out) const {
2308+ if(_compiled) _compiled->toString(out);
2309+ else out << "liveness";
2310+ }
2311+
2312+ void KSafeCondition::_toString(std::ostream &out) const {
2313+ if(_compiled) _compiled->toString(out);
2314+ else
2315+ {
2316+ out << "k-safe(";
2317+ _bound->toString(out);
2318+ out << ")";
2319+ }
2320+ }
2321+
2322+ void UpperBoundsCondition::_toString(std::ostream& out) const {
2323+ if(_compiled) _compiled->toString(out);
2324+ else
2325+ {
2326+ out << "bounds (";
2327+ for(size_t i = 0; i < _places.size(); ++i)
2328+ {
2329+ if(i != 0) out << ", ";
2330+ out << _places[i];
2331+ }
2332+ out << ")";
2333+ }
2334+ }
2335+
2336+ void UnfoldedUpperBoundsCondition::toString(std::ostream& out) const {
2337+ out << "bounds (";
2338+ for(size_t i = 0; i < _places.size(); ++i)
2339+ {
2340+ if(i != 0) out << ", ";
2341+ out << _places[i]._name;
2342+ }
2343+ out << ")";
2344+ }
2345+
2346+ void FireableCondition::_toString(std::ostream &out) const {
2347+ out << "is-fireable(" << _name << ")";
2348+ }
2349+
2350+ void UnfoldedFireableCondition::_toString(std::ostream &out) const {
2351+ out << "is-fireable(" << _name << ")";
2352+ }
2353+>>>>>>> MERGE-SOURCE
2354
2355 /******************** To TAPAAL Query ********************/
2356
2357@@ -4090,3 +4256,4 @@
2358 } // PQL
2359 } // PetriEngine
2360
2361+
2362
2363=== modified file 'src/PetriEngine/PetriNet.cpp'
2364--- src/PetriEngine/PetriNet.cpp 2021-03-15 10:04:47 +0000
2365+++ src/PetriEngine/PetriNet.cpp 2021-04-19 13:50:22 +0000
2366@@ -26,6 +26,9 @@
2367 #include <stdlib.h>
2368 #include <string.h>
2369 #include <assert.h>
2370+#include <algorithm>
2371+#include <iostream>
2372+#include <string>
2373
2374 namespace PetriEngine {
2375
2376@@ -176,20 +179,32 @@
2377 }
2378 }
2379
2380- void PetriNet::toXML(std::ostream& out)
2381+ void PetriNet::toXML(std::ostream& out, bool timed, std::map<std::string, std::string> _invariantStrings, bool verifydtapn)
2382 {
2383- out << "<?xml version=\"1.0\"?>\n"
2384- << "<pnml xmlns=\"http://www.pnml.org/version-2009/grammar/pnml\">\n"
2385- << "<net id=\"ClientsAndServers-PT-N0500P0\" type=\"http://www.pnml.org/version-2009/grammar/ptnet\">\n";
2386- out << "<page id=\"page0\">\n"
2387- << "<name>\n"
2388- << "<text>DefaultPage</text>"
2389- << "</name>";
2390+ if(!timed) {
2391+ out << "<?xml version=\"1.0\"?>\n"
2392+ << "<pnml xmlns=\"http://www.pnml.org/version-2009/grammar/pnml\">\n"
2393+ << "<net id=\"ClientsAndServers-PT-N0500P0\" type=\"http://www.pnml.org/version-2009/grammar/ptnet\">\n";
2394+ out << "<page id=\"page0\">\n"
2395+ << "<name>\n"
2396+ << "<text>DefaultPage</text>"
2397+ << "</name>";
2398+ } else {
2399+ if (!verifydtapn) {
2400+ out << "<?xml version=\"1.0\"?>\n";
2401+ }
2402+
2403+ out << "<pnml xmlns=\"http://www.pnml.org/version-2009/grammar/pnml\">\n"
2404+ << "<net id=\"ClientsAndServers-PT-N0500P0\" active=\"true\" type=\"P/T net\">\n";
2405+
2406+
2407+ }
2408
2409 for(size_t i = 0; i < _nplaces; ++i)
2410 {
2411 auto& p = _placenames[i];
2412 auto& placelocation = _placelocations[i];
2413+<<<<<<< TREE
2414 out << "<place id=\"" << p << "\">\n"
2415 << "<graphics><position x=\"" << std::get<0>(placelocation)
2416 << "\" y=\"" << std::get<1>(placelocation) << "\"/></graphics>\n"
2417@@ -197,17 +212,62 @@
2418 if(_initialMarking[i] > 0)
2419 {
2420 out << "<initialMarking><text>" << _initialMarking[i] << "</text></initialMarking>\n";
2421+=======
2422+ if(!timed) {
2423+ out << "<place id=\"" << p << "\">\n"
2424+ << "<graphics><position x=\"" << get<0>(placelocation)
2425+ << "\" y=\"" << get<1>(placelocation) << "\"/></graphics>\n"
2426+ << "<name><text>" << p << "</text></name>\n";
2427+ if(_initialMarking[i] > 0)
2428+ {
2429+ out << "<initialMarking><text>" << _initialMarking[i] << "</text></initialMarking>\n";
2430+ }
2431+ out << "</place>\n";
2432+ } else {
2433+ std::string invariant = _invariantStrings.at(p);
2434+ std::string toReplace("<");
2435+ size_t pos = invariant.find(toReplace);
2436+ invariant.replace(pos, toReplace.length(), "&lt;");
2437+
2438+ if (verifydtapn) {
2439+ out << R"(<place id=")" << p << "\"" << R"( initialMarking=")" << _initialMarking[i] << R"(" invariant=")" << invariant <<
2440+ R"(" name=")" << p << "\"/>\n";
2441+ }
2442+ else {
2443+ out << R"(<place displayName="true" id=")" << p << "\"" << R"( initialMarking=")" << _initialMarking[i] << R"(" invariant=")" << invariant <<
2444+ R"(" markingOffsetX="0.0" markingOffsetY="0.0" name=")" << p << R"(" nameOffsetX="-5.0" nameOffsetY="35.0" positionX=")" << get<0>(placelocation) << R"(" positionY=")" << get<1>(placelocation) << "\" />\n";
2445+ }
2446+>>>>>>> MERGE-SOURCE
2447 }
2448- out << "</place>\n";
2449 }
2450 for(size_t i = 0; i < _ntransitions; ++i)
2451 {
2452 auto& transitionlocation = _transitionlocations[i];
2453+<<<<<<< TREE
2454 out << "<transition id=\"" << _transitionnames[i] << "\">\n"
2455 << "<name><text>" << _transitionnames[i] << "</text></name>\n";
2456 out << "<graphics><position x=\"" << std::get<0>(transitionlocation)
2457 << "\" y=\"" << std::get<1>(transitionlocation) << "\"/></graphics>\n";
2458 out << "</transition>\n";
2459+=======
2460+ if (!timed) {
2461+ out << "<transition id=\"" << _transitionnames[i] << "\">\n"
2462+ << "<name><text>" << _transitionnames[i] << "</text></name>\n";
2463+ out << "<graphics><position x=\"" << get<0>(transitionlocation)
2464+ << "\" y=\"" << get<1>(transitionlocation) << "\"/></graphics>\n";
2465+ out << "</transition>\n";
2466+ } else {
2467+ if (verifydtapn) {
2468+ out << R"(<transition id=")" << _transitionnames[i] << "\" name=\"" << _transitionnames[i] << R"(" urgent=")" << BoolToString(_transitions[i].urgent) << "\"";
2469+ out << "/>\n";
2470+ }
2471+ else {
2472+ out << R"(<transition angle="0" displayName="true" id=")" << _transitionnames[i] << "\" name=\"" << _transitionnames[i] << R"(" infiniteServer="false" nameOffsetX="-5.0" nameOffsetY="35.0" positionX=")" << get<0>(transitionlocation) << R"(" positionY=")" << get<1>(transitionlocation) << R"(" priority="0"
2473+ urgent=")" << BoolToString(_transitions[i].urgent) << " \"";
2474+ out << "/>\n";
2475+ }
2476+ }
2477+>>>>>>> MERGE-SOURCE
2478 }
2479 size_t id = 0;
2480 for(size_t t = 0; t < _ntransitions; ++t)
2481@@ -216,37 +276,123 @@
2482
2483 for(; pre.first != pre.second; ++pre.first)
2484 {
2485- out << "<arc id=\"" << (id++) << "\" source=\""
2486- << _placenames[pre.first->place] << "\" target=\""
2487- << _transitionnames[t]
2488- << "\" type=\""
2489- << (pre.first->inhibitor ? "inhibitor" : "normal")
2490- << "\">\n";
2491-
2492- if(pre.first->tokens > 1)
2493- {
2494- out << "<inscription><text>" << pre.first->tokens << "</text></inscription>\n";
2495+ if(!timed) {
2496+ out << "<arc id=\"" << (id++) << "\" source=\""
2497+ << _placenames[pre.first->place] << "\" target=\""
2498+ << _transitionnames[t]
2499+ << "\" type=\""
2500+ << (pre.first->inhibitor ? "inhibitor" : "normal")
2501+ << "\">\n";
2502+
2503+ if(pre.first->tokens > 1)
2504+ {
2505+ out << "<inscription><text>" << pre.first->tokens << "</text></inscription>\n";
2506+ }
2507+
2508+ out << "</arc>\n";
2509+ } else {
2510+ std::string type = getType(pre, true);
2511+ std::string arcName = getArcIdentifier(type);
2512+ if (verifydtapn) {
2513+ if (arcName.compare("transportArc") == 0) {
2514+ auto post = postset(t);
2515+ for (; post.first != post.second; ++post.first) {
2516+ if (post.first->transportID.compare(pre.first->transportID) == 0 && (getType(post, false).compare("transport")) == 0) {
2517+ out << "<" << arcName << R"( id=")" << (id++) << R"(" inscription=")" << pre.first->interval << R"(" source=")" << _placenames[pre.first->place] << R"(" transition=")" << _transitionnames[t] << "\" weight=\"" << pre.first->tokens << "\" target=\"" << _placenames[post.first->place] << "\" />\n";
2518+ continue;
2519+ }
2520+ }
2521+ } else {
2522+ out << "<" << arcName << R"( id=")" << (id++) << R"(" inscription=")" << pre.first->interval << R"(" source=")" << _placenames[pre.first->place] << "\" weight=\"" << pre.first->tokens << "\" target=\"" << _transitionnames[t] << "\" />\n";
2523+ }
2524+ }
2525+ else {
2526+ if (arcName.compare("transportArc") == 0) {
2527+ auto post = postset(t);
2528+ for (; post.first != post.second; ++post.first) {
2529+ if (post.first->transportID.compare(pre.first->transportID) == 0 && (getType(post, false).compare("transport")) == 0) {
2530+ out << R"(<arc id=")" << (id++) << R"(" inscription=")" << pre.first->interval << R"(" nameOffsetX="0.0" source=")" << _placenames[pre.first->place] << "\" weight=\"" << pre.first->tokens << "\" target=\"" << _transitionnames[t] << "\" type=\"" << type << "\" />\n";
2531+ out << R"(<arc id=")" << (id++) << R"(" inscription=")" << pre.first->interval
2532+ << R"(" nameOffsetX="0.0" source=")" << _transitionnames[t] << "\" weight=\"" << post.first->tokens << "\" target=\"" << _placenames[post.first->place] << "\" type=\"" << type << "\" />\n";
2533+ continue;
2534+ }
2535+ }
2536+ }
2537+ else {
2538+ out << R"(<arc id=")" << (id++) << R"(" inscription=")" << pre.first->interval << R"(" nameOffsetX="0.0" source=")" << _placenames[pre.first->place] << "\" weight=\"" << pre.first->tokens << "\" target=\"" << _transitionnames[t] << "\" type=\"" << type << "\" />\n";
2539+ }
2540+
2541+ }
2542 }
2543-
2544- out << "</arc>\n";
2545 }
2546
2547 auto post = postset(t);
2548 for(; post.first != post.second; ++post.first)
2549 {
2550- out << "<arc id=\"" << (id++) << "\" source=\""
2551- << _transitionnames[t] << "\" target=\""
2552- << _placenames[post.first->place] << "\">\n";
2553-
2554- if(post.first->tokens > 1)
2555- {
2556- out << "<inscription><text>" << post.first->tokens << "</text></inscription>\n";
2557- }
2558-
2559- out << "</arc>\n";
2560+ if (!timed) {
2561+ out << "<arc id=\"" << (id++) << "\" source=\""
2562+ << _transitionnames[t] << "\" target=\""
2563+ << _placenames[post.first->place] << "\">\n";
2564+
2565+ if(post.first->tokens > 1)
2566+ {
2567+ out << "<inscription><text>" << post.first->tokens << "</text></inscription>\n";
2568+ }
2569+
2570+ out << "</arc>\n";
2571+ }
2572+ else {
2573+ std::string type = getType(post, false);
2574+ if(type.compare("transport") == 0)
2575+ continue;
2576+ if (verifydtapn) {
2577+ std::string arcName = getArcIdentifier(type);
2578+ out << "<" << arcName << " id=\"" << (id++) << "\" source=\""
2579+ << _transitionnames[t] << "\" target=\""
2580+ << _placenames[post.first->place] << "\" weight=\"" << post.first->tokens << "\"/>\n";
2581+ } else {
2582+ out << "<arc id=\"" << (id++) << "\" source=\""
2583+ << _transitionnames[t] << "\" target=\""
2584+ << _placenames[post.first->place] << R"(" type=")" << type << "\" weight=\"" << post.first->tokens << "\"/>\n";
2585+ }
2586+ }
2587 }
2588 }
2589- out << "</page></net>\n</pnml>";
2590+ if (!timed)
2591+ out << "</page></net>\n</pnml>";
2592+ else
2593+ out << "</net>\n</pnml>";
2594+ }
2595+
2596+ std::string PetriNet::getType(std::pair<const Invariant*, const Invariant*> pair, bool pre) {
2597+ if(pre) {
2598+ if (pair.first->transport)
2599+ return "transport";
2600+ else if (pair.first->inhibitor)
2601+ return "inhibitor";
2602+ else
2603+ return "timed";
2604+ } else {
2605+ if (pair.first->transport)
2606+ return "transport";
2607+ else
2608+ return "normal";
2609+ }
2610+ }
2611+
2612+ std::string PetriNet::getArcIdentifier(std::string arcType) {
2613+ std::string arcIdentifier;
2614+ if (arcType.compare("normal") == 0) {
2615+ arcIdentifier = "outputArc";
2616+ } else if (arcType.compare("timed") == 0 ) {
2617+ arcIdentifier = "inputArc";
2618+ } else if (arcType.compare("transport") == 0) {
2619+ arcIdentifier = "transportArc";
2620+ } else {
2621+ arcIdentifier = "inhibitorArc";
2622+ }
2623+ return arcIdentifier;
2624 }
2625
2626 } // PetriEngine
2627+
2628
2629=== modified file 'src/PetriEngine/PetriNetBuilder.cpp'
2630--- src/PetriEngine/PetriNetBuilder.cpp 2021-03-15 10:04:47 +0000
2631+++ src/PetriEngine/PetriNetBuilder.cpp 2021-04-19 13:50:22 +0000
2632@@ -60,7 +60,27 @@
2633
2634 }
2635
2636+<<<<<<< TREE
2637 void PetriNetBuilder::addTransition(const std::string &name,
2638+=======
2639+ void PetriNetBuilder::addPlace(const string &name, int tokens, Colored::TimeInvariant invariant,
2640+ double x, double y) {
2641+ if(_placenames.count(name) == 0){
2642+ uint32_t next = _placenames.size();
2643+ _places.emplace_back();
2644+ _placenames[name] = next;
2645+ _invariantStrings[name] = invariant.toString();
2646+ _placelocations.push_back(std::tuple<double, double>(x,y));
2647+
2648+ }
2649+ uint32_t id = _placenames[name];
2650+ while(initialMarking.size() <= id) initialMarking.emplace_back();
2651+ initialMarking[id] = tokens;
2652+
2653+ }
2654+
2655+ void PetriNetBuilder::addTransition(const string &name,
2656+>>>>>>> MERGE-SOURCE
2657 double x, double y) {
2658 if(_transitionnames.count(name) == 0)
2659 {
2660@@ -71,7 +91,23 @@
2661 }
2662 }
2663
2664+<<<<<<< TREE
2665 void PetriNetBuilder::addInputArc(const std::string &place, const std::string &transition, bool inhibitor, int weight) {
2666+=======
2667+ void PetriNetBuilder::addTransition(const string &name, bool urgent,
2668+ double x, double y) {
2669+ if(_transitionnames.count(name) == 0)
2670+ {
2671+ uint32_t next = _transitionnames.size();
2672+ _transitions.emplace_back();
2673+ _transitionnames[name] = next;
2674+ _transitions[next].urgent = urgent;
2675+ _transitionlocations.push_back(std::tuple<double, double>(x,y));
2676+ }
2677+ }
2678+
2679+ void PetriNetBuilder::addInputArc(const string &place, const string &transition, bool inhibitor, int weight) {
2680+>>>>>>> MERGE-SOURCE
2681 if(_transitionnames.count(transition) == 0)
2682 {
2683 addTransition(transition,0.0,0.0);
2684@@ -96,7 +132,54 @@
2685 _places[p].inhib |= inhibitor;
2686 }
2687
2688+<<<<<<< TREE
2689 void PetriNetBuilder::addOutputArc(const std::string &transition, const std::string &place, int weight) {
2690+=======
2691+ void PetriNetBuilder::addInputArc(const std::string &place,
2692+ const std::string &transition,
2693+ bool inhibitor, bool transport,
2694+ int weight,
2695+ PetriEngine::Colored::TimeInterval &interval, std::string transportID) {
2696+ if(_transitionnames.count(transition) == 0)
2697+ {
2698+ addTransition(transition,0.0,0.0);
2699+ }
2700+ if(_placenames.count(place) == 0)
2701+ {
2702+ //addPlace(place,0,0,0);
2703+ }
2704+ uint32_t p = _placenames[place];
2705+ uint32_t t = _transitionnames[transition];
2706+
2707+
2708+ uint32_t lowerBound = interval.getLowerBound();
2709+ uint32_t upperBound = interval.getUpperBound();
2710+ bool lowerStrict = interval.isLowerBoundStrict();
2711+ bool upperStrict = interval.isUpperBoundStrict();
2712+
2713+ Arc arc;
2714+ arc.place = p;
2715+ arc.weight = weight;
2716+ arc.skip = false;
2717+ arc.inhib = inhibitor;
2718+ arc.transport = transport;
2719+ arc.lowerBound = lowerBound;
2720+ arc.upperBound = upperBound;
2721+ arc.lowerStrict = lowerStrict;
2722+ arc.upperStrict = upperStrict;
2723+ arc.interval = interval.toString();
2724+ arc.transportID = transportID;
2725+ assert(t < _transitions.size());
2726+ assert(p < _places.size());
2727+ _transitions[t].pre.push_back(arc);
2728+ _transitions[t].inhib |= inhibitor;
2729+ _places[p].consumers.push_back(t);
2730+ _places[p].inhib |= inhibitor;
2731+
2732+ }
2733+
2734+ void PetriNetBuilder::addOutputArc(const string &transition, const string &place, int weight, bool transport, std::string transportID) {
2735+>>>>>>> MERGE-SOURCE
2736 if(_transitionnames.count(transition) == 0)
2737 {
2738 addTransition(transition,0,0);
2739@@ -110,11 +193,12 @@
2740
2741 assert(t < _transitions.size());
2742 assert(p < _places.size());
2743-
2744 Arc arc;
2745 arc.place = p;
2746 arc.weight = weight;
2747 arc.skip = false;
2748+ arc.transport = transport;
2749+ arc.transportID = transportID;
2750 _transitions[t].post.push_back(arc);
2751 _places[p].producers.push_back(t);
2752 }
2753@@ -159,7 +243,7 @@
2754 * If anybody wants to spend time on it, this is the first step towards
2755 * a decision-tree like construction, possibly improving successor generation.
2756 */
2757-
2758+
2759 uint32_t nplaces = _places.size() - reducer.RemovedPlaces();
2760 uint32_t ntrans = _transitions.size() - reducer.RemovedTransitions();
2761
2762@@ -167,9 +251,13 @@
2763 std::vector<uint32_t> place_prod_count = std::vector<uint32_t>(_places.size());
2764 std::vector<uint32_t> place_idmap = std::vector<uint32_t>(_places.size());
2765 std::vector<uint32_t> trans_idmap = std::vector<uint32_t>(_transitions.size());
2766+<<<<<<< TREE
2767
2768
2769
2770+=======
2771+
2772+>>>>>>> MERGE-SOURCE
2773 uint32_t invariants = 0;
2774
2775 for(uint32_t i = 0; i < _places.size(); ++i)
2776@@ -190,7 +278,11 @@
2777
2778
2779 PetriNet* net = new PetriNet(ntrans, invariants, nplaces);
2780-
2781+ if (isTimed()) {
2782+ net->setTimed(true);
2783+ net->setInvariants(_invariantStrings);
2784+ }
2785+
2786 uint32_t next = nextPlaceId(place_cons_count, place_prod_count, place_idmap, reorder);
2787 uint32_t free = 0;
2788 uint32_t freeinv = 0;
2789@@ -208,6 +300,7 @@
2790
2791 if(trans.skip) continue;
2792 net->_transitions[freetrans].inputs = freeinv;
2793+ net->_transitions[freetrans].urgent = trans.urgent;
2794
2795 // add inhibitors
2796 for(auto pre : trans.pre)
2797@@ -216,6 +309,9 @@
2798 iv.place = pre.place;
2799 iv.tokens = pre.weight;
2800 iv.inhibitor = pre.inhib;
2801+ iv.transport = pre.transport;
2802+ iv.interval = pre.interval;
2803+ iv.transportID = pre.transportID;
2804 assert(pre.inhib);
2805 assert(place_cons_count[pre.place] > 0);
2806 --place_cons_count[pre.place];
2807@@ -228,7 +324,9 @@
2808 {
2809 assert(freeinv < net->_ninvariants);
2810 net->_invariants[freeinv].place = post.place;
2811- net->_invariants[freeinv].tokens = post.weight;
2812+ net->_invariants[freeinv].tokens = post.weight;
2813+ net->_invariants[freeinv].transport = post.transport;
2814+ net->_invariants[freeinv].transportID = post.transportID;
2815 ++freeinv;
2816 }
2817
2818@@ -297,6 +395,9 @@
2819 iv.place = pre.place;
2820 iv.tokens = pre.weight;
2821 iv.inhibitor = pre.inhib;
2822+ iv.transport = pre.transport;
2823+ iv.interval = pre.interval;
2824+ iv.transportID = pre.transportID;
2825 ++freeinv;
2826 assert(place_cons_count[pre.place] > 0);
2827 --place_cons_count[pre.place];
2828@@ -306,9 +407,11 @@
2829 for(auto post : trans.post)
2830 {
2831 assert(freeinv < net->_ninvariants);
2832- auto& post_inv = net->_invariants[freeinv];
2833+ Invariant& post_inv = net->_invariants[freeinv];
2834 post_inv.place = post.place;
2835- post_inv.tokens = post.weight;
2836+ post_inv.tokens = post.weight;
2837+ post_inv.transport = post.transport;
2838+ post_inv.transportID = post.transportID;
2839 --place_prod_count[post.place];
2840 ++freeinv;
2841 }
2842@@ -476,3 +579,4 @@
2843
2844
2845 } // PetriEngine
2846+
2847
2848=== modified file 'src/PetriParse/PNMLParser.cpp'
2849--- src/PetriParse/PNMLParser.cpp 2021-04-14 10:41:18 +0000
2850+++ src/PetriParse/PNMLParser.cpp 2021-04-19 13:50:22 +0000
2851@@ -23,6 +23,7 @@
2852 #include <cstdlib>
2853 #include <iostream>
2854 #include <limits>
2855+#include <fstream>
2856 #include <cstring>
2857
2858
2859@@ -38,7 +39,6 @@
2860 id2name.clear();
2861 arcs.clear();
2862 transitions.clear();
2863- inhibarcs.clear();
2864 colorTypes.clear();
2865
2866 //Set the builder
2867@@ -57,12 +57,38 @@
2868 exit(ErrorCode);
2869 }
2870
2871- auto declarations = root->first_node("net")->first_node("declaration");
2872+ auto declarations = root->first_node("declaration");
2873+ if(declarations == nullptr){
2874+ declarations = root->first_node("net")->first_node("declaration");
2875+ }
2876+
2877 isColored = declarations != nullptr;
2878 if (isColored) {
2879 builder->enableColors();
2880 parseDeclarations(declarations);
2881 }
2882+
2883+ auto netType = root->first_node("net");
2884+ rapidxml::xml_node<> *placeElement = netType->first_node("place");
2885+ while(placeElement == nullptr && netType != nullptr){
2886+ netType = netType->first_node();
2887+ placeElement = netType->first_node("place");
2888+ }
2889+
2890+ if (isColored && checkIsTimed(netType)){
2891+ builder->enableTimed();
2892+ isTimed = true;
2893+ } else {
2894+ isTimed = false;
2895+ }
2896+
2897+ //xml_node<> *child = node->first_node(); child; child = child->next_sibling()
2898+ for (auto it = root->first_node(); it; it = it->next_sibling()) {
2899+ if (strcmp(it->name(), "constant") == 0)
2900+ constantValues[it->first_attribute("name")->value()] = atoi(it->first_attribute("value")->value());
2901+ else
2902+ break;
2903+ }
2904 parseElement(root);
2905
2906 //Add all the transition
2907@@ -70,7 +96,10 @@
2908 if (!isColored) {
2909 builder->addTransition(transition.id, transition.x, transition.y);
2910 } else {
2911- builder->addTransition(transition.id, transition.expr, transition.x, transition.y);
2912+ if (isTimed)
2913+ builder->addTransition(transition.id, transition.expr, transition.urgent, transition.x, transition.y);
2914+ else
2915+ builder->addTransition(transition.id, transition.expr, transition.x, transition.y);
2916 }
2917
2918 //Add all the arcs
2919@@ -97,14 +126,18 @@
2920
2921 if (source.isPlace && !target.isPlace) {
2922 if (!isColored) {
2923- builder->addInputArc(source.id, target.id, false, arc.weight);
2924+ builder->addInputArc(source.id, target.id, arc.inhib, arc.weight);
2925+ } else if(isTimed) {
2926+ builder->addInputArc(source.id, target.id, arc.inhib, arc.transport, arc.expr, arc.interval, arc.weight, arc.transportID);
2927 } else {
2928- builder->addInputArc(source.id, target.id, arc.expr);
2929+ builder->addInputArc(source.id, target.id, arc.expr, arc.inhib, arc.weight);
2930 }
2931
2932 } else if (!source.isPlace && target.isPlace) {
2933 if (!isColored) {
2934 builder->addOutputArc(source.id, target.id, arc.weight);
2935+ } else if (isTimed) {
2936+ builder->addOutputArc(source.id, target.id, arc.expr, arc.transport, arc.transportID);
2937 } else {
2938 builder->addOutputArc(source.id, target.id, arc.expr);
2939 }
2940@@ -116,21 +149,28 @@
2941 }
2942 }
2943
2944- for(Arc& inhibitor : inhibarcs)
2945- {
2946- NodeName source = id2name[inhibitor.source];
2947- NodeName target = id2name[inhibitor.target];
2948- if (source.isPlace && !target.isPlace) {
2949- builder->addInputArc(source.id, target.id, true, inhibitor.weight);
2950- }
2951- else
2952- {
2953- fprintf(stderr,
2954- "XML Parsing error: Inhibitor from \"%s\" to \"%s\" is not valid!\n",
2955- source.id.c_str(),
2956- target.id.c_str());
2957- }
2958- }
2959+ // std::cout << "Found " << inhibarcs.size() << " inhibitor arcs " << std::endl;
2960+ // for(Arc& inhibitor : inhibarcs)
2961+ // {
2962+ // NodeName source = id2name[inhibitor.source];
2963+ // NodeName target = id2name[inhibitor.target];
2964+ // if (source.isPlace && !target.isPlace) {
2965+ // if(!isColored){
2966+ // builder->addInputArc(source.id, target.id, inhibitor.inhib, inhibitor.weight);
2967+ // } else if (isTimed){
2968+ // builder->addInputArc(source.id, target.id, inhibitor.inhib, inhibitor.transport, inhibitor.expr, inhibitor.interval, inhibitor.weight, inhibitor.transportID);
2969+ // } else {
2970+ // builder->addInputArc(source.id, target.id, inhibitor.expr, inhibitor.inhib);
2971+ // }
2972+ // }
2973+ // else
2974+ // {
2975+ // fprintf(stderr,
2976+ // "XML Parsing error: Inhibitor from \"%s\" to \"%s\" is not valid!\n",
2977+ // source.id.c_str(),
2978+ // target.id.c_str());
2979+ // }
2980+ // }
2981
2982 //Unset the builder
2983 this->builder = nullptr;
2984@@ -139,11 +179,39 @@
2985 id2name.clear();
2986 arcs.clear();
2987 transitions.clear();
2988- inhibarcs.clear();
2989 colorTypes.clear();
2990 builder->sort();
2991 }
2992
2993+bool PNMLParser::checkIsTimed(rapidxml::xml_node<> *netType){
2994+ rapidxml::xml_node<char> * placeElement = netType->first_node("place");
2995+ rapidxml::xml_node<char> * arcElement = netType->first_node("inputArc");
2996+ while(placeElement == nullptr && netType != nullptr){
2997+ netType = netType->first_node();
2998+ if(netType != nullptr){
2999+ placeElement = netType->first_node("place");
3000+ }
3001+ }
3002+ while(arcElement == nullptr && netType != nullptr){
3003+ netType = netType->first_node();
3004+ if(netType != nullptr){
3005+ arcElement = netType->first_node("inputArc");
3006+ }
3007+ }
3008+ if(placeElement != nullptr){
3009+ if(placeElement->first_attribute("invariant") == nullptr){
3010+ return false;
3011+ }
3012+ }
3013+ if(arcElement != nullptr){
3014+ if(arcElement->first_attribute("inscription") == nullptr){
3015+ return false;
3016+ }
3017+ }
3018+
3019+ return true;
3020+}
3021+
3022 void PNMLParser::parseDeclarations(rapidxml::xml_node<>* element) {
3023 for (auto it = element->first_node(); it; it = it->next_sibling()) {
3024 if (strcmp(it->name(), "namedsort") == 0) {
3025@@ -481,6 +549,13 @@
3026 number = 1;
3027 first = num;
3028 }
3029+
3030+ if(strcmp(first->first_node()->name(), "tuple") == 0){
3031+ std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> collectedColors;
3032+ collectColorsInTuple(first->first_node(), collectedColors);
3033+ return constructAddExpressionFromTupleExpression(first->first_node(), collectedColors, number);
3034+ }
3035+
3036 auto allExpr = parseAllExpression(first);
3037 if (allExpr) {
3038 return std::make_shared<PetriEngine::Colored::NumberOfExpression>(std::move(allExpr), number);
3039@@ -493,6 +568,86 @@
3040 }
3041 }
3042
3043+void PNMLParser::collectColorsInTuple(rapidxml::xml_node<>* element, std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>>& collectedColors){
3044+ if (strcmp(element->name(), "tuple") == 0) {
3045+ for (auto it = element->first_node(); it; it = it->next_sibling()) {
3046+ collectColorsInTuple(it->first_node(), collectedColors);
3047+ }
3048+ } else if (strcmp(element->name(), "all") == 0) {
3049+ std::vector<PetriEngine::Colored::ColorExpression_ptr> expressionsToAdd;
3050+ auto expr = parseAllExpression(element);
3051+ std::unordered_map<uint32_t, std::vector<const PetriEngine::Colored::Color *>> constantMap;
3052+ uint32_t index = 0;
3053+ expr->getConstants(constantMap, index);
3054+ for(auto positionColors : constantMap){
3055+ for(auto color : positionColors.second){
3056+ expressionsToAdd.push_back(std::make_shared<PetriEngine::Colored::UserOperatorExpression>(color));
3057+ }
3058+ }
3059+ collectedColors.push_back(expressionsToAdd);
3060+ return;
3061+ } else if (strcmp(element->name(), "subterm") == 0 || strcmp(element->name(), "structure") == 0) {
3062+ collectColorsInTuple(element->first_node(), collectedColors);
3063+ } else if (strcmp(element->name(), "useroperator") == 0 || strcmp(element->name(), "dotconstant") == 0 || strcmp(element->name(), "variable") == 0
3064+ || strcmp(element->name(), "successor") == 0 || strcmp(element->name(), "predecessor") == 0) {
3065+ std::vector<PetriEngine::Colored::ColorExpression_ptr> expressionsToAdd;
3066+ auto color = parseColorExpression(element);
3067+ expressionsToAdd.push_back(color);
3068+ collectedColors.push_back(expressionsToAdd);
3069+ return;
3070+ } else{
3071+ printf("Could not collect tuple colors from arc expression '%s'\n", element->name());
3072+ return;
3073+ }
3074+}
3075+
3076+PetriEngine::Colored::ArcExpression_ptr PNMLParser::constructAddExpressionFromTupleExpression(rapidxml::xml_node<>* element,std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> collectedColors, uint32_t numberof){
3077+ auto initCartesianSet = cartesianProduct(collectedColors[0], collectedColors[1]);
3078+ for(uint32_t i = 2; i < collectedColors.size(); i++){
3079+ initCartesianSet = cartesianProduct(initCartesianSet, collectedColors[i]);
3080+ }
3081+ std::vector<PetriEngine::Colored::NumberOfExpression_ptr> numberOfExpressions;
3082+ for(auto set : initCartesianSet){
3083+ std::vector<PetriEngine::Colored::ColorExpression_ptr> colors;
3084+ for (auto color : set) {
3085+ colors.push_back(color);
3086+ }
3087+ std::shared_ptr<PetriEngine::Colored::TupleExpression> tupleExpr = std::make_shared<PetriEngine::Colored::TupleExpression>(std::move(colors));
3088+ tupleExpr->setColorType(tupleExpr->getColorType(colorTypes));
3089+ std::vector<PetriEngine::Colored::ColorExpression_ptr> placeholderVector;
3090+ placeholderVector.push_back(tupleExpr);
3091+ numberOfExpressions.push_back(std::make_shared<PetriEngine::Colored::NumberOfExpression>(std::move(placeholderVector),numberof));
3092+ }
3093+ std::vector<PetriEngine::Colored::ArcExpression_ptr> constituents;
3094+ for (auto expr : numberOfExpressions) {
3095+ constituents.push_back(expr);
3096+ }
3097+ return std::make_shared<PetriEngine::Colored::AddExpression>(std::move(constituents));
3098+}
3099+
3100+std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> PNMLParser::cartesianProduct(std::vector<PetriEngine::Colored::ColorExpression_ptr> rightSet, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftSet){
3101+ std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> returnSet;
3102+ for(auto expr : rightSet){
3103+ for(auto expr2 : leftSet){
3104+ std::vector<PetriEngine::Colored::ColorExpression_ptr> toAdd;
3105+ toAdd.push_back(expr);
3106+ toAdd.push_back(expr2);
3107+ returnSet.push_back(toAdd);
3108+ }
3109+ }
3110+ return returnSet;
3111+}
3112+std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> PNMLParser::cartesianProduct(std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> rightSet, std::vector<PetriEngine::Colored::ColorExpression_ptr> leftSet){
3113+ std::vector<std::vector<PetriEngine::Colored::ColorExpression_ptr>> returnSet;
3114+ for(auto set : rightSet){
3115+ for(auto expr2 : leftSet){
3116+ set.push_back(expr2);
3117+ returnSet.push_back(set);
3118+ }
3119+ }
3120+ return returnSet;
3121+}
3122+
3123 void PNMLParser::parseElement(rapidxml::xml_node<>* element) {
3124
3125 for (auto it = element->first_node(); it; it = it->next_sibling()) {
3126@@ -514,11 +669,11 @@
3127 } else if (strcmp(it->name(),"queries") == 0) {
3128 parseQueries(it);
3129 } else if (strcmp(it->name(), "k-bound") == 0) {
3130- std::cerr << "k-bound should be given as command line option -k" << std::endl;
3131- exit(ErrorCode);
3132+ //std::cerr << "k-bound should be given as command line option -k" << std::endl;
3133+ //exit(ErrorCode);
3134 } else if (strcmp(it->name(),"query") == 0) {
3135- std::cerr << "query tag not supported, please use PQL or XML-style queries instead" << std::endl;
3136- exit(ErrorCode);
3137+ //std::cerr << "query tag not supported, please use PQL or XML-style queries instead" << std::endl;
3138+ //exit(ErrorCode);
3139 }
3140 else
3141 {
3142@@ -527,6 +682,41 @@
3143 }
3144 }
3145
3146+std::pair<string, std::vector<const Colored::Color*>> PNMLParser::parseTimeConstraint(rapidxml::xml_node<> *element) { // parses the inscription and colors belonging to either an interval or invariant and returns it.
3147+ string colorTypeName;
3148+ string inscription;
3149+ std::vector<const Colored::Color*> colors;
3150+ for (auto i = element->first_node(); i; i = i->next_sibling()) {
3151+ if (strcmp(i->name(), "colortype") == 0) {
3152+ colorTypeName = i->first_attribute("name")->value();
3153+
3154+ if (colorTypes.find(colorTypeName) == colorTypes.end()) {
3155+ cerr << "The color type " << colorTypeName << " does not exist" << std::endl;
3156+ exit(ErrorCode);
3157+ }
3158+ else {
3159+ for (auto it = i->first_node(); it; it = it->next_sibling()) {
3160+ if (strcmp(it->name(), "color") == 0) {
3161+ Colored::Color* test = new Colored::Color(colorTypes[colorTypeName], 0, it->first_attribute("value")->value());
3162+ colors.push_back(test);
3163+
3164+ }
3165+ else {
3166+ std::cerr << "the colortype to the place element " << element->first_attribute("id")->value() << " does not have or should only have colors" << std::endl;
3167+ exit(ErrorCode);
3168+ }
3169+ }
3170+ }
3171+
3172+
3173+ } else if (strcmp(i->name(), "inscription") == 0) {
3174+ inscription = i->first_attribute("inscription")->value();
3175+
3176+ }
3177+ }
3178+ return std::make_pair(inscription, colors);
3179+}
3180+
3181 void PNMLParser::parseQueries(rapidxml::xml_node<>* element) {
3182 std::string query;
3183
3184@@ -542,17 +732,44 @@
3185
3186 void PNMLParser::parsePlace(rapidxml::xml_node<>* element) {
3187 double x = 0, y = 0;
3188+<<<<<<< TREE
3189 std::string id(element->first_attribute("id")->value());
3190+=======
3191+ string starInvariant;
3192+ string id(element->first_attribute("id")->value());
3193+>>>>>>> MERGE-SOURCE
3194
3195 auto initial = element->first_attribute("initialMarking");
3196 long long initialMarking = 0;
3197 PetriEngine::Colored::Multiset hlinitialMarking;
3198 PetriEngine::Colored::ColorType* type = nullptr;
3199+ std::vector<PetriEngine::Colored::TimeInvariant> timeInvariants;
3200 if(initial)
3201 initialMarking = atoll(initial->value());
3202
3203+ if (isTimed) {
3204+ auto posX = element->first_attribute("positionX");
3205+ if (posX != nullptr){
3206+ x = atoll(posX->value());
3207+ }
3208+ auto posY = element->first_attribute("positionY");
3209+ if ( posY != nullptr){
3210+ y = atoll(posY->value());
3211+ }
3212+ auto invariant = element->first_attribute("invariant");
3213+ if(invariant != nullptr){
3214+ starInvariant = invariant->value();
3215+ }
3216+
3217+
3218+ std::vector<const Colored::Color*> colors;
3219+ colors.push_back(new Colored::Color());
3220+ timeInvariants.push_back(Colored::TimeInvariant::createFor(starInvariant, colors, constantValues));
3221+ }
3222+
3223 for (auto it = element->first_node(); it; it = it->next_sibling()) {
3224 // name element is ignored
3225+<<<<<<< TREE
3226 if (strcmp(it->name(), "graphics") == 0) {
3227 parsePosition(it, x, y);
3228 } else if (strcmp(it->name(),"initialMarking") == 0) {
3229@@ -566,6 +783,33 @@
3230 hlinitialMarking = parseArcExpression(it->first_node("structure"))->eval(context);
3231 } else if (strcmp(it->name(), "type") == 0) {
3232 type = parseUserSort(it);
3233+=======
3234+ if (isTimed) {
3235+ if (strcmp(it->name(), "colorinvariant") == 0) {
3236+ std::pair<string, std::vector<const Colored::Color*>> pair = parseTimeConstraint(it);
3237+ timeInvariants.push_back(Colored::TimeInvariant::createFor(pair.first, pair.second, constantValues));
3238+ } else if (strcmp(it->name(),"hlinitialMarking") == 0) {
3239+ std::unordered_map<std::string, const PetriEngine::Colored::Color*> binding;
3240+ PetriEngine::Colored::ExpressionContext context {binding, colorTypes};
3241+ hlinitialMarking = parseArcExpression(it->first_node("structure"))->eval(context);
3242+ } else if (strcmp(it->name(), "type") == 0) {
3243+ type = parseUserSort(it);
3244+ }
3245+ } else {
3246+ if (strcmp(it->name(), "graphics") == 0) {
3247+ parsePosition(it, x, y);
3248+ } else if (strcmp(it->name(),"initialMarking") == 0) {
3249+ string text;
3250+ parseValue(it, text);
3251+ initialMarking = atoll(text.c_str());
3252+ } else if (strcmp(it->name(),"hlinitialMarking") == 0) {
3253+ std::unordered_map<std::string, const PetriEngine::Colored::Color*> binding;
3254+ PetriEngine::Colored::ExpressionContext context {binding, colorTypes};
3255+ hlinitialMarking = parseArcExpression(it->first_node("structure"))->eval(context);
3256+ } else if (strcmp(it->name(), "type") == 0) {
3257+ type = parseUserSort(it);
3258+ }
3259+>>>>>>> MERGE-SOURCE
3260 }
3261 }
3262
3263@@ -584,7 +828,10 @@
3264 }
3265 else
3266 {
3267- builder->addPlace(id, type, std::move(hlinitialMarking), x, y);
3268+ if (isTimed)
3269+ builder->addPlace(id, std::move(hlinitialMarking), type, timeInvariants, x, y);
3270+ else
3271+ builder->addPlace(id, type, std::move(hlinitialMarking), x, y);
3272 }
3273 }
3274 //Map id to name
3275@@ -599,17 +846,31 @@
3276 target = element->first_attribute("target")->value();
3277 int weight = 1;
3278 auto type = element->first_attribute("type");
3279- if(type && strcmp(type->value(), "timed") == 0)
3280+ bool transport = false;
3281+ string starInterval;
3282+ bool normal = false;
3283+ std::string transportID = "0";
3284+ std::vector<Colored::TimeInterval> timeIntervals;
3285+ if((type && strcmp(type->value(), "timed") == 0) || (element && strcmp(element->name(), "timedArc") == 0))
3286 {
3287- std::cerr << "timed arcs are not supported" << std::endl;
3288- exit(ErrorCode);
3289+ //TODO:: parse standard interval
3290 }
3291- else if(type && strcmp(type->value(), "inhibitor") == 0)
3292+ else if((type && strcmp(type->value(), "inhibitor") == 0) || (element && strcmp(element->name(), "inhibitorArc") == 0) || (type && strcmp(type->value(), "tapnInhibitor") == 0))
3293 {
3294+ std::cout << "Found inhib arc" << std::endl;
3295 inhibitor = true;
3296 }
3297+ else if((type && strcmp(type->value(), "transport") == 0) || (element && strcmp(element->name(), "transportArc") == 0))
3298+ {
3299+ transportID = element->first_attribute("transportID")->value();
3300+ transport = true;
3301+ }
3302+ else if ((type && strcmp(type->value(), "normal") == 0) || (element && (strcmp(element->name(), "inputArc") == 0 || strcmp(element->name(), "outputArc") == 0))) {
3303+ normal = true;
3304+ }
3305
3306 bool first = true;
3307+<<<<<<< TREE
3308 for (auto it = element->first_node("inscription"); it; it = it->next_sibling("inscription")) {
3309 std::string text;
3310 parseValue(it, text);
3311@@ -619,13 +880,32 @@
3312 std::cerr << "ERROR: Found non-integer-text in inscription-tag (weight) on arc from " << source << " to " << target << " with value \"" << text << "\". An integer was expected." << std::endl;
3313 exit(ErrorCode);
3314 }
3315+=======
3316+ auto weightTag = element->first_attribute("weight");
3317+ if(weightTag != nullptr){
3318+ string text;
3319+ weight = atoi(weightTag->value());
3320+>>>>>>> MERGE-SOURCE
3321 assert(weight > 0);
3322- if(!first)
3323- {
3324- std::cerr << "ERROR: Multiple inscription tags in xml of a arc from " << source << " to " << target << "." << std::endl;
3325- exit(ErrorCode);
3326+ } else {
3327+ for (auto it = element->first_node("inscription"); it; it = it->next_sibling("inscription")) {
3328+ string text;
3329+ parseValue(it, text);
3330+ weight = atoi(text.c_str());
3331+ /*
3332+ if(std::find_if(text.begin(), text.end(), [](char c) { return !std::isdigit(c) && !std::isblank(c); }) != text.end())
3333+ {
3334+ std::cerr << "ERROR: Found non-integer-text in inscription-tag (weight) on arc from " << source << " to " << target << " with value \"" << text << "\". An integer was expected." << std::endl;
3335+ exit(ErrorCode);
3336+ }*/
3337+ assert(weight > 0);
3338+ if(!first)
3339+ {
3340+ std::cerr << "ERROR: Multiple inscription tags in xml of a arc from " << source << " to " << target << "." << std::endl;
3341+ exit(ErrorCode);
3342+ }
3343+ first = false;
3344 }
3345- first = false;
3346 }
3347
3348 PetriEngine::Colored::ArcExpression_ptr expr;
3349@@ -639,31 +919,36 @@
3350 }
3351 first = false;
3352 }
3353+ if(isTimed && !normal && !inhibitor) {
3354+ starInterval = element->first_attribute("inscription")->value();
3355+ std::vector<const Colored::Color*> colors;
3356+ colors.push_back(new Colored::Color());
3357+ timeIntervals.push_back(Colored::TimeInterval::createFor(starInterval, colors, constantValues));
3358+ for (auto it = element->first_node("colorinterval"); it; it = it->next_sibling("colorinterval")) {
3359+ std::pair<string, std::vector<const Colored::Color*>> pair = parseTimeConstraint(it);
3360+ timeIntervals.push_back(Colored::TimeInterval::createFor(pair.first, pair.second, constantValues));
3361+ }
3362+ }
3363
3364- if (isColored)
3365+ if (isColored && !normal && !inhibitor)
3366 assert(expr != nullptr);
3367 Arc arc;
3368 arc.source = source;
3369 arc.target = target;
3370 arc.weight = weight;
3371- arc.expr = expr;
3372+ arc.inhib = inhibitor;
3373+ arc.transport = transport;
3374+ arc.normal = normal;
3375+ arc.transportID = transportID;
3376+ if(!inhibitor)
3377+ arc.expr = expr;
3378+ if(!normal && !inhibitor)
3379+ arc.interval = timeIntervals;
3380 assert(weight > 0);
3381
3382- if (inhibitor && isColored) {
3383- std::cerr << "inhibitor arcs are not supported in colored Petri nets" << std::endl;
3384- exit(ErrorCode);
3385- }
3386-
3387 if(weight != 0)
3388- {
3389- if(inhibitor)
3390- {
3391- inhibarcs.push_back(arc);
3392- }
3393- else
3394- {
3395- arcs.push_back(arc);
3396- }
3397+ {
3398+ arcs.push_back(arc);
3399 }
3400 else
3401 {
3402@@ -703,6 +988,23 @@
3403 t.y = 0;
3404 t.id = element->first_attribute("id")->value();
3405 t.expr = nullptr;
3406+ t.urgent = false;
3407+
3408+
3409+ if(isTimed) {
3410+ auto posX = element->first_attribute("positionX");
3411+ if (posX != nullptr){
3412+ t.x = atoll(posX->value());
3413+ }
3414+ auto posY = element->first_attribute("positionY");
3415+ if ( posY != nullptr){
3416+ t.y = atoll(posY->value());
3417+ }
3418+ auto urgent = element->first_attribute("urgent");
3419+ if (urgent != nullptr) {
3420+ t.urgent = stringToBool(urgent->value());
3421+ }
3422+ }
3423
3424
3425 for (auto it = element->first_node(); it; it = it->next_sibling()) {
3426@@ -768,6 +1070,7 @@
3427 printf("Could not find color: %s\nCANNOT_COMPUTE\n", name);
3428 exit(ErrorCode);
3429 }
3430+<<<<<<< TREE
3431
3432 const PetriEngine::Colored::Color* PNMLParser::findColorForIntRange(const char* value, uint32_t start, uint32_t end) const{
3433 for (const auto& elem : colorTypes) {
3434@@ -780,3 +1083,6 @@
3435 printf("Could not find color: %s\nCANNOT_COMPUTE\n", value);
3436 exit(ErrorCode);
3437 }
3438+=======
3439+
3440+>>>>>>> MERGE-SOURCE
3441
3442=== modified file 'src/VerifyPN.cpp'
3443--- src/VerifyPN.cpp 2021-04-16 18:53:36 +0000
3444+++ src/VerifyPN.cpp 2021-04-19 13:50:22 +0000
3445@@ -330,6 +330,7 @@
3446 {
3447 options.model_out_file = std::string(argv[++i]);
3448 }
3449+<<<<<<< TREE
3450 else if (strcmp(argv[i], "--write-buchi") == 0)
3451 {
3452 options.buchi_out_file = std::string(argv[++i]);
3453@@ -354,6 +355,14 @@
3454 ++i;
3455 }
3456 }
3457+=======
3458+ else if (strcmp(argv[i], "-verifydtapn") == 0 ) {
3459+ std::string outputOption = argv[++i];
3460+ if (outputOption.compare("tt") == 0 ) {
3461+ options.outputVerifydtapnFormat = true;
3462+ }
3463+ }
3464+>>>>>>> MERGE-SOURCE
3465 #ifdef VERIFYPN_MC_Simplification
3466 else if (strcmp(argv[i], "-z") == 0)
3467 {
3468@@ -464,6 +473,7 @@
3469 #ifdef VERIFYPN_MC_Simplification
3470 " -z <number of cores> Number of cores to use (currently only query simplification)\n"
3471 #endif
3472+<<<<<<< TREE
3473 " -tar Enables Trace Abstraction Refinement for reachability properties\n"
3474 " --max-intervals <interval count> The max amount of intervals kept when computing the color fixpoint\n"
3475 " <interval count> Default is 255 and then after <interval-timeout> second(s) to 5\n"
3476@@ -482,6 +492,18 @@
3477 " For some queries this helps reduce the overhead of query\n"
3478 " simplification and Büchi construction, but gives worse\n"
3479 " results since there is less opportunity for optimizations.\n"
3480+=======
3481+ " -tar Enables Trace Abstraction Refinement for reachability properties\n"
3482+ " -verifydtapn <tt> Specifies the format of the output model (tt is currently the only valid value)\n"
3483+ " - tt output as dtapn format\n"
3484+ " --write-simplified <filename> Outputs the queries to the given file after simplification\n"
3485+ " --write-reduced <filename> Outputs the model to the given file after structural reduction\n"
3486+ " --binary-query-io <0,1,2,3> Determines the input/output format of the query-file\n"
3487+ " - 0 MCC XML format for Input and Output\n"
3488+ " - 1 Input is binary, output is XML\n"
3489+ " - 2 Output is binary, input is XML\n"
3490+ " - 3 Input and Output is binary\n"
3491+>>>>>>> MERGE-SOURCE
3492 "\n"
3493 "Return Values:\n"
3494 " 0 Successful, query satisfiable\n"
3495@@ -833,7 +855,11 @@
3496 out.open(filename, std::ios::binary | std::ios::out);
3497 uint32_t cnt = 0;
3498 for(uint32_t j = 0; j < queries.size(); j++) {
3499- if(queries[j]->isTriviallyTrue() || queries[j]->isTriviallyFalse()) continue;
3500+ if(queries[j]->isTriviallyTrue())
3501+ queries[j] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(true));
3502+ else if(queries[j]->isTriviallyFalse())
3503+ queries[j] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(false));
3504+
3505 ++cnt;
3506 }
3507 out.write(reinterpret_cast<const char *>(&cnt), sizeof(uint32_t));
3508@@ -854,7 +880,10 @@
3509
3510 for(uint32_t j = 0; j < queries.size(); j++) {
3511 auto i = order[j];
3512- if(queries[i]->isTriviallyTrue() || queries[i]->isTriviallyFalse()) continue;
3513+ if(queries[i]->isTriviallyTrue())
3514+ queries[i] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(true));
3515+ else if(queries[i]->isTriviallyFalse())
3516+ queries[i] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(false));
3517 if(binary)
3518 {
3519 out.write(querynames[i].data(), querynames[i].size());
3520@@ -998,6 +1027,7 @@
3521 if (options.printstatistics) {
3522 std::cout << "Finished parsing model" << std::endl;
3523 }
3524+
3525
3526 //----------------------- Parse Query -----------------------//
3527 std::vector<std::string> querynames;
3528@@ -1095,6 +1125,7 @@
3529 #endif
3530 std::vector<std::stringstream> tstream(queries.size());
3531 uint32_t old = to_handle;
3532+
3533 for(size_t c = 0; c < std::min<uint32_t>(options.cores, old); ++c)
3534 {
3535 #ifdef VERIFYPN_MC_Simplification
3536@@ -1126,6 +1157,7 @@
3537 #endif
3538 // this is used later, we already know that this is a plain reachability (or AG)
3539 bool wasAGCPNApprox = dynamic_cast<NotCondition*>(queries[i].get()) != nullptr;
3540+<<<<<<< TREE
3541 int preSize=queries[i]->formulaSize();
3542
3543 if (options.logic == TemporalLogic::LTL) {
3544@@ -1138,9 +1170,24 @@
3545 }
3546 queries[i] = Condition::initialMarkingRW([&](){ return queries[i]; }, stats, context, false, false, true)
3547 ->pushNegation(stats, context, false, false, true);
3548+=======
3549+ int preSize=queries[i]->formulaSize();
3550+ //If the reduction time is set to 0 then the queries should not be reduced
3551+ if(options.queryReductionTimeout != 0){
3552+ queries[i] = Condition::initialMarkingRW([&](){ return queries[i]; }, stats, context, false, false, true)
3553+ ->pushNegation(stats, context, false, false, true);
3554+ }
3555+
3556+>>>>>>> MERGE-SOURCE
3557 wasAGCPNApprox |= dynamic_cast<NotCondition*>(queries[i].get()) != nullptr;
3558+<<<<<<< TREE
3559
3560 if(options.queryReductionTimeout > 0 && options.printstatistics) {
3561+=======
3562+
3563+ if(options.queryReductionTimeout > 0 && options.printstatistics)
3564+ {
3565+>>>>>>> MERGE-SOURCE
3566 out << "RWSTATS PRE:";
3567 stats.print(out);
3568 out << std::endl;
3569@@ -1191,9 +1238,9 @@
3570 if(options.cpnOverApprox && wasAGCPNApprox)
3571 {
3572 if(queries[i]->isTriviallyTrue())
3573- queries[i] = std::make_shared<BooleanCondition>(false);
3574+ queries[i] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(true));
3575 else if(queries[i]->isTriviallyFalse())
3576- queries[i] = std::make_shared<BooleanCondition>(true);
3577+ queries[i] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(false));
3578 queries[i]->setInvariant(wasAGCPNApprox);
3579 }
3580
3581@@ -1243,7 +1290,26 @@
3582 return queries[a]->containsNext() < queries[b]->containsNext();
3583 return queries[a]->formulaSize() < queries[b]->formulaSize();
3584 });
3585- writeQueries(queries, querynames, reorder, options.query_out_file, options.binary_query_io & 2, builder.getPlaceNames());
3586+ // if (options.outputVerifydtapnFormat) {
3587+ // std::ofstream queryFile(options.query_out_file);
3588+ // for (uint32_t i = 0; i < queries.size(); ++i) {
3589+ // std::cout << "Writing query ";
3590+ // queries[i].get()->toString(std::cout);
3591+ // std::cout << std::endl;
3592+
3593+ // if(queries[i]->isTriviallyTrue()){
3594+ // std::cout << "trivially true" << std::endl;
3595+ // queries[i] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(true));
3596+ // } else if(queries[i]->isTriviallyFalse()){
3597+ // queries[i] = std::make_shared<EFCondition>(std::make_shared<BooleanCondition>(false));
3598+ // std::cout << "trivially false" << std::endl;
3599+ // }
3600+ // queries[i].get()->toString(queryFile);
3601+ // }
3602+
3603+ // } else {
3604+ writeQueries(queries, querynames, reorder, options.query_out_file, options.binary_query_io & 2, builder.getPlaceNames());
3605+ // }
3606 }
3607
3608 qnet = nullptr;
3609@@ -1306,7 +1372,7 @@
3610 {
3611 std::fstream file;
3612 file.open(options.model_out_file, std::ios::out);
3613- net->toXML(file);
3614+ net->toXML(file, cpnBuilder.isTimed(), cpnBuilder.getInvariants(), options.outputVerifydtapnFormat);
3615 }
3616
3617 if(alldone) return SuccessCode;

Subscribers

People subscribed via source and target branches