Merge lp:~peter-gjoel/verifydtapn/WorkflowRefactor into lp:verifydtapn
- WorkflowRefactor
- Merge into trunk
Proposed by
Peter Gjøl Jensen
Status: | Merged |
---|---|
Merged at revision: | 330 |
Proposed branch: | lp:~peter-gjoel/verifydtapn/WorkflowRefactor |
Merge into: | lp:verifydtapn |
Prerequisite: | lp:~peter-gjoel/verifydtapn/MemLeakFix |
Diff against target: |
750 lines (+216/-132) 12 files modified
src/DiscreteVerification/DataStructures/PWList.hpp (+11/-9) src/DiscreteVerification/DataStructures/WaitingList.cpp (+1/-1) src/DiscreteVerification/DataStructures/WaitingList.hpp (+13/-16) src/DiscreteVerification/DataStructures/WorkflowPWList.cpp (+9/-1) src/DiscreteVerification/DataStructures/WorkflowPWList.hpp (+27/-6) src/DiscreteVerification/VerificationTypes/AbstractNaiveVerification.hpp (+1/-1) src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp (+1/-1) src/DiscreteVerification/VerificationTypes/Workflow.hpp (+15/-13) src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp (+67/-45) src/DiscreteVerification/VerificationTypes/WorkflowSoundness.hpp (+11/-6) src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp (+43/-31) src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.hpp (+17/-2) |
To merge this branch: | bzr merge lp:~peter-gjoel/verifydtapn/WorkflowRefactor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Needs Fixing | ||
Mathias Grund Sørensen | Pending | ||
Jakob Taankvist | Pending | ||
Review via email: mp+262640@code.launchpad.net |
Commit message
Description of the change
Refactorings to ease ptrie-implement
To post a comment you must log in.
- 348. By Peter Gjøl Jensen
-
Warning fix
Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote : | # |
Should be fixed now.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/DiscreteVerification/DataStructures/PWList.hpp' |
2 | --- src/DiscreteVerification/DataStructures/PWList.hpp 2015-06-22 21:03:26 +0000 |
3 | +++ src/DiscreteVerification/DataStructures/PWList.hpp 2015-06-24 13:24:40 +0000 |
4 | @@ -40,7 +40,7 @@ |
5 | inline void setMaxNumTokensIfGreater(int i){ if(i>maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i; }; |
6 | }; |
7 | |
8 | -class PWList : public PWListBase { |
9 | +class PWList : public virtual PWListBase { |
10 | public: |
11 | typedef std::vector<NonStrictMarking*> NonStrictMarkingList; |
12 | typedef google::sparse_hash_map<size_t, NonStrictMarkingList> HashMap; |
13 | @@ -55,11 +55,6 @@ |
14 | return (waiting_list->size() > 0); |
15 | }; |
16 | |
17 | - virtual bool addToWaiting(NonStrictMarking* marking){ |
18 | - waiting_list->add(marking, marking); |
19 | - return true; |
20 | - } |
21 | - |
22 | virtual long long size() const { |
23 | return stored; |
24 | }; |
25 | @@ -76,13 +71,19 @@ |
26 | WaitingList<NonStrictMarking*>* waiting_list; |
27 | }; |
28 | |
29 | -class PWListHybrid : public PWListBase { |
30 | +class PWListHybrid : public virtual PWListBase { |
31 | public: |
32 | typedef unsigned int uint; |
33 | |
34 | public: |
35 | |
36 | - PWListHybrid(TAPN::TimedArcPetriNet& tapn, WaitingList<ptriepointer_t<MetaData*> >* w_l, int knumber, int nplaces, int mage, bool isLiveness, bool makeTrace) : |
37 | + PWListHybrid( TAPN::TimedArcPetriNet& tapn, |
38 | + WaitingList<ptriepointer_t<MetaData*> >* w_l, |
39 | + int knumber, |
40 | + int nplaces, |
41 | + int mage, |
42 | + bool isLiveness, |
43 | + bool makeTrace) : |
44 | PWListBase(isLiveness), |
45 | waiting_list(w_l), |
46 | makeTrace(makeTrace), |
47 | @@ -121,10 +122,11 @@ |
48 | virtual bool add(NonStrictMarking* marking); |
49 | virtual NonStrictMarking* getNextUnexplored(); |
50 | |
51 | - public: |
52 | + protected: |
53 | |
54 | WaitingList<ptriepointer_t<MetaData*> >* waiting_list; |
55 | bool makeTrace; |
56 | + public: |
57 | MetaDataWithTraceAndEncoding* parent; |
58 | ptrie_t<MetaData*> passed; |
59 | MarkingEncoder<MetaData*, NonStrictMarking> encoder; |
60 | |
61 | === modified file 'src/DiscreteVerification/DataStructures/WaitingList.cpp' |
62 | --- src/DiscreteVerification/DataStructures/WaitingList.cpp 2015-06-17 09:03:12 +0000 |
63 | +++ src/DiscreteVerification/DataStructures/WaitingList.cpp 2015-06-24 13:24:40 +0000 |
64 | @@ -11,7 +11,7 @@ |
65 | template <> |
66 | int MinFirstWaitingList<NonStrictMarking*>::calculateWeight(NonStrictMarking* marking) |
67 | { |
68 | - return marking->meta->totalDelay; |
69 | + return marking->meta->totalDelay; |
70 | } |
71 | |
72 | template <> |
73 | |
74 | === modified file 'src/DiscreteVerification/DataStructures/WaitingList.hpp' |
75 | --- src/DiscreteVerification/DataStructures/WaitingList.hpp 2015-06-22 21:03:26 +0000 |
76 | +++ src/DiscreteVerification/DataStructures/WaitingList.hpp 2015-06-24 13:24:40 +0000 |
77 | @@ -136,8 +136,7 @@ |
78 | virtual T pop(); |
79 | virtual size_t size() { return queue.size(); }; |
80 | protected: |
81 | - virtual int calculateWeight(T payload); |
82 | - virtual int calculateWeight(NonStrictMarkingBase* marking); |
83 | + virtual int calculateWeight(T payload); |
84 | |
85 | priority_queue queue; |
86 | AST::Query* query; |
87 | @@ -342,20 +341,18 @@ |
88 | queue.push(weighted_item); |
89 | } |
90 | |
91 | - |
92 | -template <class T> |
93 | -int MinFirstWaitingList<T>::calculateWeight(NonStrictMarkingBase* marking) |
94 | -{ |
95 | - assert(false); |
96 | - return 0; |
97 | -} |
98 | - |
99 | -template <class T> |
100 | -int MinFirstWaitingList<T>::calculateWeight(T) |
101 | -{ |
102 | - assert(false); |
103 | - return 0; |
104 | -} |
105 | +template <class T> |
106 | +int MinFirstWaitingList<T>::calculateWeight(T tmp) |
107 | +{ |
108 | + assert(false); |
109 | + return 0; |
110 | +} |
111 | + |
112 | +template <> |
113 | +int MinFirstWaitingList<NonStrictMarking*>::calculateWeight(NonStrictMarking* tmp); |
114 | + |
115 | +template <> |
116 | +int MinFirstWaitingList<ptriepointer_t<MetaData*> >::calculateWeight(ptriepointer_t<MetaData*> ); |
117 | |
118 | template <class T> |
119 | T MinFirstWaitingList<T>::pop() |
120 | |
121 | === modified file 'src/DiscreteVerification/DataStructures/WorkflowPWList.cpp' |
122 | --- src/DiscreteVerification/DataStructures/WorkflowPWList.cpp 2015-06-22 21:03:26 +0000 |
123 | +++ src/DiscreteVerification/DataStructures/WorkflowPWList.cpp 2015-06-24 13:24:40 +0000 |
124 | @@ -129,15 +129,23 @@ |
125 | return NULL; |
126 | } |
127 | |
128 | - NonStrictMarking* WorkflowPWList::addToPassed(NonStrictMarking* marking) { |
129 | + NonStrictMarking* WorkflowPWList::addToPassed( |
130 | + NonStrictMarking* marking, bool strong) |
131 | + { |
132 | discoveredMarkings++; |
133 | NonStrictMarking* existing = lookup(marking); |
134 | if (existing != NULL) { |
135 | + last = existing; |
136 | return existing; |
137 | } else { |
138 | + last = marking; |
139 | NonStrictMarkingList& m = markings_storage[marking->getHashKey()]; |
140 | stored++; |
141 | m.push_back(marking); |
142 | + |
143 | + if(strong) marking->meta = new MetaData(); |
144 | + else marking->meta = new WorkflowSoundnessMetaData(); |
145 | + |
146 | return NULL; |
147 | } |
148 | } |
149 | |
150 | === modified file 'src/DiscreteVerification/DataStructures/WorkflowPWList.hpp' |
151 | --- src/DiscreteVerification/DataStructures/WorkflowPWList.hpp 2015-06-14 22:27:50 +0000 |
152 | +++ src/DiscreteVerification/DataStructures/WorkflowPWList.hpp 2015-06-24 13:24:40 +0000 |
153 | @@ -19,15 +19,36 @@ |
154 | namespace VerifyTAPN { |
155 | namespace DiscreteVerification { |
156 | |
157 | - class WorkflowPWList : public PWList { |
158 | - |
159 | + class WorkflowPWListBasic : virtual public PWListBase |
160 | + { |
161 | + public: |
162 | + virtual NonStrictMarking* getCoveredMarking(NonStrictMarking* marking, bool useLinearSweep) = 0; |
163 | + virtual NonStrictMarking* getUnpassed() = 0; |
164 | + virtual bool add(NonStrictMarking* marking) = 0; |
165 | + virtual NonStrictMarking* addToPassed(NonStrictMarking* marking, bool strong) = 0; |
166 | + virtual void addLastToWaiting() = 0; |
167 | + virtual void setParent(NonStrictMarking*, NonStrictMarking*) = 0; |
168 | + }; |
169 | + |
170 | + class WorkflowPWList : public WorkflowPWListBasic, public PWList { |
171 | + private: |
172 | + NonStrictMarking* last; |
173 | public: |
174 | WorkflowPWList(WaitingList<NonStrictMarking*>* w_l); |
175 | - NonStrictMarking* getCoveredMarking(NonStrictMarking* marking, bool useLinearSweep); |
176 | - NonStrictMarking* getUnpassed(); |
177 | - bool add(NonStrictMarking* marking); |
178 | - NonStrictMarking* addToPassed(NonStrictMarking* marking); |
179 | + virtual NonStrictMarking* getCoveredMarking(NonStrictMarking* marking, bool useLinearSweep); |
180 | + virtual NonStrictMarking* getUnpassed(); |
181 | + virtual bool add(NonStrictMarking* marking); |
182 | + virtual NonStrictMarking* addToPassed(NonStrictMarking* marking, bool strong); |
183 | NonStrictMarking* lookup(NonStrictMarking* marking); |
184 | + |
185 | + virtual void addLastToWaiting(){ |
186 | + waiting_list->add(last, last); |
187 | + } |
188 | + |
189 | + virtual void setParent(NonStrictMarking* marking, NonStrictMarking* parent) |
190 | + { |
191 | + marking->setParent(parent); |
192 | + } |
193 | |
194 | }; |
195 | |
196 | |
197 | === modified file 'src/DiscreteVerification/VerificationTypes/AbstractNaiveVerification.hpp' |
198 | --- src/DiscreteVerification/VerificationTypes/AbstractNaiveVerification.hpp 2015-06-22 21:03:26 +0000 |
199 | +++ src/DiscreteVerification/VerificationTypes/AbstractNaiveVerification.hpp 2015-06-24 13:24:40 +0000 |
200 | @@ -68,7 +68,7 @@ |
201 | |
202 | template<typename T,typename U> |
203 | AbstractNaiveVerification<T,U>::AbstractNaiveVerification(TAPN::TimedArcPetriNet& tapn, U& initialMarking, AST::Query* query, VerificationOptions options, T* pwList) |
204 | - : Verification<U>(tapn, initialMarking, query, options), lastMarking(NULL), successorGenerator(tapn, *this), pwList(pwList) { |
205 | + : Verification<U>(tapn, initialMarking, query, options), successorGenerator(tapn, *this), lastMarking(NULL), pwList(pwList) { |
206 | |
207 | }; |
208 | |
209 | |
210 | === modified file 'src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp' |
211 | --- src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2015-06-16 18:44:21 +0000 |
212 | +++ src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2015-06-24 13:24:40 +0000 |
213 | @@ -98,7 +98,7 @@ |
214 | |
215 | void ReachabilitySearchPTrie::getTrace(){ |
216 | stack < NonStrictMarking*> printStack; |
217 | - PWListHybrid* pwhlist = (PWListHybrid*)(this->pwList); |
218 | + PWListHybrid* pwhlist = dynamic_cast<PWListHybrid*>(this->pwList); |
219 | MetaDataWithTraceAndEncoding* next = pwhlist->parent; |
220 | NonStrictMarking* last = lastMarking; |
221 | printStack.push(lastMarking); |
222 | |
223 | === modified file 'src/DiscreteVerification/VerificationTypes/Workflow.hpp' |
224 | --- src/DiscreteVerification/VerificationTypes/Workflow.hpp 2015-06-14 22:27:50 +0000 |
225 | +++ src/DiscreteVerification/VerificationTypes/Workflow.hpp 2015-06-24 13:24:40 +0000 |
226 | @@ -29,27 +29,29 @@ |
227 | namespace VerifyTAPN { |
228 | namespace DiscreteVerification { |
229 | |
230 | -template<typename T> |
231 | -class Workflow : public AbstractNaiveVerification<WorkflowPWList,T> { |
232 | + |
233 | +class Workflow : public AbstractNaiveVerification<WorkflowPWListBasic,NonStrictMarking> { |
234 | public: |
235 | - Workflow(TAPN::TimedArcPetriNet& tapn, T& initialMarking, AST::Query* query, VerificationOptions options, WaitingList<NonStrictMarking*>* waiting_list); |
236 | + Workflow(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options) |
237 | + : AbstractNaiveVerification<WorkflowPWListBasic,NonStrictMarking>(tapn, initialMarking, query, options, NULL), in(NULL), out(NULL){ |
238 | + |
239 | + for (TimedPlace::Vector::const_iterator iter = tapn.getPlaces().begin(); |
240 | + iter != tapn.getPlaces().end(); iter++) { |
241 | + if ((*iter)->getType() == Dead) { |
242 | + (*iter)->setType(Std); |
243 | + } |
244 | + } |
245 | + } |
246 | virtual void printExecutionTime(ostream& stream) = 0; |
247 | |
248 | protected: |
249 | + virtual void deleteMarking(NonStrictMarking* marking){ |
250 | + |
251 | + }; |
252 | TimedPlace* in; |
253 | TimedPlace* out; |
254 | }; |
255 | |
256 | -template<typename T> |
257 | -Workflow<T>::Workflow(TAPN::TimedArcPetriNet& tapn, T& initialMarking, AST::Query* query, VerificationOptions options, WaitingList<NonStrictMarking*>* waiting_list) |
258 | -: AbstractNaiveVerification<WorkflowPWList,T>(tapn, initialMarking, query, options, new WorkflowPWList(waiting_list)), in(NULL), out(NULL){ |
259 | - for (TimedPlace::Vector::const_iterator iter = tapn.getPlaces().begin(); iter != tapn.getPlaces().end(); iter++) { |
260 | - if ((*iter)->getType() == Dead) { |
261 | - (*iter)->setType(Std); |
262 | - } |
263 | - } |
264 | -} |
265 | - |
266 | } /* namespace DiscreteVerification */ |
267 | } /* namespace VerifyTAPN */ |
268 | #endif /* NONSTRICTSEARCH_HPP_ */ |
269 | \ No newline at end of file |
270 | |
271 | === modified file 'src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp' |
272 | --- src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp 2015-06-22 21:34:37 +0000 |
273 | +++ src/DiscreteVerification/VerificationTypes/WorkflowSoundness.cpp 2015-06-24 13:24:40 +0000 |
274 | @@ -11,10 +11,17 @@ |
275 | namespace DiscreteVerification { |
276 | |
277 | WorkflowSoundness::WorkflowSoundness(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options, WaitingList<NonStrictMarking*>* waiting_list) |
278 | -: Workflow<NonStrictMarking>(tapn, initialMarking, query, options, waiting_list), passedStack(), minExec(INT_MAX), linearSweepTreshold(3), coveredMarking(NULL), modelType(calculateModelType()){ |
279 | - |
280 | +: Workflow(tapn, initialMarking, query, options), passedStack(), minExec(INT_MAX), linearSweepTreshold(3), coveredMarking(NULL), modelType(calculateModelType()){ |
281 | + pwList = new WorkflowPWList(waiting_list); |
282 | } |
283 | |
284 | + |
285 | +WorkflowSoundness::WorkflowSoundness(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options) |
286 | +: Workflow(tapn, initialMarking, query, options), passedStack(), minExec(INT_MAX), linearSweepTreshold(3), coveredMarking(NULL), modelType(calculateModelType()){ |
287 | + |
288 | +}; |
289 | + |
290 | + |
291 | bool WorkflowSoundness::verify(){ |
292 | if(addToPW(&initialMarking, NULL)){ |
293 | return false; |
294 | @@ -22,10 +29,12 @@ |
295 | |
296 | // Phase 1 |
297 | while(pwList->hasWaitingStates()){ |
298 | - NonStrictMarking& next_marking = *pwList->getNextUnexplored(); |
299 | - tmpParent = &next_marking; |
300 | + |
301 | + NonStrictMarking* next_marking = pwList->getNextUnexplored(); |
302 | + tmpParent = next_marking; |
303 | bool noDelay = false; |
304 | - Result res = successorGenerator.generateAndInsertSuccessors(next_marking); |
305 | + |
306 | + Result res = successorGenerator.generateAndInsertSuccessors(*next_marking); |
307 | if(res == ADDTOPW_RETURNED_TRUE){ |
308 | return false; |
309 | } else if (res == ADDTOPW_RETURNED_FALSE_URGENTENABLED) { |
310 | @@ -33,11 +42,11 @@ |
311 | } |
312 | |
313 | // Generate next markings |
314 | - if(!noDelay && isDelayPossible(next_marking)){ |
315 | - NonStrictMarking* marking = new NonStrictMarking(next_marking); |
316 | + if(!noDelay && isDelayPossible(*next_marking)){ |
317 | + NonStrictMarking* marking = new NonStrictMarking(*next_marking); |
318 | marking->incrementAge(); |
319 | marking->setGeneratedBy(NULL); |
320 | - if(addToPW(marking, &next_marking)){ |
321 | + if(addToPW(marking, next_marking)){ |
322 | return false; |
323 | } |
324 | } |
325 | @@ -45,18 +54,7 @@ |
326 | |
327 | // Phase 2 |
328 | // mark all as passed which ends in a final marking |
329 | - int passed = 0; |
330 | - while(passedStack.size()){ |
331 | - WorkflowSoundnessMetaData* next = passedStack.top(); |
332 | - passedStack.pop(); |
333 | - if(next->passed) continue; |
334 | - next->passed = true; |
335 | - ++passed; |
336 | - for(vector<MetaData*>::iterator iter = next->parents.begin(); |
337 | - iter != next->parents.end(); iter++){ |
338 | - passedStack.push((WorkflowSoundnessMetaData*)*iter); |
339 | - } |
340 | - } |
341 | + int passed = numberOfPassed(); |
342 | |
343 | if(passed < pwList->stored){ |
344 | lastMarking = pwList->getUnpassed(); |
345 | @@ -66,6 +64,25 @@ |
346 | } |
347 | } |
348 | |
349 | +int WorkflowSoundness::numberOfPassed() |
350 | +{ |
351 | + int passed = 0; |
352 | + while(passedStack.size()){ |
353 | + WorkflowSoundnessMetaData* next = |
354 | + static_cast<WorkflowSoundnessMetaData*>(passedStack.top()); |
355 | + passedStack.pop(); |
356 | + if(next->passed) continue; |
357 | + next->passed = true; |
358 | + ++passed; |
359 | + for(vector<MetaData*>::iterator iter = next->parents.begin(); |
360 | + iter != next->parents.end(); iter++){ |
361 | + passedStack.push(*iter); |
362 | + } |
363 | + } |
364 | + return passed; |
365 | +} |
366 | + |
367 | + |
368 | bool WorkflowSoundness::addToPW(NonStrictMarking* marking, NonStrictMarking* parent){ |
369 | marking->cut(placeStats); |
370 | |
371 | @@ -79,8 +96,9 @@ |
372 | } |
373 | |
374 | // Map to existing marking if any |
375 | - NonStrictMarking* old = pwList->addToPassed(marking); |
376 | bool isNew = false; |
377 | + marking->setParent(parent); |
378 | + NonStrictMarking* old = pwList->addToPassed(marking, false); |
379 | if(old == NULL){ |
380 | isNew = true; |
381 | marking->meta = new WorkflowSoundnessMetaData(); |
382 | @@ -89,20 +107,17 @@ |
383 | delete marking; |
384 | marking = old; |
385 | } |
386 | - |
387 | - WorkflowSoundnessMetaData* marking_meta_data = ((WorkflowSoundnessMetaData*)marking->meta); |
388 | - |
389 | + |
390 | // add to parents_set |
391 | if(parent != NULL){ |
392 | - WorkflowSoundnessMetaData* parent_meta_data = ((WorkflowSoundnessMetaData*)parent->meta); |
393 | - marking_meta_data->parents.push_back(parent_meta_data); |
394 | + addParentMeta(marking->meta, parent->meta); |
395 | if(marking->getGeneratedBy() == NULL){ |
396 | - marking_meta_data->totalDelay = min(marking_meta_data->totalDelay, parent_meta_data->totalDelay+1); // Delay |
397 | + marking->meta->totalDelay = min(marking->meta->totalDelay, parent->meta->totalDelay+1); // Delay |
398 | }else{ |
399 | - marking_meta_data->totalDelay = min(marking_meta_data->totalDelay, parent_meta_data->totalDelay); // Transition |
400 | + marking->meta->totalDelay = min(marking->meta->totalDelay, parent->meta->totalDelay); // Transition |
401 | } |
402 | }else{ |
403 | - marking_meta_data->totalDelay = 0; |
404 | + marking->meta->totalDelay = 0; |
405 | } |
406 | |
407 | |
408 | @@ -110,15 +125,14 @@ |
409 | // Test if final place |
410 | if(marking->numberOfTokensInPlace(out->getIndex()) > 0){ |
411 | if(size == 1){ |
412 | - marking_meta_data = ((WorkflowSoundnessMetaData*)marking->meta); |
413 | - marking_meta_data->parents.push_back(((WorkflowSoundnessMetaData*)parent->meta)); |
414 | + passedStack.push(marking->meta); |
415 | // Set min |
416 | - marking_meta_data->totalDelay = min(marking_meta_data->totalDelay, ((WorkflowSoundnessMetaData*)parent->meta)->totalDelay); // Transition |
417 | - passedStack.push(marking_meta_data); |
418 | + marking->meta->totalDelay = min(marking->meta->totalDelay, parent->meta->totalDelay); // Transition |
419 | // keep track of shortest trace |
420 | - if (marking_meta_data->totalDelay < minExec) { |
421 | - minExec = marking_meta_data->totalDelay; |
422 | + if (marking->meta->totalDelay < minExec) { |
423 | + minExec = marking->meta->totalDelay; |
424 | lastMarking = marking; |
425 | + return false; |
426 | } |
427 | }else{ |
428 | lastMarking = marking; |
429 | @@ -127,7 +141,7 @@ |
430 | }else{ |
431 | // If new marking |
432 | if(isNew){ |
433 | - pwList->addToWaiting(marking); |
434 | + pwList->addLastToWaiting(); |
435 | if(parent != NULL && marking->canDeadlock(tapn, 0)){ |
436 | lastMarking = marking; |
437 | return true; |
438 | @@ -141,6 +155,14 @@ |
439 | return false; |
440 | } |
441 | |
442 | +void WorkflowSoundness::addParentMeta(MetaData* meta, MetaData* parent) |
443 | +{ |
444 | + WorkflowSoundnessMetaData* markingmeta = ((WorkflowSoundnessMetaData*)meta); |
445 | + markingmeta->parents.push_back(parent); |
446 | + |
447 | +} |
448 | + |
449 | + |
450 | bool WorkflowSoundness::checkForCoveredMarking(NonStrictMarking* marking){ |
451 | if(marking->size() <= options.getKBound()){ |
452 | return false; // Do not run check on small markings (invoke more rarely) |
453 | @@ -148,16 +170,17 @@ |
454 | |
455 | NonStrictMarking* covered = pwList->getCoveredMarking(marking, (marking->size() > linearSweepTreshold)); |
456 | if(covered != NULL){ |
457 | - coveredMarking = covered; |
458 | - return true; |
459 | + coveredMarking = covered; |
460 | + return true; |
461 | } |
462 | |
463 | return false; |
464 | } |
465 | |
466 | -void WorkflowSoundness::getTrace(NonStrictMarking* base){ |
467 | +void WorkflowSoundness::getTrace(NonStrictMarking* marking){ |
468 | + |
469 | stack < NonStrictMarking*> printStack; |
470 | - NonStrictMarking* next = lastMarking; |
471 | + NonStrictMarking* next = marking; |
472 | if(next != NULL){ |
473 | do{ |
474 | printStack.push(next); |
475 | @@ -165,13 +188,12 @@ |
476 | } while(next); |
477 | } |
478 | |
479 | - if(options.getXmlTrace()){ |
480 | - printXMLTrace(lastMarking, printStack, query, tapn); |
481 | - } else { |
482 | - printHumanTrace(lastMarking, printStack, query->getQuantifier()); |
483 | - } |
484 | + printXMLTrace(marking, printStack, query, tapn); |
485 | + |
486 | } |
487 | |
488 | + |
489 | + |
490 | WorkflowSoundness::ModelType WorkflowSoundness::calculateModelType() { |
491 | bool isin, isout; |
492 | bool hasInvariant = false; |
493 | |
494 | === modified file 'src/DiscreteVerification/VerificationTypes/WorkflowSoundness.hpp' |
495 | --- src/DiscreteVerification/VerificationTypes/WorkflowSoundness.hpp 2015-06-14 22:27:50 +0000 |
496 | +++ src/DiscreteVerification/VerificationTypes/WorkflowSoundness.hpp 2015-06-24 13:24:40 +0000 |
497 | @@ -29,18 +29,20 @@ |
498 | namespace VerifyTAPN { |
499 | namespace DiscreteVerification { |
500 | |
501 | -class WorkflowSoundness : public Workflow<NonStrictMarking> { |
502 | +class WorkflowSoundness : public Workflow { |
503 | public: |
504 | enum ModelType{ |
505 | MTAWFN, ETAWFN, NOTTAWFN |
506 | }; |
507 | |
508 | WorkflowSoundness(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options, WaitingList<NonStrictMarking*>* waiting_list); |
509 | + WorkflowSoundness(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options); |
510 | + |
511 | virtual ~WorkflowSoundness(); |
512 | bool verify(); |
513 | - virtual void getTrace(){ |
514 | - return getTrace(lastMarking); |
515 | - } |
516 | + virtual void getTrace(NonStrictMarking* marking); |
517 | + virtual void getTrace() {this->getTrace(lastMarking);}; |
518 | + |
519 | void printExecutionTime(ostream& stream){ |
520 | stream << "Minimum execution time: " << minExec << endl; |
521 | } |
522 | @@ -51,14 +53,17 @@ |
523 | } |
524 | } |
525 | inline const ModelType getModelType() const{ return modelType; } |
526 | + virtual int numberOfPassed(); |
527 | + |
528 | protected: |
529 | bool addToPW(NonStrictMarking* marking, NonStrictMarking* parent); |
530 | bool checkForCoveredMarking(NonStrictMarking* marking); |
531 | - void getTrace(NonStrictMarking* base); |
532 | ModelType calculateModelType(); |
533 | + virtual void addParentMeta(MetaData* meta, MetaData* parent); |
534 | + virtual void setMetaParent(NonStrictMarking*){}; |
535 | |
536 | protected: |
537 | - stack<WorkflowSoundnessMetaData*> passedStack; |
538 | + stack<MetaData*> passedStack; |
539 | int minExec; |
540 | unsigned int linearSweepTreshold; |
541 | NonStrictMarking* coveredMarking; |
542 | |
543 | === modified file 'src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp' |
544 | --- src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp 2015-06-14 22:27:50 +0000 |
545 | +++ src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.cpp 2015-06-24 13:24:40 +0000 |
546 | @@ -11,8 +11,14 @@ |
547 | namespace DiscreteVerification { |
548 | |
549 | WorkflowStrongSoundnessReachability::WorkflowStrongSoundnessReachability(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options, WaitingList<NonStrictMarking*>* waiting_list) |
550 | - : Workflow<NonStrictMarking>(tapn, initialMarking, query, options, waiting_list), maxValue(-1), outPlace(NULL){ |
551 | - // Find timer place and store as out |
552 | + : Workflow(tapn, initialMarking, query, options), maxValue(-1), outPlace(NULL){ |
553 | + pwList = new WorkflowPWList(waiting_list); |
554 | + findInOut(); |
555 | + }; |
556 | + |
557 | + |
558 | + void WorkflowStrongSoundnessReachability::findInOut() |
559 | + { |
560 | for (TimedPlace::Vector::const_iterator iter = tapn.getPlaces().begin(); iter != tapn.getPlaces().end(); ++iter) { |
561 | if ((*iter)->getTransportArcs().empty() && (*iter)->getInputArcs().empty()) { |
562 | outPlace = *iter; |
563 | @@ -22,23 +28,30 @@ |
564 | }; |
565 | |
566 | bool WorkflowStrongSoundnessReachability::verify() { |
567 | + |
568 | + if (outPlace == NULL) |
569 | + { |
570 | + lastMarking = &initialMarking; |
571 | + return true; |
572 | + } |
573 | + |
574 | if (addToPW(&initialMarking, NULL)) { |
575 | return true; |
576 | } |
577 | |
578 | //Main loop |
579 | while (pwList->hasWaitingStates()) { |
580 | - NonStrictMarking& next_marking = |
581 | - static_cast<NonStrictMarking&>(*pwList->getNextUnexplored()); |
582 | - tmpParent = &next_marking; |
583 | + NonStrictMarking* next_marking = |
584 | + static_cast<NonStrictMarking*>(pwList->getNextUnexplored()); |
585 | + tmpParent = next_marking; |
586 | |
587 | // push onto trace |
588 | - trace.push(&next_marking); |
589 | - next_marking.meta->inTrace = true; |
590 | + trace.push(next_marking); |
591 | + next_marking->meta->inTrace = true; |
592 | validChildren = 0; |
593 | |
594 | bool noDelay = false; |
595 | - Result res = successorGenerator.generateAndInsertSuccessors(next_marking); |
596 | + Result res = successorGenerator.generateAndInsertSuccessors(*next_marking); |
597 | if (res == ADDTOPW_RETURNED_TRUE) { |
598 | return true; |
599 | } else if (res == ADDTOPW_RETURNED_FALSE_URGENTENABLED) { |
600 | @@ -46,26 +59,20 @@ |
601 | } |
602 | |
603 | // Generate delays markings |
604 | - if (!noDelay && isDelayPossible(next_marking)) { |
605 | - NonStrictMarking* marking = new NonStrictMarking(next_marking); |
606 | + if (!noDelay && isDelayPossible(*next_marking)) { |
607 | + NonStrictMarking* marking = new NonStrictMarking(*next_marking); |
608 | marking->incrementAge(); |
609 | marking->setGeneratedBy(NULL); |
610 | |
611 | - if (addToPW(marking, &next_marking)) { |
612 | + if (addToPW(marking, next_marking)) { |
613 | + |
614 | lastMarking = marking; |
615 | return true; |
616 | } |
617 | |
618 | - if(marking->meta && |
619 | - marking->meta->totalDelay > options.getWorkflowBound()){ |
620 | - // if the bound is exceeded, terminate |
621 | - marking->setParent(&next_marking); |
622 | - lastMarking = marking; |
623 | - return true; |
624 | - } |
625 | } |
626 | if(validChildren != 0){ |
627 | - next_marking.setNumberOfChildren(validChildren); |
628 | + next_marking->setNumberOfChildren(validChildren); |
629 | } else { |
630 | // remove childless markings from stack |
631 | while(!trace.empty() && trace.top()->getNumberOfChildren() <= 1){ |
632 | @@ -94,15 +101,11 @@ |
633 | |
634 | } while (next != NULL && next->getParent() != NULL); |
635 | |
636 | - if (printStack.top() != next) { |
637 | + if (next != NULL && printStack.top() != next) { |
638 | printStack.push(next); |
639 | } |
640 | |
641 | - if (options.getXmlTrace()) { |
642 | - printXMLTrace(lastMarking, printStack, query, tapn); |
643 | - } else { |
644 | - printHumanTrace(lastMarking, printStack, query->getQuantifier()); |
645 | - } |
646 | + printXMLTrace(lastMarking, printStack, query, tapn); |
647 | } |
648 | |
649 | bool WorkflowStrongSoundnessReachability::addToPW(NonStrictMarking* marking, NonStrictMarking* parent) { |
650 | @@ -122,7 +125,8 @@ |
651 | |
652 | /* Handle max */ |
653 | // Map to existing marking if any |
654 | - NonStrictMarking* old = (NonStrictMarking*)pwList->addToPassed(marking); |
655 | + NonStrictMarking* old = (NonStrictMarking*)pwList->addToPassed(marking, true); |
656 | + |
657 | if(old != NULL) { |
658 | if(old->meta->totalDelay < totalDelay) { |
659 | if(old->meta->inTrace){ |
660 | @@ -130,14 +134,11 @@ |
661 | lastMarking = marking; |
662 | // make sure we can print trace |
663 | marking->setNumberOfChildren(1); |
664 | - trace.push(marking); |
665 | maxValue = totalDelay; |
666 | return true; |
667 | } else { |
668 | // search again to find maxdelay |
669 | - // copy data from new |
670 | - old->setParent(marking->getParent()); |
671 | - old->setGeneratedBy(marking->getGeneratedBy()); |
672 | + swapData(marking, old); |
673 | old->meta->totalDelay = totalDelay; |
674 | delete marking; |
675 | marking = old; |
676 | @@ -153,19 +154,30 @@ |
677 | marking->meta->totalDelay = totalDelay; |
678 | } |
679 | |
680 | + // if we reached bound |
681 | + if(marking->meta->totalDelay > options.getWorkflowBound()) return true; |
682 | + |
683 | + |
684 | if(marking->numberOfTokensInPlace(outPlace->getIndex()) == 0){ |
685 | // if nonterminal, add to waiting |
686 | - pwList->addToWaiting(marking); |
687 | + pwList->addLastToWaiting(); |
688 | ++validChildren; |
689 | } else { |
690 | // if terminal, update max_value and last marking of trace |
691 | if(maxValue < marking->meta->totalDelay) { |
692 | maxValue = marking->meta->totalDelay; |
693 | lastMarking = marking; |
694 | + return false; |
695 | } |
696 | } |
697 | return false; |
698 | } |
699 | + |
700 | + void WorkflowStrongSoundnessReachability::swapData(NonStrictMarking* marking, NonStrictMarking* old) |
701 | + { |
702 | + old->setGeneratedBy(marking->getGeneratedBy()); |
703 | + old->setParent(marking->getParent()); |
704 | + } |
705 | |
706 | } /* namespace DiscreteVerification */ |
707 | } /* namespace VerifyTAPN */ |
708 | |
709 | === modified file 'src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.hpp' |
710 | --- src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.hpp 2015-06-14 22:27:50 +0000 |
711 | +++ src/DiscreteVerification/VerificationTypes/WorkflowStrongSoundness.hpp 2015-06-24 13:24:40 +0000 |
712 | @@ -17,21 +17,36 @@ |
713 | namespace VerifyTAPN { |
714 | namespace DiscreteVerification { |
715 | |
716 | -class WorkflowStrongSoundnessReachability : public Workflow<NonStrictMarking>{ |
717 | +class WorkflowStrongSoundnessReachability : public Workflow{ |
718 | public: |
719 | |
720 | WorkflowStrongSoundnessReachability(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options, WaitingList<NonStrictMarking*>* waiting_list); |
721 | |
722 | + WorkflowStrongSoundnessReachability(TAPN::TimedArcPetriNet& tapn, NonStrictMarking& initialMarking, AST::Query* query, VerificationOptions options); |
723 | + |
724 | + ~WorkflowStrongSoundnessReachability() |
725 | + { |
726 | + pwList->deleteWaitingList(); |
727 | + delete lastMarking; |
728 | + delete pwList; |
729 | + } |
730 | + |
731 | bool verify(); |
732 | - void getTrace(); |
733 | + virtual void getTrace(); |
734 | |
735 | void printExecutionTime(ostream& stream){ |
736 | stream << "Maximum execution time: " << (maxValue * tapn.getGCD()) << endl; |
737 | } |
738 | |
739 | |
740 | + |
741 | + |
742 | protected: |
743 | + void findInOut(); |
744 | bool addToPW(NonStrictMarking* marking, NonStrictMarking* parent); |
745 | + virtual void swapData(NonStrictMarking* marking, NonStrictMarking* old); |
746 | + virtual void clearTrace(){}; // cleanup |
747 | + |
748 | protected: |
749 | int maxValue; |
750 | TimedPlace* outPlace; |
I get these warnings:
src/DiscreteVer ification/ VerificationTyp es/Reachability Search. cpp:14: 4: note: VerifyTAPN: :DiscreteVerifi cation: :AbstractNaiveV erification< VerifyTAPN: :DiscreteVerifi cation: :PWListBase, N::DiscreteVeri fication: :NonStrictMarki ng>::AbstractNa iveVerification ' rification< PWListBase, NonStrictMarkin g>(tapn, i...
in instantiation of member function
'
VerifyTAP
requested here
: AbstractNaiveVe
^
and
src/DiscreteVer ification/ VerificationTyp es/AbstractNaiv eVerification. hpp:71: 66: warning: ator' U>(tapn, initialMarking, query, options), lastMar...
^ ification/ VerificationTyp es/Workflow. hpp:36: 11: note: in VerifyTAPN: :DiscreteVerifi cation: :AbstractNaiveV erification< VerifyTAPN: :DiscreteVerifi cation: :WorkflowPWList Basic, N::DiscreteVeri fication: :NonStrictMarki ng>::AbstractNa iveVerification ' rification< WorkflowPWListB asic,NonStrictM arking. ..
field 'lastMarking' will be initialized after field 'successorGener
[-Wreorder]
: Verification<
src/DiscreteVer
instantiation of member function
'
VerifyTAP
requested here
: AbstractNaiveVe
^