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-13 00:34:43 -0400
committerLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-05-13 00:34:43 -0400
commit4d914f3a77f64dc326933921b03735d4aabd9214 (patch)
tree2d2a7374c5becd54029e872cc38960cf3ce3610b /Tests/MODELS2020-CaseStudies/case.study.pledge.run/src
parentAdjust FamilyTree MM. Add new Taxation MM with possible Multiple Roots (diff)
downloadVIATRA-Generator-4d914f3a77f64dc326933921b03735d4aabd9214.tar.gz
VIATRA-Generator-4d914f3a77f64dc326933921b03735d4aabd9214.tar.zst
VIATRA-Generator-4d914f3a77f64dc326933921b03735d4aabd9214.zip
Adjust measurement setup. TaxationWithRoot support. JAR creation
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql338
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend125
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend123
3 files changed, 523 insertions, 63 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql
new file mode 100644
index 00000000..cd876200
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/queries/case_study_A_withRoot.vql
@@ -0,0 +1,338 @@
1package queries
2
3import "http:///TaxCardWithRoot.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})
186pattern inv15(ea : External_Allowance) {
187 neg find x_inv15(ea);
188}
189pattern 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})
207pattern 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})
221pattern 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})
241pattern 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})
251pattern 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})
261pattern 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})
283pattern 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} or {
289 Legal_Union_Record.end_year(lur, endY);
290 Legal_Union_Record.start_year(lur, startY);
291 check(endY!= -1);
292 check(startY >= endY);
293}
294pattern x_inv47(lur : Legal_Union_Record) {
295 Legal_Union_Record.separation_cause(lur, ::NONE);
296}
297
298//inv48-attributes-handled by multiplicity
299@Constraint(message = "inv48", severity = "error", key = {p})
300pattern inv48(p : Physical_Person) {
301 Physical_Person.disability_percentage(p, disPer);
302 check(disPer > 1.0);
303} or {
304 Physical_Person.disability_percentage(p, disPer);
305 check(disPer < 0.0);
306} or {
307 Physical_Person.disability_type(p, ::NONE);
308 Physical_Person.disability_percentage(p, disPer);
309 check(disPer != 0.0);
310} or {
311 neg find x_inv48(p);
312 Physical_Person.disability_percentage(p, disPer);
313 check(disPer == 0.0);
314}
315pattern x_inv48(p : Physical_Person) {
316 Physical_Person.disability_type(p, ::NONE);
317}
318
319//inv49-OclKindOf-handled by multiplicity
320@Constraint(message = "inv49", severity = "error", key = {lur})
321pattern inv49_A(lur : Legal_Union_Record) {
322 Legal_Union_Record.individual_A(lur, i);
323 Legal_Union_Record.individual_B(lur, i);
324}
325//inv49-OclKindOf-handled by multiplicity
326@Constraint(message = "inv49", severity = "error", key = {lur})
327pattern inv49_B(lur : Legal_Union_Record) {
328 Legal_Union_Record.individual_A(lur, i);
329 Dependent(i);
330} or {
331 Legal_Union_Record.individual_B(lur, i);
332 Dependent(i);
333}
334
335//inv50-MultiplicityChecked
336//inv51-MultiplicityChecked
337//inv52-MultiplicityChecked
338//inv53-MultiplicityChecked \ No newline at end of file
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
index 5cda1e16..ccb0d7b3 100644
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend
+++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend
@@ -48,15 +48,15 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
48import org.eclipse.viatra.query.runtime.api.IQueryGroup 48import org.eclipse.viatra.query.runtime.api.IQueryGroup
49 49
50class GenerateFromConfig { 50class GenerateFromConfig {
51 static val SIZE_LB = 20 51 static val SIZE_LB = 200
52 static val SIZE_UB = 20 52 static val SIZE_UB = 200
53 static val SIZE_MUL = 1 53 static val SIZE_MUL = 1
54 static val SIZE_INC = 5 54 static val SIZE_INC = 5
55 55
56 static var REPS = 5 56 static var REPS = 3
57 static val RUNTIME = 2100 57 static val RUNTIME = 600
58 58
59 static val DOMAIN = "Satellite" // "FamilyTree", "Taxation", "Satellite" 59 static val DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite"
60 static val QUERIES = true 60 static val QUERIES = true
61 static val INITIAL = true 61 static val INITIAL = true
62 static val INDIV_WRT = false 62 static val INDIV_WRT = false
@@ -69,7 +69,7 @@ class GenerateFromConfig {
69 // Workspace setup 69 // Workspace setup
70 val Date date = new Date(System.currentTimeMillis) 70 val Date date = new Date(System.currentTimeMillis)
71 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); 71 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm");
72 val formattedDate = DOMAIN + "-" + format.format(date) 72 val formattedDate = DOMAIN + "/" + format.format(date)
73 73
74 val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "") 74 val workspace = new FileSystemWorkspace('''output/''' + formattedDate + '''/''', "")
75 workspace.initAndClear 75 workspace.initAndClear
@@ -106,60 +106,59 @@ class GenerateFromConfig {
106 } 106 }
107 107
108 println() 108 println()
109 println("DOMAIN: " + DOMAIN + ", SIZE=" + size) 109 println("<<DOMAIN: " + DOMAIN + ", SIZE=" + size + ">>")
110 110
111 for (var i = 0; i < REPS; i++) { 111// for (var i = 0; i < REPS; i++) {
112 112//
113 print("<<Run number " + i + ">> : ") 113// print("<<Run number " + i + ">> : ")
114 114 // /////////////////////////////////////////////////////
115 115 // Define Config File
116 // ///////////////////////////////////////////////////// 116// val knownIntegers = new ArrayList<Integer>
117 // Define Config File 117// knownIntegers.addAll(0, 10, 20, 30, 40, 50)
118 val knownIntegers = new ArrayList<Integer> 118//
119 knownIntegers.addAll(0, 10, 20, 30, 40, 50) 119// val knownReals = new ArrayList<BigDecimal>
120 120// knownReals.addAll(new BigDecimal("0.0"))
121 val knownReals = new ArrayList<BigDecimal> 121//
122 knownReals.addAll(new BigDecimal("0.0")) 122// val knownStrings = new ArrayList<String>
123 123// knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6")
124 val knownStrings = new ArrayList<String> 124
125 knownStrings.addAll("r0", "r1", "r2", "r3", "r4", "r5", "r6") 125 val outputPath = "output/" + formattedDate + "/size" + size + "/models/"
126 126 val debugPath = "output/" + formattedDate + "/size" + size + "/debug/"
127 val outputPath = "output/" + formattedDate + "/size" + size + "/run" + i + "/models/" 127 val logPath = debugPath + "log.txt"
128 val debugPath = "output/" + formattedDate + "/size" + size + "/run" + i + "/debug/" 128 val statsPath = debugPath + "statistics.csv"
129 val logPath = debugPath + "log.txt" 129
130 val statsPath = debugPath + "statistics.csv" 130 // Adjust configuration
131 131 val genTask = config.commands.get(0) as GenerationTask
132 // Adjust configuration 132 if(!QUERIES) genTask.patterns = null
133 val genTask = config.commands.get(0) as GenerationTask 133 if(!INITIAL) genTask.partialModel = null
134 if(!QUERIES) genTask.patterns = null 134 genTask.runs = REPS
135 if(!INITIAL) genTask.partialModel = null 135
136 136 val scopeSpec = genTask.scope as ScopeSpecification
137 val scopeSpec = genTask.scope as ScopeSpecification 137 val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope
138 val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope 138 val interval = objScope.number as IntervallNumber
139 val interval = objScope.number as IntervallNumber 139 interval.min = size
140 interval.min = size 140 interval.maxUnlimited = true
141 interval.maxUnlimited = true 141
142 142 val configScope = genTask.config as ConfigSpecification
143 val configScope = genTask.config as ConfigSpecification 143 val runtimeEntry = configScope.entries.get(0) as RuntimeEntry
144 val runtimeEntry = configScope.entries.get(0) as RuntimeEntry 144 runtimeEntry.millisecLimit = RUNTIME
145 runtimeEntry.millisecLimit = RUNTIME 145
146 146 // TODO add known ints, reals, string...
147 // TODO add known ints, reals, string... 147 val debug = genTask.debugFolder as FileSpecification
148 val debug = genTask.debugFolder as FileSpecification 148 debug.path = debugPath
149 debug.path = debugPath 149 val output = genTask.tagetFolder as FileSpecification
150 val output = genTask.tagetFolder as FileSpecification 150 output.path = outputPath
151 output.path = outputPath 151 val log = genTask.targetLogFile as FileSpecification
152 val log = genTask.targetLogFile as FileSpecification 152 log.path = logPath
153 log.path = logPath 153 val stats = genTask.targetStatisticsFile as FileSpecification
154 val stats = genTask.targetStatisticsFile as FileSpecification 154 stats.path = statsPath
155 stats.path = statsPath
156 155
157// workspace.writeModel(config, '''x.xmi''') 156// workspace.writeModel(config, '''x.xmi''')
158 val startTime = System.currentTimeMillis 157 val startTime = System.currentTimeMillis
159 executor.executeScript(config, new NullProgressMonitor) 158 executor.executeScript(config, new NullProgressMonitor)
160 val measuredTime = System.currentTimeMillis - startTime 159 val measuredTime = System.currentTimeMillis - startTime
161 160
162 println("<<END ->" + measuredTime / 1000.0 + "s >>\n") 161 println("<<END ->" + measuredTime / 1000.0 + "s >>\n")
163 162
164// val toAddtoCSV = DOMAIN + "," + QUERIES + "," + size + "," + 163// val toAddtoCSV = DOMAIN + "," + QUERIES + "," + size + "," +
165// (solution.class == ModelResultImpl).toString + "," + RUNTIME + "," + measuredTime / 1000.0 + "," + 164// (solution.class == ModelResultImpl).toString + "," + RUNTIME + "," + measuredTime / 1000.0 + "," +
@@ -169,13 +168,13 @@ class GenerateFromConfig {
169// if(GLOBAL_WRT) global_writer.append(toAddtoCSV) 168// if(GLOBAL_WRT) global_writer.append(toAddtoCSV)
170// if(INDIV_WRT) indiv_writer.append(toAddtoCSV) 169// if(INDIV_WRT) indiv_writer.append(toAddtoCSV)
171// solution.writeStats(totalTime, solverConfig) 170// solution.writeStats(totalTime, solverConfig)
172 // Run Garbage Collector 171 // Run Garbage Collector
173 val Runtime r = Runtime.getRuntime(); 172// val Runtime r = Runtime.getRuntime();
174 r.gc(); 173// r.gc();
175 r.gc(); 174// r.gc();
176 r.gc(); 175// r.gc();
177 Thread.sleep(3000) 176// Thread.sleep(3000)
178 } 177// }
179 if(INDIV_WRT) indiv_writer.close 178 if(INDIV_WRT) indiv_writer.close
180 } 179 }
181 if(GLOBAL_WRT) global_writer.close 180 if(GLOBAL_WRT) global_writer.close
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
new file mode 100644
index 00000000..c2ad68f5
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/RunGeneratorConfig.xtend
@@ -0,0 +1,123 @@
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 java.text.SimpleDateFormat
14import java.util.Date
15import org.apache.commons.cli.CommandLine
16import org.apache.commons.cli.CommandLineParser
17import org.apache.commons.cli.HelpFormatter
18import org.apache.commons.cli.Option
19import org.apache.commons.cli.Options
20import org.apache.commons.cli.ParseException
21import org.eclipse.core.runtime.NullProgressMonitor
22import org.apache.commons.cli.BasicParser
23
24class RunGeneratorConfig {
25 static var SIZE = 20
26
27 static var RUNS = 10
28 static var RUNTIME = 600
29
30 static var DOMAIN = "FamilyTree" // "FamilyTree", "Taxation", "Satellite"
31 static val QUERIES = true
32 static val INITIAL = true
33
34 def static void main(String[] args) {
35
36 val options = new Options()
37
38 val s = new Option("s", "size", true, "generated model Lower bound")
39 options.addOption(s)
40
41 val n = new Option("n", "numRuns", true, "number of runs")
42 options.addOption(n)
43
44 val rt = new Option("rt", "runtime", true, "runtime limit")
45 options.addOption(rt)
46
47 val d = new Option("d", "domain", true, "domain")
48 options.addOption(d)
49
50 val CommandLineParser parser = new BasicParser
51 val formatter = new HelpFormatter()
52 var CommandLine cmd
53
54 try {
55 cmd = parser.parse(options, args)
56 } catch (ParseException e) {
57 System.out.println(e.getMessage())
58 formatter.printHelp("utility-name", options)
59 System.exit(1)
60 }
61
62 val sIn = cmd.getOptionValue("size")
63 if(sIn !== null) SIZE = Integer.parseInt(sIn)
64 val nIn = cmd.getOptionValue("numRuns")
65 if(nIn !== null) RUNS = Integer.parseInt(nIn)
66 val rtIn = cmd.getOptionValue("runtime")
67 if(rtIn !== null) RUNTIME = Integer.parseInt(rtIn)
68 val dIn = cmd.getOptionValue("domain")
69 if(dIn !== null) DOMAIN = dIn
70
71 // Workspace setup
72 val Date date = new Date(System.currentTimeMillis)
73 val SimpleDateFormat format = new SimpleDateFormat("dd-HHmm")
74 val formattedDate = format.format(date)
75
76 val executor = new ScriptExecutor
77 val path = "config//generic" + DOMAIN + ".vsconfig"
78 var ConfigurationScript config = StandaloneScriptExecutor.loadScript(path)
79
80 // /////////////////////////
81 // BEGIN RUN
82 println("<<DOMAIN: " + DOMAIN + ", SIZE=" + SIZE + ",Runs=" + RUNS + ",Runtime=" + RUNTIME+">>\n")
83
84 val outputPath = "measurements/" + "models/"+ DOMAIN + "/size" + SIZE + "_" + formattedDate
85 val debugPath = "measurements/" + "debug/" + DOMAIN + "/size" + SIZE + "_" + formattedDate
86 val logPath = debugPath + "/log.txt"
87 val statsPath = "measurements/" + "stats/" + DOMAIN + "/size" + SIZE + "x" + RUNS + "stats_" + formattedDate + ".csv"
88
89 // Basic Adjustments
90 val genTask = config.commands.get(1) as GenerationTask
91 if(!QUERIES) genTask.patterns = null
92 if(!INITIAL) genTask.partialModel = null
93 genTask.runs = RUNS
94
95 // Size
96 val scopeSpec = genTask.scope as ScopeSpecification
97 val objScope = scopeSpec.scopes.get(0) as ObjectTypeScope
98 val interval = objScope.number as IntervallNumber
99 interval.min = SIZE
100 interval.maxUnlimited = true
101
102 // Runtime
103 val configScope = genTask.config as ConfigSpecification
104 val runtimeEntry = configScope.entries.get(0) as RuntimeEntry
105 runtimeEntry.millisecLimit = RUNTIME
106
107 // Output locations
108 val debug = genTask.debugFolder as FileSpecification
109 debug.path = debugPath
110 val output = genTask.tagetFolder as FileSpecification
111 output.path = outputPath
112 val log = genTask.targetLogFile as FileSpecification
113 log.path = logPath
114 val stats = genTask.targetStatisticsFile as FileSpecification
115 stats.path = statsPath
116
117 // Run Generator
118 executor.executeScript(config, new NullProgressMonitor)
119
120 println()
121 }
122
123}