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

Proposed by Søren Moss Nielsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 95
Merged at revision: 93
Proposed branch: lp:~tapaal-dist-ctl/verifypn/true_false_and_equal_support
Merge into: lp:~verifypn-maintainers/verifypn/trunk
Diff against target: 169 lines (+58/-19)
3 files modified
CTL/OnTheFlyDG.cpp (+13/-5)
CTLParser/CTLParser_v2.cpp (+12/-6)
CTLParser/EvaluateableProposition.cpp (+33/-8)
To merge this branch: bzr merge lp:~tapaal-dist-ctl/verifypn/true_false_and_equal_support
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+302011@code.launchpad.net

Commit message

add all binary comparison operators for the CTL query predicates

Description of the change

All operators should be supported now.
== : <integer-eq>
>= : <integer-ge>
<= : <integer-le>
<= : <integer-le>
 < : <integer-ls>
 > : <integer-gr>

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

Looks fine, there is one warning:

CTLParser/CTLParser_v2.cpp:485:1: warning: control may reach end of non-void
      function [-Wreturn-type]
}

I will merge it anyway now, but please fix the warning is a new branch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CTL/OnTheFlyDG.cpp'
--- CTL/OnTheFlyDG.cpp 2016-05-16 12:24:30 +0000
+++ CTL/OnTheFlyDG.cpp 2016-08-04 11:04:35 +0000
@@ -367,10 +367,13 @@
367367
368int OnTheFlyDG::GetParamValue(CardinalityParameter *param, Marking& marking) {368int OnTheFlyDG::GetParamValue(CardinalityParameter *param, Marking& marking) {
369 if(param->isPlace){369 if(param->isPlace){
370 bool foundplace = false;
370 int res = 0;371 int res = 0;
371 for(int place : param->places_i){372 for(int place : param->places_i){
372 res = res + marking.Value()[place];373 res = res + marking.Value()[place];
374 foundplace = true;
373 }375 }
376 assert(foundplace && "Place parameter does not contain places. Please provide valid place names in the query.");
374 return res;377 return res;
375 }378 }
376 else{379 else{
@@ -379,16 +382,21 @@
379}382}
380383
381bool OnTheFlyDG::EvalCardianlity(int a, LoperatorType lop, int b) {384bool OnTheFlyDG::EvalCardianlity(int a, LoperatorType lop, int b) {
382 if(lop == EQ)385 if(lop == EQ){
383 return a == b;386 return a == b;
384 else if (lop == LE)387 }
388 else if (lop == LE){
385 return a < b;389 return a < b;
386 else if (lop == LEQ)390 }
391 else if (lop == LEQ){
387 return a <= b;392 return a <= b;
388 else if (lop == GR)393 }
394 else if (lop == GR){
389 return a > b;395 return a > b;
390 else if (lop == GRQ)396 }
397 else if (lop == GRQ){
391 return a >= b;398 return a >= b;
399 }
392 assert(false && "Unsupported LOperator attemped evaluated");400 assert(false && "Unsupported LOperator attemped evaluated");
393}401}
394402
395403
=== modified file 'CTLParser/CTLParser_v2.cpp'
--- CTLParser/CTLParser_v2.cpp 2016-05-16 12:24:30 +0000
+++ CTLParser/CTLParser_v2.cpp 2016-08-04 11:04:35 +0000
@@ -374,13 +374,13 @@
374 return query;374 return query;
375 }375 }
376 else if (firstLetter == 't' ){376 else if (firstLetter == 't' ){
377 std::string atom_str = "integer-constant(0) le integer-constant(0)";377 std::string atom_str = "true";
378 query = new CTLQuery(EMPTY, pError, true, atom_str);378 query = new CTLQuery(EMPTY, pError, true, atom_str);
379 query->Depth = 0;379 query->Depth = 0;
380 return query;380 return query;
381 }381 }
382 else if (firstLetter == 'f' ){382 else if (firstLetter == 'f' ){
383 std::string atom_str = "integer-constant(2) le integer-constant(0)";383 std::string atom_str = "false";
384 query = new CTLQuery(EMPTY, pError, true, atom_str);384 query = new CTLQuery(EMPTY, pError, true, atom_str);
385 query->Depth = 0;385 query->Depth = 0;
386 return query;386 return query;
@@ -466,16 +466,22 @@
466}466}
467467
468std::string CTLParser_v2::loperator_sym(std::string loperator){468std::string CTLParser_v2::loperator_sym(std::string loperator){
469 if(loperator.compare("integer-le") == 0){469 if(loperator.compare("integer-le")== 0){
470 return " le ";470 return " le ";
471 }471 }
472 else if(loperator.compare("integer-ge")){472 else if(loperator.compare("integer-ge")== 0){
473 return " ge ";473 return " ge ";
474 }474 }
475 else if(loperator.compare("integer-eq")){475 else if(loperator.compare("integer-eq")== 0){
476 return " eq ";476 return " eq ";
477 }477 }
478 else return " " + loperator + " ";478 else if(loperator.compare("integer-gr")== 0){
479 return " gr ";
480 }
481 else if(loperator.compare("integer-ls")== 0){
482 return " ls ";
483 }
484 else assert(true && "Could not parse unsupported logical operator");
479}485}
480486
481CTLQuery * CTLParser_v2::CopyQuery(CTLQuery *source){487CTLQuery * CTLParser_v2::CopyQuery(CTLQuery *source){
482488
=== modified file 'CTLParser/EvaluateableProposition.cpp'
--- CTLParser/EvaluateableProposition.cpp 2016-05-16 12:24:30 +0000
+++ CTLParser/EvaluateableProposition.cpp 2016-08-04 11:04:35 +0000
@@ -30,6 +30,7 @@
30}30}
3131
32EvaluateableProposition::EvaluateableProposition(std::string a, PetriEngine::PetriNet *net) {32EvaluateableProposition::EvaluateableProposition(std::string a, PetriEngine::PetriNet *net) {
33 std::cout<<a<<std::endl;
33 if(a.substr(0,2).compare("in") == 0 || a.substr(0,2).compare("to") == 0){34 if(a.substr(0,2).compare("in") == 0 || a.substr(0,2).compare("to") == 0){
34 _type = CARDINALITY;35 _type = CARDINALITY;
35 _loperator = SetLoperator(a);36 _loperator = SetLoperator(a);
@@ -57,10 +58,30 @@
57 SetFireset(fireset_str, net->transitionNames(), net->numberOfTransitions());58 SetFireset(fireset_str, net->transitionNames(), net->numberOfTransitions());
58 }59 }
59 else if(a.substr(0,2).compare("tr") == 0){60 else if(a.substr(0,2).compare("tr") == 0){
60 61 _type = CARDINALITY;
62 _loperator = EQ;
63
64 _firstParameter = new CardinalityParameter();
65 _secondParameter = new CardinalityParameter();
66
67 _firstParameter->isPlace = false;
68 _firstParameter->value = 0;
69
70 _secondParameter->isPlace = false;
71 _secondParameter->value = 0;
61 }72 }
62 else if(a.substr(0,2).compare("fa") == 0){73 else if(a.substr(0,2).compare("fa") == 0){
63 74 _type = CARDINALITY;
75 _loperator = EQ;
76
77 _firstParameter = new CardinalityParameter();
78 _secondParameter = new CardinalityParameter();
79
80 _firstParameter->isPlace = false;
81 _firstParameter->value = 0;
82
83 _secondParameter->isPlace = false;
84 _secondParameter->value = 1;
64 }85 }
65 else{86 else{
66 assert(false && "Atomic string proposed for proposition could not be parsed");87 assert(false && "Atomic string proposed for proposition could not be parsed");
@@ -140,14 +161,18 @@
140}161}
141162
142LoperatorType EvaluateableProposition::SetLoperator(std::string atom_str){163LoperatorType EvaluateableProposition::SetLoperator(std::string atom_str){
143 std::string loperator_str = atom_str.substr(atom_str.find(')'));164 std::string loperator_str = atom_str.substr(atom_str.find(')') + 1);
144 loperator_str = loperator_str.substr(0, loperator_str.find('('));165 loperator_str = loperator_str.substr(0, 4);
145 if(loperator_str.compare(" le "))166 if(loperator_str.compare(" le ")== 0)
146 return LEQ;167 return LEQ;
147 else if (loperator_str.compare(" ge "))168 else if (loperator_str.compare(" ge ")== 0)
148 return GRQ;169 return GRQ;
149 else if (loperator_str.compare(" eq "))170 else if (loperator_str.compare(" eq ")== 0)
150 return EQ;171 return EQ;
172 else if (loperator_str.compare(" gr ")== 0)
173 return GR;
174 else if (loperator_str.compare(" ls ")== 0)
175 return LE;
151 else assert(false && "Could not parse the given logical operator");176 else assert(false && "Could not parse the given logical operator");
152}177}
153178
@@ -166,7 +191,7 @@
166 else191 else
167 cardi_str = cardi_str = patch::to_string(_firstParameter->value);192 cardi_str = cardi_str = patch::to_string(_firstParameter->value);
168 193
169 cardi_str = cardi_str + " le ";194 cardi_str = cardi_str + " loperator ";
170 195
171 if(_secondParameter->isPlace)196 if(_secondParameter->isPlace)
172 cardi_str = cardi_str + "place(" + patch::to_string(_secondParameter->value) + ")";197 cardi_str = cardi_str + "place(" + patch::to_string(_secondParameter->value) + ")";

Subscribers

People subscribed via source and target branches