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

Proposed by Peter Gjøl Jensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 439
Merged at revision: 283
Proposed branch: lp:~verifydtapn-contributers/verifydtapn/urgentTransitions
Merge into: lp:verifydtapn
Diff against target: 300 lines (+91/-22)
8 files modified
src/Core/ArgsParser.hpp (+1/-1)
src/Core/TAPN/TimedTransition.cpp (+24/-2)
src/Core/TAPN/TimedTransition.hpp (+6/-2)
src/Core/TAPNParser/TAPNXmlParser.cpp (+9/-1)
src/DiscreteVerification/SuccessorGenerator.hpp (+27/-6)
src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp (+10/-5)
src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp (+10/-5)
src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp (+4/-0)
To merge this branch: bzr merge lp:~verifydtapn-contributers/verifydtapn/urgentTransitions
Reviewer Review Type Date Requested Status
Mathias Grund Sørensen Approve
Jakob Taankvist Approve
Jiri Srba Approve
Review via email: mp+176040@code.launchpad.net

Description of the change

Implementation of urgent transitions for the pointwise engine.
The only major change is the return-type of the successor-generator which now returns "Query Satisfied", "Query Unsatisfied" and "Urgent Enabled" to be able to allow/disallow the aging of a marking when needed.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) :
review: Approve
Revision history for this message
Jakob Taankvist (jakob-taankvist) :
review: Approve
Revision history for this message
Mathias Grund Sørensen (mathias.grund) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Core/ArgsParser.hpp'
2--- src/Core/ArgsParser.hpp 2013-05-14 19:30:32 +0000
3+++ src/Core/ArgsParser.hpp 2013-07-21 08:22:24 +0000
4@@ -80,7 +80,7 @@
5 class ArgsParser {
6 typedef std::vector< boost::shared_ptr<Switch> > parser_vec;
7 public:
8- ArgsParser() : parsers(), version(2,0,1) { initialize(); };
9+ ArgsParser() : parsers(), version(2,2,0) { initialize(); };
10 virtual ~ArgsParser() {};
11
12 VerificationOptions parse(int argc, char* argv[]) const;
13
14=== modified file 'src/Core/TAPN/TimedTransition.cpp'
15--- src/Core/TAPN/TimedTransition.cpp 2013-05-08 15:10:14 +0000
16+++ src/Core/TAPN/TimedTransition.cpp 2013-07-21 08:22:24 +0000
17@@ -1,17 +1,28 @@
18 #include "TimedTransition.hpp"
19+#include "TimedPlace.hpp"
20
21 namespace VerifyTAPN {
22 namespace TAPN {
23 void TimedTransition::print(std::ostream& out) const
24 {
25- out << getName() << "(" << index << ")";
26+ out << getName();
27+ if(this->urgent)
28+ out << " urgent ";
29+ out << "(" << index << ")";
30 }
31
32 void TimedTransition::addToPreset(const boost::shared_ptr<TimedInputArc>& arc)
33 {
34 if(arc)
35 {
36- preset.push_back(arc);
37+ if(this->urgent){ // all urgency in discrete time must have untimed
38+ //inputarcs to not break semantics
39+ if(!arc.get()->getInterval().isZeroInfinity()){
40+ std::cout << "Urgent transitions must have untimed input arcs" << std::endl;
41+ exit(1);
42+ }
43+ }
44+ preset.push_back(arc);
45 }
46 }
47
48@@ -19,6 +30,17 @@
49 {
50 if(arc)
51 {
52+ if(this->urgent){ // all urgency in discrete time must have untimed
53+ //inputarcs to not break semantics
54+ if(!arc.get()->getInterval().isZeroInfinity()){
55+ std::cout << "Urgent transitions must have untimed transportarcs" << std::endl;
56+ exit(1);
57+ } else if(arc.get()->getDestination().getInvariant() != TimeInvariant::LS_INF){
58+ // urgency breaks if we have invariant at destination
59+ std::cout << "Transportarcs going through an urgent transition cannot have invariants at destination-places." << std::endl;
60+ exit(1);
61+ }
62+ }
63 transportArcs.push_back(arc);
64 }
65 }
66
67=== modified file 'src/Core/TAPN/TimedTransition.hpp'
68--- src/Core/TAPN/TimedTransition.hpp 2013-05-08 15:10:14 +0000
69+++ src/Core/TAPN/TimedTransition.hpp 2013-07-21 08:22:24 +0000
70@@ -21,8 +21,8 @@
71 public: // typedefs
72 typedef std::vector< boost::shared_ptr<TimedTransition> > Vector;
73 public:
74- TimedTransition(const std::string& name, const std::string& id) : name(name), id(id), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };
75- TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };
76+ TimedTransition(const std::string& name, const std::string& id, bool urgent) : name(name), id(id), preset(), postset(), transportArcs(), index(-1), untimedPostset(true), urgent(urgent) { };
77+ TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1), untimedPostset(true),urgent(false) { };
78 virtual ~TimedTransition() { /* empty */ }
79
80 public: // modifiers
81@@ -49,6 +49,9 @@
82 inline unsigned int getIndex() const { return index; }
83 inline const bool hasUntimedPostset() const { return untimedPostset; }
84 inline void setUntimedPostset(bool untimed){ untimedPostset = untimed; }
85+ inline const bool isUrgent() const {
86+ return urgent;
87+ }
88
89 private: // data
90 std::string name;
91@@ -59,6 +62,7 @@
92 InhibitorArc::WeakPtrVector inhibitorArcs;
93 unsigned int index;
94 bool untimedPostset;
95+ bool urgent;
96 };
97
98 inline std::ostream& operator<<(std::ostream& out, const TimedTransition& transition)
99
100=== modified file 'src/Core/TAPNParser/TAPNXmlParser.cpp'
101--- src/Core/TAPNParser/TAPNXmlParser.cpp 2013-05-08 15:23:45 +0000
102+++ src/Core/TAPNParser/TAPNXmlParser.cpp 2013-07-21 08:22:24 +0000
103@@ -95,7 +95,15 @@
104 {
105 std::string id(transitionNode.first_attribute("id")->value());
106 std::string name(transitionNode.first_attribute("name")->value());
107- return boost::make_shared<TimedTransition>(name, id);
108+ xml_attribute<char>* urgenatt = transitionNode.first_attribute("urgent");
109+ bool urgent = false;
110+ if(urgenatt != NULL){
111+ std::string urgentStr = urgenatt->value();
112+ if(urgentStr.compare("true") == 0){
113+ urgent = true;
114+ }
115+ }
116+ return boost::make_shared<TimedTransition>(name, id,urgent );
117 }
118
119 TAPNXmlParser::ArcCollections TAPNXmlParser::parseArcs(const xml_node<>& root, const TimedPlace::Vector& places, const TimedTransition::Vector& transitions) const
120
121=== modified file 'src/DiscreteVerification/SuccessorGenerator.hpp'
122--- src/DiscreteVerification/SuccessorGenerator.hpp 2013-05-08 15:10:14 +0000
123+++ src/DiscreteVerification/SuccessorGenerator.hpp 2013-07-21 08:22:24 +0000
124@@ -132,6 +132,8 @@
125 }
126 };
127
128+ enum Result {QUERY_SATISFIED, QUERY_UNSATISFIED, URGENT_ENABLED};
129+
130 template<typename T>
131 class SuccessorGenerator {
132 typedef google::sparse_hash_map<const void*, TokenList> ArcHashMap;
133@@ -139,10 +141,13 @@
134 typedef typename boost::ptr_vector< ArcAndTokenWithType > ArcAndTokensVector;
135
136 public:
137+
138 SuccessorGenerator(TAPN::TimedArcPetriNet& tapn, Verification<T>& verifier);
139 ~SuccessorGenerator();
140- bool generateAndInsertSuccessors(const T& marking);
141+
142+ Result generateAndInsertSuccessors(const T& marking);
143 void printTransitionStatistics(std::ostream & out) const;
144+
145 inline bool doSuccessorsExist();
146
147 private:
148@@ -165,7 +170,7 @@
149 const TimedTransition& transition,
150 int bound = std::numeric_limits<int>().max(),
151 bool isInhib = false
152- ) const;
153+ );
154
155 inline void clearTransitionsArray() {
156 memset(transitionStatistics, 0, numberoftransitions * sizeof (transitionStatistics[0]));
157@@ -175,6 +180,7 @@
158 unsigned int* transitionStatistics;
159 Verification<T>& verifier;
160 bool succesorsExist;
161+ bool urgentEnabled;
162 };
163
164 template<typename T>
165@@ -200,11 +206,12 @@
166 }
167
168 template<typename T>
169- bool SuccessorGenerator<T>::generateAndInsertSuccessors(const T& marking) {
170+ Result SuccessorGenerator<T>::generateAndInsertSuccessors(const T& marking) {
171 succesorsExist = false;
172-
173+ urgentEnabled = false;
174 ArcHashMap enabledArcs(tapn.getInhibitorArcs().size() + tapn.getInputArcs().size() + tapn.getTransportArcs().size());
175 std::vector<unsigned int> enabledTransitionArcs(tapn.getTransitions().size(), 0);
176+
177 std::vector<const TAPN::TimedTransition* > enabledTransitions;
178
179 for (PlaceList::const_iterator iter = marking.getPlaceList().begin(); iter < marking.getPlaceList().end(); iter++) {
180@@ -230,7 +237,16 @@
181 }
182
183 enabledTransitions.insert(enabledTransitions.end(), allwaysEnabled.begin(), allwaysEnabled.end());
184- return generateMarkings(marking, enabledTransitions, enabledArcs);
185+ if(generateMarkings(marking, enabledTransitions, enabledArcs)){
186+ return QUERY_SATISFIED;
187+ } else {
188+ if(urgentEnabled){
189+ return URGENT_ENABLED;
190+ } else{
191+ return QUERY_UNSATISFIED;
192+ }
193+ }
194+
195 }
196
197 template<typename T>
198@@ -244,7 +260,7 @@
199 const TimedTransition& transition,
200 int bound,
201 bool isInhib
202- ) const {
203+ ) {
204 bool arcIsEnabled = false;
205 for (TokenList::const_iterator token_iter = place.tokens.begin(); token_iter != place.tokens.end(); token_iter++) {
206 if (interval.getLowerBound() <= token_iter->getAge() && token_iter->getAge() <= interval.getUpperBound() && token_iter->getAge() <= bound) {
207@@ -310,6 +326,11 @@
208 }
209 }
210
211+ // only here the weights have been properly checked.
212+ if(transition.isUrgent()){
213+ this->urgentEnabled = true;
214+ }
215+
216 // Write statistics
217 transitionStatistics[transition.getIndex()]++;
218
219
220=== modified file 'src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp'
221--- src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp 2013-05-08 13:49:42 +0000
222+++ src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp 2013-07-21 08:22:24 +0000
223@@ -37,8 +37,16 @@
224 trace.push(&next_marking);
225 validChildren = 0;
226
227-
228- if(isDelayPossible(next_marking)){
229+ bool noDelay = false;
230+ Result res = successorGenerator.generateAndInsertSuccessors(next_marking);
231+ if (res == QUERY_SATISFIED) {
232+ return true;
233+ } else if (res == URGENT_ENABLED) {
234+ noDelay = true;
235+ }
236+
237+
238+ if(!noDelay && isDelayPossible(next_marking)){
239 NonStrictMarking* marking = new NonStrictMarking(next_marking);
240 marking->incrementAge();
241 marking->setGeneratedBy(NULL);
242@@ -47,9 +55,6 @@
243 }
244 endOfMaxRun = false;
245 }
246- if(successorGenerator.generateAndInsertSuccessors(next_marking)){
247- return true;
248- }
249 // if no delay is possible, and no transition-based succecors are possible, we have reached a max run
250 endOfMaxRun = endOfMaxRun && (!successorGenerator.doSuccessorsExist());
251
252
253=== modified file 'src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp'
254--- src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2013-05-08 13:49:42 +0000
255+++ src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2013-07-21 08:22:24 +0000
256@@ -32,8 +32,16 @@
257 trace.push(&next_marking);
258 validChildren = 0;
259
260+ bool noDelay = false;
261+ Result res = successorGenerator.generateAndInsertSuccessors(next_marking);
262+ if(res == QUERY_SATISFIED){
263+ return true;
264+ } else if (res == URGENT_ENABLED) {
265+ noDelay = true;
266+ }
267+
268 // Generate next markings
269- if(isDelayPossible(next_marking)){
270+ if(!noDelay && isDelayPossible(next_marking)){
271 NonStrictMarking* marking = new NonStrictMarking(next_marking);
272 marking->incrementAge();
273 marking->setGeneratedBy(NULL);
274@@ -41,11 +49,8 @@
275 return true;
276 }
277 }
278- if(successorGenerator.generateAndInsertSuccessors(next_marking)){
279- return true;
280- }
281-
282 deleteMarking(&next_marking);
283+
284 }
285
286 return false;
287
288=== modified file 'src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp'
289--- src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp 2013-05-08 15:10:14 +0000
290+++ src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp 2013-07-21 08:22:24 +0000
291@@ -28,6 +28,10 @@
292 if ((*iter)->getPreset().size() + (*iter)->getTransportArcs().size() == 0) {
293 allwaysEnabled.push_back(iter->get());
294 }
295+ if((*iter)->isUrgent()){ // no implementation for urgency in timedart engine yet
296+ cout << "The TimeDart engine cannot handle urgent transitions" << endl;
297+ exit(1);
298+ }
299 }
300 }
301

Subscribers

People subscribed via source and target branches