Merge lp:~tapaal-contributor/verifypn/show-reduced-net into lp:verifypn

Proposed by Thomas Pedersen
Status: Merged
Approved by: Jiri Srba
Approved revision: no longer in the source branch.
Merged at revision: 228
Proposed branch: lp:~tapaal-contributor/verifypn/show-reduced-net
Merge into: lp:verifypn
Diff against target: 162 lines (+28/-2)
5 files modified
include/PetriEngine/PetriNet.h (+3/-0)
include/PetriEngine/PetriNetBuilder.h (+3/-0)
src/PetriEngine/PetriNet.cpp (+6/-0)
src/PetriEngine/PetriNetBuilder.cpp (+15/-2)
src/VerifyPN.cpp (+1/-0)
To merge this branch: bzr merge lp:~tapaal-contributor/verifypn/show-reduced-net
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Peter Gjøl Jensen Pending
Review via email: mp+390959@code.launchpad.net

Commit message

Added place and transition locations to the petri net and include them when writing the reduced net.

This change was made to retain locations for the reduced net in the bug https://bugs.launchpad.net/tapaal/+bug/1879130

To post a comment you must log in.
227. By <email address hidden>

fixed compilation with static libraries for mac

Revision history for this message
Jiri Srba (srba) :
review: Approve
228. By Jiri Srba

merged in lp:~tapaal-contributor/verifypn/show-reduced-net adding x,y coordinates when eexporting reduced net

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/PetriEngine/PetriNet.h'
--- include/PetriEngine/PetriNet.h 2020-04-22 07:57:20 +0000
+++ include/PetriEngine/PetriNet.h 2020-10-19 19:48:12 +0000
@@ -124,6 +124,9 @@
124 std::vector<std::string> _transitionnames;124 std::vector<std::string> _transitionnames;
125 std::vector<std::string> _placenames;125 std::vector<std::string> _placenames;
126126
127 std::vector< std::tuple<double, double> > _placelocations;
128 std::vector< std::tuple<double, double> > _transitionlocations;
129
127 friend class PetriNetBuilder;130 friend class PetriNetBuilder;
128 friend class Reducer;131 friend class Reducer;
129 friend class SuccessorGenerator;132 friend class SuccessorGenerator;
130133
=== modified file 'include/PetriEngine/PetriNetBuilder.h'
--- include/PetriEngine/PetriNetBuilder.h 2020-03-02 21:03:24 +0000
+++ include/PetriEngine/PetriNetBuilder.h 2020-10-19 19:48:12 +0000
@@ -131,6 +131,9 @@
131 protected:131 protected:
132 std::unordered_map<std::string, uint32_t> _placenames;132 std::unordered_map<std::string, uint32_t> _placenames;
133 std::unordered_map<std::string, uint32_t> _transitionnames;133 std::unordered_map<std::string, uint32_t> _transitionnames;
134
135 std::vector< std::tuple<double, double> > _placelocations;
136 std::vector< std::tuple<double, double> > _transitionlocations;
134 137
135 std::vector<Transition> _transitions;138 std::vector<Transition> _transitions;
136 std::vector<Place> _places;139 std::vector<Place> _places;
137140
=== modified file 'src/PetriEngine/PetriNet.cpp'
--- src/PetriEngine/PetriNet.cpp 2020-03-13 13:35:25 +0000
+++ src/PetriEngine/PetriNet.cpp 2020-10-19 19:48:12 +0000
@@ -191,7 +191,10 @@
191 for(size_t i = 0; i < _nplaces; ++i)191 for(size_t i = 0; i < _nplaces; ++i)
192 {192 {
193 auto& p = _placenames[i];193 auto& p = _placenames[i];
194 auto& placelocation = _placelocations[i];
194 out << "<place id=\"" << p << "\">\n"195 out << "<place id=\"" << p << "\">\n"
196 << "<graphics><position x=\"" << get<0>(placelocation)
197 << "\" y=\"" << get<1>(placelocation) << "\"/></graphics>\n"
195 << "<name><text>" << p << "</text></name>\n";198 << "<name><text>" << p << "</text></name>\n";
196 if(_initialMarking[i] > 0)199 if(_initialMarking[i] > 0)
197 {200 {
@@ -201,8 +204,11 @@
201 }204 }
202 for(size_t i = 0; i < _ntransitions; ++i)205 for(size_t i = 0; i < _ntransitions; ++i)
203 {206 {
207 auto& transitionlocation = _transitionlocations[i];
204 out << "<transition id=\"" << _transitionnames[i] << "\">\n"208 out << "<transition id=\"" << _transitionnames[i] << "\">\n"
205 << "<name><text>" << _transitionnames[i] << "</text></name>\n";209 << "<name><text>" << _transitionnames[i] << "</text></name>\n";
210 out << "<graphics><position x=\"" << get<0>(transitionlocation)
211 << "\" y=\"" << get<1>(transitionlocation) << "\"/></graphics>\n";
206 out << "</transition>\n";212 out << "</transition>\n";
207 }213 }
208 size_t id = 0;214 size_t id = 0;
209215
=== modified file 'src/PetriEngine/PetriNetBuilder.cpp'
--- src/PetriEngine/PetriNetBuilder.cpp 2020-03-02 21:03:24 +0000
+++ src/PetriEngine/PetriNetBuilder.cpp 2020-10-19 19:48:12 +0000
@@ -38,18 +38,20 @@
38 }38 }
39 PetriNetBuilder::PetriNetBuilder(const PetriNetBuilder& other)39 PetriNetBuilder::PetriNetBuilder(const PetriNetBuilder& other)
40 : _placenames(other._placenames), _transitionnames(other._transitionnames),40 : _placenames(other._placenames), _transitionnames(other._transitionnames),
41 _placelocations(other._placelocations), _transitionlocations(other._transitionlocations),
41 _transitions(other._transitions), _places(other._places), 42 _transitions(other._transitions), _places(other._places),
42 initialMarking(other.initialMarking), reducer(this)43 initialMarking(other.initialMarking), reducer(this)
43 {44 {
4445
45 }46 }
4647
47 void PetriNetBuilder::addPlace(const string &name, int tokens, double, double) {48 void PetriNetBuilder::addPlace(const string &name, int tokens, double x, double y) {
48 if(_placenames.count(name) == 0)49 if(_placenames.count(name) == 0)
49 {50 {
50 uint32_t next = _placenames.size();51 uint32_t next = _placenames.size();
51 _places.emplace_back();52 _places.emplace_back();
52 _placenames[name] = next;53 _placenames[name] = next;
54 _placelocations.push_back(std::tuple<double, double>(x,y));
53 }55 }
54 56
55 uint32_t id = _placenames[name];57 uint32_t id = _placenames[name];
@@ -60,12 +62,13 @@
60 }62 }
6163
62 void PetriNetBuilder::addTransition(const string &name,64 void PetriNetBuilder::addTransition(const string &name,
63 double, double) {65 double x, double y) {
64 if(_transitionnames.count(name) == 0)66 if(_transitionnames.count(name) == 0)
65 {67 {
66 uint32_t next = _transitionnames.size();68 uint32_t next = _transitionnames.size();
67 _transitions.emplace_back();69 _transitions.emplace_back();
68 _transitionnames[name] = next;70 _transitionnames[name] = next;
71 _transitionlocations.push_back(std::tuple<double, double>(x,y));
69 }72 }
70 }73 }
7174
@@ -318,6 +321,7 @@
318 ++free;321 ++free;
319 next = nextPlaceId(place_cons_count, place_prod_count, place_idmap, reorder);322 next = nextPlaceId(place_cons_count, place_prod_count, place_idmap, reorder);
320 }323 }
324
321 325
322 // Reindex for great justice!326 // Reindex for great justice!
323 for(uint32_t i = 0; i < freeinv; i++)327 for(uint32_t i = 0; i < freeinv; i++)
@@ -336,6 +340,9 @@
336// std::cout << place_idmap[i] << " : " << initialMarking[i] << std::endl;340// std::cout << place_idmap[i] << " : " << initialMarking[i] << std::endl;
337 }341 }
338 }342 }
343
344 net->_placelocations = _placelocations;
345 net->_transitionlocations = _transitionlocations;
339 346
340 // reindex place-names347 // reindex place-names
341348
@@ -343,15 +350,18 @@
343 int rindex = _placenames.size() - 1;350 int rindex = _placenames.size() - 1;
344 for(auto& i : _placenames)351 for(auto& i : _placenames)
345 {352 {
353 auto& placelocation = _placelocations[i.second];
346 i.second = place_idmap[i.second];354 i.second = place_idmap[i.second];
347 if(i.second != std::numeric_limits<uint32_t>::max())355 if(i.second != std::numeric_limits<uint32_t>::max())
348 {356 {
349 net->_placenames[i.second] = i.first;357 net->_placenames[i.second] = i.first;
350 assert(_placenames[net->_placenames[i.second]] == i.second);358 assert(_placenames[net->_placenames[i.second]] == i.second);
359 net->_placelocations[i.second] = placelocation;
351 }360 }
352 else361 else
353 {362 {
354 net->_placenames[rindex] = i.first;363 net->_placenames[rindex] = i.first;
364 net->_placelocations[rindex] = placelocation;
355 --rindex;365 --rindex;
356 }366 }
357 }367 }
@@ -360,14 +370,17 @@
360 int trindex = _transitionnames.size() - 1;370 int trindex = _transitionnames.size() - 1;
361 for(auto& i : _transitionnames)371 for(auto& i : _transitionnames)
362 {372 {
373 auto& transitionlocation = _transitionlocations[i.second];
363 i.second = trans_idmap[i.second];374 i.second = trans_idmap[i.second];
364 if(i.second != std::numeric_limits<uint32_t>::max())375 if(i.second != std::numeric_limits<uint32_t>::max())
365 {376 {
366 net->_transitionnames[i.second] = i.first;377 net->_transitionnames[i.second] = i.first;
378 net->_transitionlocations[i.second] = transitionlocation;
367 }379 }
368 else380 else
369 {381 {
370 net->_transitionnames[trindex] = i.first;382 net->_transitionnames[trindex] = i.first;
383 net->_transitionlocations[trindex] = transitionlocation;
371 --trindex;384 --trindex;
372 }385 }
373 }386 }
374387
=== modified file 'src/VerifyPN.cpp'
--- src/VerifyPN.cpp 2020-04-28 20:13:40 +0000
+++ src/VerifyPN.cpp 2020-10-19 19:48:12 +0000
@@ -372,6 +372,7 @@
372 printf(" Søren Moss Nielsen <soren_moss@mac.com>\n");372 printf(" Søren Moss Nielsen <soren_moss@mac.com>\n");
373 printf(" Thomas Søndersø Nielsen <primogens@gmail.com>\n");373 printf(" Thomas Søndersø Nielsen <primogens@gmail.com>\n");
374 printf(" Samuel Pastva <daemontus@gmail.com>\n");374 printf(" Samuel Pastva <daemontus@gmail.com>\n");
375 printf(" Thomas Pedersen <thomas.pedersen@stofanet.dk\n");
375 printf(" Jiri Srba <srba.jiri@gmail.com>\n");376 printf(" Jiri Srba <srba.jiri@gmail.com>\n");
376 printf(" Lars Kærlund Østergaard <larsko@gmail.com>\n");377 printf(" Lars Kærlund Østergaard <larsko@gmail.com>\n");
377 printf("GNU GPLv3 or later <http://gnu.org/licenses/gpl.html>\n");378 printf("GNU GPLv3 or later <http://gnu.org/licenses/gpl.html>\n");

Subscribers

People subscribed via source and target branches