Merge lp:~tapaal-dist-ctl/verifypn/verifypn-ctl-bfs into lp:~verifypn-maintainers/verifypn/trunk

Proposed by Søren Moss Nielsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 67
Merged at revision: 72
Proposed branch: lp:~tapaal-dist-ctl/verifypn/verifypn-ctl-bfs
Merge into: lp:~verifypn-maintainers/verifypn/trunk
Diff against target: 115 lines (+79/-3)
3 files modified
CTL/SearchStrategies/BreadthFirstSearch.cpp (+44/-0)
CTL/SearchStrategies/BreadthFirstSearch.h (+28/-0)
VerifyPN.cpp (+7/-3)
To merge this branch: bzr merge lp:~tapaal-dist-ctl/verifypn/verifypn-ctl-bfs
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+291455@code.launchpad.net

Commit message

Minor bug fix in main

Description of the change

===============================================================
::::::::::::::::::::Added BFS Strategy ::::::::::::::::::::::::
===============================================================
Setup:
   - TIMEOUT: 60sec
   - ModelDB size: 78
   - Total possible answers: 1248

Base(DFS):
   //The current trunk as of commit 65
   ANSWERS: 747

BFS
   ANSWERS: 606
   More specific statistics are communicated via E-mail
   (All answers are consistent

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'CTL/SearchStrategies/BreadthFirstSearch.cpp'
2--- CTL/SearchStrategies/BreadthFirstSearch.cpp 1970-01-01 00:00:00 +0000
3+++ CTL/SearchStrategies/BreadthFirstSearch.cpp 2016-04-10 10:18:24 +0000
4@@ -0,0 +1,44 @@
5+#include "BreadthFirstSearch.h"
6+
7+ctl::BreadthFirstSearch::BreadthFirstSearch()
8+{
9+
10+}
11+
12+void ctl::BreadthFirstSearch::push(ctl::Edge *e)
13+{
14+ W.push_back(e);
15+}
16+
17+void ctl::BreadthFirstSearch::push_dependency(ctl::Edge *e)
18+{
19+ W.push_back(e);
20+}
21+
22+ctl::Edge *ctl::BreadthFirstSearch::pop()
23+{
24+ Edge *e = W.front();
25+ W.pop_front();
26+ return e;
27+}
28+
29+bool ctl::BreadthFirstSearch::remove(ctl::Edge *e)
30+{
31+ iterator current = W.begin();
32+ iterator end = W.end();
33+
34+ while(current != end){
35+ if((*current) == e){
36+ W.erase(current);
37+ return true;
38+ }
39+ }
40+
41+ return false;
42+}
43+
44+size_t ctl::BreadthFirstSearch::size() {return W.size();}
45+
46+bool ctl::BreadthFirstSearch::empty() {return W.empty();}
47+
48+void ctl::BreadthFirstSearch::clear(){ W.clear();}
49
50=== added file 'CTL/SearchStrategies/BreadthFirstSearch.h'
51--- CTL/SearchStrategies/BreadthFirstSearch.h 1970-01-01 00:00:00 +0000
52+++ CTL/SearchStrategies/BreadthFirstSearch.h 2016-04-10 10:18:24 +0000
53@@ -0,0 +1,28 @@
54+#ifndef BREADTHFIRSTSEARCH_H
55+#define BREADTHFIRSTSEARCH_H
56+
57+#include <deque>
58+#include "AbstractSearchStrategy.h"
59+
60+namespace ctl{
61+
62+class BreadthFirstSearch : public ctl::AbstractSearchStrategy
63+{
64+public:
65+ BreadthFirstSearch();
66+
67+ // AbstractSearchStrategy interface
68+ void push(Edge *e);
69+ void push_dependency(Edge *e);
70+ Edge *pop();
71+ bool remove(Edge *e);
72+ size_t size();
73+ bool empty();
74+ void clear();
75+
76+private:
77+ std::deque<Edge*> W; //Waiting list
78+ typedef std::deque<Edge*>::iterator iterator;
79+};
80+}
81+#endif // BREADTHFIRSTSEARCH_H
82
83=== modified file 'VerifyPN.cpp'
84--- VerifyPN.cpp 2016-04-06 12:58:00 +0000
85+++ VerifyPN.cpp 2016-04-10 10:18:24 +0000
86@@ -64,6 +64,7 @@
87
88 #include "CTL/SearchStrategies/AbstractSearchStrategy.h"
89 #include "CTL/SearchStrategies/DepthFirstSearch.h"
90+#include "CTL/SearchStrategies/BreadthFirstSearch.h"
91
92 using namespace std;
93 using namespace PetriEngine;
94@@ -170,6 +171,9 @@
95 if(t_strategy == DFS){
96 strategy = new ctl::DepthFirstSearch();
97 }
98+ else if (t_strategy == BFS){
99+ strategy = new ctl::BreadthFirstSearch();
100+ }
101 else{
102 fprintf(stderr, "Error: unsupported ctl search strategy");
103 exit(EXIT_FAILURE);
104@@ -420,9 +424,9 @@
105 // the default search strategy for CTL logic is DFS
106 searchstrategy = DFS;
107 }
108- if (isCTLlogic && searchstrategy != DFS) {
109- // for CTL logic only DFS strategy is supported
110- fprintf(stderr, "Only DFS search strategy may be used with CTL logic.\n\n");
111+ if (isCTLlogic && (searchstrategy != DFS && searchstrategy != BFS)) {
112+ // for CTL logic only DFS and BFS strategy is supported
113+ fprintf(stderr, "Only DFS and BFS search strategy may be used with CTL logic.\n\n");
114 return ErrorCode;
115 }
116

Subscribers

People subscribed via source and target branches