diff options
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src')
2 files changed, 50 insertions, 7 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend index d718bb91..3563163e 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend | |||
@@ -17,11 +17,13 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | |||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml |
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration | ||
20 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | 21 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser |
21 | import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace | 22 | import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace |
22 | import java.io.File | 23 | import java.io.File |
23 | import java.util.LinkedHashMap | 24 | import java.util.LinkedHashMap |
24 | import java.util.LinkedList | 25 | import java.util.LinkedList |
26 | import java.util.Map | ||
25 | import java.util.Optional | 27 | import java.util.Optional |
26 | import org.eclipse.core.runtime.IProgressMonitor | 28 | import org.eclipse.core.runtime.IProgressMonitor |
27 | import org.eclipse.emf.common.util.URI | 29 | import org.eclipse.emf.common.util.URI |
@@ -101,6 +103,13 @@ class GenerationTaskExecutor { | |||
101 | } | 103 | } |
102 | monitor.worked(50) | 104 | monitor.worked(50) |
103 | 105 | ||
106 | // 5. create a solver and a configuration | ||
107 | // 5.1 initialize | ||
108 | val solver = solverLoader.loadSolver(task.solver,configurationMap) | ||
109 | val objectiveSpecification = scriptExecutor.getObjectiveSpecification(task.objectives) | ||
110 | val objectiveEntries = objectiveSpecification?.entries ?: emptyList | ||
111 | val solverConfig = solverLoader.loadSolverConfig(task.solver,configurationMap,objectiveEntries,console) | ||
112 | |||
104 | // 4. translate all description to a logic problem | 113 | // 4. translate all description to a logic problem |
105 | monitor.subTask('''Translating all resources to logic''') | 114 | monitor.subTask('''Translating all resources to logic''') |
106 | var domain2LogicTransformationTime = System.nanoTime | 115 | var domain2LogicTransformationTime = System.nanoTime |
@@ -112,9 +121,15 @@ class GenerationTaskExecutor { | |||
112 | var modelGeneration = ecore2Logic.transformMetamodel(metamodelDescriptor,new Ecore2LogicConfiguration()) | 121 | var modelGeneration = ecore2Logic.transformMetamodel(metamodelDescriptor,new Ecore2LogicConfiguration()) |
113 | var problem = modelGeneration.output | 122 | var problem = modelGeneration.output |
114 | if(partialModelDescriptor !== null) { | 123 | if(partialModelDescriptor !== null) { |
124 | //get ignored attributes | ||
125 | var Map<String, Map<String, String>>ignoredAttributes = null | ||
126 | if (solverConfig instanceof ViatraReasonerConfiguration) | ||
127 | ignoredAttributes = (solverConfig as ViatraReasonerConfiguration).ignoredAttributesMap | ||
128 | |||
115 | problem = instanceModel2Logic.transform( | 129 | problem = instanceModel2Logic.transform( |
116 | modelGeneration, | 130 | modelGeneration, |
117 | partialModelDescriptor | 131 | partialModelDescriptor, |
132 | ignoredAttributes | ||
118 | ).output | 133 | ).output |
119 | } | 134 | } |
120 | if(queryDescriptor !== null){ | 135 | if(queryDescriptor !== null){ |
@@ -128,13 +143,8 @@ class GenerationTaskExecutor { | |||
128 | if(documentationLevel.atLeastNormal) { | 143 | if(documentationLevel.atLeastNormal) { |
129 | reasonerWorkspace.writeModel(problem,"generation.logicproblem") | 144 | reasonerWorkspace.writeModel(problem,"generation.logicproblem") |
130 | } | 145 | } |
146 | // END 4 | ||
131 | 147 | ||
132 | // 5. create a solver and a configuration | ||
133 | // 5.1 initialize | ||
134 | val solver = solverLoader.loadSolver(task.solver,configurationMap) | ||
135 | val objectiveSpecification = scriptExecutor.getObjectiveSpecification(task.objectives) | ||
136 | val objectiveEntries = objectiveSpecification?.entries ?: emptyList | ||
137 | val solverConfig = solverLoader.loadSolverConfig(task.solver,configurationMap,objectiveEntries,console) | ||
138 | // 5.2 set values that defined directly | 148 | // 5.2 set values that defined directly |
139 | solverConfig.solutionScope = new SolutionScope => [ | 149 | solverConfig.solutionScope = new SolutionScope => [ |
140 | it.numberOfRequiredSolutions = if(task.numberSpecified) { | 150 | it.numberOfRequiredSolutions = if(task.numberSpecified) { |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend index 94b84bc3..da8ca0eb 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend | |||
@@ -30,6 +30,7 @@ import org.eclipse.xtext.EcoreUtil2 | |||
30 | import org.eclipse.xtext.xbase.lib.Functions.Function1 | 30 | import org.eclipse.xtext.xbase.lib.Functions.Function1 |
31 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver | 31 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver |
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.NumericSolverSelection | 32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.NumericSolverSelection |
33 | import java.util.HashMap | ||
33 | 34 | ||
34 | class SolverLoader { | 35 | class SolverLoader { |
35 | def loadSolver(Solver solver, Map<String, String> config) { | 36 | def loadSolver(Solver solver, Map<String, String> config) { |
@@ -166,6 +167,10 @@ class SolverLoader { | |||
166 | default: throw new IllegalArgumentException("Unknown scope propagator: " + stringValue) | 167 | default: throw new IllegalArgumentException("Unknown scope propagator: " + stringValue) |
167 | } | 168 | } |
168 | } | 169 | } |
170 | if (config.containsKey("ignored-attributes")) { | ||
171 | val stringValue = config.get("ignored-attributes") | ||
172 | c.ignoredAttributesMap = parseIgnoredAttributes(stringValue) | ||
173 | } | ||
169 | for (objectiveEntry : objectiveEntries) { | 174 | for (objectiveEntry : objectiveEntries) { |
170 | val costObjectiveConfig = new CostObjectiveConfiguration | 175 | val costObjectiveConfig = new CostObjectiveConfiguration |
171 | switch (objectiveEntry) { | 176 | switch (objectiveEntry) { |
@@ -232,6 +237,34 @@ class SolverLoader { | |||
232 | throw new UnsupportedOperationException('''Unknown solver: «solver»''') | 237 | throw new UnsupportedOperationException('''Unknown solver: «solver»''') |
233 | } | 238 | } |
234 | } | 239 | } |
240 | |||
241 | def Map<String, Map<String, String>> parseIgnoredAttributes(String input) { | ||
242 | val Map<String, Map<String, String>> clAttVal = newHashMap | ||
243 | val List<String> entries = input.split(",") | ||
244 | //TODO add some validation here | ||
245 | for (entry : entries) { | ||
246 | val List<String> components = entry.split("=") | ||
247 | if (components.size != 2) | ||
248 | throw new IllegalArgumentException("Invalid ignoredAttributes Specification: \"" + entry + "\"") | ||
249 | |||
250 | val clAtt = components.get(0) | ||
251 | val List<String> clAttArray = clAtt.split("\\.") | ||
252 | if (clAttArray.size != 2) | ||
253 | throw new IllegalArgumentException("Invalid attribute specification : \"" + clAtt + "\"") | ||
254 | |||
255 | val c = clAttArray.get(0).strip | ||
256 | val a = clAttArray.get(1).strip | ||
257 | val v = components.get(1).strip | ||
258 | |||
259 | val clInMap = clAttVal.get(c) | ||
260 | if (clInMap === null) { | ||
261 | clAttVal.put(c, newHashMap(a -> v)) | ||
262 | } else { | ||
263 | clInMap.put(a, v) | ||
264 | } | ||
265 | } | ||
266 | return clAttVal | ||
267 | } | ||
235 | 268 | ||
236 | def dispatch void setRunIndex(AlloySolverConfiguration config, Map<String, String> parameters, int runIndex, | 269 | def dispatch void setRunIndex(AlloySolverConfiguration config, Map<String, String> parameters, int runIndex, |
237 | ScriptConsole console) { | 270 | ScriptConsole console) { |