diff options
author | Oszkar Semerath <semerath@mit.bme.hu> | 2020-05-10 20:13:33 +0200 |
---|---|---|
committer | Oszkar Semerath <semerath@mit.bme.hu> | 2020-05-10 20:13:33 +0200 |
commit | 021a46f4feb6503effb612ce154d3568c3d64b4f (patch) | |
tree | fcf6ddf76d1fc346e7c7d5d40c75304b463ec284 /Tests | |
parent | measurement time statistics + activation selection strategies (diff) | |
parent | Adjust PLEDEG Java Case Study file (diff) | |
download | VIATRA-Generator-021a46f4feb6503effb612ce154d3568c3d64b4f.tar.gz VIATRA-Generator-021a46f4feb6503effb612ce154d3568c3d64b4f.tar.zst VIATRA-Generator-021a46f4feb6503effb612ce154d3568c3d64b4f.zip |
Merge branch 'master' of https://github.com/viatra/VIATRA-Generator
Diffstat (limited to 'Tests')
12 files changed, 1284 insertions, 491 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/.gitignore b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/.gitignore index 3d70f0da..07e30191 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/.gitignore +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/.gitignore | |||
@@ -1,2 +1 @@ | |||
1 | /queries/ | ||
2 | /run/ | /run/ | |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/.gitignore b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/.gitignore new file mode 100644 index 00000000..527f3a0e --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/.gitignore | |||
@@ -0,0 +1,112 @@ | |||
1 | /.Inv17.java._trace | ||
2 | /.Inv20.java._trace | ||
3 | /.Inv33_con.java._trace | ||
4 | /.Inv34.java._trace | ||
5 | /.Inv35.java._trace | ||
6 | /.Inv47.java._trace | ||
7 | /.Inv48.java._trace | ||
8 | /.Inv48_helper.java._trace | ||
9 | /.Case_study_A.java._trace | ||
10 | /.Inv49.java._trace | ||
11 | /.Inv49_con.java._trace | ||
12 | /.Inv49_helper.java._trace | ||
13 | /.H_inv49.java._trace | ||
14 | /.Ocl_inv49.java._trace | ||
15 | /.Vql_inv49.java._trace | ||
16 | /.Vql_inv492.java._trace | ||
17 | /.H1_inv48.java._trace | ||
18 | /.H2_inv48.java._trace | ||
19 | /.Vql_inv48.java._trace | ||
20 | /.H3_inv48.java._trace | ||
21 | /.H1_inv49.java._trace | ||
22 | /.H2_inv49.java._trace | ||
23 | /.H_inv47.java._trace | ||
24 | /.Inv35test.java._trace | ||
25 | /.Inv33.java._trace | ||
26 | /.X.java._trace | ||
27 | /.H_inv16_moreThan1.java._trace | ||
28 | /.H_inv48_1.java._trace | ||
29 | /.H_inv48_2.java._trace | ||
30 | /.H_inv48_3.java._trace | ||
31 | /.H_inv49_1.java._trace | ||
32 | /.H_inv49_2.java._trace | ||
33 | /.Inv16.java._trace | ||
34 | /.Inv15.java._trace | ||
35 | /.H_inv13.java._trace | ||
36 | /.Inv13.java._trace | ||
37 | /.Inv12.java._trace | ||
38 | /.H_inv12_notNonRes.java._trace | ||
39 | /.H_inv12_notZZ.java._trace | ||
40 | /.H_inv11_incOver100.java._trace | ||
41 | /.Inv11.java._trace | ||
42 | /.H_inv11_incNotOver100.java._trace | ||
43 | /.H_inv8_notEI.java._trace | ||
44 | /.Inv8.java._trace | ||
45 | /.H_inv08_notEI.java._trace | ||
46 | /.Inv08.java._trace | ||
47 | /.H_inv08_inRange.java._trace | ||
48 | /.X_inv08_inRange.java._trace | ||
49 | /.X_inv08_notEI.java._trace | ||
50 | /.X_inv11_incNotOver100.java._trace | ||
51 | /.X_inv11_incOver100.java._trace | ||
52 | /.X_inv12_notNonRes.java._trace | ||
53 | /.X_inv12_notZZ.java._trace | ||
54 | /.X_inv13.java._trace | ||
55 | /.X_inv47.java._trace | ||
56 | /.X_inv48_1.java._trace | ||
57 | /.X_inv48_2.java._trace | ||
58 | /.X_inv48_3.java._trace | ||
59 | /.X_inv49_1.java._trace | ||
60 | /.X_inv49_2.java._trace | ||
61 | /.X_inv48_Dis.java._trace | ||
62 | /.X_inv48_notDis.java._trace | ||
63 | /.X_inv08_noType.java._trace | ||
64 | /.X_inv08_invalidType.java._trace | ||
65 | /.Inv06.java._trace | ||
66 | /.X_inv06_inRange.java._trace | ||
67 | /.Inv05.java._trace | ||
68 | /.X_inv05_inRange.java._trace | ||
69 | /.Inv03.java._trace | ||
70 | /.X_inv03_noAll.java._trace | ||
71 | /.X_inv03_eligAll.java._trace | ||
72 | /.X_inv03_hasAll.java._trace | ||
73 | /.Inv07.java._trace | ||
74 | /.Inv10.java._trace | ||
75 | /.X_inv15.java._trace | ||
76 | /Inv03.java | ||
77 | /Inv05.java | ||
78 | /Inv06.java | ||
79 | /X_inv03_eligAll.java | ||
80 | /X_inv03_hasAll.java | ||
81 | /X_inv05_inRange.java | ||
82 | /Case_study_A.java | ||
83 | /Inv07.java | ||
84 | /Inv08.java | ||
85 | /Inv10.java | ||
86 | /Inv11.java | ||
87 | /Inv12.java | ||
88 | /Inv13.java | ||
89 | /Inv15.java | ||
90 | /Inv17.java | ||
91 | /Inv20.java | ||
92 | /Inv33.java | ||
93 | /Inv34.java | ||
94 | /Inv35.java | ||
95 | /Inv47.java | ||
96 | /Inv48.java | ||
97 | /Inv49.java | ||
98 | /X_inv08_inRange.java | ||
99 | /X_inv08_noType.java | ||
100 | /X_inv08_notEI.java | ||
101 | /X_inv11_incNotOver100.java | ||
102 | /X_inv11_incOver100.java | ||
103 | /X_inv12_notNonRes.java | ||
104 | /X_inv12_notZZ.java | ||
105 | /X_inv13.java | ||
106 | /X_inv15.java | ||
107 | /X_inv47.java | ||
108 | /X_inv48_3.java | ||
109 | /X_inv48_Dis.java | ||
110 | /X_inv48_notDis.java | ||
111 | /X_inv49_1.java | ||
112 | /X_inv49_2.java | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/NewOCLFileX.ocl b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/NewOCLFileX.ocl new file mode 100644 index 00000000..66ae728e --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/NewOCLFileX.ocl | |||
@@ -0,0 +1,45 @@ | |||
1 | import 'file:/Users/Aren Babikian/git/VIATRA-Attributes/case.study.a.model/model/Taxation.ecore' | ||
2 | |||
3 | package Taxation | ||
4 | |||
5 | --context Income inv inv8: | ||
6 | --if(not self.income_type.oclIsTypeOf(Employment_Income)) then | ||
7 | --self.details->forAll(d| d.distance = 0) | ||
8 | --else | ||
9 | --self.details->forAll(d| d.distance >= 0.0 and d.distance <= 100) | ||
10 | --endif | ||
11 | -- | ||
12 | --context Legal_Union_Record inv inv490: | ||
13 | --self.individual_A.oclIsKindOf(Tax_Payer) | ||
14 | -- | ||
15 | --context Legal_Union_Record inv inv491: | ||
16 | --self.individual_B->forAll(i | i.oclIsKindOf(Physical_Person) ) | ||
17 | -- | ||
18 | --context Legal_Union_Record inv inv492: | ||
19 | --self.individual_B->forAll(i | not i.oclIsTypeOf(Dependent) ) | ||
20 | -- | ||
21 | --context Legal_Union_Record inv inv493: | ||
22 | --self.individual_A <> self.individual_B | ||
23 | -- | ||
24 | --context Tax_Payer inv inv13: | ||
25 | -- self.addresses->exists( hab_add:Address | hab_add.oclIsTypeOf(Habitual_Address) = true and hab_add.country=Country::ZZ) | ||
26 | --implies | ||
27 | -- self.oclIsTypeOf(Resident_Tax_Payer) | ||
28 | |||
29 | context Income inv inv7: | ||
30 | let val:Real =self.details->asOrderedSet()->first().distance in | ||
31 | self.details->forAll(d: Income_Detail|d.distance = val) | ||
32 | |||
33 | --context External_Allowance inv inv15: | ||
34 | --let child:Dependent = self.person in | ||
35 | --let h:Household = Household.allInstances()->select(children->includes(child))->asOrderedSet()->first() in | ||
36 | --let t1:Set(Physical_Person) = Set{h.parents.individual_A}->union(h.parents.individual_B)->select(oclIsKindOf(Tax_Payer)) in | ||
37 | --if(t1->size()=1) then | ||
38 | --self.reciver = t1->asOrderedSet()->first() | ||
39 | --else | ||
40 | --self.reciver = t1->asOrderedSet()->at(2) or self.reciver = t1->asOrderedSet()->at(1) | ||
41 | --endif | ||
42 | |||
43 | |||
44 | |||
45 | endpackage \ No newline at end of file | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/case_study_A.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/case_study_A.vql new file mode 100644 index 00000000..f736ec58 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/bin/queries/case_study_A.vql | |||
@@ -0,0 +1,334 @@ | |||
1 | package queries | ||
2 | |||
3 | import "http:///TaxCard.ecore" | ||
4 | |||
5 | //AttributeRemoved -> DF | ||
6 | |||
7 | //inv1-External_Allowance.amount is a derived feature (TODOcheck) | ||
8 | //inv2-Tax_Card.income.taxPayer.taxesDue is a derived feature (TODOcheck) | ||
9 | |||
10 | //inv3-multiplicity adjusted | ||
11 | @Constraint(message = "inv03", severity = "error", key = {dep}) | ||
12 | pattern inv03(dep : Dependent) { | ||
13 | find x_inv03_eligAll(dep); | ||
14 | neg find x_inv03_hasAll(dep); | ||
15 | } or { | ||
16 | Dependent.birth_year(dep, by); | ||
17 | check(2018-by > 21); | ||
18 | Dependent.continued_studies(dep, false); | ||
19 | Dependent.allowances(dep, _); | ||
20 | } | ||
21 | pattern x_inv03_eligAll(dep : Dependent) { | ||
22 | Dependent.birth_year(dep, by); | ||
23 | check(2018-by <= 21); | ||
24 | } or { | ||
25 | Dependent.continued_studies(dep, true); | ||
26 | } | ||
27 | pattern x_inv03_hasAll(dep : Dependent) { | ||
28 | Dependent.allowances(dep, _); | ||
29 | } | ||
30 | |||
31 | //inv5 - oclIsTypeOf - handled here | ||
32 | @Constraint(message = "inv05", severity = "error", key = {inc}) | ||
33 | pattern inv05(inc : Income) { | ||
34 | //income_type: None | ||
35 | neg find x_inv08_noType(inc); | ||
36 | Income.details.worked_days(inc, wd); | ||
37 | check(wd != 0); | ||
38 | } or { | ||
39 | //income_type: Not Employment_Income | ||
40 | Income.income_type(inc, type); | ||
41 | neg find x_inv08_notEI(type); | ||
42 | Income.details.worked_days(inc, wd); | ||
43 | check(wd != 0); | ||
44 | } or { | ||
45 | //income_type: Employment Income | ||
46 | Income.income_type(inc, type); | ||
47 | Employment_Income(type); | ||
48 | find x_inv05_inRange(inc); | ||
49 | } | ||
50 | pattern x_inv05_inRange(inc : Income) { | ||
51 | Income.details.worked_days(inc, wd); | ||
52 | check(wd < 1); | ||
53 | } or { | ||
54 | Income.details.worked_days(inc, wd); | ||
55 | check(wd > 25); | ||
56 | } | ||
57 | |||
58 | //inv6-Does not make sens, but directly from OCL | ||
59 | //first part of or from definition of getAge() | ||
60 | @Constraint(message = "inv06", severity = "error", key = {tp}) | ||
61 | pattern inv06(tp : Tax_Payer) { | ||
62 | Tax_Payer.dependents(tp, _); | ||
63 | Tax_Payer.birth_year(tp, TPBy); | ||
64 | check(2018 - TPBy > 2018-16); | ||
65 | } or { | ||
66 | Tax_Payer.birth_year(tp, TPBy); | ||
67 | Tax_Payer.dependents(tp, dep); | ||
68 | Dependent.birth_year(dep, DepBy); | ||
69 | check(2018-DepBy <= 2018-TPBy-16); | ||
70 | } | ||
71 | |||
72 | //inv7-OrderedSet | ||
73 | @Constraint(message = "inv07", severity = "error", key = {inc}) | ||
74 | pattern inv07(inc : Income) { | ||
75 | Income.details.distance(inc, d1); | ||
76 | Income.details.distance(inc, d2); | ||
77 | check(d1 != d2);//compare values | ||
78 | } | ||
79 | |||
80 | //user_complete_details-AttributeRemoved | ||
81 | |||
82 | //inv8 - oclIsTypeOf - handled here | ||
83 | @Constraint(message = "inv08", severity = "error", key = {inc}) | ||
84 | pattern inv08(inc : Income) { | ||
85 | //income_type: None | ||
86 | neg find x_inv08_noType(inc); | ||
87 | Income.details.distance(inc, dist); | ||
88 | check(dist != 0); | ||
89 | } or { | ||
90 | //income_type: Not Employment_Income | ||
91 | Income.income_type(inc, type); | ||
92 | neg find x_inv08_notEI(type); | ||
93 | Income.details.distance(inc, dist); | ||
94 | check(dist != 0); | ||
95 | } or { | ||
96 | //income_type: Employment Income | ||
97 | Income.income_type(inc, type); | ||
98 | Employment_Income(type); | ||
99 | find x_inv08_inRange(inc); | ||
100 | } | ||
101 | pattern x_inv08_notEI(type : Employment_Income) { | ||
102 | Employment_Income(type); | ||
103 | } | ||
104 | pattern x_inv08_noType(inc : Income) { | ||
105 | Income.income_type(inc, _); | ||
106 | } | ||
107 | pattern x_inv08_inRange(inc : Income) { | ||
108 | Income.details.distance(inc, dist); | ||
109 | check(dist < 0); | ||
110 | } or { | ||
111 | Income.details.distance(inc, dist); | ||
112 | check(dist > 100); | ||
113 | } | ||
114 | //inv9-DerivedFeature | ||
115 | |||
116 | //inv10-Ordered Sets | ||
117 | @Constraint(message = "inv10", severity = "error", key = {inc}) | ||
118 | pattern inv10(inc : Income) { | ||
119 | Income.details.amount(inc, a1); | ||
120 | Income.details.amount(inc, a2); | ||
121 | check(a1 != a2);//compare values | ||
122 | } | ||
123 | |||
124 | //inv11-attributes-handled by multiplicity | ||
125 | @Constraint(message = "inv11", severity = "error", key = {exp}) | ||
126 | pattern inv11(exp : Expense) { | ||
127 | find x_inv11_incOver100(exp); | ||
128 | find x_inv11_incNotOver100(exp); | ||
129 | } | ||
130 | pattern x_inv11_incOver100(exp : Expense) { | ||
131 | Expense.income.income_amount(exp, incVal); | ||
132 | check(incVal / 2 > 50); | ||
133 | |||
134 | } or { | ||
135 | Expense.declared_amount(exp, decl); | ||
136 | check(decl != 50); | ||
137 | } | ||
138 | pattern x_inv11_incNotOver100(exp : Expense) { | ||
139 | Expense.income.income_amount(exp, incVal); | ||
140 | check(incVal / 2 <= 50); | ||
141 | } or { | ||
142 | Expense.declared_amount(exp, decl); | ||
143 | check(decl < 50); | ||
144 | } or { | ||
145 | Expense.income.income_amount(exp, incVal); | ||
146 | Expense.declared_amount(exp, decl); | ||
147 | check(decl > incVal/2); | ||
148 | } | ||
149 | |||
150 | //inv12 | ||
151 | //exists - handled logically | ||
152 | @Constraint(message = "inv12", severity = "error", key = {tp}) | ||
153 | pattern inv12(tp : Tax_Payer) { | ||
154 | Tax_Payer.addresses(tp, hab_add); | ||
155 | Habitual_Address(hab_add); | ||
156 | neg find x_inv12_notZZ(hab_add); | ||
157 | Tax_Payer.incomes(tp, inc); | ||
158 | Local_Income(inc); | ||
159 | neg find x_inv12_notNonRes(tp); | ||
160 | } | ||
161 | pattern x_inv12_notNonRes(tp : Non_Resident_Tax_Payer) { | ||
162 | Non_Resident_Tax_Payer(tp); | ||
163 | } | ||
164 | pattern x_inv12_notZZ(hab_add : Habitual_Address) { | ||
165 | Address.country(hab_add, ::ZZ); | ||
166 | } | ||
167 | |||
168 | //inv13 - Added new containment rel Phys_Pers->Address | ||
169 | //exists - handled logically | ||
170 | @Constraint(message = "inv13", severity = "error", key = {tp}) | ||
171 | pattern inv13(tp : Tax_Payer) { | ||
172 | Tax_Payer.addresses(tp, hab_add); | ||
173 | Habitual_Address(hab_add); | ||
174 | Address.country(hab_add, ::ZZ); | ||
175 | neg find x_inv13(tp); | ||
176 | } | ||
177 | pattern x_inv13(tp : Resident_Tax_Payer) { | ||
178 | Resident_Tax_Payer(tp); | ||
179 | } | ||
180 | |||
181 | //inv14-MultiplicityChanged | ||
182 | |||
183 | //inv15-Ordered Sets in assignment if block | ||
184 | //ERROR if no household object | ||
185 | @Constraint(message = "inv15", severity = "error", key = {ea}) | ||
186 | pattern inv15(ea : External_Allowance) { | ||
187 | neg find x_inv15(ea); | ||
188 | } | ||
189 | pattern x_inv15(ea : External_Allowance) { | ||
190 | External_Allowance.person(ea, child); | ||
191 | Household.children(h, child);//only one due to multiplicity | ||
192 | Household.parents.individual_A(h, iA); | ||
193 | Tax_Payer(iA); | ||
194 | External_Allowance.reciver(ea, iA); | ||
195 | } or { | ||
196 | External_Allowance.person(ea, child); | ||
197 | Household.children(h, child);//only one due to multiplicity | ||
198 | Household.parents.individual_B(h, iB); | ||
199 | Tax_Payer(iB); | ||
200 | External_Allowance.reciver(ea, iB); | ||
201 | } | ||
202 | |||
203 | //inv16-Tax_Card.tax_card_type is a derived feature | ||
204 | |||
205 | //inv17-attribute-handled by multiplicity | ||
206 | @Constraint(message = "inv17", severity = "error", key = {lur}) | ||
207 | pattern inv17(lur : Legal_Union_Record) { | ||
208 | Legal_Union_Record.start_year(lur, sy); | ||
209 | check(sy < 1950); | ||
210 | } or { | ||
211 | Legal_Union_Record.start_year(lur, sy); | ||
212 | check(sy > 2018); | ||
213 | } | ||
214 | |||
215 | //inv18-MultiplicityChecked | ||
216 | //inv19-MultiplicityChecked | ||
217 | |||
218 | //inv20-Useless constraint since both edges are containment (TODOCheck) | ||
219 | //OclIsUndefined-Handled by multiplicity | ||
220 | @Constraint(message = "inv20", severity = "error", key = {lur}) | ||
221 | pattern inv20(lur : Legal_Union_Record) { | ||
222 | Legal_Union_Record.individual_A(lur, iA); | ||
223 | Legal_Union_Record.individual_B(lur, iB); | ||
224 | iA == iB; | ||
225 | } | ||
226 | //inv21-MultiplicityChecked | ||
227 | //inv22-MultiplicityChecked | ||
228 | //inv23-MultiplicityChecked | ||
229 | //inv24-MultiplicityChecked | ||
230 | //inv25-MultiplicityChecked | ||
231 | //inv26-MultiplicityChanged | ||
232 | //inv27-dupOfInv24 | ||
233 | //inv28-dubOfInv23 | ||
234 | //inv29-MultiplicityChanged | ||
235 | //inv30-AttributeRemoved | ||
236 | //inv31-AttributeRemoved | ||
237 | //inv32-AttributeRemoved | ||
238 | |||
239 | //inv33-attribute-handled by multiplicity | ||
240 | @Constraint(message = "inv33", severity = "error", key = {p}) | ||
241 | pattern inv33(p : Physical_Person) { | ||
242 | Physical_Person.birth_year(p, by); | ||
243 | check(2018-by < 0); | ||
244 | } or { | ||
245 | Physical_Person.birth_year(p, by); | ||
246 | check(2018-by > 100); | ||
247 | } | ||
248 | |||
249 | //inv34-attribute-handled by multiplicity | ||
250 | @Constraint(message = "inv34", severity = "error", key = {p}) | ||
251 | pattern inv34(p : Physical_Person) { | ||
252 | Physical_Person.birth_month(p, birthMonth); | ||
253 | check(birthMonth < 1); | ||
254 | } or { | ||
255 | Physical_Person.birth_month(p, birthMonth); | ||
256 | check(birthMonth > 12); | ||
257 | } | ||
258 | |||
259 | //inv35-attribute-handled by multiplicity | ||
260 | @Constraint(message = "inv35", severity = "error", key = {p}) | ||
261 | pattern inv35(p : Physical_Person) { | ||
262 | Physical_Person.birth_day(p, birthDay); | ||
263 | check(birthDay < 1); | ||
264 | } or { | ||
265 | Physical_Person.birth_day(p, birthDay); | ||
266 | check(birthDay > 28); | ||
267 | } | ||
268 | |||
269 | //inv36-AttributeRemoved | ||
270 | //inv37-AttributeRemoved | ||
271 | //inv38-AttributeRemoved | ||
272 | //inv39-AttributeRemoved | ||
273 | //inv40-AttributeRemoved | ||
274 | //inv41-AttributeRemoved | ||
275 | //inv42-AttributeRemoved | ||
276 | //inv43-AttributeRemoved | ||
277 | //inv44-AttributeRemoved | ||
278 | //inv45-AttributeRemoved | ||
279 | //inv46-AttributeRemoved | ||
280 | |||
281 | //inv47-attributes-handled by multiplicity | ||
282 | @Constraint(message = "inv47", severity = "error", key = {lur}) | ||
283 | pattern inv47(lur : Legal_Union_Record) { | ||
284 | Legal_Union_Record.end_year(lur, endY); | ||
285 | Legal_Union_Record.start_year(lur, startY); | ||
286 | neg find x_inv47(lur); | ||
287 | check(startY >= endY); | ||
288 | } | ||
289 | pattern x_inv47(lur : Legal_Union_Record) { | ||
290 | Legal_Union_Record.separation_cause(lur, ::NONE); | ||
291 | Legal_Union_Record.end_year(lur, -1); | ||
292 | } | ||
293 | |||
294 | //inv48-attributes-handled by multiplicity | ||
295 | @Constraint(message = "inv48", severity = "error", key = {p}) | ||
296 | pattern inv48(p : Physical_Person) { | ||
297 | neg find x_inv48_notDis(p); | ||
298 | neg find x_inv48_Dis(p); | ||
299 | } | ||
300 | pattern x_inv48_notDis(p : Physical_Person) { | ||
301 | Physical_Person.disability_type(p, ::NONE); | ||
302 | Physical_Person.disability_percentage(p, 0.0); | ||
303 | } | ||
304 | pattern x_inv48_Dis(p : Physical_Person) { | ||
305 | neg find x_inv48_3(p); | ||
306 | Physical_Person.disability_percentage(p, disPer); | ||
307 | check(disPer > 0.0); | ||
308 | check(disPer <= 1.0); | ||
309 | } | ||
310 | pattern x_inv48_3(p : Physical_Person) { | ||
311 | Physical_Person.disability_type(p, ::NONE); | ||
312 | } | ||
313 | |||
314 | //inv49-OclKindOf-handled by multiplicity | ||
315 | @Constraint(message = "inv49", severity = "error", key = {lur}) | ||
316 | pattern inv49(lur : Legal_Union_Record) { | ||
317 | neg find x_inv49_1(lur); | ||
318 | } | ||
319 | pattern x_inv49_1(lur : Legal_Union_Record) { | ||
320 | Legal_Union_Record.individual_A(lur, iA); | ||
321 | Legal_Union_Record.individual_B(lur, iB); | ||
322 | Tax_Payer(iA); | ||
323 | Physical_Person(iB); | ||
324 | neg find x_inv49_2(iB); | ||
325 | iA != iB; | ||
326 | } | ||
327 | pattern x_inv49_2(iB: Dependent) { | ||
328 | Dependent(iB); | ||
329 | } | ||
330 | |||
331 | //inv50-MultiplicityChecked | ||
332 | //inv51-MultiplicityChecked | ||
333 | //inv52-MultiplicityChecked | ||
334 | //inv53-MultiplicityChecked \ No newline at end of file | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/taxation.vsconfig b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/taxation.vsconfig index fa3f6000..0c819976 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/taxation.vsconfig +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/taxation.vsconfig | |||
@@ -1,25 +1,25 @@ | |||
1 | import epackage "config/Taxation.ecore" | 1 | //import epackage "config/Taxation.ecore" |
2 | //import viatra "src/queries/familyTreeConstraints.vql" | 2 | ////import viatra "src/queries/familyTreeConstraints.vql" |
3 | 3 | // | |
4 | generate { | 4 | //generate { |
5 | metamodel = { package Taxation } | 5 | // metamodel = { package Taxation } |
6 | //constraints = { package queries} | 6 | // //constraints = { package queries} |
7 | solver = ViatraSolver | 7 | // solver = ViatraSolver |
8 | scope = { | 8 | // scope = { |
9 | //#node = 6, | 9 | // //#node = 6, |
10 | #int = {0}, | 10 | // #int = {0}, |
11 | #real = {0.0} | 11 | // #real = {0.0} |
12 | } | 12 | // } |
13 | 13 | // | |
14 | config = { | 14 | // config = { |
15 | runtime = 10, | 15 | // runtime = 10, |
16 | log-level = normal | 16 | // log-level = normal |
17 | } | 17 | // } |
18 | 18 | // | |
19 | runs = 1 | 19 | // runs = 1 |
20 | 20 | // | |
21 | debug = "config/output/debug/" | 21 | // debug = "config/output/debug/" |
22 | log = "config/output/debug/log.txt" | 22 | // log = "config/output/debug/log.txt" |
23 | output = "config/output/models" | 23 | // output = "config/output/models" |
24 | statistics = "config/output/debug/statistics.csv" | 24 | // statistics = "config/output/debug/statistics.csv" |
25 | } \ No newline at end of file | 25 | //} \ No newline at end of file |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/inputs/FamilyTree.xmi b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/inputs/FamilyTree.xmi new file mode 100644 index 00000000..066b286f --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/inputs/FamilyTree.xmi | |||
@@ -0,0 +1,3 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <familytree:FamilyTree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | xmlns:familytree="http://www.example.org/familytree" xsi:schemaLocation="http://www.example.org/familytree familytree.ecore"/> | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml index 8b036ff2..63aa0b02 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml | |||
@@ -1,42 +1,42 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><plugin> | 1 | <?xml version="1.0" encoding="UTF-8"?><plugin> |
2 | <extension id="queries.Case_study_A" point="org.eclipse.viatra.query.runtime.queryspecification"> | 2 | <extension id="queries.Case_study_A" point="org.eclipse.viatra.query.runtime.queryspecification"> |
3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.Case_study_A" id="queries.Case_study_A"> | 3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.Case_study_A" id="queries.Case_study_A"> |
4 | <query-specification fqn="queries.inv03"/> | 4 | <query-specification fqn="queries.inv03"/> |
5 | <query-specification fqn="queries.x_inv03_eligAll"/> | 5 | <query-specification fqn="queries.x_inv03_eligAll"/> |
6 | <query-specification fqn="queries.x_inv03_hasAll"/> | 6 | <query-specification fqn="queries.x_inv03_hasAll"/> |
7 | <query-specification fqn="queries.inv05"/> | 7 | <query-specification fqn="queries.inv05"/> |
8 | <query-specification fqn="queries.x_inv05_inRange"/> | 8 | <query-specification fqn="queries.x_inv05_inRange"/> |
9 | <query-specification fqn="queries.inv06"/> | 9 | <query-specification fqn="queries.inv06"/> |
10 | <query-specification fqn="queries.inv07"/> | 10 | <query-specification fqn="queries.inv07"/> |
11 | <query-specification fqn="queries.inv08"/> | 11 | <query-specification fqn="queries.inv08"/> |
12 | <query-specification fqn="queries.x_inv08_notEI"/> | 12 | <query-specification fqn="queries.x_inv08_notEI"/> |
13 | <query-specification fqn="queries.x_inv08_noType"/> | 13 | <query-specification fqn="queries.x_inv08_noType"/> |
14 | <query-specification fqn="queries.x_inv08_inRange"/> | 14 | <query-specification fqn="queries.x_inv08_inRange"/> |
15 | <query-specification fqn="queries.inv10"/> | 15 | <query-specification fqn="queries.inv10"/> |
16 | <query-specification fqn="queries.inv11"/> | 16 | <query-specification fqn="queries.inv11"/> |
17 | <query-specification fqn="queries.x_inv11_incOver100"/> | 17 | <query-specification fqn="queries.x_inv11_incOver100"/> |
18 | <query-specification fqn="queries.x_inv11_incNotOver100"/> | 18 | <query-specification fqn="queries.x_inv11_incNotOver100"/> |
19 | <query-specification fqn="queries.inv12"/> | 19 | <query-specification fqn="queries.inv12"/> |
20 | <query-specification fqn="queries.x_inv12_notNonRes"/> | 20 | <query-specification fqn="queries.x_inv12_notNonRes"/> |
21 | <query-specification fqn="queries.x_inv12_notZZ"/> | 21 | <query-specification fqn="queries.x_inv12_notZZ"/> |
22 | <query-specification fqn="queries.inv13"/> | 22 | <query-specification fqn="queries.inv13"/> |
23 | <query-specification fqn="queries.x_inv13"/> | 23 | <query-specification fqn="queries.x_inv13"/> |
24 | <query-specification fqn="queries.inv15"/> | 24 | <query-specification fqn="queries.inv15"/> |
25 | <query-specification fqn="queries.x_inv15"/> | 25 | <query-specification fqn="queries.x_inv15"/> |
26 | <query-specification fqn="queries.inv17"/> | 26 | <query-specification fqn="queries.inv17"/> |
27 | <query-specification fqn="queries.inv20"/> | 27 | <query-specification fqn="queries.inv20"/> |
28 | <query-specification fqn="queries.inv33"/> | 28 | <query-specification fqn="queries.inv33"/> |
29 | <query-specification fqn="queries.inv34"/> | 29 | <query-specification fqn="queries.inv34"/> |
30 | <query-specification fqn="queries.inv35"/> | 30 | <query-specification fqn="queries.inv35"/> |
31 | <query-specification fqn="queries.inv47"/> | 31 | <query-specification fqn="queries.inv47"/> |
32 | <query-specification fqn="queries.x_inv47"/> | 32 | <query-specification fqn="queries.x_inv47"/> |
33 | <query-specification fqn="queries.inv48"/> | 33 | <query-specification fqn="queries.inv48"/> |
34 | <query-specification fqn="queries.x_inv48_notDis"/> | 34 | <query-specification fqn="queries.x_inv48_notDis"/> |
35 | <query-specification fqn="queries.x_inv48_Dis"/> | 35 | <query-specification fqn="queries.x_inv48_Dis"/> |
36 | <query-specification fqn="queries.x_inv48_3"/> | 36 | <query-specification fqn="queries.x_inv48_3"/> |
37 | <query-specification fqn="queries.inv49"/> | 37 | <query-specification fqn="queries.inv49"/> |
38 | <query-specification fqn="queries.x_inv49_1"/> | 38 | <query-specification fqn="queries.x_inv49_1"/> |
39 | <query-specification fqn="queries.x_inv49_2"/> | 39 | <query-specification fqn="queries.x_inv49_2"/> |
40 | </group> | 40 | </group> |
41 | </extension> | 41 | </extension> |
42 | </plugin> | 42 | </plugin> |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql index 5d46bf42..f736ec58 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql | |||
@@ -1,5 +1,5 @@ | |||
1 | package queries | 1 | package queries |
2 | 2 | ||
3 | import "http:///TaxCard.ecore" | 3 | import "http:///TaxCard.ecore" |
4 | 4 | ||
5 | //AttributeRemoved -> DF | 5 | //AttributeRemoved -> DF |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend index ff0e1d03..3f5855d8 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend | |||
@@ -1,6 +1,7 @@ | |||
1 | package run | 1 | package run |
2 | 2 | ||
3 | import Taxation.TaxationPackage | 3 | import Taxation.TaxationPackage |
4 | import familytree.FamilytreePackage | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | 6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration |
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
@@ -11,6 +12,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | |||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.impl.ModelResultImpl | ||
14 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | 16 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore |
15 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | 17 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic |
16 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | 18 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration |
@@ -18,12 +20,12 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | |||
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | 20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic |
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | 22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml |
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration | ||
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner | 23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner |
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration | 24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration |
24 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | 25 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser |
25 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | 26 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace |
26 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | 27 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace |
28 | import java.io.PrintWriter | ||
27 | import java.math.BigDecimal | 29 | import java.math.BigDecimal |
28 | import java.text.SimpleDateFormat | 30 | import java.text.SimpleDateFormat |
29 | import java.util.Date | 31 | import java.util.Date |
@@ -31,6 +33,7 @@ import java.util.HashMap | |||
31 | import java.util.List | 33 | import java.util.List |
32 | import java.util.Map | 34 | import java.util.Map |
33 | import java.util.TreeSet | 35 | import java.util.TreeSet |
36 | import org.eclipse.emf.common.util.EList | ||
34 | import org.eclipse.emf.ecore.EAttribute | 37 | import org.eclipse.emf.ecore.EAttribute |
35 | import org.eclipse.emf.ecore.EClass | 38 | import org.eclipse.emf.ecore.EClass |
36 | import org.eclipse.emf.ecore.EEnum | 39 | import org.eclipse.emf.ecore.EEnum |
@@ -43,118 +46,216 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | |||
43 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | 46 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup |
44 | import org.eclipse.viatra.query.runtime.api.IQueryGroup | 47 | import org.eclipse.viatra.query.runtime.api.IQueryGroup |
45 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine | 48 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine |
49 | import queries.Case_study_A | ||
50 | import queries.FamilyTreeConstraints | ||
46 | 51 | ||
47 | class GeneratePledgeModels { | 52 | class GeneratePledgeModels { |
48 | def static void main(String[] args) { | 53 | static val SIZE_LB = 20 |
49 | val x = (new EMFPatternLanguageStandaloneSetup).createInjectorAndDoEMFRegistration | 54 | static val SIZE_UB = 20 |
50 | // //PatternLanguageWithRSSetup.createInjectorAndDoEMFRegistration | 55 | static val SIZE_MUL = 1 |
51 | // ApplicationConfigurationStandaloneSetup.doSetup | 56 | static val SIZE_INC = 5 |
52 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl) | 57 | |
53 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem", new XMIResourceFactoryImpl) | 58 | static var REPS = 1 |
54 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel", new XMIResourceFactoryImpl) | 59 | static val RUNTIME = 600 |
55 | ReteEngine.getClass | 60 | |
56 | 61 | static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation" | |
57 | val Ecore2Logic ecore2Logic = new Ecore2Logic | 62 | static val QUERIES = false |
58 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | 63 | static val INDIV_WRT = true |
59 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | 64 | static val GLOBAL_WRT = true |
60 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | 65 | static val q2t = if(QUERIES) "Y" else "N" |
61 | 66 | ||
62 | // Workspace setup | 67 | def static void main(String[] args) { |
63 | val Date date = new Date(System.currentTimeMillis) | 68 | (new EMFPatternLanguageStandaloneSetup).createInjectorAndDoEMFRegistration |
64 | val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); | 69 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl) |
65 | val formattedDate = format.format(date) | 70 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem", new XMIResourceFactoryImpl) |
66 | 71 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel", new XMIResourceFactoryImpl) | |
67 | val inputs = new FileSystemWorkspace('''inputs/''', "") | 72 | ReteEngine.getClass |
68 | val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "") | 73 | val Ecore2Logic ecore2Logic = new Ecore2Logic |
69 | val debug = new FileSystemWorkspace('''output/''' + formattedDate + '''/debug/''', "") | 74 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) |
70 | workspace.initAndClear | 75 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) |
71 | 76 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | |
72 | println("Input and output workspaces are created") | 77 | |
73 | 78 | // Workspace setup | |
74 | // print(TaxationPackage.eINSTANCE.getEClassifiers.filter(EClass).toList.get(0)) | 79 | val Date date = new Date(System.currentTimeMillis) |
75 | //* | 80 | val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); |
76 | val metamodel = loadMetamodel(TaxationPackage.eINSTANCE) | 81 | val formattedDate = format.format(date) |
77 | val partialModel = loadPartialModel(inputs, "Household.xmi") | 82 | |
78 | // val queries = loadQueries(metamodel, Case_study_A.instance) | 83 | val inputs = new FileSystemWorkspace('''inputs/''', "") |
79 | /*/ | 84 | val dataws = new FileSystemWorkspace('''output/''', "") |
80 | val metamodel = loadMetamodel(FamilytreePackage.eINSTANCE) | 85 | val modelsws = new FileSystemWorkspace('''output/''' + formattedDate + '''/models/''', "") |
81 | // val partialModel = loadPartialModel(inputs, "yakindu/Yakindu.xmi") | 86 | val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "") |
82 | val queries = loadQueries(metamodel, FamilyTreeConstraints.instance) | 87 | val debug = new FileSystemWorkspace('''output/''' + DOMAIN + "-" + formattedDate + '''/debug/''', "") |
83 | // */ | 88 | workspace.initAndClear |
84 | println("DSL loaded") | 89 | modelsws.initAndClear |
85 | 90 | ||
86 | val SIZE = 2 | 91 | println("Input and output workspaces are created") |
87 | var REPS = 1 | 92 | |
88 | val RUNTIME = 600 | 93 | // ////////////////////////// |
89 | 94 | // DOMAIN | |
90 | // ///////////////////////// | 95 | var EcoreMetamodelDescriptor metamodel = null |
91 | // Prepare Problem | 96 | var EList<EObject> partialModel = null |
92 | val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration()) | 97 | var ViatraQuerySetDescriptor queries = null |
93 | var problem = modelGenerationProblem.output | 98 | switch DOMAIN { |
94 | 99 | case "Taxation": { | |
95 | // val modelExtensionProblem = instanceModel2Logic.transform(modelGenerationProblem, partialModel) | 100 | metamodel = loadMetamodel(TaxationPackage.eINSTANCE) |
96 | // problem = modelExtensionProblem.output | 101 | partialModel = loadPartialModel(inputs, "Household.xmi") |
97 | // val validModelExtensionProblem = viatra2Logic.transformQueries(queries, modelGenerationProblem, | 102 | queries = loadQueries(metamodel, Case_study_A.instance) |
98 | // new Viatra2LogicConfiguration) | 103 | } |
99 | // problem = validModelExtensionProblem.output | 104 | case "FamilyTree": { |
100 | debug.writeModel(problem, "problem.logicproblem") | 105 | metamodel = loadMetamodel(FamilytreePackage.eINSTANCE) |
101 | println("Problem created") | 106 | partialModel = loadPartialModel(inputs, "FamilyTree.xmi") |
102 | // End Prepare Problem | 107 | queries = loadQueries(metamodel, FamilyTreeConstraints.instance) |
103 | // ///////////////////////// | 108 | } |
109 | default: { | ||
110 | System.err.println("Unsupported Domain") | ||
111 | throw new Exception | ||
112 | } | ||
113 | } | ||
114 | println("DSL loaded") | ||
115 | |||
116 | // ///////////////////////// | ||
117 | // Prepare Problem | ||
118 | val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration()) | ||
119 | var problem = modelGenerationProblem.output | ||
120 | val modelExtensionProblem = instanceModel2Logic.transform(modelGenerationProblem, partialModel) | ||
121 | problem = modelExtensionProblem.output | ||
122 | if (QUERIES) { | ||
123 | val validModelExtensionProblem = viatra2Logic.transformQueries(queries, modelExtensionProblem, | ||
124 | new Viatra2LogicConfiguration) | ||
125 | problem = validModelExtensionProblem.output | ||
126 | } | ||
127 | // debug.writeModel(problem, "problem.logicproblem") | ||
128 | println("Problem created") | ||
129 | // ///////////////////////// | ||
130 | // BEGIN RUN | ||
131 | var PrintWriter global_writer = null | ||
132 | val header = "domain, queries?,size,model?,timeout,measuredTime,TransformatonTime,SolverTime\n" | ||
133 | if (GLOBAL_WRT) { | ||
134 | global_writer = new PrintWriter( | ||
135 | workspace.workspaceURI + "//_" + DOMAIN + SIZE_LB + "to" + SIZE_UB + "x" + REPS + "q" + q2t + "-" + | ||
136 | formattedDate + ".csv") | ||
137 | global_writer.append(header) | ||
138 | } | ||
139 | |||
140 | var NEXT_INC = SIZE_INC | ||
141 | for (var size = SIZE_LB; size <= SIZE_UB; size += NEXT_INC) { | ||
142 | NEXT_INC *= SIZE_MUL | ||
143 | |||
144 | var PrintWriter indiv_writer = null | ||
145 | if (INDIV_WRT) { | ||
146 | indiv_writer = new PrintWriter( // TODO | ||
147 | workspace.workspaceURI + "//__" + DOMAIN + "Sz" + size + "x" + REPS + "q" + q2t + "-" + formattedDate + | ||
148 | ".csv") | ||
149 | indiv_writer.append(header) | ||
150 | } | ||
151 | |||
152 | println() | ||
153 | println("DOMAIN: " + DOMAIN + ", SIZE=" + size) | ||
154 | |||
104 | for (var i = 0; i < REPS; i++) { | 155 | for (var i = 0; i < REPS; i++) { |
105 | 156 | ||
106 | var ViatraReasoner reasoner = new ViatraReasoner | 157 | print("<<Run number " + i + ">> : ") |
158 | |||
159 | var ViatraReasoner reasoner = new ViatraReasoner | ||
107 | 160 | ||
108 | // ///////////////////////////////////////////////////// | 161 | // ///////////////////////////////////////////////////// |
109 | // Define Config File | 162 | // Define Config File |
110 | val knownIntegers = new TreeSet<Integer> | 163 | val knownIntegers = new TreeSet<Integer> |
111 | knownIntegers.addAll(0) | 164 | knownIntegers.addAll(0, 10, 20, 30, 40, 50) |
112 | 165 | ||
113 | val knownReals = new TreeSet<BigDecimal> | 166 | val knownReals = new TreeSet<BigDecimal> |
114 | knownReals.addAll(new BigDecimal("0.0")) | 167 | knownReals.addAll(new BigDecimal("0.0")) |
115 | 168 | ||
116 | val knownStrings = new TreeSet<String> | 169 | val knownStrings = new TreeSet<String> |
117 | knownStrings.addAll("r0", "r1", "r2") | 170 | knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6") |
118 | 171 | ||
119 | val solverConfig = new ViatraReasonerConfiguration => [ | 172 | val curSize = size |
120 | it.documentationLevel = DocumentationLevel::FULL | 173 | val solverConfig = new ViatraReasonerConfiguration => [ |
121 | it.debugCongiguration = new DebugConfiguration => [logging = true] | 174 | it.documentationLevel = DocumentationLevel::NONE |
122 | it.runtimeLimit = RUNTIME | 175 | // it.debugCongiguration = new DebugConfiguration => [logging = true] |
123 | // it.typeScopes.maxNewElements = SIZE | 176 | it.runtimeLimit = RUNTIME |
124 | // it.typeScopes.minNewElements = 3 | 177 | // it.typeScopes.maxNewElements = SIZE |
125 | if(!knownIntegers.isEmpty) it.typeScopes.knownIntegers = knownIntegers | 178 | it.typeScopes.minNewElements = curSize |
126 | if(!knownReals.isEmpty) it.typeScopes.knownReals = knownReals | ||
127 | // if(!knownStrings.isEmpty) it.typeScopes.knownStrings = knownStrings | ||
128 | ] | ||
129 | 179 | ||
130 | println("Run #" + i + ":") | 180 | // if(!knownIntegers.isEmpty) it.typeScopes.knownIntegers = knownIntegers |
131 | val startTime = System.currentTimeMillis | 181 | if(!knownReals.isEmpty) it.typeScopes.knownReals = knownReals |
132 | var solution = reasoner.solve(problem, solverConfig, debug) | 182 | // if(!knownStrings.isEmpty) it.typeScopes.knownStrings = knownStrings |
133 | val totalTime = System.currentTimeMillis - startTime | 183 | ] |
134 | 184 | ||
135 | println(" Problem Solved") | 185 | val startTime = System.currentTimeMillis |
136 | solution.writeStats(totalTime, solverConfig) | 186 | var solution = reasoner.solve(problem, solverConfig, debug) |
187 | val measuredTime = System.currentTimeMillis - startTime | ||
137 | 188 | ||
189 | print("<<END") | ||
190 | |||
191 | val toAddtoCSV = DOMAIN + "," + QUERIES + "," + size + "," + (solution.class == ModelResultImpl).toString + | ||
192 | "," + RUNTIME + "," + measuredTime / 1000.0 + "," + solution.statistics.transformationTime / 1000.0 + | ||
193 | "," + solution.statistics.solverTime / 1000.0 + "\n" | ||
194 | |||
195 | if (GLOBAL_WRT) global_writer.append(toAddtoCSV) | ||
196 | // { | ||
197 | // global_writer.append(DOMAIN + ",") | ||
198 | // global_writer.append(QUERIES + ",") | ||
199 | // global_writer.append(size + ",") | ||
200 | // global_writer.append((solution.class == ModelResultImpl).toString + ",") | ||
201 | // global_writer.append(RUNTIME + ",") | ||
202 | // global_writer.append(measuredTime / 1000.0 + ",") | ||
203 | // | ||
204 | // global_writer.append(solution.statistics.transformationTime / 1000.0 + ",") | ||
205 | // global_writer.append(solution.statistics.solverTime / 1000.0 + "") | ||
206 | // global_writer.append("\n") | ||
207 | // } | ||
208 | if (INDIV_WRT) indiv_writer.append(toAddtoCSV) | ||
209 | // { | ||
210 | // indiv_writer.append(DOMAIN + ",") | ||
211 | // indiv_writer.append(QUERIES + ",") | ||
212 | // indiv_writer.append(size + ",") | ||
213 | // indiv_writer.append((solution.class == ModelResultImpl).toString + ",") | ||
214 | // global_writer.append(RUNTIME + ",") | ||
215 | // indiv_writer.append(measuredTime / 1000.0 + ",") | ||
216 | // | ||
217 | // indiv_writer.append(solution.statistics.transformationTime / 1000.0 + ",") | ||
218 | // indiv_writer.append(solution.statistics.solverTime / 1000.0 + "") | ||
219 | // indiv_writer.append("\n") | ||
220 | // } | ||
221 | |||
222 | println("->" + measuredTime / 1000.0 + "s") | ||
223 | |||
224 | // solution.writeStats(totalTime, solverConfig) | ||
225 | try { | ||
138 | if (solution instanceof ModelResult) { | 226 | if (solution instanceof ModelResult) { |
139 | solution.writeRepresentation(workspace, i) | 227 | solution.writeInterpretation(logic2Ecore, modelsws, size + "_" + i, reasoner, modelGenerationProblem) |
140 | solution.writeInterpretation(logic2Ecore, workspace, i, reasoner, modelGenerationProblem) | 228 | println(" (XMI Success)") |
141 | println(" Solution saved and visualised") | 229 | } |
142 | } else | 230 | } catch (Exception e) { |
143 | println(" Returned: " + solution.class.simpleName.toString) | 231 | System.err.println(" (XMI Error)" + e.message) |
144 | 232 | } | |
145 | // println("Stats Created") | 233 | |
146 | // Run Garbage Collector | 234 | try { |
147 | val Runtime r = Runtime.getRuntime(); | 235 | if (solution instanceof ModelResult) { |
148 | r.gc(); | 236 | solution.writeRepresentation(modelsws, size + "_" + i) |
149 | r.gc(); | 237 | println(" (VIZ Success) >>") |
150 | r.gc(); | 238 | } |
151 | Thread.sleep(3000) | 239 | } catch (Exception e) { |
240 | System.err.println(" (VIZ Error)" + e.message + ">>") | ||
152 | } | 241 | } |
153 | println("---End---") | ||
154 | 242 | ||
243 | println() | ||
244 | // Run Garbage Collector | ||
245 | val Runtime r = Runtime.getRuntime(); | ||
246 | r.gc(); | ||
247 | r.gc(); | ||
248 | r.gc(); | ||
249 | Thread.sleep(3000) | ||
155 | } | 250 | } |
251 | if(INDIV_WRT) indiv_writer.close | ||
252 | } | ||
253 | if(GLOBAL_WRT) global_writer.close | ||
254 | } | ||
255 | |||
256 | def | ||
156 | 257 | ||
157 | def static Map<Type, Integer> getTypeMap(Map<Class, Integer> classMap, EcoreMetamodelDescriptor metamodel, | 258 | static Map<Type, Integer> getTypeMap(Map<Class, Integer> classMap, EcoreMetamodelDescriptor metamodel, |
158 | Ecore2Logic e2l, Ecore2Logic_Trace trace) { | 259 | Ecore2Logic e2l, Ecore2Logic_Trace trace) { |
159 | val typeMap = new HashMap<Type, Integer> | 260 | val typeMap = new HashMap<Type, Integer> |
160 | val listMap = metamodel.classes.toMap[s|s.name] | 261 | val listMap = metamodel.classes.toMap[s|s.name] |
@@ -168,7 +269,9 @@ class GeneratePledgeModels { | |||
168 | return typeMap | 269 | return typeMap |
169 | } | 270 | } |
170 | 271 | ||
171 | def static loadMetamodel(EPackage pckg) { | 272 | def |
273 | |||
274 | static loadMetamodel(EPackage pckg) { | ||
172 | val List<EClass> classes = pckg.getEClassifiers.filter(EClass).toList | 275 | val List<EClass> classes = pckg.getEClassifiers.filter(EClass).toList |
173 | val List<EEnum> enums = pckg.getEClassifiers.filter(EEnum).toList | 276 | val List<EEnum> enums = pckg.getEClassifiers.filter(EEnum).toList |
174 | val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList | 277 | val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList |
@@ -177,13 +280,17 @@ class GeneratePledgeModels { | |||
177 | return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) | 280 | return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) |
178 | } | 281 | } |
179 | 282 | ||
180 | def static loadPartialModel(ReasonerWorkspace inputs, String path) { | 283 | def |
284 | |||
285 | static loadPartialModel(ReasonerWorkspace inputs, String path) { | ||
181 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()) | 286 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()) |
182 | inputs.readModel(EObject, path).eResource.contents | 287 | inputs.readModel(EObject, path).eResource.contents |
183 | // inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList | 288 | // inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList |
184 | } | 289 | } |
185 | 290 | ||
186 | def static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) { | 291 | def |
292 | |||
293 | static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) { | ||
187 | val patterns = i.specifications.toList | 294 | val patterns = i.specifications.toList |
188 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet | 295 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet |
189 | val derivedFeatures = emptyMap | 296 | val derivedFeatures = emptyMap |
@@ -199,37 +306,45 @@ class GeneratePledgeModels { | |||
199 | return res | 306 | return res |
200 | } | 307 | } |
201 | 308 | ||
202 | def static writeInterpretation(LogicResult solution, Logic2Ecore logic2Ecore, ReasonerWorkspace workspace, int i, | 309 | def |
203 | ViatraReasoner reasoner, TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | 310 | |
311 | static writeInterpretation(LogicResult solution, Logic2Ecore logic2Ecore, ReasonerWorkspace workspace, | ||
312 | String id, ViatraReasoner reasoner, TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | ||
204 | val interpretations = reasoner.getInterpretations(solution as ModelResult) | 313 | val interpretations = reasoner.getInterpretations(solution as ModelResult) |
205 | for (interpIndex : 0 ..< interpretations.size) { | 314 | for (interpIndex : 0 ..< interpretations.size) { |
206 | // val extension b = new LogicStructureBuilder | 315 | // val extension b = new LogicStructureBuilder |
207 | // val extension a = new LogicProblemBuilder | 316 | // val extension a = new LogicProblemBuilder |
208 | val interpretation = interpretations.get(interpIndex) | 317 | val interpretation = interpretations.get(interpIndex) |
209 | val model = logic2Ecore.transformInterpretation(interpretation, mgProb.trace) | 318 | val model = logic2Ecore.transformInterpretation(interpretation, mgProb.trace) |
210 | workspace.writeModel(model, '''solution«i»_«interpIndex».xmi''') | 319 | // println(model) |
320 | workspace.writeModel(model, '''sol-«id»_«interpIndex».xmi''') | ||
211 | } | 321 | } |
212 | } | 322 | } |
213 | 323 | ||
214 | def static writeRepresentation(LogicResult solution, ReasonerWorkspace workspace, int i) { | 324 | def |
325 | |||
326 | static writeRepresentation(LogicResult solution, ReasonerWorkspace workspace, String id) { | ||
215 | val representations = solution.representation | 327 | val representations = solution.representation |
216 | for (representationIndex : 0 ..< representations.size) { | 328 | for (representationIndex : 0 ..< representations.size) { |
217 | val representation = representations.get(representationIndex) | 329 | val representation = representations.get(representationIndex) |
218 | if (representation instanceof PartialInterpretation) { | 330 | if (representation instanceof PartialInterpretation) { |
219 | val gml = (new PartialInterpretation2Gml).transform(representation) | 331 | val gml = (new PartialInterpretation2Gml).transform(representation) |
220 | workspace.writeText('''solution«i»_«representationIndex».gml''', gml) | 332 | workspace.writeText('''sol-«id»_«representationIndex».gml''', gml) |
221 | 333 | ||
222 | val png = (new GraphvizVisualiser).visualiseConcretization(representation) | 334 | val png = (new GraphvizVisualiser).visualiseConcretization(representation) |
223 | png.writeToFile(workspace, '''solution«i»_«representationIndex».png''') | 335 | // println(png) |
336 | png.writeToFile(workspace, '''sol-«id»_«representationIndex».png''') | ||
224 | 337 | ||
225 | // workspace.writeModel(representation, '''solution«representationIndex».partialintrpretation''') | 338 | // workspace.writeModel(representation, '''solution«representationIndex».partialintrpretation''') |
226 | } else { | 339 | } else { |
227 | workspace.writeText('''solution«representationIndex».txt''', representation.toString) | 340 | workspace.writeText('''sol-«representationIndex».txt''', representation.toString) |
228 | } | 341 | } |
229 | } | 342 | } |
230 | } | 343 | } |
231 | 344 | ||
232 | def static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) { | 345 | def |
346 | |||
347 | static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) { | ||
233 | val stats = solution.statistics | 348 | val stats = solution.statistics |
234 | println(" Statistics:") | 349 | println(" Statistics:") |
235 | // for (e : stats.entries.filter[name.substring(0, 9) == "_Solution"]) { | 350 | // for (e : stats.entries.filter[name.substring(0, 9) == "_Solution"]) { |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin index 163f84a1..c5572067 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.gitignore b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.gitignore index f3c882e4..a93ae854 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.gitignore +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.gitignore | |||
@@ -6,3 +6,4 @@ | |||
6 | /.GeneratePledgeModels.java._trace | 6 | /.GeneratePledgeModels.java._trace |
7 | /.GeneratePledgeModels.xtendbin | 7 | /.GeneratePledgeModels.xtendbin |
8 | /GeneratePledgeModels.java | 8 | /GeneratePledgeModels.java |
9 | /.UML2TGF.java._trace | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java index 2809679d..84232a13 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java | |||
@@ -1,314 +1,498 @@ | |||
1 | package run; | 1 | package run; |
2 | 2 | ||
3 | import Taxation.TaxationPackage; | 3 | import Taxation.TaxationPackage; |
4 | import com.google.common.base.Objects; | 4 | import com.google.common.base.Objects; |
5 | import com.google.common.collect.Iterables; | 5 | import com.google.common.collect.Iterables; |
6 | import com.google.inject.Injector; | 6 | import familytree.FamilytreePackage; |
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | 7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; |
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; | 8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; |
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | 9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; |
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | 10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; |
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | 15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; |
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | 16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; |
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | 17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; |
18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; | 18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; |
19 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; | 19 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.impl.ModelResultImpl; |
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | 20 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; |
21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | 21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | 22 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; |
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 23 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; |
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | 24 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; |
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; |
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | 27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; |
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
29 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | 29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; |
30 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | 30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
31 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | 31 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; |
32 | import java.math.BigDecimal; | 32 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; |
33 | import java.text.SimpleDateFormat; | 33 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; |
34 | import java.util.Collections; | 34 | import java.io.PrintWriter; |
35 | import java.util.Date; | 35 | import java.math.BigDecimal; |
36 | import java.util.HashMap; | 36 | import java.text.SimpleDateFormat; |
37 | import java.util.List; | 37 | import java.util.Collections; |
38 | import java.util.Map; | 38 | import java.util.Date; |
39 | import java.util.Set; | 39 | import java.util.HashMap; |
40 | import java.util.TreeSet; | 40 | import java.util.List; |
41 | import org.eclipse.emf.common.util.EList; | 41 | import java.util.Map; |
42 | import org.eclipse.emf.ecore.EAttribute; | 42 | import java.util.Set; |
43 | import org.eclipse.emf.ecore.EClass; | 43 | import java.util.TreeSet; |
44 | import org.eclipse.emf.ecore.EEnum; | 44 | import org.eclipse.emf.common.util.EList; |
45 | import org.eclipse.emf.ecore.EEnumLiteral; | 45 | import org.eclipse.emf.common.util.URI; |
46 | import org.eclipse.emf.ecore.EObject; | 46 | import org.eclipse.emf.ecore.EAttribute; |
47 | import org.eclipse.emf.ecore.EPackage; | 47 | import org.eclipse.emf.ecore.EClass; |
48 | import org.eclipse.emf.ecore.EReference; | 48 | import org.eclipse.emf.ecore.EEnum; |
49 | import org.eclipse.emf.ecore.EStructuralFeature; | 49 | import org.eclipse.emf.ecore.EEnumLiteral; |
50 | import org.eclipse.emf.ecore.resource.Resource; | 50 | import org.eclipse.emf.ecore.EObject; |
51 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | 51 | import org.eclipse.emf.ecore.EPackage; |
52 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | 52 | import org.eclipse.emf.ecore.EReference; |
53 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; | 53 | import org.eclipse.emf.ecore.EStructuralFeature; |
54 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 54 | import org.eclipse.emf.ecore.resource.Resource; |
55 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 55 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
56 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; | 56 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; |
57 | import org.eclipse.xtend2.lib.StringConcatenation; | 57 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; |
58 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; | 58 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
59 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | 59 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
60 | import org.eclipse.xtext.xbase.lib.Exceptions; | 60 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; |
61 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | 61 | import org.eclipse.xtend2.lib.StringConcatenation; |
62 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | 62 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; |
63 | import org.eclipse.xtext.xbase.lib.InputOutput; | 63 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
64 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | 64 | import org.eclipse.xtext.xbase.lib.Exceptions; |
65 | import org.eclipse.xtext.xbase.lib.ListExtensions; | 65 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; |
66 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | 66 | import org.eclipse.xtext.xbase.lib.Functions.Function0; |
67 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | 67 | import org.eclipse.xtext.xbase.lib.Functions.Function1; |
68 | 68 | import org.eclipse.xtext.xbase.lib.InputOutput; | |
69 | @SuppressWarnings("all") | 69 | import org.eclipse.xtext.xbase.lib.IterableExtensions; |
70 | public class GeneratePledgeModels { | 70 | import org.eclipse.xtext.xbase.lib.ListExtensions; |
71 | public static void main(final String[] args) { | 71 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; |
72 | try { | 72 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
73 | final Injector x = new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); | 73 | import queries.Case_study_A; |
74 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 74 | import queries.FamilyTreeConstraints; |
75 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 75 | |
76 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); | 76 | @SuppressWarnings("all") |
77 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 77 | public class GeneratePledgeModels { |
78 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); | 78 | private static final int SIZE_LB = 20; |
79 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); | 79 | |
80 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 80 | private static final int SIZE_UB = 20; |
81 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); | 81 | |
82 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); | 82 | private static final int SIZE_MUL = 1; |
83 | ReteEngine.class.getClass(); | 83 | |
84 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); | 84 | private static final int SIZE_INC = 5; |
85 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); | 85 | |
86 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); | 86 | private static int REPS = 1; |
87 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | 87 | |
88 | long _currentTimeMillis = System.currentTimeMillis(); | 88 | private static final int RUNTIME = 600; |
89 | final Date date = new Date(_currentTimeMillis); | 89 | |
90 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); | 90 | private static final String DOMAIN = "FamilyTree"; |
91 | final String formattedDate = format.format(date); | 91 | |
92 | StringConcatenation _builder = new StringConcatenation(); | 92 | private static final boolean QUERIES = false; |
93 | _builder.append("inputs/"); | 93 | |
94 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); | 94 | private static final boolean INDIV_WRT = true; |
95 | StringConcatenation _builder_1 = new StringConcatenation(); | 95 | |
96 | _builder_1.append("output/"); | 96 | private static final boolean GLOBAL_WRT = true; |
97 | String _plus = (_builder_1.toString() + formattedDate); | 97 | |
98 | StringConcatenation _builder_2 = new StringConcatenation(); | 98 | private static final String q2t = new Function0<String>() { |
99 | _builder_2.append("/"); | 99 | @Override |
100 | String _plus_1 = (_plus + _builder_2); | 100 | public String apply() { |
101 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_1, ""); | 101 | String _xifexpression = null; |
102 | StringConcatenation _builder_3 = new StringConcatenation(); | 102 | if (GeneratePledgeModels.QUERIES) { |
103 | _builder_3.append("output/"); | 103 | _xifexpression = "Y"; |
104 | String _plus_2 = (_builder_3.toString() + formattedDate); | 104 | } else { |
105 | StringConcatenation _builder_4 = new StringConcatenation(); | 105 | _xifexpression = "N"; |
106 | _builder_4.append("/debug/"); | 106 | } |
107 | String _plus_3 = (_plus_2 + _builder_4); | 107 | return _xifexpression; |
108 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_3, ""); | 108 | } |
109 | workspace.initAndClear(); | 109 | }.apply(); |
110 | InputOutput.<String>println("Input and output workspaces are created"); | 110 | |
111 | final EcoreMetamodelDescriptor metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); | 111 | public static void main(final String[] args) { |
112 | final EList<EObject> partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); | 112 | try { |
113 | InputOutput.<String>println("DSL loaded"); | 113 | new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); |
114 | final int SIZE = 2; | 114 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
115 | int REPS = 1; | 115 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
116 | final int RUNTIME = 600; | 116 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); |
117 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | 117 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
118 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | 118 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); |
119 | LogicProblem problem = modelGenerationProblem.getOutput(); | 119 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); |
120 | debug.writeModel(problem, "problem.logicproblem"); | 120 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
121 | InputOutput.<String>println("Problem created"); | 121 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); |
122 | for (int i = 0; (i < REPS); i++) { | 122 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); |
123 | { | 123 | ReteEngine.class.getClass(); |
124 | ViatraReasoner reasoner = new ViatraReasoner(); | 124 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); |
125 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); | 125 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); |
126 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0)); | 126 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); |
127 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); | 127 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); |
128 | BigDecimal _bigDecimal = new BigDecimal("0.0"); | 128 | long _currentTimeMillis = System.currentTimeMillis(); |
129 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); | 129 | final Date date = new Date(_currentTimeMillis); |
130 | final TreeSet<String> knownStrings = new TreeSet<String>(); | 130 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); |
131 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2"); | 131 | final String formattedDate = format.format(date); |
132 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | 132 | StringConcatenation _builder = new StringConcatenation(); |
133 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { | 133 | _builder.append("inputs/"); |
134 | it.documentationLevel = DocumentationLevel.FULL; | 134 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); |
135 | DebugConfiguration _debugConfiguration = new DebugConfiguration(); | 135 | StringConcatenation _builder_1 = new StringConcatenation(); |
136 | final Procedure1<DebugConfiguration> _function_1 = (DebugConfiguration it_1) -> { | 136 | _builder_1.append("output/"); |
137 | it_1.logging = true; | 137 | final FileSystemWorkspace dataws = new FileSystemWorkspace(_builder_1.toString(), ""); |
138 | }; | 138 | StringConcatenation _builder_2 = new StringConcatenation(); |
139 | DebugConfiguration _doubleArrow = ObjectExtensions.<DebugConfiguration>operator_doubleArrow(_debugConfiguration, _function_1); | 139 | _builder_2.append("output/"); |
140 | it.debugCongiguration = _doubleArrow; | 140 | String _plus = (_builder_2.toString() + formattedDate); |
141 | it.runtimeLimit = RUNTIME; | 141 | StringConcatenation _builder_3 = new StringConcatenation(); |
142 | boolean _isEmpty = knownIntegers.isEmpty(); | 142 | _builder_3.append("/models/"); |
143 | boolean _not = (!_isEmpty); | 143 | String _plus_1 = (_plus + _builder_3); |
144 | if (_not) { | 144 | final FileSystemWorkspace modelsws = new FileSystemWorkspace(_plus_1, ""); |
145 | it.typeScopes.knownIntegers = knownIntegers; | 145 | StringConcatenation _builder_4 = new StringConcatenation(); |
146 | } | 146 | _builder_4.append("output/"); |
147 | boolean _isEmpty_1 = knownReals.isEmpty(); | 147 | String _plus_2 = (_builder_4.toString() + formattedDate); |
148 | boolean _not_1 = (!_isEmpty_1); | 148 | StringConcatenation _builder_5 = new StringConcatenation(); |
149 | if (_not_1) { | 149 | _builder_5.append("/"); |
150 | it.typeScopes.knownReals = knownReals; | 150 | String _plus_3 = (_plus_2 + _builder_5); |
151 | } | 151 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_3, ""); |
152 | }; | 152 | StringConcatenation _builder_6 = new StringConcatenation(); |
153 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); | 153 | _builder_6.append("output/"); |
154 | InputOutput.<String>println((("Run #" + Integer.valueOf(i)) + ":")); | 154 | String _plus_4 = (_builder_6.toString() + GeneratePledgeModels.DOMAIN); |
155 | final long startTime = System.currentTimeMillis(); | 155 | String _plus_5 = (_plus_4 + "-"); |
156 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); | 156 | String _plus_6 = (_plus_5 + formattedDate); |
157 | long _currentTimeMillis_1 = System.currentTimeMillis(); | 157 | StringConcatenation _builder_7 = new StringConcatenation(); |
158 | final long totalTime = (_currentTimeMillis_1 - startTime); | 158 | _builder_7.append("/debug/"); |
159 | InputOutput.<String>println(" Problem Solved"); | 159 | String _plus_7 = (_plus_6 + _builder_7); |
160 | GeneratePledgeModels.writeStats(solution, totalTime, solverConfig); | 160 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_7, ""); |
161 | if ((solution instanceof ModelResult)) { | 161 | workspace.initAndClear(); |
162 | GeneratePledgeModels.writeRepresentation(solution, workspace, i); | 162 | modelsws.initAndClear(); |
163 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, workspace, i, reasoner, modelGenerationProblem); | 163 | InputOutput.<String>println("Input and output workspaces are created"); |
164 | InputOutput.<String>println(" Solution saved and visualised"); | 164 | EcoreMetamodelDescriptor metamodel = null; |
165 | } else { | 165 | EList<EObject> partialModel = null; |
166 | String _string = solution.getClass().getSimpleName().toString(); | 166 | ViatraQuerySetDescriptor queries = null; |
167 | String _plus_4 = (" Returned: " + _string); | 167 | final String DOMAIN = GeneratePledgeModels.DOMAIN; |
168 | InputOutput.<String>println(_plus_4); | 168 | if (DOMAIN != null) { |
169 | } | 169 | switch (DOMAIN) { |
170 | final Runtime r = Runtime.getRuntime(); | 170 | case "Taxation": |
171 | r.gc(); | 171 | metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); |
172 | r.gc(); | 172 | partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); |
173 | r.gc(); | 173 | queries = GeneratePledgeModels.loadQueries(metamodel, Case_study_A.instance()); |
174 | Thread.sleep(3000); | 174 | break; |
175 | } | 175 | case "FamilyTree": |
176 | } | 176 | metamodel = GeneratePledgeModels.loadMetamodel(FamilytreePackage.eINSTANCE); |
177 | InputOutput.<String>println("---End---"); | 177 | partialModel = GeneratePledgeModels.loadPartialModel(inputs, "FamilyTree.xmi"); |
178 | } catch (Throwable _e) { | 178 | queries = GeneratePledgeModels.loadQueries(metamodel, FamilyTreeConstraints.instance()); |
179 | throw Exceptions.sneakyThrow(_e); | 179 | break; |
180 | } | 180 | default: |
181 | } | 181 | { |
182 | 182 | System.err.println("Unsupported Domain"); | |
183 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | 183 | throw new Exception(); |
184 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | 184 | } |
185 | final Function1<EClass, String> _function = (EClass s) -> { | 185 | } |
186 | return s.getName(); | 186 | } else { |
187 | }; | 187 | { |
188 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | 188 | System.err.println("Unsupported Domain"); |
189 | Set<Class> _keySet = classMap.keySet(); | 189 | throw new Exception(); |
190 | for (final Class elem : _keySet) { | 190 | } |
191 | typeMap.put( | 191 | } |
192 | e2l.TypeofEClass(trace, | 192 | InputOutput.<String>println("DSL loaded"); |
193 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | 193 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); |
194 | } | 194 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); |
195 | return typeMap; | 195 | LogicProblem problem = modelGenerationProblem.getOutput(); |
196 | } | 196 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelExtensionProblem = instanceModel2Logic.transform(modelGenerationProblem, partialModel); |
197 | 197 | problem = modelExtensionProblem.getOutput(); | |
198 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | 198 | if (GeneratePledgeModels.QUERIES) { |
199 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | 199 | Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration(); |
200 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | 200 | final TracedOutput<LogicProblem, Viatra2LogicTrace> validModelExtensionProblem = viatra2Logic.transformQueries(queries, modelExtensionProblem, _viatra2LogicConfiguration); |
201 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | 201 | problem = validModelExtensionProblem.getOutput(); |
202 | return it.getELiterals(); | 202 | } |
203 | }; | 203 | InputOutput.<String>println("Problem created"); |
204 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | 204 | PrintWriter global_writer = null; |
205 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | 205 | final String header = "domain, queries?,size,model?,timeout,measuredTime,TransformatonTime,SolverTime\n"; |
206 | return it.getEReferences(); | 206 | if (GeneratePledgeModels.GLOBAL_WRT) { |
207 | }; | 207 | URI _workspaceURI = workspace.getWorkspaceURI(); |
208 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | 208 | String _plus_8 = (_workspaceURI + "//_"); |
209 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | 209 | String _plus_9 = (_plus_8 + GeneratePledgeModels.DOMAIN); |
210 | return it.getEAttributes(); | 210 | String _plus_10 = (_plus_9 + Integer.valueOf(GeneratePledgeModels.SIZE_LB)); |
211 | }; | 211 | String _plus_11 = (_plus_10 + "to"); |
212 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | 212 | String _plus_12 = (_plus_11 + Integer.valueOf(GeneratePledgeModels.SIZE_UB)); |
213 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | 213 | String _plus_13 = (_plus_12 + "x"); |
214 | } | 214 | String _plus_14 = (_plus_13 + Integer.valueOf(GeneratePledgeModels.REPS)); |
215 | 215 | String _plus_15 = (_plus_14 + "q"); | |
216 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | 216 | String _plus_16 = (_plus_15 + GeneratePledgeModels.q2t); |
217 | EList<EObject> _xblockexpression = null; | 217 | String _plus_17 = (_plus_16 + "-"); |
218 | { | 218 | String _plus_18 = (_plus_17 + formattedDate); |
219 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 219 | String _plus_19 = (_plus_18 + ".csv"); |
220 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 220 | PrintWriter _printWriter = new PrintWriter(_plus_19); |
221 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | 221 | global_writer = _printWriter; |
222 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | 222 | global_writer.append(header); |
223 | } | 223 | } |
224 | return _xblockexpression; | 224 | int NEXT_INC = GeneratePledgeModels.SIZE_INC; |
225 | } | 225 | { |
226 | 226 | int size = GeneratePledgeModels.SIZE_LB; | |
227 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | 227 | boolean _while = (size <= GeneratePledgeModels.SIZE_UB); |
228 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | 228 | while (_while) { |
229 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | 229 | { |
230 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | 230 | int _NEXT_INC = NEXT_INC; |
231 | String _name = it_1.getName(); | 231 | NEXT_INC = (_NEXT_INC * GeneratePledgeModels.SIZE_MUL); |
232 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | 232 | PrintWriter indiv_writer = null; |
233 | }; | 233 | if (GeneratePledgeModels.INDIV_WRT) { |
234 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | 234 | URI _workspaceURI_1 = workspace.getWorkspaceURI(); |
235 | }; | 235 | String _plus_20 = (_workspaceURI_1 + "//__"); |
236 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | 236 | String _plus_21 = (_plus_20 + GeneratePledgeModels.DOMAIN); |
237 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | 237 | String _plus_22 = (_plus_21 + "Sz"); |
238 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | 238 | String _plus_23 = (_plus_22 + Integer.valueOf(size)); |
239 | return res; | 239 | String _plus_24 = (_plus_23 + "x"); |
240 | } | 240 | String _plus_25 = (_plus_24 + Integer.valueOf(GeneratePledgeModels.REPS)); |
241 | 241 | String _plus_26 = (_plus_25 + "q"); | |
242 | public static void writeInterpretation(final LogicResult solution, final Logic2Ecore logic2Ecore, final ReasonerWorkspace workspace, final int i, final ViatraReasoner reasoner, final TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | 242 | String _plus_27 = (_plus_26 + GeneratePledgeModels.q2t); |
243 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | 243 | String _plus_28 = (_plus_27 + "-"); |
244 | int _size = interpretations.size(); | 244 | String _plus_29 = (_plus_28 + formattedDate); |
245 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 245 | String _plus_30 = (_plus_29 + |
246 | for (final Integer interpIndex : _doubleDotLessThan) { | 246 | ".csv"); |
247 | { | 247 | PrintWriter _printWriter_1 = new PrintWriter(_plus_30); |
248 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | 248 | indiv_writer = _printWriter_1; |
249 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | 249 | indiv_writer.append(header); |
250 | StringConcatenation _builder = new StringConcatenation(); | 250 | } |
251 | _builder.append("solution"); | 251 | InputOutput.println(); |
252 | _builder.append(i); | 252 | InputOutput.<String>println(((("DOMAIN: " + GeneratePledgeModels.DOMAIN) + ", SIZE=") + Integer.valueOf(size))); |
253 | _builder.append("_"); | 253 | for (int i = 0; (i < GeneratePledgeModels.REPS); i++) { |
254 | _builder.append(interpIndex); | 254 | { |
255 | _builder.append(".xmi"); | 255 | InputOutput.<String>print((("<<Run number " + Integer.valueOf(i)) + ">> : ")); |
256 | workspace.writeModel(model, _builder.toString()); | 256 | ViatraReasoner reasoner = new ViatraReasoner(); |
257 | } | 257 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); |
258 | } | 258 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0), Integer.valueOf(10), Integer.valueOf(20), Integer.valueOf(30), Integer.valueOf(40), Integer.valueOf(50)); |
259 | } | 259 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); |
260 | 260 | BigDecimal _bigDecimal = new BigDecimal("0.0"); | |
261 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final int i) { | 261 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); |
262 | final EList<Object> representations = solution.getRepresentation(); | 262 | final TreeSet<String> knownStrings = new TreeSet<String>(); |
263 | int _size = representations.size(); | 263 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2", "r3", "r4", "r5", "r6"); |
264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 264 | final int curSize = size; |
265 | for (final Integer representationIndex : _doubleDotLessThan) { | 265 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); |
266 | { | 266 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { |
267 | final Object representation = representations.get((representationIndex).intValue()); | 267 | it.documentationLevel = DocumentationLevel.NONE; |
268 | if ((representation instanceof PartialInterpretation)) { | 268 | it.runtimeLimit = GeneratePledgeModels.RUNTIME; |
269 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | 269 | it.typeScopes.minNewElements = curSize; |
270 | StringConcatenation _builder = new StringConcatenation(); | 270 | boolean _isEmpty = knownReals.isEmpty(); |
271 | _builder.append("solution"); | 271 | boolean _not = (!_isEmpty); |
272 | _builder.append(i); | 272 | if (_not) { |
273 | _builder.append("_"); | 273 | it.typeScopes.knownReals = knownReals; |
274 | _builder.append(representationIndex); | 274 | } |
275 | _builder.append(".gml"); | 275 | }; |
276 | workspace.writeText(_builder.toString(), gml); | 276 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); |
277 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | 277 | final long startTime = System.currentTimeMillis(); |
278 | StringConcatenation _builder_1 = new StringConcatenation(); | 278 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); |
279 | _builder_1.append("solution"); | 279 | long _currentTimeMillis_1 = System.currentTimeMillis(); |
280 | _builder_1.append(i); | 280 | final long measuredTime = (_currentTimeMillis_1 - startTime); |
281 | _builder_1.append("_"); | 281 | InputOutput.<String>print("<<END"); |
282 | _builder_1.append(representationIndex); | 282 | Class<? extends LogicResult> _class = solution.getClass(); |
283 | _builder_1.append(".png"); | 283 | String _string = Boolean.valueOf(Objects.equal(_class, ModelResultImpl.class)).toString(); |
284 | png.writeToFile(workspace, _builder_1.toString()); | 284 | String _plus_31 = ((((((GeneratePledgeModels.DOMAIN + ",") + Boolean.valueOf(GeneratePledgeModels.QUERIES)) + ",") + Integer.valueOf(size)) + ",") + _string); |
285 | } else { | 285 | String _plus_32 = (_plus_31 + |
286 | StringConcatenation _builder_2 = new StringConcatenation(); | 286 | ","); |
287 | _builder_2.append("solution"); | 287 | String _plus_33 = (_plus_32 + Integer.valueOf(GeneratePledgeModels.RUNTIME)); |
288 | _builder_2.append(representationIndex); | 288 | String _plus_34 = (_plus_33 + ","); |
289 | _builder_2.append(".txt"); | 289 | String _plus_35 = (_plus_34 + Double.valueOf((measuredTime / 1000.0))); |
290 | workspace.writeText(_builder_2.toString(), representation.toString()); | 290 | String _plus_36 = (_plus_35 + ","); |
291 | } | 291 | int _transformationTime = solution.getStatistics().getTransformationTime(); |
292 | } | 292 | double _divide = (_transformationTime / 1000.0); |
293 | } | 293 | String _plus_37 = (_plus_36 + Double.valueOf(_divide)); |
294 | } | 294 | String _plus_38 = (_plus_37 + |
295 | 295 | ","); | |
296 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | 296 | int _solverTime = solution.getStatistics().getSolverTime(); |
297 | String _xblockexpression = null; | 297 | double _divide_1 = (_solverTime / 1000.0); |
298 | { | 298 | String _plus_39 = (_plus_38 + Double.valueOf(_divide_1)); |
299 | final Statistics stats = solution.getStatistics(); | 299 | final String toAddtoCSV = (_plus_39 + "\n"); |
300 | InputOutput.<String>println(" Statistics:"); | 300 | if (GeneratePledgeModels.GLOBAL_WRT) { |
301 | Object _xifexpression = null; | 301 | global_writer.append(toAddtoCSV); |
302 | if ((config.typeScopes.maxNewElements == 2147483647)) { | 302 | } |
303 | _xifexpression = "*"; | 303 | if (GeneratePledgeModels.INDIV_WRT) { |
304 | } else { | 304 | indiv_writer.append(toAddtoCSV); |
305 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); | 305 | } |
306 | } | 306 | InputOutput.<String>println((("->" + Double.valueOf((measuredTime / 1000.0))) + "s")); |
307 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); | 307 | try { |
308 | String _plus_1 = (_plus + "]"); | 308 | if ((solution instanceof ModelResult)) { |
309 | InputOutput.<String>println(_plus_1); | 309 | String _plus_40 = (Integer.valueOf(size) + "_"); |
310 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); | 310 | String _plus_41 = (_plus_40 + Integer.valueOf(i)); |
311 | } | 311 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, modelsws, _plus_41, reasoner, modelGenerationProblem); |
312 | return _xblockexpression; | 312 | InputOutput.<String>println(" (XMI Success)"); |
313 | } | 313 | } |
314 | } | 314 | } catch (final Throwable _t) { |
315 | if (_t instanceof Exception) { | ||
316 | final Exception e = (Exception)_t; | ||
317 | String _message = e.getMessage(); | ||
318 | String _plus_42 = (" (XMI Error)" + _message); | ||
319 | System.err.println(_plus_42); | ||
320 | } else { | ||
321 | throw Exceptions.sneakyThrow(_t); | ||
322 | } | ||
323 | } | ||
324 | try { | ||
325 | if ((solution instanceof ModelResult)) { | ||
326 | String _plus_40 = (Integer.valueOf(size) + "_"); | ||
327 | String _plus_41 = (_plus_40 + Integer.valueOf(i)); | ||
328 | GeneratePledgeModels.writeRepresentation(solution, modelsws, _plus_41); | ||
329 | InputOutput.<String>println(" (VIZ Success) >>"); | ||
330 | } | ||
331 | } catch (final Throwable _t) { | ||
332 | if (_t instanceof Exception) { | ||
333 | final Exception e = (Exception)_t; | ||
334 | String _message = e.getMessage(); | ||
335 | String _plus_42 = (" (VIZ Error)" + _message); | ||
336 | String _plus_43 = (_plus_42 + ">>"); | ||
337 | System.err.println(_plus_43); | ||
338 | } else { | ||
339 | throw Exceptions.sneakyThrow(_t); | ||
340 | } | ||
341 | } | ||
342 | InputOutput.println(); | ||
343 | final Runtime r = Runtime.getRuntime(); | ||
344 | r.gc(); | ||
345 | r.gc(); | ||
346 | r.gc(); | ||
347 | Thread.sleep(3000); | ||
348 | } | ||
349 | } | ||
350 | if (GeneratePledgeModels.INDIV_WRT) { | ||
351 | indiv_writer.close(); | ||
352 | } | ||
353 | } | ||
354 | int _size = size; | ||
355 | size = (_size + NEXT_INC); | ||
356 | _while = (size <= GeneratePledgeModels.SIZE_UB); | ||
357 | } | ||
358 | } | ||
359 | if (GeneratePledgeModels.GLOBAL_WRT) { | ||
360 | global_writer.close(); | ||
361 | } | ||
362 | } catch (Throwable _e) { | ||
363 | throw Exceptions.sneakyThrow(_e); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | ||
368 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | ||
369 | final Function1<EClass, String> _function = (EClass s) -> { | ||
370 | return s.getName(); | ||
371 | }; | ||
372 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | ||
373 | Set<Class> _keySet = classMap.keySet(); | ||
374 | for (final Class elem : _keySet) { | ||
375 | typeMap.put( | ||
376 | e2l.TypeofEClass(trace, | ||
377 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | ||
378 | } | ||
379 | return typeMap; | ||
380 | } | ||
381 | |||
382 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | ||
383 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | ||
384 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | ||
385 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | ||
386 | return it.getELiterals(); | ||
387 | }; | ||
388 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | ||
389 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | ||
390 | return it.getEReferences(); | ||
391 | }; | ||
392 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | ||
393 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | ||
394 | return it.getEAttributes(); | ||
395 | }; | ||
396 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | ||
397 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | ||
398 | } | ||
399 | |||
400 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | ||
401 | EList<EObject> _xblockexpression = null; | ||
402 | { | ||
403 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
404 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
405 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | ||
406 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | ||
407 | } | ||
408 | return _xblockexpression; | ||
409 | } | ||
410 | |||
411 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | ||
412 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | ||
413 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | ||
414 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | ||
415 | String _name = it_1.getName(); | ||
416 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | ||
417 | }; | ||
418 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | ||
419 | }; | ||
420 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | ||
421 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | ||
422 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | ||
423 | return res; | ||
424 | } | ||
425 | |||
426 | public static void writeInterpretation(final LogicResult solution, final Logic2Ecore logic2Ecore, final ReasonerWorkspace workspace, final String id, final ViatraReasoner reasoner, final TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | ||
427 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | ||
428 | int _size = interpretations.size(); | ||
429 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
430 | for (final Integer interpIndex : _doubleDotLessThan) { | ||
431 | { | ||
432 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | ||
433 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | ||
434 | StringConcatenation _builder = new StringConcatenation(); | ||
435 | _builder.append("sol-"); | ||
436 | _builder.append(id); | ||
437 | _builder.append("_"); | ||
438 | _builder.append(interpIndex); | ||
439 | _builder.append(".xmi"); | ||
440 | workspace.writeModel(model, _builder.toString()); | ||
441 | } | ||
442 | } | ||
443 | } | ||
444 | |||
445 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final String id) { | ||
446 | final EList<Object> representations = solution.getRepresentation(); | ||
447 | int _size = representations.size(); | ||
448 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
449 | for (final Integer representationIndex : _doubleDotLessThan) { | ||
450 | { | ||
451 | final Object representation = representations.get((representationIndex).intValue()); | ||
452 | if ((representation instanceof PartialInterpretation)) { | ||
453 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | ||
454 | StringConcatenation _builder = new StringConcatenation(); | ||
455 | _builder.append("sol-"); | ||
456 | _builder.append(id); | ||
457 | _builder.append("_"); | ||
458 | _builder.append(representationIndex); | ||
459 | _builder.append(".gml"); | ||
460 | workspace.writeText(_builder.toString(), gml); | ||
461 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | ||
462 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
463 | _builder_1.append("sol-"); | ||
464 | _builder_1.append(id); | ||
465 | _builder_1.append("_"); | ||
466 | _builder_1.append(representationIndex); | ||
467 | _builder_1.append(".png"); | ||
468 | png.writeToFile(workspace, _builder_1.toString()); | ||
469 | } else { | ||
470 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
471 | _builder_2.append("sol-"); | ||
472 | _builder_2.append(representationIndex); | ||
473 | _builder_2.append(".txt"); | ||
474 | workspace.writeText(_builder_2.toString(), representation.toString()); | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | |||
480 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | ||
481 | String _xblockexpression = null; | ||
482 | { | ||
483 | final Statistics stats = solution.getStatistics(); | ||
484 | InputOutput.<String>println(" Statistics:"); | ||
485 | Object _xifexpression = null; | ||
486 | if ((config.typeScopes.maxNewElements == 2147483647)) { | ||
487 | _xifexpression = "*"; | ||
488 | } else { | ||
489 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); | ||
490 | } | ||
491 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); | ||
492 | String _plus_1 = (_plus + "]"); | ||
493 | InputOutput.<String>println(_plus_1); | ||
494 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); | ||
495 | } | ||
496 | return _xblockexpression; | ||
497 | } | ||
498 | } | ||