-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.gipsl
110 lines (90 loc) · 2.73 KB
/
Model.gipsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import "platform:/resource/gips.sort.listmodel/model/Listmodel.ecore"
config {
solver := GUROBI [home:="fu", license:="bar"];
launchConfig := true [main := "TODO"];
timeLimit := true [value := 42.0];
randomSeed := true [value := 73];
presolve := true;
debugOutput := true;
}
rule sortOne {
root: Root {
-entries -> valA
-entries -> valB
}
valA: Entry {
++ -next -> valB
}
valB: Entry
# valA.^value <= valB.^value
}
rule sortLast {
root: Root {
-entries -> val
}
val: Entry {
++ -next -> val
}
}
// TODO: This is just a workaround; normally, this should be a pattern
rule findFirst {
root: Root {
-entries -> valB
}
valB: Entry {
.^value := -1
}
}
when noPredecessor
condition noPredecessor = forbid findPredecessor
pattern findPredecessor {
root: Root {
-entries -> valA
-entries -> valB
}
valA: Entry
valB: Entry
# valA.^value <= valB.^value
}
//rule sortFirst () {
// root: Root {
// -entries -> val
// ++ -first -> val
// }
//
// val: Entry
//}
//when entryIsSmallest
//condition entryIsSmallest = forbid entryNotSmallest
//pattern entryNotSmallest {
// valA: Entry
// valB: Entry
//
// # valA.^value > valB.^value
//}
mapping e2e with sortOne;
mapping e2self with sortLast;
mapping eFirst with findFirst;
constraint -> class::Entry {
mappings.e2e->filter(m | m.nodes().valA == self)->count() + mappings.e2self->filter(m | m.nodes().val == self)->count() == 1
// mappings.e2e->filter(m | m.nodes().valA == self)->count() == 1
}
constraint -> global {
mappings.e2self->count() == 1
}
// TODO: ^ this constraint does generate A WRONG ILP CONSTRAINT: "GlobalConstraint0_0: + e2self#1 + e2e#0 = 1" (only in GLPK? WTF???)
//constraint -> class::Root {
// mappings.e2self->count() == 1 + (self.entries->count() - self.entries->count())
// // ^ workaround (at the end) until validation of global constraints is fixed
//}
//constraint -> class::Entry {
// mappings.e2e->filter(m | m.nodes().valB == self)->count() + mappings.e2self->filter(m | m.nodes().val == self)->count() == 1
//}
constraint -> global {
mappings.e2e->count() == classes.Entry->count() - 1
}
constraint -> class::Entry {
// mappings.e2e->filter(m | m.nodes().valB == self)->count() + mappings.e2self->filter(m | m.nodes().val == self)->count() == 1
// mappings.eFirst->filter(m | m.nodes().valB == self)->count() + mappings.e2e->filter(m | m.nodes().valB == self)->count() + mappings.e2self->filter(m | m.nodes().val == self)->count() == 1
patterns.findFirst->filter(m | m.nodes().valB == self)->count() + mappings.e2e->filter(m | m.nodes().valB == self)->count() + mappings.e2self->filter(m | m.nodes().val == self)->count() == 1
}