aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src
diff options
context:
space:
mode:
authorLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-05-17 01:58:13 -0400
committerLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-05-17 01:58:13 -0400
commit48871e1be75169e4e3768a7c0c47791e02c7e634 (patch)
treecfcd4e4fdc0dea4f4b0102a610459ed7509f47f8 /Tests/MODELS2020-CaseStudies/case.study.pledge.run/src
parentAdjust Taxation model. (diff)
downloadVIATRA-Generator-48871e1be75169e4e3768a7c0c47791e02c7e634.tar.gz
VIATRA-Generator-48871e1be75169e4e3768a7c0c47791e02c7e634.tar.zst
VIATRA-Generator-48871e1be75169e4e3768a7c0c47791e02c7e634.zip
update measurements setup. make archives.
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl45
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql356
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql51
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java13
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend196
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend360
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend61
7 files changed, 33 insertions, 1049 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl
deleted file mode 100644
index 66ae728e..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/NewOCLFileX.ocl
+++ /dev/null
@@ -1,45 +0,0 @@
1import 'file:/Users/Aren Babikian/git/VIATRA-Attributes/case.study.a.model/model/Taxation.ecore'
2
3package 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:
30let val:Real =self.details->asOrderedSet()->first().distance in
31self.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
45endpackage \ No newline at end of file
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
deleted file mode 100644
index 03e6847d..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A.vql
+++ /dev/null
@@ -1,356 +0,0 @@
1package queries
2
3import "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})
12pattern 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}
21pattern 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}
27pattern x_inv03_hasAll(dep : Dependent) {
28 Dependent.allowances(dep, _);
29}
30
31//inv5 - oclIsTypeOf - handled here
32@Constraint(message = "inv05", severity = "error", key = {inc})
33pattern 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}
50pattern 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})
61pattern 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})
74pattern 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})
84pattern 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}
101pattern x_inv08_notEI(type : Employment_Income) {
102 Employment_Income(type);
103}
104pattern x_inv08_noType(inc : Income) {
105 Income.income_type(inc, _);
106}
107pattern 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})
118pattern 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})
126pattern inv11(exp : Expense) {
127 find x_inv11_incOver100(exp);
128 find x_inv11_incNotOver100(exp);
129}
130pattern 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}
138pattern 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})
153pattern 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}
161pattern x_inv12_notNonRes(tp : Non_Resident_Tax_Payer) {
162 Non_Resident_Tax_Payer(tp);
163}
164pattern 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})
171pattern 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}
177pattern 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@Constraint(message = "inv15", severity = "error", key = {ea})
204pattern inv15(ea : External_Allowance) {
205 External_Allowance.person(ea, child);
206 Household.children(h, child);//only one due to multiplicity
207 External_Allowance.reciver(ea, i);
208 Tax_Payer(i);
209 neg find x_inv15(h, i);
210} or {
211 External_Allowance.reciver(ea, i);
212 Dependent(i);
213}
214
215pattern x_inv15(h : Household, i : Tax_Payer) {
216 Household.parents.individual_A(h, i);
217} or {
218 Household.parents.individual_B(h, i);
219}
220
221//inv16-Tax_Card.tax_card_type is a derived feature
222
223//inv17-attribute-handled by multiplicity
224@Constraint(message = "inv17", severity = "error", key = {lur})
225pattern inv17(lur : Legal_Union_Record) {
226 Legal_Union_Record.start_year(lur, sy);
227 check(sy < 1950);
228} or {
229 Legal_Union_Record.start_year(lur, sy);
230 check(sy > 2018);
231}
232
233//inv18-MultiplicityChecked
234//inv19-MultiplicityChecked
235
236//inv20-Useless constraint since both edges are containment (TODOCheck)
237//OclIsUndefined-Handled by multiplicity
238@Constraint(message = "inv20", severity = "error", key = {lur})
239pattern inv20(lur : Legal_Union_Record) {
240 Legal_Union_Record.individual_A(lur, iA);
241 Legal_Union_Record.individual_B(lur, iB);
242 iA == iB;
243}
244//inv21-MultiplicityChecked
245//inv22-MultiplicityChecked
246//inv23-MultiplicityChecked
247//inv24-MultiplicityChecked
248//inv25-MultiplicityChecked
249//inv26-MultiplicityChanged
250//inv27-dupOfInv24
251//inv28-dubOfInv23
252//inv29-MultiplicityChanged
253//inv30-AttributeRemoved
254//inv31-AttributeRemoved
255//inv32-AttributeRemoved
256
257//inv33-attribute-handled by multiplicity
258@Constraint(message = "inv33", severity = "error", key = {p})
259pattern inv33(p : Physical_Person) {
260 Physical_Person.birth_year(p, by);
261 check(2018-by < 0);
262} or {
263 Physical_Person.birth_year(p, by);
264 check(2018-by > 100);
265}
266
267//inv34-attribute-handled by multiplicity
268@Constraint(message = "inv34", severity = "error", key = {p})
269pattern inv34(p : Physical_Person) {
270 Physical_Person.birth_month(p, birthMonth);
271 check(birthMonth < 1);
272} or {
273 Physical_Person.birth_month(p, birthMonth);
274 check(birthMonth > 12);
275}
276
277//inv35-attribute-handled by multiplicity
278@Constraint(message = "inv35", severity = "error", key = {p})
279pattern inv35(p : Physical_Person) {
280 Physical_Person.birth_day(p, birthDay);
281 check(birthDay < 1);
282} or {
283 Physical_Person.birth_day(p, birthDay);
284 check(birthDay > 28);
285}
286
287//inv36-AttributeRemoved
288//inv37-AttributeRemoved
289//inv38-AttributeRemoved
290//inv39-AttributeRemoved
291//inv40-AttributeRemoved
292//inv41-AttributeRemoved
293//inv42-AttributeRemoved
294//inv43-AttributeRemoved
295//inv44-AttributeRemoved
296//inv45-AttributeRemoved
297//inv46-AttributeRemoved
298
299//inv47-attributes-handled by multiplicity
300@Constraint(message = "inv47", severity = "error", key = {lur})
301pattern inv47(lur : Legal_Union_Record) {
302 Legal_Union_Record.end_year(lur, endY);
303 Legal_Union_Record.start_year(lur, startY);
304 neg find x_inv47(lur);
305 check(startY >= endY);
306} or {
307 Legal_Union_Record.end_year(lur, endY);
308 Legal_Union_Record.start_year(lur, startY);
309 check(endY!= -1);
310 check(startY >= endY);
311}
312pattern x_inv47(lur : Legal_Union_Record) {
313 Legal_Union_Record.separation_cause(lur, ::NONE);
314}
315
316//inv48-attributes-handled by multiplicity
317@Constraint(message = "inv48", severity = "error", key = {p})
318pattern inv48(p : Physical_Person) {
319 Physical_Person.disability_percentage(p, disPer);
320 check(disPer > 1.0);
321} or {
322 Physical_Person.disability_percentage(p, disPer);
323 check(disPer < 0.0);
324} or {
325 Physical_Person.disability_type(p, ::NONE);
326 Physical_Person.disability_percentage(p, disPer);
327 check(disPer != 0.0);
328} or {
329 neg find x_inv48(p);
330 Physical_Person.disability_percentage(p, disPer);
331 check(disPer == 0.0);
332}
333pattern x_inv48(p : Physical_Person) {
334 Physical_Person.disability_type(p, ::NONE);
335}
336
337//inv49-OclKindOf-handled by multiplicity
338@Constraint(message = "inv49", severity = "error", key = {lur})
339pattern inv49_A(lur : Legal_Union_Record) {
340 Legal_Union_Record.individual_A(lur, i);
341 Legal_Union_Record.individual_B(lur, i);
342}
343//inv49-OclKindOf-handled by multiplicity
344@Constraint(message = "inv49", severity = "error", key = {lur})
345pattern inv49_B(lur : Legal_Union_Record) {
346 Legal_Union_Record.individual_A(lur, i);
347 Dependent(i);
348} or {
349 Legal_Union_Record.individual_B(lur, i);
350 Dependent(i);
351}
352
353//inv50-MultiplicityChecked
354//inv51-MultiplicityChecked
355//inv52-MultiplicityChecked
356//inv53-MultiplicityChecked \ No newline at end of file
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql
deleted file mode 100644
index f11ef7b7..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_short.vql
+++ /dev/null
@@ -1,51 +0,0 @@
1package queries
2
3import "http:///TaxCard.ecore"
4
5//inv47-attributes-handled by multiplicity
6//@Constraint(message = "inv47", severity = "error", key = {lur})
7//pattern inv47(lur : Legal_Union_Record) {
8// Legal_Union_Record.end_year(lur, endY);
9// Legal_Union_Record.start_year(lur, startY);
10// neg find x_inv47(lur);
11// check(startY >= endY);
12//} or {
13// Legal_Union_Record.end_year(lur, endY);
14// Legal_Union_Record.start_year(lur, startY);
15// check(endY!= -1);
16// check(startY >= endY);
17//}
18//pattern x_inv47(lur : Legal_Union_Record) {
19// Legal_Union_Record.separation_cause(lur, ::NONE);
20//}
21//
22////inv17-attribute-handled by multiplicity
23//@Constraint(message = "inv17", severity = "error", key = {lur})
24//pattern inv17(lur : Legal_Union_Record) {
25// Legal_Union_Record.start_year(lur, sy);
26// check(sy < 1950);
27//} or {
28// Legal_Union_Record.start_year(lur, sy);
29// check(sy > 2018);
30//}
31
32////inv48-attributes-handled by multiplicity
33@Constraint(message = "inv48", severity = "error", key = {p})
34pattern inv48(p : Physical_Person) {
35 Physical_Person.disability_percentage(p, disPer);
36 check(disPer > 1.0);
37} or {
38 Physical_Person.disability_percentage(p, disPer);
39 check(disPer < 0.0);
40} or {
41 Physical_Person.disability_type(p, ::NONE);
42 Physical_Person.disability_percentage(p, disPer);
43 check(disPer != 0.0);
44} or {
45 neg find x_inv48(p);
46 Physical_Person.disability_percentage(p, disPer);
47 check(disPer == 0.0);
48}
49pattern x_inv48(p : Physical_Person) {
50 Physical_Person.disability_type(p, ::NONE);
51} \ No newline at end of file
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java
deleted file mode 100644
index 044d2651..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/ConfigGenerator.java
+++ /dev/null
@@ -1,13 +0,0 @@
1package run;
2
3import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor;
4
5public class ConfigGenerator {
6 public static void main(String[] args) {
7 String errorMessages = StandaloneScriptExecutor.executeScript("config/taxation.vsconfig");
8 if(errorMessages!=null) {
9 System.out.println(errorMessages);
10 }
11 }
12
13}
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend
deleted file mode 100644
index ccb0d7b3..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend
+++ /dev/null
@@ -1,196 +0,0 @@
1package run
2
3import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification
4import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript
5import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.FileSpecification
6import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.GenerationTask
7import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.IntervallNumber
8import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ObjectTypeScope
9import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RuntimeEntry
10import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpecification
11import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor
12import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor
13import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
14import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
15import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor
16import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
17import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
18import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
19import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult
20import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult
21import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore
22import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor
23import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
24import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml
25import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner
26import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration
27import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser
28import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace
29import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
30import java.io.PrintWriter
31import java.math.BigDecimal
32import java.text.SimpleDateFormat
33import java.util.ArrayList
34import java.util.Date
35import java.util.HashMap
36import java.util.List
37import java.util.Map
38import org.eclipse.core.runtime.NullProgressMonitor
39import org.eclipse.emf.ecore.EAttribute
40import org.eclipse.emf.ecore.EClass
41import org.eclipse.emf.ecore.EEnum
42import org.eclipse.emf.ecore.EEnumLiteral
43import org.eclipse.emf.ecore.EObject
44import org.eclipse.emf.ecore.EPackage
45import org.eclipse.emf.ecore.EReference
46import org.eclipse.emf.ecore.resource.Resource
47import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
48import org.eclipse.viatra.query.runtime.api.IQueryGroup
49
50class GenerateFromConfig {
51 static val SIZE_LB = 200
52 static val SIZE_UB = 200
53 static val SIZE_MUL = 1
54 static val SIZE_INC = 5
55
56 static var REPS = 3
57 static val RUNTIME = 600
58
59 static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite"
60 static val QUERIES = true
61 static val INITIAL = true
62 static val INDIV_WRT = false
63 static val GLOBAL_WRT = false
64 static val q2t = if(QUERIES) "Y" else "N"
65
66 def static void main(String[] args) {
67 Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl)
68
69 // Workspace setup
70 val Date date = new Date(System.currentTimeMillis)
71 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm");
72 val formattedDate = DOMAIN + "/" + format.format(date)
73
74 val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "")
75 workspace.initAndClear
76
77 println("Input and output workspaces are created")
78
79 val executor = new ScriptExecutor
80 val path = "config//generic" + DOMAIN + ".vsconfig"
81 var ConfigurationScript config = StandaloneScriptExecutor.loadScript(path)
82
83 println("Config File loaded")
84
85 // /////////////////////////
86 // BEGIN RUN
87 var PrintWriter global_writer = null
88 val header = "domain, queries?,size,model?,timeout,measuredTime,TransformatonTime,SolverTime\n"
89 if (GLOBAL_WRT) {
90 global_writer = new PrintWriter(
91 workspace.workspaceURI + "//_" + DOMAIN + SIZE_LB + "to" + SIZE_UB + "x" + REPS + "q" + q2t + "-" +
92 formattedDate + ".csv")
93 global_writer.append(header)
94 }
95
96 var NEXT_INC = SIZE_INC
97 for (var size = SIZE_LB; size <= SIZE_UB; size += NEXT_INC) {
98 NEXT_INC *= SIZE_MUL
99
100 var PrintWriter indiv_writer = null
101 if (INDIV_WRT) {
102 indiv_writer = new PrintWriter( // TODO
103 workspace.workspaceURI + "//__" + DOMAIN + "Sz" + size + "x" + REPS + "q" + q2t + "-" + formattedDate +
104 ".csv")
105 indiv_writer.append(header)
106 }
107
108 println()
109 println("<<DOMAIN: " + DOMAIN + ", SIZE=" + size + ">>")
110
111// for (var i = 0; i < REPS; i++) {
112//
113// print("<<Run number " + i + ">> : ")
114 // /////////////////////////////////////////////////////
115 // Define Config File
116// val knownIntegers = new ArrayList<Integer>
117// knownIntegers.addAll(0, 10, 20, 30, 40, 50)
118//
119// val knownReals = new ArrayList<BigDecimal>
120// knownReals.addAll(new BigDecimal("0.0"))
121//
122// val knownStrings = new ArrayList<String>
123// knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6")
124
125 val outputPath = "output/" + formattedDate + "/size" + size + "/models/"
126 val debugPath = "output/" + formattedDate + "/size" + size + "/debug/"
127 val logPath = debugPath + "log.txt"
128 val statsPath = debugPath + "statistics.csv"
129
130 // Adjust configuration
131 val genTask = config.commands.get(0) as GenerationTask
132 if(!QUERIES) genTask.patterns = null
133 if(!INITIAL) genTask.partialModel = null
134 genTask.runs = REPS
135
136 val scopeSpec = genTask.scope as ScopeSpecification
137 val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope
138 val interval = objScope.number as IntervallNumber
139 interval.min = size
140 interval.maxUnlimited = true
141
142 val configScope = genTask.config as ConfigSpecification
143 val runtimeEntry = configScope.entries.get(0) as RuntimeEntry
144 runtimeEntry.millisecLimit = RUNTIME
145
146 // TODO add known ints, reals, string...
147 val debug = genTask.debugFolder as FileSpecification
148 debug.path = debugPath
149 val output = genTask.tagetFolder as FileSpecification
150 output.path = outputPath
151 val log = genTask.targetLogFile as FileSpecification
152 log.path = logPath
153 val stats = genTask.targetStatisticsFile as FileSpecification
154 stats.path = statsPath
155
156// workspace.writeModel(config, '''x.xmi''')
157 val startTime = System.currentTimeMillis
158 executor.executeScript(config, new NullProgressMonitor)
159 val measuredTime = System.currentTimeMillis - startTime
160
161 println("<<END ->" + measuredTime / 1000.0 + "s >>\n")
162
163// val toAddtoCSV = DOMAIN + "," + QUERIES + "," + size + "," +
164// (solution.class == ModelResultImpl).toString + "," + RUNTIME + "," + measuredTime / 1000.0 + "," +
165// solution.statistics.transformationTime / 1000.0 + "," + solution.statistics.solverTime / 1000.0 +
166// "\n"
167//
168// if(GLOBAL_WRT) global_writer.append(toAddtoCSV)
169// if(INDIV_WRT) indiv_writer.append(toAddtoCSV)
170// solution.writeStats(totalTime, solverConfig)
171 // Run Garbage Collector
172// val Runtime r = Runtime.getRuntime();
173// r.gc();
174// r.gc();
175// r.gc();
176// Thread.sleep(3000)
177// }
178 if(INDIV_WRT) indiv_writer.close
179 }
180 if(GLOBAL_WRT) global_writer.close
181 }
182
183 def static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) {
184 val stats = solution.statistics
185 println(" Statistics:")
186// for (e : stats.entries.filter[name.substring(0, 9) == "_Solution"]) {
187// println(" " + e.name + ": " + (e as IntStatisticEntry).value + " ms")
188// }
189 println(
190 " #new nodes : [" + config.typeScopes.minNewElements + ".." +
191 (if(config.typeScopes.maxNewElements == 2147483647) "*" else config.typeScopes.maxNewElements) + "]")
192 println(" \"solve\" time: " + time as double / 1000 + " s")
193
194// println("<<End Statistics>>")
195 }
196}
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
deleted file mode 100644
index 23a34bf1..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GeneratePledgeModels.xtend
+++ /dev/null
@@ -1,360 +0,0 @@
1package run
2
3import Taxation.TaxationPackage
4import familytree.FamilytreePackage
5import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
6import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration
7import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
8import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor
9import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel
10import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
12import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
13import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult
14import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult
15import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.impl.ModelResultImpl
16import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore
17import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic
18import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration
19import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor
20import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic
21import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
22import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml
23import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner
24import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration
25import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser
26import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace
27import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
28import java.io.PrintWriter
29import java.math.BigDecimal
30import java.text.SimpleDateFormat
31import java.util.Date
32import java.util.HashMap
33import java.util.List
34import java.util.Map
35import java.util.TreeSet
36import org.eclipse.emf.common.util.EList
37import org.eclipse.emf.ecore.EAttribute
38import org.eclipse.emf.ecore.EClass
39import org.eclipse.emf.ecore.EEnum
40import org.eclipse.emf.ecore.EEnumLiteral
41import org.eclipse.emf.ecore.EObject
42import org.eclipse.emf.ecore.EPackage
43import org.eclipse.emf.ecore.EReference
44import org.eclipse.emf.ecore.resource.Resource
45import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
46import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup
47import org.eclipse.viatra.query.runtime.api.IQueryGroup
48import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine
49import queries.Case_study_A
50import queries.FamilyTreeConstraints
51
52class GeneratePledgeModels {
53static val SIZE_LB = 20
54static val SIZE_UB = 20
55static val SIZE_MUL = 1
56static val SIZE_INC = 5
57
58static var REPS = 1
59static val RUNTIME = 600
60
61static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation"
62static val QUERIES = false
63static val INDIV_WRT = true
64static val GLOBAL_WRT = true
65static val q2t = if(QUERIES) "Y" else "N"
66
67def static void main(String[] args) {
68 (new EMFPatternLanguageStandaloneSetup).createInjectorAndDoEMFRegistration
69 Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl)
70 Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem", new XMIResourceFactoryImpl)
71 Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel", new XMIResourceFactoryImpl)
72 ReteEngine.getClass
73 val Ecore2Logic ecore2Logic = new Ecore2Logic
74 val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic)
75 val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic)
76 val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic
77
78 // Workspace setup
79 val Date date = new Date(System.currentTimeMillis)
80 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm");
81 val formattedDate = format.format(date)
82
83 val inputs = new FileSystemWorkspace('''inputs/''', "")
84 val dataws = new FileSystemWorkspace('''output/''', "")
85 val modelsws = new FileSystemWorkspace('''output/''' + formattedDate + '''/models/''', "")
86 val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "")
87 val debug = new FileSystemWorkspace('''output/''' + DOMAIN + "-" + formattedDate + '''/debug/''', "")
88 workspace.initAndClear
89 modelsws.initAndClear
90
91 println("Input and output workspaces are created")
92
93 // //////////////////////////
94 // DOMAIN
95 var EcoreMetamodelDescriptor metamodel = null
96 var EList<EObject> partialModel = null
97 var ViatraQuerySetDescriptor queries = null
98 switch DOMAIN {
99 case "Taxation": {
100 metamodel = loadMetamodel(TaxationPackage.eINSTANCE)
101 partialModel = loadPartialModel(inputs, "Household.xmi")
102// queries = loadQueries(metamodel, Case_study_A.instance)
103 }
104 case "FamilyTree": {
105 metamodel = loadMetamodel(FamilytreePackage.eINSTANCE)
106 partialModel = loadPartialModel(inputs, "FamilyTree.xmi")
107// queries = loadQueries(metamodel, FamilyTreeConstraints.instance)
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
155 for (var i = 0; i < REPS; i++) {
156
157 print("<<Run number " + i + ">> : ")
158
159 var ViatraReasoner reasoner = new ViatraReasoner
160
161 // /////////////////////////////////////////////////////
162 // Define Config File
163 val knownIntegers = new TreeSet<Integer>
164 knownIntegers.addAll(0, 10, 20, 30, 40, 50)
165
166 val knownReals = new TreeSet<BigDecimal>
167 knownReals.addAll(new BigDecimal("0.0"))
168
169 val knownStrings = new TreeSet<String>
170 knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6")
171
172 val curSize = size
173 val solverConfig = new ViatraReasonerConfiguration => [
174 it.documentationLevel = DocumentationLevel::NONE
175// it.debugCongiguration = new DebugConfiguration => [logging = true]
176 it.runtimeLimit = RUNTIME
177 // it.typeScopes.maxNewElements = SIZE
178 it.typeScopes.minNewElements = curSize
179
180// if(!knownIntegers.isEmpty) it.typeScopes.knownIntegers = knownIntegers
181 if(!knownReals.isEmpty) it.typeScopes.knownReals = knownReals
182 // if(!knownStrings.isEmpty) it.typeScopes.knownStrings = knownStrings
183 ]
184
185 val startTime = System.currentTimeMillis
186 var solution = reasoner.solve(problem, solverConfig, debug)
187 val measuredTime = System.currentTimeMillis - startTime
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 {
226 if (solution instanceof ModelResult) {
227 solution.writeInterpretation(logic2Ecore, modelsws, size + "_" + i, reasoner, modelGenerationProblem)
228 println(" (XMI Success)")
229 }
230 } catch (Exception e) {
231 System.err.println(" (XMI Error)" + e.message)
232 }
233
234 try {
235 if (solution instanceof ModelResult) {
236 solution.writeRepresentation(modelsws, size + "_" + i)
237 println(" (VIZ Success) >>")
238 }
239 } catch (Exception e) {
240 System.err.println(" (VIZ Error)" + e.message + ">>")
241 }
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)
250 }
251 if(INDIV_WRT) indiv_writer.close
252}
253if(GLOBAL_WRT) global_writer.close
254 }
255
256 def
257
258static Map<Type, Integer> getTypeMap(Map<Class, Integer> classMap, EcoreMetamodelDescriptor metamodel,
259 Ecore2Logic e2l, Ecore2Logic_Trace trace) {
260 val typeMap = new HashMap<Type, Integer>
261 val listMap = metamodel.classes.toMap[s|s.name]
262
263 for (Class elem : classMap.keySet) {
264 typeMap.put(e2l.TypeofEClass(
265 trace,
266 listMap.get(elem.simpleName)
267 ), classMap.get(elem))
268 }
269 return typeMap
270 }
271
272 def
273
274static loadMetamodel(EPackage pckg) {
275 val List<EClass> classes = pckg.getEClassifiers.filter(EClass).toList
276 val List<EEnum> enums = pckg.getEClassifiers.filter(EEnum).toList
277 val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList
278 val List<EReference> references = classes.map[getEReferences].flatten.toList
279 val List<EAttribute> attributes = classes.map[getEAttributes].flatten.toList
280 return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes)
281 }
282
283 def
284
285static loadPartialModel(ReasonerWorkspace inputs, String path) {
286 Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl())
287 inputs.readModel(EObject, path).eResource.contents
288// inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList
289 }
290
291 def
292
293static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) {
294 val patterns = i.specifications.toList
295 val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet
296 val derivedFeatures = emptyMap
297 // NO DERIVED FEATURES
298// val derivedFeatures = new LinkedHashMap
299// derivedFeatures.put(i.type,metamodel.attributes.filter[it.name == "type"].head)
300// derivedFeatures.put(i.model,metamodel.references.filter[it.name == "model"].head)
301 val res = new ViatraQuerySetDescriptor(
302 patterns,
303 wfPatterns,
304 derivedFeatures
305 )
306 return res
307 }
308
309 def
310
311static writeInterpretation(LogicResult solution, Logic2Ecore logic2Ecore, ReasonerWorkspace workspace,
312 String id, ViatraReasoner reasoner, TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) {
313 val interpretations = reasoner.getInterpretations(solution as ModelResult)
314 for (interpIndex : 0 ..< interpretations.size) {
315// val extension b = new LogicStructureBuilder
316// val extension a = new LogicProblemBuilder
317 val interpretation = interpretations.get(interpIndex)
318 val model = logic2Ecore.transformInterpretation(interpretation, mgProb.trace)
319// println(model)
320 workspace.writeModel(model, '''sol-«id»_«interpIndex».xmi''')
321 }
322 }
323
324 def
325
326static writeRepresentation(LogicResult solution, ReasonerWorkspace workspace, String id) {
327 val representations = solution.representation
328 for (representationIndex : 0 ..< representations.size) {
329 val representation = representations.get(representationIndex)
330 if (representation instanceof PartialInterpretation) {
331 val gml = (new PartialInterpretation2Gml).transform(representation)
332 workspace.writeText('''sol-«id»_«representationIndex».gml''', gml)
333
334 val png = (new GraphvizVisualiser).visualiseConcretization(representation)
335// println(png)
336 png.writeToFile(workspace, '''sol-«id»_«representationIndex».png''')
337
338// workspace.writeModel(representation, '''solution«representationIndex».partialintrpretation''')
339 } else {
340 workspace.writeText('''sol-«representationIndex».txt''', representation.toString)
341 }
342 }
343 }
344
345 def
346
347static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) {
348 val stats = solution.statistics
349 println(" Statistics:")
350// for (e : stats.entries.filter[name.substring(0, 9) == "_Solution"]) {
351// println(" " + e.name + ": " + (e as IntStatisticEntry).value + " ms")
352// }
353 println(
354 " #new nodes : [" + config.typeScopes.minNewElements + ".." +
355 (if(config.typeScopes.maxNewElements == 2147483647) "*" else config.typeScopes.maxNewElements) + "]")
356 println(" \"solve\" time: " + time as double / 1000 + " s")
357
358// println("<<End Statistics>>")
359 }
360}
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend
index 98bf7c83..c84f55d3 100644
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend
+++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend
@@ -12,6 +12,7 @@ import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RuntimeEn
12import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpecification 12import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpecification
13import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor 13import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor
14import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor 14import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor
15import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace
15import java.text.SimpleDateFormat 16import java.text.SimpleDateFormat
16import java.util.Date 17import java.util.Date
17import org.apache.commons.cli.BasicParser 18import org.apache.commons.cli.BasicParser
@@ -22,6 +23,8 @@ import org.apache.commons.cli.Option
22import org.apache.commons.cli.Options 23import org.apache.commons.cli.Options
23import org.apache.commons.cli.ParseException 24import org.apache.commons.cli.ParseException
24import org.eclipse.core.runtime.NullProgressMonitor 25import org.eclipse.core.runtime.NullProgressMonitor
26import org.eclipse.emf.ecore.resource.Resource
27import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
25 28
26class RunGeneratorConfig { 29class RunGeneratorConfig {
27 static var SIZE_LB = 20 30 static var SIZE_LB = 20
@@ -29,9 +32,10 @@ class RunGeneratorConfig {
29 static var HOUSEHOLD = 0 32 static var HOUSEHOLD = 0
30 33
31 static var RUNS = 10 34 static var RUNS = 10
32 static var RUNTIME = 900 35 static var MODELS = 10
36 static var RUNTIME = 1500
33 37
34 static var DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite" 38 static var DOMAIN = "FamilyTree" // "FamilyTree", "Satellite", "Taxation"
35 static val QUERIES = true 39 static val QUERIES = true
36 static val INITIAL = true 40 static val INITIAL = true
37 41
@@ -39,7 +43,7 @@ class RunGeneratorConfig {
39// Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl) 43// Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi", new XMIResourceFactoryImpl)
40// val workspace = new FileSystemWorkspace('''x/''', "") 44// val workspace = new FileSystemWorkspace('''x/''', "")
41// workspace.initAndClear 45// workspace.initAndClear
42 46
43 val options = new Options() 47 val options = new Options()
44 48
45 val lb = new Option("lb", "lowerBound", true, "generated model Lower bound") 49 val lb = new Option("lb", "lowerBound", true, "generated model Lower bound")
@@ -48,8 +52,11 @@ class RunGeneratorConfig {
48 val ub = new Option("ub", "upperBound", true, "generated model Upper bound") 52 val ub = new Option("ub", "upperBound", true, "generated model Upper bound")
49 options.addOption(ub) 53 options.addOption(ub)
50 54
51 val n = new Option("n", "numRuns", true, "number of runs") 55 val nr = new Option("nr", "numRuns", true, "number of runs")
52 options.addOption(n) 56 options.addOption(nr)
57
58 val nm = new Option("nm", "numModels", true, "number of models")
59 options.addOption(nm)
53 60
54 val rt = new Option("rt", "runtime", true, "runtime limit") 61 val rt = new Option("rt", "runtime", true, "runtime limit")
55 options.addOption(rt) 62 options.addOption(rt)
@@ -76,8 +83,10 @@ class RunGeneratorConfig {
76 if(lbIn !== null) SIZE_LB = Integer.parseInt(lbIn) 83 if(lbIn !== null) SIZE_LB = Integer.parseInt(lbIn)
77 val ubIn = cmd.getOptionValue("upperBound") 84 val ubIn = cmd.getOptionValue("upperBound")
78 if(ubIn !== null) SIZE_UB = Integer.parseInt(ubIn) 85 if(ubIn !== null) SIZE_UB = Integer.parseInt(ubIn)
79 val nIn = cmd.getOptionValue("numRuns") 86 val nrIn = cmd.getOptionValue("numRuns")
80 if(nIn !== null) RUNS = Integer.parseInt(nIn) 87 if(nrIn !== null) RUNS = Integer.parseInt(nrIn)
88 val nmIn = cmd.getOptionValue("numModels")
89 if(nmIn !== null) MODELS = Integer.parseInt(nmIn)
81 val rtIn = cmd.getOptionValue("runtime") 90 val rtIn = cmd.getOptionValue("runtime")
82 if(rtIn !== null) RUNTIME = Integer.parseInt(rtIn) 91 if(rtIn !== null) RUNTIME = Integer.parseInt(rtIn)
83 val dIn = cmd.getOptionValue("domain") 92 val dIn = cmd.getOptionValue("domain")
@@ -85,6 +94,7 @@ class RunGeneratorConfig {
85 val hhIn = cmd.getOptionValue("household") 94 val hhIn = cmd.getOptionValue("household")
86 if(hhIn !== null) HOUSEHOLD = Integer.parseInt(hhIn) 95 if(hhIn !== null) HOUSEHOLD = Integer.parseInt(hhIn)
87 96
97 val isTaxation = DOMAIN == "Taxation"
88 // Workspace setup 98 // Workspace setup
89 val Date date = new Date(System.currentTimeMillis) 99 val Date date = new Date(System.currentTimeMillis)
90 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm") 100 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm")
@@ -97,27 +107,23 @@ class RunGeneratorConfig {
97 // ///////////////////////// 107 // /////////////////////////
98 // BEGIN RUN 108 // BEGIN RUN
99 println( 109 println(
100 "<<DOMAIN: " + DOMAIN + ", SIZE=" + SIZE_LB + "to" + SIZE_UB + ", Runs=" + RUNS + ", Runtime=" + RUNTIME + 110 "<<DOMAIN: " + DOMAIN + ", SIZE=" + SIZE_LB + "to" + SIZE_UB + ", Runs=" + RUNS + ", ModelsPerRun=" +
101 ">>") 111 MODELS + ", Runtime=" + RUNTIME + ">>")
102 if (DOMAIN == "TaxationWithRoot") { 112 if (isTaxation) println("<<Households: " + HOUSEHOLD + ">>")
103 println("<<Households: " + HOUSEHOLD + ">>") 113
104 } 114 var naming = DOMAIN + "/size" + toStr(SIZE_LB) + "to" + toStr(SIZE_UB) + "r" + RUNS + "n" + MODELS + "rt" + RUNTIME
105 115 if (isTaxation) naming = naming + "hh" + HOUSEHOLD
106
107
108 val naming = DOMAIN + "/size" + toStr(SIZE_LB) + "to" + toStr(SIZE_UB) + "x" + RUNS
109
110 val outputPath = "measurements/" + "models/" + naming + "_" + formattedDate 116 val outputPath = "measurements/" + "models/" + naming + "_" + formattedDate
111 val debugPath = "measurements/" + "debug/" + naming + "_" + formattedDate 117 val debugPath = "measurements/" + "debug/" + naming + "_" + formattedDate
112 val logPath = debugPath + "/log.txt" 118 val logPath = debugPath + "/log.txt"
113 val statsPath = "measurements/" + "stats/" + naming + 119 val statsPath = "measurements/" + "stats/" + naming + "stats_" + formattedDate + ".csv"
114 "stats_" + formattedDate + ".csv"
115 120
116 // Basic Adjustments 121 // Basic Adjustments
117 val genTask = config.commands.get(1) as GenerationTask 122 val genTask = config.commands.get(1) as GenerationTask
118 if(!QUERIES) genTask.patterns = null 123 if(!QUERIES) genTask.patterns = null
119 if(!INITIAL) genTask.partialModel = null 124 if(!INITIAL) genTask.partialModel = null
120 genTask.runs = RUNS 125 genTask.runs = RUNS
126 genTask.number = MODELS
121 127
122 // Size 128 // Size
123 val scopeSpec = genTask.scope as ScopeSpecification 129 val scopeSpec = genTask.scope as ScopeSpecification
@@ -130,20 +136,19 @@ class RunGeneratorConfig {
130 interval.maxUnlimited = false 136 interval.maxUnlimited = false
131 interval.maxNumber = SIZE_UB 137 interval.maxNumber = SIZE_UB
132 } 138 }
133// workspace.writeModel(config, '''x.xmi''')
134
135
136 139
137 if (DOMAIN == "TaxationWithRoot") { 140 if (isTaxation) {
138 if (HOUSEHOLD > 0) { 141 if (HOUSEHOLD > 0) {
139 val pms = genTask.partialModel as PartialModelSpecification 142 val pms = genTask.partialModel as PartialModelSpecification
140 val me = pms.entry.get(0) as ModelEntry 143 val me = pms.entry.get(0) as ModelEntry
141 val fs = me.path as FileSpecification 144 val fs = me.path as FileSpecification
142 fs.path = "inputs/Resource" + HOUSEHOLD + "hh.xmi" 145 fs.path = "inputs/Resource" + HOUSEHOLD + "hh.xmi"
143 println("<<Using " + fs.path + " as initial model>>") 146 println("<<Using " + fs.path + " as initial model>>")
144 } 147 } else {
148 scopeSpec.scopes.remove(1)
149 }
145 } 150 }
146 151// workspace.writeModel(config, '''x.xmi''')
147 // Runtime 152 // Runtime
148 val configScope = genTask.config as ConfigSpecification 153 val configScope = genTask.config as ConfigSpecification
149 val runtimeEntry = configScope.entries.get(0) as RuntimeEntry 154 val runtimeEntry = configScope.entries.get(0) as RuntimeEntry
@@ -165,11 +170,11 @@ class RunGeneratorConfig {
165 170
166 println() 171 println()
167 } 172 }
168 173
169 static def String toStr(int i) { 174 static def String toStr(int i) {
170 var toAdd = "" 175 var toAdd = ""
171 if(i<100 && i != -1) toAdd = "0" 176 if(i < 100 && i != -1) toAdd = "0"
172 return toAdd+i 177 return toAdd + i
173 } 178 }
174 179
175} 180}