Merge lp:~verifydtapn-contributers/verifydtapn/PlaceStatistics into lp:verifydtapn

Proposed by Peter Gjøl Jensen
Status: Merged
Merged at revision: 313
Proposed branch: lp:~verifydtapn-contributers/verifydtapn/PlaceStatistics
Merge into: lp:verifydtapn
Diff against target: 255 lines (+50/-13)
11 files modified
src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp (+17/-1)
src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp (+1/-1)
src/DiscreteVerification/DiscreteVerification.cpp (+1/-0)
src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp (+1/-1)
src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp (+1/-1)
src/DiscreteVerification/VerificationTypes/TimeDartLiveness.cpp (+1/-1)
src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.cpp (+1/-1)
src/DiscreteVerification/VerificationTypes/TimeDartVerification.cpp (+4/-4)
src/DiscreteVerification/VerificationTypes/Verification.hpp (+21/-1)
src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp (+1/-1)
src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp (+1/-1)
To merge this branch: bzr merge lp:~verifydtapn-contributers/verifydtapn/PlaceStatistics
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+226605@code.launchpad.net

Description of the change

implemented place-bound-statistics. The changes should be fairly obvious and easy to read.

To post a comment you must log in.
315. By Jiri Srba

fixed an explanation in a comment

316. By Jiri Srba

changed some formating issues in place-statistic print

Revision history for this message
Jiri Srba (srba) wrote :

