Merge lp:~verifypn-cpn/verifypn/color-fixpoint into lp:~tapaal-ltl/verifypn/mcc2021

Proposed by Thomas Pedersen
Status: Merged
Merged at revision: 251
Proposed branch: lp:~verifypn-cpn/verifypn/color-fixpoint
Merge into: lp:~tapaal-ltl/verifypn/mcc2021
Diff against target: 166 lines (+34/-19)
5 files modified
include/PetriEngine/Colored/ColoredPetriNetBuilder.h (+1/-1)
include/PetriEngine/Colored/Intervals.h (+3/-4)
src/PetriEngine/Colored/BindingGenerator.cpp (+5/-6)
src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp (+24/-7)
src/PetriEngine/Colored/GuardRestrictor.cpp (+1/-1)
To merge this branch: bzr merge lp:~verifypn-cpn/verifypn/color-fixpoint
Reviewer Review Type Date Requested Status
Jiri Srba Pending
Peter Gjøl Jensen Pending
Review via email: mp+400243@code.launchpad.net

This proposal supersedes a proposal from 2021-03-18.

Commit message

Merge color fixpoint into MCC2021

Description of the change

Colored net unfolding has been tested, but the LTL code still needs to be tested

We believe the previous errors have been corrected

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/PetriEngine/Colored/ColoredPetriNetBuilder.h'
--- include/PetriEngine/Colored/ColoredPetriNetBuilder.h 2021-03-17 13:16:57 +0000
+++ include/PetriEngine/Colored/ColoredPetriNetBuilder.h 2021-03-26 10:35:05 +0000
@@ -182,7 +182,7 @@
182 182
183 void unfoldPlace(const Colored::Place* place, const PetriEngine::Colored::Color *color);183 void unfoldPlace(const Colored::Place* place, const PetriEngine::Colored::Color *color);
184 void unfoldTransition(Colored::Transition& transition);184 void unfoldTransition(Colored::Transition& transition);
185 void handleOrphanPlace(Colored::Place& place);185 void handleOrphanPlace(Colored::Place& place, std::unordered_map<std::string, uint32_t> unfoldedPlaceMap);
186186
187 void unfoldArc(Colored::Arc& arc, Colored::ExpressionContext::BindingMap& binding, std::string& name, bool input);187 void unfoldArc(Colored::Arc& arc, Colored::ExpressionContext::BindingMap& binding, std::string& name, bool input);
188 };188 };
189189
=== modified file 'include/PetriEngine/Colored/Intervals.h'
--- include/PetriEngine/Colored/Intervals.h 2021-03-15 10:04:47 +0000
+++ include/PetriEngine/Colored/Intervals.h 2021-03-26 10:35:05 +0000
@@ -475,7 +475,6 @@
475475
476 void applyModifier(int32_t modifier, std::vector<size_t> sizes){476 void applyModifier(int32_t modifier, std::vector<size_t> sizes){
477 std::vector<interval_t> collectedIntervals;477 std::vector<interval_t> collectedIntervals;
478
479 for(auto& interval : _intervals){478 for(auto& interval : _intervals){
480 std::vector<interval_t> newIntervals;479 std::vector<interval_t> newIntervals;
481 newIntervals.push_back(std::move(interval));480 newIntervals.push_back(std::move(interval));
@@ -494,15 +493,15 @@
494 newInterval[i]._upper = sizes[i]-1;493 newInterval[i]._upper = sizes[i]-1;
495 tempIntervals.push_back(std::move(newInterval));494 tempIntervals.push_back(std::move(newInterval));
496 }else {495 }else {
497 interval[i]._lower = shiftedInterval.first;496 interval1[i]._lower = shiftedInterval.first;
498 interval[i]._upper = shiftedInterval.second;497 interval1[i]._upper = shiftedInterval.second;
499 }498 }
500 }499 }
501 newIntervals.insert(newIntervals.end(), tempIntervals.begin(), tempIntervals.end()); 500 newIntervals.insert(newIntervals.end(), tempIntervals.begin(), tempIntervals.end());
502 }501 }
503 collectedIntervals.insert(collectedIntervals.end(), newIntervals.begin(), newIntervals.end());502 collectedIntervals.insert(collectedIntervals.end(), newIntervals.begin(), newIntervals.end());
504 }503 }
505504
506 _intervals = std::move(collectedIntervals);505 _intervals = std::move(collectedIntervals);
507 }506 }
508507
509508
=== modified file 'src/PetriEngine/Colored/BindingGenerator.cpp'
--- src/PetriEngine/Colored/BindingGenerator.cpp 2021-03-15 10:04:47 +0000
+++ src/PetriEngine/Colored/BindingGenerator.cpp 2021-03-26 10:35:05 +0000
@@ -105,18 +105,19 @@
105 while (!test) {105 while (!test) {
106 bool next = true;106 bool next = true;
107107
108 for (auto& _binding : _bindings) {108 for (auto& _binding : _bindings) {
109 auto varInterval = _transition.variableMaps[_nextIndex][_binding.first];109 auto varInterval = _transition.variableMaps[_nextIndex][_binding.first];
110 std::vector<uint32_t> colorIds;110 std::vector<uint32_t> colorIds;
111 _binding.second->getTupleId(&colorIds);111 _binding.second->getTupleId(&colorIds);
112 auto nextIntervalBinding = varInterval.isRangeEnd(colorIds);112 auto nextIntervalBinding = varInterval.isRangeEnd(colorIds);
113113
114 if (nextIntervalBinding.size() == 0){114 if (nextIntervalBinding.size() == 0){
115 _binding.second = &_binding.second->operator++();115 _binding.second = &_binding.second->operator++();
116 next = false;116 next = false;
117 break; 117 break;
118 } else {118 } else {
119 _binding.second = _binding.second->getColorType()->getColor(nextIntervalBinding.getLowerIds());119 _binding.second = _binding.second->getColorType()->getColor(nextIntervalBinding.getLowerIds());
120
120 if(!nextIntervalBinding.equals(varInterval.getFirst())){121 if(!nextIntervalBinding.equals(varInterval.getFirst())){
121 next = false;122 next = false;
122 break;123 break;
@@ -132,10 +133,8 @@
132 for(auto& _binding : _bindings){133 for(auto& _binding : _bindings){
133 _binding.second = _binding.second->getColorType()->getColor(_transition.variableMaps[_nextIndex][_binding.first].getFirst().getLowerIds());134 _binding.second = _binding.second->getColorType()->getColor(_transition.variableMaps[_nextIndex][_binding.first].getFirst().getLowerIds());
134 }135 }
135 }136 }
136
137 test = eval();137 test = eval();
138
139 }138 }
140 139
141 return _bindings;140 return _bindings;
142141
=== modified file 'src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp'
--- src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp 2021-03-17 13:16:57 +0000
+++ src/PetriEngine/Colored/ColoredPetriNetBuilder.cpp 2021-03-26 10:35:05 +0000
@@ -197,7 +197,7 @@
197197
198 _fixPointCreationTime = (std::chrono::duration_cast<std::chrono::microseconds>(end - start).count())*0.000001;198 _fixPointCreationTime = (std::chrono::duration_cast<std::chrono::microseconds>(end - start).count())*0.000001;
199199
200 // printPlaceTable();200 //printPlaceTable();
201 _placeColorFixpoints.clear();201 _placeColorFixpoints.clear();
202 }202 }
203203
@@ -331,8 +331,9 @@
331 for (auto& transition : _transitions) {331 for (auto& transition : _transitions) {
332 unfoldTransition(transition);332 unfoldTransition(transition);
333 }333 }
334 auto unfoldedPlaceMap = _ptBuilder.getPlaceNames();
334 for (auto& place : _places) {335 for (auto& place : _places) {
335 handleOrphanPlace(place);336 handleOrphanPlace(place, unfoldedPlaceMap);
336 }337 }
337 _unfolded = true;338 _unfolded = true;
338 auto end = std::chrono::high_resolution_clock::now();339 auto end = std::chrono::high_resolution_clock::now();
@@ -345,17 +346,33 @@
345 //However, in queries asking about orphan places it cannot find these, as they have not been unfolded346 //However, in queries asking about orphan places it cannot find these, as they have not been unfolded
346 //so we make a placeholder place which just has tokens equal to the number of colored tokens347 //so we make a placeholder place which just has tokens equal to the number of colored tokens
347 //Ideally, orphan places should just be translated to a constant in the query348 //Ideally, orphan places should just be translated to a constant in the query
348 void ColoredPetriNetBuilder::handleOrphanPlace(Colored::Place& place) {349 void ColoredPetriNetBuilder::handleOrphanPlace(Colored::Place& place, std::unordered_map<std::string, uint32_t> unfoldedPlaceMap) {
349 if(_ptplacenames.count(place.name) <= 0){ 350 if(_ptplacenames.count(place.name) <= 0){
350 std::string name = place.name + "_" + std::to_string(place.marking.size());351
352 std::string name = place.name + "_orphan";
351 _ptBuilder.addPlace(name, place.marking.size(), 0.0, 0.0);353 _ptBuilder.addPlace(name, place.marking.size(), 0.0, 0.0);
352 _ptplacenames[place.name][0] = std::move(name);354 _ptplacenames[place.name][0] = std::move(name);
355 } else {
356 uint32_t usedTokens = 0;
357
358 for(std::pair<const uint32_t, std::string> unfoldedPlace : _ptplacenames[place.name]){
359 auto unfoldedMarking = _ptBuilder.initMarking();
360
361 auto unfoldedPlaceId = unfoldedPlaceMap[unfoldedPlace.second];
362 usedTokens += unfoldedMarking[unfoldedPlaceId];
363 }
364
365 if(place.marking.size() > usedTokens){
366 std::string name = place.name + "_orphan";
367 _ptBuilder.addPlace(name, place.marking.size() - usedTokens, 0.0, 0.0);
368 _ptplacenames[place.name][UINT32_MAX] = std::move(name);
369 }
353 }370 }
354 371
355 //++_nptplaces; 372 //++_nptplaces;
356 }373 }
357 374
358 void ColoredPetriNetBuilder::unfoldPlace(const Colored::Place* place, const PetriEngine::Colored::Color *color) {375 void ColoredPetriNetBuilder::unfoldPlace(const Colored::Place* place, const PetriEngine::Colored::Color *color) {
359 std::string name = place->name + "_" + std::to_string(color->getId());376 std::string name = place->name + "_" + std::to_string(color->getId());
360 _ptBuilder.addPlace(name, place->marking[color], 0.0, 0.0);377 _ptBuilder.addPlace(name, place->marking[color], 0.0, 0.0);
361 _ptplacenames[place->name][color->getId()] = std::move(name);378 _ptplacenames[place->name][color->getId()] = std::move(name);
@@ -365,7 +382,7 @@
365 void ColoredPetriNetBuilder::unfoldTransition(Colored::Transition& transition) {382 void ColoredPetriNetBuilder::unfoldTransition(Colored::Transition& transition) {
366 FixpointBindingGenerator gen(transition, _colors);383 FixpointBindingGenerator gen(transition, _colors);
367 size_t i = 0;384 size_t i = 0;
368 for (auto b : gen) { 385 for (auto b : gen) {
369 std::string name = transition.name + "_" + std::to_string(i++);386 std::string name = transition.name + "_" + std::to_string(i++);
370 _ptBuilder.addTransition(name, 0.0, 0.0);387 _ptBuilder.addTransition(name, 0.0, 0.0);
371 _pttransitionnames[transition.name].push_back(name);388 _pttransitionnames[transition.name].push_back(name);
372389
=== modified file 'src/PetriEngine/Colored/GuardRestrictor.cpp'
--- src/PetriEngine/Colored/GuardRestrictor.cpp 2021-03-15 10:04:47 +0000
+++ src/PetriEngine/Colored/GuardRestrictor.cpp 2021-03-26 10:35:05 +0000
@@ -244,7 +244,7 @@
244 //comparing vars of same size244 //comparing vars of same size
245 if(varPositionPair.second->colorType->productSize() == varPositionsR->operator[](index)->colorType->productSize()){245 if(varPositionPair.second->colorType->productSize() == varPositionsR->operator[](index)->colorType->productSize()){
246 intervalTuple_t newIntervalTuple = getIntervalOverlap(&leftTupleIntervalVal._intervals, &rightTupleIntervalVal._intervals);246 intervalTuple_t newIntervalTuple = getIntervalOverlap(&leftTupleIntervalVal._intervals, &rightTupleIntervalVal._intervals);
247 247
248 *leftTupleInterval = newIntervalTuple;248 *leftTupleInterval = newIntervalTuple;
249 *rightTupleInterval = newIntervalTuple;249 *rightTupleInterval = newIntervalTuple;
250 leftTupleInterval->applyModifier(leftVarModifier, varPositionPair.second->colorType->getConstituentsSizes());250 leftTupleInterval->applyModifier(leftVarModifier, varPositionPair.second->colorType->getConstituentsSizes());

Subscribers

People subscribed via source and target branches

to all changes: