diff options
author | 2019-10-29 17:33:59 +0100 | |
---|---|---|
committer | 2019-10-29 17:33:59 +0100 | |
commit | 78b145df05795a71bef18c73526b0c8ff6a53e7e (patch) | |
tree | a721e49904f752b7252657237e559c7691dc60bc /Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend | |
parent | Polyhedron solver SAT fix and initial scope filtering (diff) | |
download | VIATRA-Generator-78b145df05795a71bef18c73526b0c8ff6a53e7e.tar.gz VIATRA-Generator-78b145df05795a71bef18c73526b0c8ff6a53e7e.tar.zst VIATRA-Generator-78b145df05795a71bef18c73526b0c8ff6a53e7e.zip |
MeasurementScriptRunner fix
Diffstat (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend')
-rw-r--r-- | Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend index bfbbf329..1127f01a 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend | |||
@@ -1,11 +1,14 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run.script | 1 | package hu.bme.mit.inf.dslreasoner.run.script |
2 | 2 | ||
3 | import com.google.gson.Gson | 3 | import com.google.gson.Gson |
4 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolver | ||
5 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolverConfiguration | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EClassMapper | 6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EClassMapper |
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | 8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration |
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
8 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 10 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration | ||
9 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes |
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral |
@@ -138,12 +141,10 @@ class MeasurementScriptRunner { | |||
138 | Thread.sleep(800) | 141 | Thread.sleep(800) |
139 | } | 142 | } |
140 | 143 | ||
141 | private def runExperiment(int modelSize) { | 144 | private def createViatraConfig() { |
142 | if (script.solver != Solver.ViatraSolver) { | ||
143 | throw new IllegalArgumentException("Only VIATRA-Generator is supported") | ||
144 | } | ||
145 | val config = new ViatraReasonerConfiguration | 145 | val config = new ViatraReasonerConfiguration |
146 | config.solutionScope.numberOfRequiredSolutions = 1 | 146 | config.debugConfiguration.partialInterpretatioVisualiser = null |
147 | config.searchSpaceConstraints.additionalGlobalConstraints += metamodelLoader.additionalConstraints | ||
147 | config.scopePropagatorStrategy = switch (script.scopePropagator) { | 148 | config.scopePropagatorStrategy = switch (script.scopePropagator) { |
148 | case none: | 149 | case none: |
149 | ScopePropagatorStrategy.None | 150 | ScopePropagatorStrategy.None |
@@ -187,11 +188,28 @@ class MeasurementScriptRunner { | |||
187 | default: | 188 | default: |
188 | throw new IllegalArgumentException("Unknown scope propagator: " + script.scopePropagator) | 189 | throw new IllegalArgumentException("Unknown scope propagator: " + script.scopePropagator) |
189 | } | 190 | } |
191 | config | ||
192 | } | ||
193 | |||
194 | private def createAlloyConfig() { | ||
195 | val config = new AlloySolverConfiguration | ||
196 | config | ||
197 | } | ||
198 | |||
199 | private def createConfig(int modelSize) { | ||
200 | val config = switch (solver : script.solver) { | ||
201 | case ViatraSolver: createViatraConfig() | ||
202 | case AlloySolver: createAlloyConfig() | ||
203 | default: throw new IllegalArgumentException("Unknown solver: " + solver) | ||
204 | } | ||
205 | config.solutionScope.numberOfRequiredSolutions = 1 | ||
190 | config.runtimeLimit = script.timeout | 206 | config.runtimeLimit = script.timeout |
191 | config.documentationLevel = if(script.saveTemporaryFiles) DocumentationLevel.NORMAL else DocumentationLevel.NONE | 207 | config.documentationLevel = if(script.saveTemporaryFiles) DocumentationLevel.NORMAL else DocumentationLevel.NONE |
192 | config.debugConfiguration.partialInterpretatioVisualiser = null | 208 | config |
193 | config.searchSpaceConstraints.additionalGlobalConstraints += metamodelLoader.additionalConstraints | 209 | } |
194 | 210 | ||
211 | private def runExperiment(int modelSize) { | ||
212 | val config = createConfig(modelSize) | ||
195 | val modelLoadingStart = System.nanoTime | 213 | val modelLoadingStart = System.nanoTime |
196 | val metamodelDescriptor = metamodelLoader.loadMetamodel | 214 | val metamodelDescriptor = metamodelLoader.loadMetamodel |
197 | val partialModelDescriptor = metamodelLoader.loadPartialModel | 215 | val partialModelDescriptor = metamodelLoader.loadPartialModel |
@@ -214,8 +232,8 @@ class MeasurementScriptRunner { | |||
214 | new Viatra2LogicConfiguration | 232 | new Viatra2LogicConfiguration |
215 | ).output | 233 | ).output |
216 | initializeScope(config, modelSize, problem, ecore2Logic, modelGeneration.trace) | 234 | initializeScope(config, modelSize, problem, ecore2Logic, modelGeneration.trace) |
217 | if (script.propagatedConstraints == ScopeConstraints.hints) { | 235 | if (config instanceof ViatraReasonerConfiguration && script.propagatedConstraints == ScopeConstraints.hints) { |
218 | config.hints = metamodelLoader.getHints(ecore2Logic, modelGeneration.trace) | 236 | (config as ViatraReasonerConfiguration).hints = metamodelLoader.getHints(ecore2Logic, modelGeneration.trace) |
219 | } | 237 | } |
220 | val domain2LogicTransformationTime = System.nanoTime - domain2LogicTransformationStart | 238 | val domain2LogicTransformationTime = System.nanoTime - domain2LogicTransformationStart |
221 | 239 | ||
@@ -223,7 +241,11 @@ class MeasurementScriptRunner { | |||
223 | outputWorkspace.writeModel(problem, "initial.logicproblem") | 241 | outputWorkspace.writeModel(problem, "initial.logicproblem") |
224 | } | 242 | } |
225 | 243 | ||
226 | val solver = new ViatraReasoner | 244 | val solver = switch (solver : script.solver) { |
245 | case ViatraSolver: new ViatraReasoner | ||
246 | case AlloySolver: new AlloySolver | ||
247 | default: throw new IllegalArgumentException("Unknown solver: " + solver) | ||
248 | } | ||
227 | val result = solver.solve(problem, config, outputWorkspace) | 249 | val result = solver.solve(problem, config, outputWorkspace) |
228 | val statistics = result.statistics | 250 | val statistics = result.statistics |
229 | statistics.entries += createIntStatisticEntry => [ | 251 | statistics.entries += createIntStatisticEntry => [ |
@@ -253,7 +275,7 @@ class MeasurementScriptRunner { | |||
253 | new ExperimentResult(result.class.simpleName, statistics, modelResult) | 275 | new ExperimentResult(result.class.simpleName, statistics, modelResult) |
254 | } | 276 | } |
255 | 277 | ||
256 | private def initializeScope(ViatraReasonerConfiguration config, int modelSize, LogicProblem problem, | 278 | private def initializeScope(LogicSolverConfiguration config, int modelSize, LogicProblem problem, |
257 | EClassMapper eClassMapper, Ecore2Logic_Trace trace) { | 279 | EClassMapper eClassMapper, Ecore2Logic_Trace trace) { |
258 | val knownElements = initializeKnownElements(problem, config.typeScopes) | 280 | val knownElements = initializeKnownElements(problem, config.typeScopes) |
259 | if (modelSize < 0) { | 281 | if (modelSize < 0) { |
@@ -278,7 +300,8 @@ class MeasurementScriptRunner { | |||
278 | val currentCount = if(knownInstances === null) 0 else knownInstances.size | 300 | val currentCount = if(knownInstances === null) 0 else knownInstances.size |
279 | val lowCount = Math.floor(modelSize * quantile.low) as int | 301 | val lowCount = Math.floor(modelSize * quantile.low) as int |
280 | val highCount = Math.ceil((modelSize + MODEL_SIZE_GAP) * quantile.high) as int | 302 | val highCount = Math.ceil((modelSize + MODEL_SIZE_GAP) * quantile.high) as int |
281 | config.typeScopes.minNewElementsByType.put(type, lowCount - currentCount) | 303 | // println('''«type.name» «lowCount» «highCount»''') |
304 | config.typeScopes.minNewElementsByType.put(type, Math.max(lowCount - currentCount, 0)) | ||
282 | config.typeScopes.maxNewElementsByType.put(type, highCount - currentCount) | 305 | config.typeScopes.maxNewElementsByType.put(type, highCount - currentCount) |
283 | } | 306 | } |
284 | } | 307 | } |