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
=== modified file 'src/Core/ArgsParser.hpp'
--- src/Core/ArgsParser.hpp 2013-05-14 19:30:32 +0000
+++ src/Core/ArgsParser.hpp 2013-07-21 08:22:24 +0000
@@ -80,7 +80,7 @@
80 class ArgsParser {80 class ArgsParser {
81 typedef std::vector< boost::shared_ptr<Switch> > parser_vec;81 typedef std::vector< boost::shared_ptr<Switch> > parser_vec;
82 public:82 public:
83 ArgsParser() : parsers(), version(2,0,1) { initialize(); };83 ArgsParser() : parsers(), version(2,2,0) { initialize(); };
84 virtual ~ArgsParser() {};84 virtual ~ArgsParser() {};
8585
86 VerificationOptions parse(int argc, char* argv[]) const;86 VerificationOptions parse(int argc, char* argv[]) const;
8787
=== modified file 'src/Core/TAPN/TimedTransition.cpp'
--- src/Core/TAPN/TimedTransition.cpp 2013-05-08 15:10:14 +0000
+++ src/Core/TAPN/TimedTransition.cpp 2013-07-21 08:22:24 +0000
@@ -1,17 +1,28 @@
1#include "TimedTransition.hpp"1#include "TimedTransition.hpp"
2#include "TimedPlace.hpp"
23
3namespace VerifyTAPN {4namespace VerifyTAPN {
4 namespace TAPN {5 namespace TAPN {
5 void TimedTransition::print(std::ostream& out) const6 void TimedTransition::print(std::ostream& out) const
6 {7 {
7 out << getName() << "(" << index << ")";8 out << getName();
9 if(this->urgent)
10 out << " urgent ";
11 out << "(" << index << ")";
8 }12 }
913
10 void TimedTransition::addToPreset(const boost::shared_ptr<TimedInputArc>& arc)14 void TimedTransition::addToPreset(const boost::shared_ptr<TimedInputArc>& arc)
11 {15 {
12 if(arc)16 if(arc)
13 {17 {
14 preset.push_back(arc);18 if(this->urgent){ // all urgency in discrete time must have untimed
19 //inputarcs to not break semantics
20 if(!arc.get()->getInterval().isZeroInfinity()){
21 std::cout << "Urgent transitions must have untimed input arcs" << std::endl;
22 exit(1);
23 }
24 }
25 preset.push_back(arc);
15 }26 }
16 }27 }
1728
@@ -19,6 +30,17 @@
19 {30 {
20 if(arc)31 if(arc)
21 {32 {
33 if(this->urgent){ // all urgency in discrete time must have untimed
34 //inputarcs to not break semantics
35 if(!arc.get()->getInterval().isZeroInfinity()){
36 std::cout << "Urgent transitions must have untimed transportarcs" << std::endl;
37 exit(1);
38 } else if(arc.get()->getDestination().getInvariant() != TimeInvariant::LS_INF){
39 // urgency breaks if we have invariant at destination
40 std::cout << "Transportarcs going through an urgent transition cannot have invariants at destination-places." << std::endl;
41 exit(1);
42 }
43 }
22 transportArcs.push_back(arc);44 transportArcs.push_back(arc);
23 }45 }
24 }46 }
2547
=== modified file 'src/Core/TAPN/TimedTransition.hpp'
--- src/Core/TAPN/TimedTransition.hpp 2013-05-08 15:10:14 +0000
+++ src/Core/TAPN/TimedTransition.hpp 2013-07-21 08:22:24 +0000
@@ -21,8 +21,8 @@
21 public: // typedefs21 public: // typedefs
22 typedef std::vector< boost::shared_ptr<TimedTransition> > Vector;22 typedef std::vector< boost::shared_ptr<TimedTransition> > Vector;
23 public:23 public:
24 TimedTransition(const std::string& name, const std::string& id) : name(name), id(id), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };24 TimedTransition(const std::string& name, const std::string& id, bool urgent) : name(name), id(id), preset(), postset(), transportArcs(), index(-1), untimedPostset(true), urgent(urgent) { };
25 TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };25 TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1), untimedPostset(true),urgent(false) { };
26 virtual ~TimedTransition() { /* empty */ }26 virtual ~TimedTransition() { /* empty */ }
2727
28 public: // modifiers28 public: // modifiers
@@ -49,6 +49,9 @@
49 inline unsigned int getIndex() const { return index; }49 inline unsigned int getIndex() const { return index; }
50 inline const bool hasUntimedPostset() const { return untimedPostset; }50 inline const bool hasUntimedPostset() const { return untimedPostset; }
51 inline void setUntimedPostset(bool untimed){ untimedPostset = untimed; }51 inline void setUntimedPostset(bool untimed){ untimedPostset = untimed; }
52 inline const bool isUrgent() const {
53 return urgent;
54 }
5255
53 private: // data56 private: // data
54 std::string name;57 std::string name;
@@ -59,6 +62,7 @@
59 InhibitorArc::WeakPtrVector inhibitorArcs;62 InhibitorArc::WeakPtrVector inhibitorArcs;
60 unsigned int index;63 unsigned int index;
61 bool untimedPostset;64 bool untimedPostset;
65 bool urgent;
62 };66 };
6367
64 inline std::ostream& operator<<(std::ostream& out, const TimedTransition& transition)68 inline std::ostream& operator<<(std::ostream& out, const TimedTransition& transition)
6569
=== modified file 'src/Core/TAPNParser/TAPNXmlParser.cpp'
--- src/Core/TAPNParser/TAPNXmlParser.cpp 2013-05-08 15:23:45 +0000
+++ src/Core/TAPNParser/TAPNXmlParser.cpp 2013-07-21 08:22:24 +0000
@@ -95,7 +95,15 @@
95{95{
96 std::string id(transitionNode.first_attribute("id")->value());96 std::string id(transitionNode.first_attribute("id")->value());
97 std::string name(transitionNode.first_attribute("name")->value());97 std::string name(transitionNode.first_attribute("name")->value());
98 return boost::make_shared<TimedTransition>(name, id);98 xml_attribute<char>* urgenatt = transitionNode.first_attribute("urgent");
99 bool urgent = false;
100 if(urgenatt != NULL){
101 std::string urgentStr = urgenatt->value();
102 if(urgentStr.compare("true") == 0){
103 urgent = true;
104 }
105 }
106 return boost::make_shared<TimedTransition>(name, id,urgent );
99}107}
100108
101TAPNXmlParser::ArcCollections TAPNXmlParser::parseArcs(const xml_node<>& root, const TimedPlace::Vector& places, const TimedTransition::Vector& transitions) const109TAPNXmlParser::ArcCollections TAPNXmlParser::parseArcs(const xml_node<>& root, const TimedPlace::Vector& places, const TimedTransition::Vector& transitions) const
102110
=== modified file 'src/DiscreteVerification/SuccessorGenerator.hpp'
--- src/DiscreteVerification/SuccessorGenerator.hpp 2013-05-08 15:10:14 +0000
+++ src/DiscreteVerification/SuccessorGenerator.hpp 2013-07-21 08:22:24 +0000
@@ -132,6 +132,8 @@
132 }132 }
133 };133 };
134134
135 enum Result {QUERY_SATISFIED, QUERY_UNSATISFIED, URGENT_ENABLED};
136
135 template<typename T>137 template<typename T>
136 class SuccessorGenerator {138 class SuccessorGenerator {
137 typedef google::sparse_hash_map<const void*, TokenList> ArcHashMap;139 typedef google::sparse_hash_map<const void*, TokenList> ArcHashMap;
@@ -139,10 +141,13 @@
139 typedef typename boost::ptr_vector< ArcAndTokenWithType > ArcAndTokensVector;141 typedef typename boost::ptr_vector< ArcAndTokenWithType > ArcAndTokensVector;
140142
141 public:143 public:
144
142 SuccessorGenerator(TAPN::TimedArcPetriNet& tapn, Verification<T>& verifier);145 SuccessorGenerator(TAPN::TimedArcPetriNet& tapn, Verification<T>& verifier);
143 ~SuccessorGenerator();146 ~SuccessorGenerator();
144 bool generateAndInsertSuccessors(const T& marking);147
148 Result generateAndInsertSuccessors(const T& marking);
145 void printTransitionStatistics(std::ostream & out) const;149 void printTransitionStatistics(std::ostream & out) const;
150
146 inline bool doSuccessorsExist();151 inline bool doSuccessorsExist();
147 152
148 private:153 private:
@@ -165,7 +170,7 @@
165 const TimedTransition& transition,170 const TimedTransition& transition,
166 int bound = std::numeric_limits<int>().max(),171 int bound = std::numeric_limits<int>().max(),
167 bool isInhib = false172 bool isInhib = false
168 ) const;173 );
169174
170 inline void clearTransitionsArray() {175 inline void clearTransitionsArray() {
171 memset(transitionStatistics, 0, numberoftransitions * sizeof (transitionStatistics[0]));176 memset(transitionStatistics, 0, numberoftransitions * sizeof (transitionStatistics[0]));
@@ -175,6 +180,7 @@
175 unsigned int* transitionStatistics;180 unsigned int* transitionStatistics;
176 Verification<T>& verifier;181 Verification<T>& verifier;
177 bool succesorsExist;182 bool succesorsExist;
183 bool urgentEnabled;
178 };184 };
179185
180 template<typename T>186 template<typename T>
@@ -200,11 +206,12 @@
200 }206 }
201 207
202 template<typename T>208 template<typename T>
203 bool SuccessorGenerator<T>::generateAndInsertSuccessors(const T& marking) {209 Result SuccessorGenerator<T>::generateAndInsertSuccessors(const T& marking) {
204 succesorsExist = false;210 succesorsExist = false;
205 211 urgentEnabled = false;
206 ArcHashMap enabledArcs(tapn.getInhibitorArcs().size() + tapn.getInputArcs().size() + tapn.getTransportArcs().size());212 ArcHashMap enabledArcs(tapn.getInhibitorArcs().size() + tapn.getInputArcs().size() + tapn.getTransportArcs().size());
207 std::vector<unsigned int> enabledTransitionArcs(tapn.getTransitions().size(), 0);213 std::vector<unsigned int> enabledTransitionArcs(tapn.getTransitions().size(), 0);
214
208 std::vector<const TAPN::TimedTransition* > enabledTransitions;215 std::vector<const TAPN::TimedTransition* > enabledTransitions;
209216
210 for (PlaceList::const_iterator iter = marking.getPlaceList().begin(); iter < marking.getPlaceList().end(); iter++) {217 for (PlaceList::const_iterator iter = marking.getPlaceList().begin(); iter < marking.getPlaceList().end(); iter++) {
@@ -230,7 +237,16 @@
230 }237 }
231238
232 enabledTransitions.insert(enabledTransitions.end(), allwaysEnabled.begin(), allwaysEnabled.end());239 enabledTransitions.insert(enabledTransitions.end(), allwaysEnabled.begin(), allwaysEnabled.end());
233 return generateMarkings(marking, enabledTransitions, enabledArcs);240 if(generateMarkings(marking, enabledTransitions, enabledArcs)){
241 return QUERY_SATISFIED;
242 } else {
243 if(urgentEnabled){
244 return URGENT_ENABLED;
245 } else{
246 return QUERY_UNSATISFIED;
247 }
248 }
249
234 }250 }
235251
236 template<typename T>252 template<typename T>
@@ -244,7 +260,7 @@
244 const TimedTransition& transition,260 const TimedTransition& transition,
245 int bound,261 int bound,
246 bool isInhib262 bool isInhib
247 ) const {263 ) {
248 bool arcIsEnabled = false;264 bool arcIsEnabled = false;
249 for (TokenList::const_iterator token_iter = place.tokens.begin(); token_iter != place.tokens.end(); token_iter++) {265 for (TokenList::const_iterator token_iter = place.tokens.begin(); token_iter != place.tokens.end(); token_iter++) {
250 if (interval.getLowerBound() <= token_iter->getAge() && token_iter->getAge() <= interval.getUpperBound() && token_iter->getAge() <= bound) {266 if (interval.getLowerBound() <= token_iter->getAge() && token_iter->getAge() <= interval.getUpperBound() && token_iter->getAge() <= bound) {
@@ -310,6 +326,11 @@
310 }326 }
311 }327 }
312328
329 // only here the weights have been properly checked.
330 if(transition.isUrgent()){
331 this->urgentEnabled = true;
332 }
333
313 // Write statistics334 // Write statistics
314 transitionStatistics[transition.getIndex()]++;335 transitionStatistics[transition.getIndex()]++;
315336
316337
=== modified file 'src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp'
--- src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp 2013-05-08 13:49:42 +0000
+++ src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp 2013-07-21 08:22:24 +0000
@@ -37,8 +37,16 @@
37 trace.push(&next_marking);37 trace.push(&next_marking);
38 validChildren = 0;38 validChildren = 0;
3939
4040 bool noDelay = false;
41 if(isDelayPossible(next_marking)){41 Result res = successorGenerator.generateAndInsertSuccessors(next_marking);
42 if (res == QUERY_SATISFIED) {
43 return true;
44 } else if (res == URGENT_ENABLED) {
45 noDelay = true;
46 }
47
48
49 if(!noDelay && isDelayPossible(next_marking)){
42 NonStrictMarking* marking = new NonStrictMarking(next_marking);50 NonStrictMarking* marking = new NonStrictMarking(next_marking);
43 marking->incrementAge();51 marking->incrementAge();
44 marking->setGeneratedBy(NULL);52 marking->setGeneratedBy(NULL);
@@ -47,9 +55,6 @@
47 }55 }
48 endOfMaxRun = false;56 endOfMaxRun = false;
49 }57 }
50 if(successorGenerator.generateAndInsertSuccessors(next_marking)){
51 return true;
52 }
53 // if no delay is possible, and no transition-based succecors are possible, we have reached a max run58 // if no delay is possible, and no transition-based succecors are possible, we have reached a max run
54 endOfMaxRun = endOfMaxRun && (!successorGenerator.doSuccessorsExist());59 endOfMaxRun = endOfMaxRun && (!successorGenerator.doSuccessorsExist());
5560
5661
=== modified file 'src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp'
--- src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2013-05-08 13:49:42 +0000
+++ src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp 2013-07-21 08:22:24 +0000
@@ -32,8 +32,16 @@
32 trace.push(&next_marking);32 trace.push(&next_marking);
33 validChildren = 0;33 validChildren = 0;
3434
35 bool noDelay = false;
36 Result res = successorGenerator.generateAndInsertSuccessors(next_marking);
37 if(res == QUERY_SATISFIED){
38 return true;
39 } else if (res == URGENT_ENABLED) {
40 noDelay = true;
41 }
42
35 // Generate next markings43 // Generate next markings
36 if(isDelayPossible(next_marking)){44 if(!noDelay && isDelayPossible(next_marking)){
37 NonStrictMarking* marking = new NonStrictMarking(next_marking);45 NonStrictMarking* marking = new NonStrictMarking(next_marking);
38 marking->incrementAge();46 marking->incrementAge();
39 marking->setGeneratedBy(NULL);47 marking->setGeneratedBy(NULL);
@@ -41,11 +49,8 @@
41 return true;49 return true;
42 }50 }
43 }51 }
44 if(successorGenerator.generateAndInsertSuccessors(next_marking)){
45 return true;
46 }
47
48 deleteMarking(&next_marking);52 deleteMarking(&next_marking);
53
49 }54 }
5055
51 return false;56 return false;
5257
=== modified file 'src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp'
--- src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp 2013-05-08 15:10:14 +0000
+++ src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp 2013-07-21 08:22:24 +0000
@@ -28,6 +28,10 @@
28 if ((*iter)->getPreset().size() + (*iter)->getTransportArcs().size() == 0) {28 if ((*iter)->getPreset().size() + (*iter)->getTransportArcs().size() == 0) {
29 allwaysEnabled.push_back(iter->get());29 allwaysEnabled.push_back(iter->get());
30 }30 }
31 if((*iter)->isUrgent()){ // no implementation for urgency in timedart engine yet
32 cout << "The TimeDart engine cannot handle urgent transitions" << endl;
33 exit(1);
34 }
31 }35 }
32 }36 }
3337

Subscribers

People subscribed via source and target branches