diff options
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend | 196 |
1 files changed, 0 insertions, 196 deletions
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 @@ | |||
1 | package run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification | ||
4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | ||
5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.FileSpecification | ||
6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.GenerationTask | ||
7 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.IntervallNumber | ||
8 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ObjectTypeScope | ||
9 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RuntimeEntry | ||
10 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpecification | ||
11 | import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor | ||
12 | import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor | ||
13 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
14 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
15 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | ||
19 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult | ||
20 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | ||
21 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | ||
22 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner | ||
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration | ||
27 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | ||
28 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
29 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | ||
30 | import java.io.PrintWriter | ||
31 | import java.math.BigDecimal | ||
32 | import java.text.SimpleDateFormat | ||
33 | import java.util.ArrayList | ||
34 | import java.util.Date | ||
35 | import java.util.HashMap | ||
36 | import java.util.List | ||
37 | import java.util.Map | ||
38 | import org.eclipse.core.runtime.NullProgressMonitor | ||
39 | import org.eclipse.emf.ecore.EAttribute | ||
40 | import org.eclipse.emf.ecore.EClass | ||
41 | import org.eclipse.emf.ecore.EEnum | ||
42 | import org.eclipse.emf.ecore.EEnumLiteral | ||
43 | import org.eclipse.emf.ecore.EObject | ||
44 | import org.eclipse.emf.ecore.EPackage | ||
45 | import org.eclipse.emf.ecore.EReference | ||
46 | import org.eclipse.emf.ecore.resource.Resource | ||
47 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
48 | import org.eclipse.viatra.query.runtime.api.IQueryGroup | ||
49 | |||
50 | class 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 | } | ||