Merge lp:~verifypn-stub/verifypn/always_compile into lp:verifypn

Proposed by Peter Gjøl Jensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 204
Merged at revision: 197
Proposed branch: lp:~verifypn-stub/verifypn/always_compile
Merge into: lp:verifypn
Diff against target: 213 lines (+68/-55)
5 files modified
CTL/PetriNets/OnTheFlyDG.cpp (+1/-3)
PetriEngine/PQL/Expressions.cpp (+5/-1)
PetriEngine/PQL/Expressions.h (+3/-2)
PetriEngine/Reducer.cpp (+1/-1)
VerifyPN.cpp (+58/-48)
To merge this branch: bzr merge lp:~verifypn-stub/verifypn/always_compile
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+336451@code.launchpad.net

Description of the change

Added forced compilation via negationPush.
Without this, the dummy FireabilityConditions are not compiled into conjunctions over the places.

To post a comment you must log in.
199. By Peter Gjøl Jensen

fixed bug in conjunction compilation

200. By Peter Gjøl Jensen

fixed conflicting flag detection

201. By Peter Gjøl Jensen

using return flags

202. By Peter Gjøl Jensen

removed debug

203. By Peter Gjøl Jensen

removed un-needed check

204. By Peter Gjøl Jensen

added error message

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=== modified file 'CTL/PetriNets/OnTheFlyDG.cpp'
2--- CTL/PetriNets/OnTheFlyDG.cpp 2018-01-04 10:18:59 +0000
3+++ CTL/PetriNets/OnTheFlyDG.cpp 2018-01-23 19:36:42 +0000
4@@ -519,9 +519,7 @@
5 working_marking.setMarking(nullptr);
6 query_marking.setMarking(nullptr);
7 initialConfiguration();
8- negstat_t s;
9- EvaluationContext context(working_marking.marking(), net);
10- this->query = query->pushNegation(s, context, false, false); // make sure that EG and AG is pushed
11+ this->query = query;
12 delete[] working_marking.marking();
13 delete[] query_marking.marking();
14 working_marking.setMarking(nullptr);
15
16=== modified file 'PetriEngine/PQL/Expressions.cpp'
17--- PetriEngine/PQL/Expressions.cpp 2018-01-04 10:06:58 +0000
18+++ PetriEngine/PQL/Expressions.cpp 2018-01-23 19:36:42 +0000
19@@ -94,7 +94,11 @@
20 if(conj->isNegated() == std::is_same<T, OrCondition>::value)
21 _conds.insert(_conds.begin(), conj);
22 else
23- _conds.insert(_conds.begin(), std::make_shared<CompareConjunction>(*conj, true));
24+ {
25+ auto next = std::make_shared<CompareConjunction>(std::is_same<T, OrCondition>::value);
26+ next->merge(*conj);
27+ _conds.insert(_conds.begin(), next);
28+ }
29 }
30 }
31 else
32
33=== modified file 'PetriEngine/PQL/Expressions.h'
34--- PetriEngine/PQL/Expressions.h 2017-12-13 14:19:34 +0000
35+++ PetriEngine/PQL/Expressions.h 2018-01-23 19:36:42 +0000
36@@ -587,9 +587,10 @@
37 }
38 };
39
40- CompareConjunction()
41- {};
42+
43 public:
44+ CompareConjunction(bool negated = false)
45+ : _negated(false) {};
46 friend FireableCondition;
47 CompareConjunction(const std::vector<cons_t>&& cons, bool negated)
48 : _constraints(cons), _negated(negated) {};
49
50=== modified file 'PetriEngine/Reducer.cpp'
51--- PetriEngine/Reducer.cpp 2017-12-13 15:38:15 +0000
52+++ PetriEngine/Reducer.cpp 2018-01-23 19:36:42 +0000
53@@ -251,7 +251,7 @@
54
55 // A3. We have weight of more than one on input
56 // and is empty on output (should not happen).
57- if(trans.pre[0].weight != 1 || trans.post[0].weight < 1) continue;
58+ if(trans.pre[0].weight != 1) continue;
59
60 // A4. Do inhibitor check, neither T, pPre or pPost can be involved with any inhibitor
61 if(parent->_places[pPre].inhib|| trans.inhib) continue;
62
63=== modified file 'VerifyPN.cpp'
64--- VerifyPN.cpp 2018-01-13 20:49:50 +0000
65+++ VerifyPN.cpp 2018-01-23 19:36:42 +0000
66@@ -551,21 +551,24 @@
67 ResultPrinter p2(&b2, &options, querynames);
68
69 if(queries.size() == 0 || contextAnalysis(b2, qnet.get(), queries) != ContinueCode) return ErrorCode;
70-
71- if (options.queryReductionTimeout > 0) {
72+
73+ if (options.strategy == PetriEngine::Reachability::OverApprox && options.queryReductionTimeout == 0)
74+ {
75+ // Conflicting flags "-s OverApprox" and "-q 0"
76+ std::cerr << "Conflicting flags '-s OverApprox' and '-q 0'" << std::endl;
77+ return ErrorCode;
78+ }
79+
80+ // simplification. We always want to do negation-push and initial marking check.
81+ {
82 LPCache cache;
83 for(size_t i = 0; i < queries.size(); ++i)
84 {
85 if (queries[i]->isUpperBound()) continue;
86
87- SimplificationContext simplificationContext(qm0, qnet.get(), options.queryReductionTimeout,
88- options.lpsolveTimeout, &cache);
89- bool isInvariant = queries[i].get()->isInvariant();
90-
91- int preSize=queries[i]->formulaSize();
92 negstat_t stats;
93 EvaluationContext context(qm0, qnet.get());
94- if(options.printstatistics)
95+ if(options.printstatistics && options.queryReductionTimeout > 0)
96 {
97 std::cout << "\nQuery before reduction: ";
98 queries[i]->toString(std::cout);
99@@ -577,53 +580,60 @@
100
101 queries[i] = Condition::initialMarkingRW([&](){ return queries[i]; }, stats, context, false, false)
102 ->pushNegation(stats, context, false, false);
103-
104- if(options.printstatistics)
105+
106+ if(options.queryReductionTimeout > 0)
107 {
108- std::cout << "RWSTATS PRE:";
109- stats.print(std::cout);
110- std::cout << std::endl;
111- }
112-
113- try {
114- negstat_t stats;
115- queries[i] = (queries[i]->simplify(simplificationContext)).formula->pushNegation(stats, context, false, false);
116+ SimplificationContext simplificationContext(qm0, qnet.get(), options.queryReductionTimeout,
117+ options.lpsolveTimeout, &cache);
118+ bool isInvariant = queries[i].get()->isInvariant();
119+
120+ int preSize=queries[i]->formulaSize();
121+
122 if(options.printstatistics)
123 {
124- std::cout << "RWSTATS POST:";
125+ std::cout << "RWSTATS PRE:";
126 stats.print(std::cout);
127 std::cout << std::endl;
128 }
129- queries[i].get()->setInvariant(isInvariant);
130- } catch (std::bad_alloc& ba){
131- std::cerr << "Query reduction failed." << std::endl;
132- std::cerr << "Exception information: " << ba.what() << std::endl;
133-
134- delete[] qm0;
135- std::exit(3);
136- }
137-
138- if(options.printstatistics)
139- {
140- std::cout << "\nQuery after reduction: ";
141- queries[i]->toString(std::cout);
142- std::cout << std::endl;
143- }
144- if(options.printstatistics){
145- int postSize=queries[i]->formulaSize();
146- double redPerc = preSize-postSize == 0 ? 0 : ((double)(preSize-postSize)/(double)preSize)*100;
147-
148- fprintf(stdout, "Query size reduced from %d to %d nodes (%.2f percent reduction).\n", preSize, postSize, redPerc);
149- if(simplificationContext.timeout()){
150- fprintf(stdout, "Query reduction reached timeout.\n");
151- } else {
152- fprintf(stdout, "Query reduction finished after %f seconds.\n", simplificationContext.getReductionTime());
153+
154+ try {
155+ negstat_t stats;
156+ queries[i] = (queries[i]->simplify(simplificationContext)).formula->pushNegation(stats, context, false, false);
157+ if(options.printstatistics)
158+ {
159+ std::cout << "RWSTATS POST:";
160+ stats.print(std::cout);
161+ std::cout << std::endl;
162+ }
163+ queries[i].get()->setInvariant(isInvariant);
164+ } catch (std::bad_alloc& ba){
165+ std::cerr << "Query reduction failed." << std::endl;
166+ std::cerr << "Exception information: " << ba.what() << std::endl;
167+
168+ delete[] qm0;
169+ std::exit(3);
170+ }
171+
172+ if(options.printstatistics)
173+ {
174+ std::cout << "\nQuery after reduction: ";
175+ queries[i]->toString(std::cout);
176+ std::cout << std::endl;
177+ }
178+ if(options.printstatistics){
179+ int postSize=queries[i]->formulaSize();
180+ double redPerc = preSize-postSize == 0 ? 0 : ((double)(preSize-postSize)/(double)preSize)*100;
181+
182+ fprintf(stdout, "Query size reduced from %d to %d nodes (%.2f percent reduction).\n", preSize, postSize, redPerc);
183+ if(simplificationContext.timeout()){
184+ fprintf(stdout, "Query reduction reached timeout.\n");
185+ } else {
186+ fprintf(stdout, "Query reduction finished after %f seconds.\n", simplificationContext.getReductionTime());
187+ }
188 }
189 }
190 }
191- } else if (options.strategy == PetriEngine::Reachability::OverApprox){ // Conflicting flags "-s OverApprox" and "-q 0"
192- return 0;
193- }
194+ }
195
196 qnet = nullptr;
197 delete[] qm0;
198@@ -737,7 +747,7 @@
199 }
200
201 if (std::find(results.begin(), results.end(), ResultPrinter::Unknown) == results.end()) {
202- return 0;
203+ return SuccessCode;
204 }
205 }
206
207@@ -760,6 +770,6 @@
208 options.printstatistics,
209 options.trace);
210
211- return 0;
212+ return SuccessCode;
213 }
214

Subscribers

People subscribed via source and target branches