aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/crossingScenario/queries/crossingScenarioQueries.vql
diff options
context:
space:
mode:
authorLibravatar Aren Babikian <aren.babikian@mail.mcgill.ca>2021-01-24 03:20:04 +0100
committerLibravatar Aren Babikian <aren.babikian@mail.mcgill.ca>2021-01-24 03:20:04 +0100
commitafa54bfd0d14cdcc53abe95aef27fe96a447d770 (patch)
tree1ed37a9d7dd224182181fb36bfa96ad10ef605a7 /Domains/crossingScenario/queries/crossingScenarioQueries.vql
parentFix bug for ignored-attributes + better logic problem creation (diff)
downloadVIATRA-Generator-afa54bfd0d14cdcc53abe95aef27fe96a447d770.tar.gz
VIATRA-Generator-afa54bfd0d14cdcc53abe95aef27fe96a447d770.tar.zst
VIATRA-Generator-afa54bfd0d14cdcc53abe95aef27fe96a447d770.zip
Simple working version. Still diversity issue
Diffstat (limited to 'Domains/crossingScenario/queries/crossingScenarioQueries.vql')
-rw-r--r--Domains/crossingScenario/queries/crossingScenarioQueries.vql325
1 files changed, 41 insertions, 284 deletions
diff --git a/Domains/crossingScenario/queries/crossingScenarioQueries.vql b/Domains/crossingScenario/queries/crossingScenarioQueries.vql
index c009e031..a26782ae 100644
--- a/Domains/crossingScenario/queries/crossingScenarioQueries.vql
+++ b/Domains/crossingScenario/queries/crossingScenarioQueries.vql
@@ -3,180 +3,6 @@ package queries
3import "http://www.example.com/crossingScenario" 3import "http://www.example.com/crossingScenario"
4import "http://www.eclipse.org/emf/2002/Ecore" 4import "http://www.eclipse.org/emf/2002/Ecore"
5 5
6//////Minimal Failing Example
7//@Constraint(severity = "error", key = {l}, message = "this defines the placedOn relation")
8//pattern patterThatOnlyWorksWithInt(l : Lane) {
9// Lane.referenceCoord(l, w);
10// check(w <= 0-10.0);
11//}
12
13//////////////
14//CrossingScenario
15/////////////
16
17/*
18//TODO Hard-code xSize?
19//TODO Hard-code ySize?
20
21//TODO Hard-code maxTime?
22@Constraint(severity="error", key={l}, message="3 CrossingScenari")
23pattern define_cs_maxTime(cs:CrossingScenario) {
24 CrossingScenario.maxTime(cs, mt);
25 check(mt != 60.0);
26}
27*/
28
29///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
30//Lane
31///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
32/*
33
34////<<<<OLD>>>>
35////Width: Different Lanes
36//@Constraint(severity="error", key={l}, message="1 Lane")
37//pattern define_numWidth_small(l : Lane) {
38// Lane.width(l, Size::S_Small);
39// Lane.numWidth(l, nw);
40// check(nw <= 5.0);
41//} or {
42// Lane.width(l, Size::S_Small);
43// Lane.numWidth(l, nw);
44// check(nw >= 10.0);
45//}
46//
47//@Constraint(severity="error", key={l}, message="2 Lane")
48//pattern define_numWidth_medium(l : Lane) {
49// Lane.width(l, ::S_Med);
50// Lane.numWidth(l, nw);
51// check(nw <= 10.0);
52//}
53//or {
54// Lane.width(l, Size::S_Med);
55// Lane.numWidth(l, nw);
56// check(nw >= 15.0);
57//}
58//
59//@Constraint(severity="error", key={l}, message="3 Lane")
60//pattern define_numWidth_large(l : Lane) {
61// Lane.width(l, Size::S_Large);
62// Lane.numWidth(l, nw);
63// check(nw <= 15.0);
64//}
65//or {
66// Lane.width(l, Size::S_Large);
67// Lane.numWidth(l, nw);
68// check(nw >= 20.0);
69//}
70
71//<<<<NEW>>>>
72//Width is FIXED: always 5
73
74/////////////Prevlane
75
76////<<<<OLD>>>>
77////Generating 2 linkedlists (1 for horizontal, 1 for vertical lanes)
78//////////head lanes do not have prevLane
79//@Constraint(severity="error", key={l}, message="6.1 Lane")
80//pattern define_prevLane_headVertLaneDoesNotHavePrevLane(cs:CrossingScenario, l:Lane_Vertical) {
81// CrossingScenario.vertical_head(cs, l);
82// Lane.prevLane(l, _);
83//}
84//
85//@Constraint(severity="error", key={l}, message="6.2 Lane")
86//pattern define_prevLane_headHoriLaneDoesNotHavePrevLane(cs:CrossingScenario, l:Lane_Horizontal) {
87// CrossingScenario.horizontal_head(cs, l);
88// Lane.prevLane(l, _);
89//}
90//
91//////////Non-head lanes must have prevLane
92//@Constraint(severity="error", key={l}, message="6.1 Lane")
93//pattern define_prevLane_nonheadVertLaneHasPrevLane(l:Lane_Vertical) {
94// neg find find_headVertLane(l);
95// neg find find_laneWithPrevLane(l);
96//}
97//
98//@Constraint(severity="error", key={l}, message="6.1 Lane")
99//pattern define_prevLane_nonheadHoriLaneHasPrevLane(l:Lane_Horizontal) {
100// neg find find_headHoriLane(l);
101// neg find find_laneWithPrevLane(l);
102//}
103//
104//private pattern find_headVertLane(l:Lane_Vertical) {
105// CrossingScenario.vertical_head(_, l);
106//}
107//private pattern find_headHoriLane(l:Lane_Horizontal) {
108// CrossingScenario.horizontal_head(_, l);
109//}
110//private pattern find_laneWithPrevLane(l:Lane) {
111// Lane.prevLane(l, _);
112//}
113//
114///////////Lane cannot be its own recursive prevLane
115//@Constraint(severity="error", key={l}, message="6.1 Lane")
116//pattern define_prevLane_lanecannotBeItsOwnPrevLane(l:Lane) {
117// Lane.prevLane(l, l);
118//}
119//
120//@Constraint(severity="error", key={l}, message="6.2 Lane")
121//pattern define_prevLane_lanecannotBeItsOwnRecursivePrevLane(l:Lane) {
122// find find_prevLane+(l, l);
123//}
124//private pattern find_prevLane(l1:Lane, l2:Lane) {
125// Lane.prevLane(l1, l2);
126//}
127//
128////////Lane cannot be prevLane of >1 other lane
129//@Constraint(severity="error", key={l1, l2}, message="7 Lane")
130//pattern define_prevLane_lanecannotbeprevLaneof2lanes(l1:Lane, l2:Lane) {
131// Lane.prevLane(l1, l);
132// Lane.prevLane(l2, l);
133// l1 != l2;
134//}
135//
136////////consecutive lanes must have same orientation
137//@Constraint(severity="error", key={l1, l2}, message="8 Lane")
138//pattern define_prevLane_consecutiveLanesMustHaveSameOrientation1(l1:Lane_Horizontal, l2:Lane_Vertical) {
139// Lane.prevLane(l1, l2);
140//}
141//
142//@Constraint(severity="error", key={l1, l2}, message="8 Lane")
143//pattern define_prevLane_consecutiveLanesMustHaveSameOrientation2(l1:Lane_Vertical, l2:Lane_Horizontal) {
144// Lane.prevLane(l1, l2);
145//}
146//
147///////////////ReferenceCoord
148//
149///////refCoord of head lanes must be 0
150//@Constraint(severity="error", key={l}, message="6.2 Lane")
151//pattern define_prevLane_headHoriLaneHas0RefCoord(cs:CrossingScenario, l:Lane_Horizontal) {
152// CrossingScenario.horizontal_head(cs, l);
153// Lane.referenceCoord(l, rc);
154// check(rc != 0.0);
155//}
156//
157//@Constraint(severity="error", key={l}, message="6.2 Lane")
158//pattern define_prevLane_headVertLaneHas0RefCoord(cs:CrossingScenario, l:Lane_Vertical) {
159// CrossingScenario.vertical_head(cs, l);
160// Lane.referenceCoord(l, rc);
161// check(rc != 0.0);
162//}
163//
164////////refCoord of a lane is prevLane.rc + curLane.numWidth
165//
166//@Constraint(severity="error", key={l}, message="6.2 Lane")
167//pattern define_referenceCoord_laneWithPrevHasCorrectRefCoord(l:Lane) {
168// Lane.prevLane(l, prev);
169// Lane.referenceCoord(l, rcCur);
170//
171// Lane.numWidth(prev, wPrev);
172// Lane.referenceCoord(prev, rcPrev);
173// check(rcCur != rcPrev + wPrev);
174//}
175
176//<<<<NEW>>>>
177//Lanes are all predefind
178*/
179
180///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*////// 6///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
181//Lane+Actor 7//Lane+Actor
182///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*////// 8///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
@@ -430,12 +256,12 @@ private pattern helper_actorsAreFar(a1: Actor, a2: Actor) {
430//Relation 256//Relation
431///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*////// 257///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
432 258
433@Constraint(severity="error", key={a1, a2}, message="1 Relation") 259//@Constraint(severity="error", key={a1, a2}, message="1 Relation")
434pattern define_relation_noSelfRelation(a1:Actor, a2:Actor) { 260//pattern define_relation_noSelfRelation(a1:Actor, a2:Actor) {
435 Relation.source(r, a1); 261// Relation.source(r, a1);
436 Relation.target(r, a2); 262// Relation.target(r, a2);
437 a1 == a2; 263// a1 == a2;
438} 264//}
439 265
440//TODO do above but transitively?/ 266//TODO do above but transitively?/
441//////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*////// 267//////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
@@ -462,7 +288,7 @@ pattern collisionExists_qualAbstr(a1:Actor, a2:Actor) {
462 Lane_Horizontal(hl2); 288 Lane_Horizontal(hl2);
463} 289}
464 290
465//<<END QUALITATIF ABSTRACTION>> 291//<<END TEMP QUALITATIF ABSTRACTION>>
466 292
467//// 293////
468//VS VisionBlocked 294//VS VisionBlocked
@@ -470,6 +296,36 @@ pattern collisionExists_qualAbstr(a1:Actor, a2:Actor) {
470//TODO Very prone to corner cases 296//TODO Very prone to corner cases
471/* 297/*
472@Constraint(severity="error", key={a1}, message="x") 298@Constraint(severity="error", key={a1}, message="x")
299pattern collisionExists_vsVisionBlockedX1(a1:Actor) {
300 VisionBlocked.blockedBy(_, a1);
301 CollisionExists.target(_, a1);
302}
303@Constraint(severity="error", key={a1}, message="x")
304pattern collisionExists_vsVisionBlockedX2(a1:Actor) {
305 VisionBlocked.blockedBy(_, a1);
306 CollisionExists.source(_, a1);
307}
308
309@Constraint(severity="error", key={a1}, message="x")
310pattern collisionExists_vsVisionBlocked1(a1:Actor) {
311 VisionBlocked.source(_, a1);
312 neg find helper_source(a1);
313}
314private pattern helper_source(a1:Actor) {
315 CollisionExists.source(_, a1);
316}
317
318@Constraint(severity="error", key={a1}, message="x")
319pattern collisionExists_vsVisionBlocked2(a1:Actor) {
320 VisionBlocked.target(_, a1);
321 neg find helper_target(a1);
322}
323private pattern helper_target(a1:Actor) {
324 CollisionExists.target(_, a1);
325}
326*/
327/*
328@Constraint(severity="error", key={a1}, message="x")
473pattern collisionExists_vsVisionBlocked(a1:Actor) { 329pattern collisionExists_vsVisionBlocked(a1:Actor) {
474 VisionBlocked.source(vb, a1); 330 VisionBlocked.source(vb, a1);
475 VisionBlocked.target(vb, a2); 331 VisionBlocked.target(vb, a2);
@@ -610,7 +466,7 @@ pattern collisionExists_defineCollision_x2(a1:Actor, a2:Actor) {
610 466
611//<<QUALTATIF ABSTRACTION>> 467//<<QUALTATIF ABSTRACTION>>
612 468
613@Constraint(severity="error", key={a1, a2}, message="x") 469@Constraint(severity="error", key={a1, a2}, message="on 3 different lanes")
614pattern visionBlocked_qualAbstr(a1:Actor, a2:Actor) { 470pattern visionBlocked_qualAbstr(a1:Actor, a2:Actor) {
615 VisionBlocked.source(vb, a1); 471 VisionBlocked.source(vb, a1);
616 VisionBlocked.target(vb, a2); 472 VisionBlocked.target(vb, a2);
@@ -628,7 +484,7 @@ pattern visionBlocked_qualAbstr(a1:Actor, a2:Actor) {
628 Actor.placedOn(a2, l); 484 Actor.placedOn(a2, l);
629} 485}
630 486
631@Constraint(severity="error", key={a1, a2}, message="x") 487@Constraint(severity="error", key={a1, a2}, message="on lanes with different orientation")
632pattern visionBlocked_qualAbstr2(a1:Actor, a2:Actor) { 488pattern visionBlocked_qualAbstr2(a1:Actor, a2:Actor) {
633 VisionBlocked.source(ce, a1); 489 VisionBlocked.source(ce, a1);
634 VisionBlocked.target(ce, a2); 490 VisionBlocked.target(ce, a2);
@@ -734,6 +590,7 @@ pattern visionBlocked_xdistBSlargerThanxdistTS(a1:Actor, a2:Actor, vb:VisionBloc
734 590
735 //check(slope of a1-to-BlockerBottom > slope of a1-to-a2) 591 //check(slope of a1-to-BlockerBottom > slope of a1-to-a2)
736 //TODO implement ABSOLUTE VALUE or MULTI-CHECK 592 //TODO implement ABSOLUTE VALUE or MULTI-CHECK
593 //TODO do pythagoras
737 check((x1-xBlocker)*(x1-xBlocker) > (x1-x2)*(x1-x2)); 594 check((x1-xBlocker)*(x1-xBlocker) > (x1-x2)*(x1-x2));
738} 595}
739 596
@@ -752,110 +609,10 @@ pattern visionBlocked_xdistBTlargerThanxdistST(a1:Actor, a2:Actor, vb:VisionBloc
752 609
753 //check(slope of a1-to-BlockerBottom > slope of a1-to-a2) 610 //check(slope of a1-to-BlockerBottom > slope of a1-to-a2)
754 //TODO implement ABSOLUTE VALUE or MULTI-CHECK 611 //TODO implement ABSOLUTE VALUE or MULTI-CHECK
612 //TODO do pythagoras
755 check((x1-xBlocker)*(x1-xBlocker) > (x1-x2)*(x1-x2)); 613 check((x1-xBlocker)*(x1-xBlocker) > (x1-x2)*(x1-x2));
756} 614}
757 615
758//TODO same as above for Y??? 616//TODO same as above for Y???
759//TODO same as above for Y ???? 617//TODO same as above for Y ????
760 618
761/////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
762//SeparationDistance
763/////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
764/*
765private pattern helper_getSeperateActorsCoords(a1:Actor,
766 a2: Actor, sd:SeparationDistance,
767 x1:java Double, x2:java Double, y1:java Double, y2:java Double) {
768 SeperationDistance.source(sd, a1);
769 SeparationDistance.target(sd, a2);
770
771 find helper_getCoords(a1, a2, x1, x2, y1, y2);
772}
773
774@Constraint(severity="error", key={a1, sd}, message="x")
775pattern SeparationDistance_near_lb(a1:Actor, a2:Actor, sd:SeparationDistance) {
776 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
777
778 find helper_getSeparateActorsCoords(a1, a2, sd, x1, x2, y1, y2);
779 SeparationDistance.distance(sd, Distance::D_Near);
780
781 //check(dx^2 + dy^2 < 5^2)
782 check((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < 5*5);
783}
784
785@Constraint(severity="error", key={a1, sd}, message="x")
786pattern SeparationDistance_near_ub(a1:Actor, a2:Actor, sd:SeparationDistance) {
787 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
788
789 find helper_getSeparateActorsCoords(a1, a2, sd, x1, x2, y1, y2);
790 SeparationDistance.distance(sd, Distance::D_Near);
791
792 //check(dx^2 + dy^2 > 10^2)
793 check((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) > 10*10);
794}
795
796@Constraint(severity="error", key={a1, sd}, message="x")
797pattern SeparationDistance_medium_lb(a1:Actor, a2:Actor, sd:SeparationDistance) {
798 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
799
800 find helper_getSeparateActorsCoords(a1, a2, sd, x1, x2, y1, y2);
801 SeparationDistance.distance(sd, Distance::D_Med);
802
803 //check(dx^2 + dy^2 < 10^2)
804 check((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < 10*10);
805}
806
807@Constraint(severity="error", key={a1, sd}, message="x")
808pattern SeparationDistance_medium_ub(a1:Actor, a2:Actor, sd:SeparationDistance) {
809 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
810
811 find helper_getSeparateActorsCoords(a1, a2, sd, x1, x2, y1, y2);
812 SeparationDistance.distance(sd, Distance::D_Med);
813
814 //check(dx^2 + dy^2 > 1^2)
815 check((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) > 15*15);
816}
817
818@Constraint(severity="error", key={a1, sd}, message="x")
819pattern SeparationDistance_far_lb(a1:Actor, a2:Actor, sd:SeparationDistance) {
820 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
821
822 find helper_getSeparateActorsCoords(a1, a2, sd, x1, x2, y1, y2);
823 SeparationDistance.distance(sd, Distance::D_Far);
824
825 //check(dx^2 + dy^2 < 15^2)
826 check((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < 15*15);
827}
828*/
829
830/////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
831//CollisionDoesNotExist
832/////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
833/*
834//TODO
835@Constraint(severity="error", key={a1, cdne}, message="x")
836pattern collisionDoesNotExist(a1:Actor, a2:Actor, ss:CrossingScenario, cdne:CollisionDoesNotExist) {
837 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
838
839 CrossingScenario.actors(ss, a1);
840 CrossingScenario.actors(ss, a2);
841 Actor.relations(a1, cdne);
842 CollisionDoesNotExist.target(cdne, a2);
843 CrossingScenario.maxTime(ss, maxTime);
844
845 Actor.width(a1, w1);
846 Actor.length(a1, l1);
847 Actor.xPos(a1, xPos1);
848 Actor.yPos(a1, yPos1);
849 Actor.xSpeed(a1, xSpeed1);
850 Actor.ySpeed(a1, ySpeed1);
851
852 Actor.width(a2, w2);
853 Actor.length(a2, l2);
854 Actor.xPos(a2, xPos2);
855 Actor.yPos(a2, yPos2);
856 Actor.xSpeed(a2, xSpeed2);
857 Actor.ySpeed(a2, ySpeed2);
858 //check(dx^2 + dy^2 < 15^2)
859 check((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < 15*15);
860}
861*/ \ No newline at end of file