tested and works in the same way as statistics for the untimed engine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp'
2--- src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp 2014-07-08 18:26:00 +0000
3+++ src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp 2014-07-14 09:32:30 +0000
4@@ -6,6 +6,7 @@
5 */
6
7 #include "NonStrictMarkingBase.hpp"
8+#include <limits>
9
10 using namespace std;
11
12@@ -357,7 +358,7 @@
13 }
14
15
16- int NonStrictMarkingBase::cut() {
17+ int NonStrictMarkingBase::cut(std::vector<int>& placeCount) {
18 #ifdef DEBUG
19 std::cout << "Before cut: " << *this << std::endl;
20 #endif
21@@ -374,6 +375,7 @@
22 }
23 //set age of too old tokens to max age
24 int count = 0;
25+ int total = 0;
26 for (TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++) {
27 if (token_iter->getAge() > place_iter->place->getMaxConstant()) { // this will also removed dead tokens
28 TokenList::iterator beginDelete = token_iter;
29@@ -381,15 +383,29 @@
30 for (; token_iter != place_iter->tokens.end(); token_iter++) {
31 count += token_iter->getCount();
32 }
33+ }
34+ else if(place_iter->place->getType() == TAPN::Dead)
35+ {
36+ // if we remove some dead tokens update place statistics
37+ if(place_iter->tokens.size() > 0) {
38+ placeCount[place_iter->place->getIndex()] = std::numeric_limits<int>::max();
39+ }
40 }
41 this->removeRangeOfTokens(*place_iter, beginDelete, place_iter->tokens.end());
42 break;
43+ } else {
44+ total += token_iter->getCount();
45 }
46 }
47+
48 if (count) {
49 Token t(place_iter->place->getMaxConstant() + 1, count);
50 this->addTokenInPlace(*place_iter, t);
51 }
52+
53+ // update place statistics
54+ total += count;
55+ placeCount[place_iter->place->getIndex()] = max(total, placeCount[place_iter->place->getIndex()]);
56 }
57 this->cleanUp();
58 return maxDelay;
59
60=== modified file 'src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp'
61--- src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp 2013-07-26 21:59:47 +0000
62+++ src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp 2014-07-14 09:32:30 +0000
63@@ -159,7 +159,7 @@
64
65 public: // modifiers
66
67- int cut();
68+ int cut(std::vector<int>&);
69 bool removeToken(int placeId, int age);
70 bool removeToken(Place& place, Token& token);
71 void addTokenInPlace(TAPN::TimedPlace& place, int age);
72
73=== modified file 'src/DiscreteVerification/DiscreteVerification.cpp'
74--- src/DiscreteVerification/DiscreteVerification.cpp 2014-06-18 19:39:40 +0000
75+++ src/DiscreteVerification/DiscreteVerification.cpp 2014-07-14 09:32:30 +0000
76@@ -215,6 +215,7 @@
77
78 verifier.printStats();
79 verifier.printTransitionStatistics();
80+ verifier.printPlaceStatistics();
81
82 std::cout << "Query is " << (result ? "satisfied" : "NOT satisfied") << "." << std::endl;
83 std::cout << "Max number of tokens found in any reachable marking: ";
84
85=== modified file 'src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp'
86--- src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp 2014-07-04 17:38:14 +0000
87+++ src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp 2014-07-14 09:32:30 +0000
88@@ -92,7 +92,7 @@
89 }
90
91 bool LivenessSearch::addToPW(NonStrictMarking* marking, NonStrictMarking* parent){
92- marking->cut();
93+ marking->cut(placeStats);
94 marking->setParent(parent);
95 unsigned int size = marking->size();
96
97
98=== modified file 'src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp'
99--- src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2014-06-15 09:02:10 +0000
100+++ src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2014-07-14 09:32:30 +0000
101@@ -57,7 +57,7 @@
102 }
103
104 bool ReachabilitySearch::addToPW(NonStrictMarking* marking, NonStrictMarking* parent){
105- marking->cut();
106+ marking->cut(placeStats);
107 marking->setParent(parent);
108
109 unsigned int size = marking->size();
110
111=== modified file 'src/DiscreteVerification/VerificationTypes/TimeDartLiveness.cpp'
112--- src/DiscreteVerification/VerificationTypes/TimeDartLiveness.cpp 2013-09-01 17:37:24 +0000
113+++ src/DiscreteVerification/VerificationTypes/TimeDartLiveness.cpp 2014-07-14 09:32:30 +0000
114@@ -125,7 +125,7 @@
115 if(options.getTrace() == VerificationOptions::SOME_TRACE){
116 start = marking->getYoungest();
117 }
118- marking->cut();
119+ marking->cut(placeStats);
120 const TimedTransition* transition = marking->getGeneratedBy();
121 unsigned int size = marking->size();
122
123
124=== modified file 'src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.cpp'
125--- src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.cpp 2014-06-14 14:17:03 +0000
126+++ src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.cpp 2014-07-14 09:32:30 +0000
127@@ -74,7 +74,7 @@
128 if(options.getTrace() != VerificationOptions::NO_TRACE){
129 start = marking->getYoungest();
130 }
131- int maxDelay = marking->cut();
132+ int maxDelay = marking->cut(placeStats);
133
134 unsigned int size = marking->size();
135
136
137=== modified file 'src/DiscreteVerification/VerificationTypes/TimeDartVerification.cpp'
138--- src/DiscreteVerification/VerificationTypes/TimeDartVerification.cpp 2014-07-05 10:15:17 +0000
139+++ src/DiscreteVerification/VerificationTypes/TimeDartVerification.cpp 2014-07-14 09:32:30 +0000
140@@ -216,7 +216,7 @@
141 }
142
143 last = mc;
144- mc->cut();
145+ mc->cut(placeStats);
146 if(l == NULL) { // set specific last marking to last marking in delay if deadlock
147 l = mc;
148 }
149@@ -230,7 +230,7 @@
150 l = new NonStrictMarkingBase(*getBase(lastMarking->dart));
151 trace = ((TraceDart*) lastMarking);
152 l->incrementAge(trace->start);
153- l->cut();
154+ l->cut(placeStats);
155 l->setParent(NULL);
156 l->setGeneratedBy( ((TraceDart*)lastMarking)->generatedBy);
157 }
158@@ -261,7 +261,7 @@
159 l->setParent(mc);
160 }
161 last = mc;
162- mc->cut();
163+ mc->cut(placeStats);
164 traceStack.push(mc); // add delay marking to the trace
165 diff--;
166 }
167@@ -272,7 +272,7 @@
168 if(!l->getParent()) {
169 l->setParent(m);
170 }
171- m->cut();
172+ m->cut(placeStats);
173 last = m;
174 traceStack.push(m); // add the marking to the trace
175
176
177=== modified file 'src/DiscreteVerification/VerificationTypes/Verification.hpp'
178--- src/DiscreteVerification/VerificationTypes/Verification.hpp 2014-07-07 19:03:13 +0000
179+++ src/DiscreteVerification/VerificationTypes/Verification.hpp 2014-07-14 09:32:30 +0000
180@@ -7,6 +7,7 @@
181 #include <stack>
182 #include "../../Core/TAPNParser/util.hpp"
183 #include "../DeadlockVisitor.hpp"
184+#include "../../Core/TAPN/TimedPlace.hpp"
185
186
187
188@@ -22,6 +23,7 @@
189 virtual bool verify() = 0;
190 virtual void printStats() = 0;
191 virtual void printTransitionStatistics() const = 0;
192+ virtual void printPlaceStatistics();
193 virtual unsigned int maxUsedTokens() = 0;
194 virtual bool addToPW(T* marking) = 0;
195
196@@ -42,14 +44,32 @@
197 T& initialMarking;
198 AST::Query* query;
199 VerificationOptions options;
200+ std::vector<int> placeStats;
201
202 };
203
204 template<typename T>
205 Verification<T>::Verification(TAPN::TimedArcPetriNet& tapn, T& initialMarking, AST::Query* query, VerificationOptions options)
206- : tapn(tapn), initialMarking(initialMarking), query(query), options(options){
207+ : tapn(tapn), initialMarking(initialMarking), query(query), options(options), placeStats(tapn.getNumberOfPlaces()){
208
209 }
210+
211+ template<typename T>
212+ void Verification<T>::printPlaceStatistics() {
213+ fprintf(stdout, "PLACE-BOUND STATISTICS\n");
214+ for (size_t p = 0; p < placeStats.size(); ++p) {
215+ // report maximum bounds for each place (? means that the place had some deadlock tokens that were removed)
216+ int count = placeStats[p];
217+ const TAPN::TimedPlace place = tapn.getPlace(p);
218+ if (count == std::numeric_limits<int>::max()) {
219+ fprintf(stdout, "<%s;?> ", place.getName().c_str());
220+ } else {
221+ fprintf(stdout, "<%s;%i> ", place.getName().c_str(), count);
222+ }
223+ }
224+ fprintf(stdout, "\n\n");
225+ }
226+
227 template<typename T>
228 void Verification<T>::printHumanTrace(T* m, std::stack<T*>& stack, AST::Quantifier query) {
229 std::cout << "Trace: " << std::endl;
230
231=== modified file 'src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp'
232--- src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp 2014-06-12 21:47:38 +0000
233+++ src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp 2014-07-14 09:32:30 +0000
234@@ -67,7 +67,7 @@
235 }
236
237 bool WorkflowSoundness::addToPW(NonStrictMarking* marking, NonStrictMarking* parent){
238- marking->cut();
239+ marking->cut(placeStats);
240
241 unsigned int size = marking->size();
242
243
244=== modified file 'src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp'
245--- src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp 2014-06-17 10:13:39 +0000
246+++ src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp 2014-07-14 09:32:30 +0000
247@@ -106,7 +106,7 @@
248 }
249
250 bool WorkflowStrongSoundnessReachability::addToPW(NonStrictMarking* marking, NonStrictMarking* parent) {
251- marking->cut();
252+ marking->cut(placeStats);
253 marking->setParent(parent);
254
255 int totalDelay = marking->calculateTotalDelay();

Subscribers

People subscribed via source and target branches