diff options
author | 2021-01-22 00:50:08 +0100 | |
---|---|---|
committer | 2021-01-22 00:50:08 +0100 | |
commit | 8ac747b1b84513c70f8445a7c84c6a3644a1f6fa (patch) | |
tree | 7dcb0ae4b0c62c5528be51e9396185fc9b7274a7 /Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend | |
parent | Major MM update + Refactor VQL + post-meeting approach change (diff) | |
download | VIATRA-Generator-8ac747b1b84513c70f8445a7c84c6a3644a1f6fa.tar.gz VIATRA-Generator-8ac747b1b84513c70f8445a7c84c6a3644a1f6fa.tar.zst VIATRA-Generator-8ac747b1b84513c70f8445a7c84c6a3644a1f6fa.zip |
implement ignored attribute values as a config option
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend | 33 |
1 files changed, 33 insertions, 0 deletions
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) { |