aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Aren Babikian <aren.babikian@mail.mcgill.ca>2021-01-22 00:50:08 +0100
committerLibravatar Aren Babikian <aren.babikian@mail.mcgill.ca>2021-01-22 00:50:08 +0100
commit8ac747b1b84513c70f8445a7c84c6a3644a1f6fa (patch)
tree7dcb0ae4b0c62c5528be51e9396185fc9b7274a7
parentMajor MM update + Refactor VQL + post-meeting approach change (diff)
downloadVIATRA-Generator-8ac747b1b84513c70f8445a7c84c6a3644a1f6fa.tar.gz
VIATRA-Generator-8ac747b1b84513c70f8445a7c84c6a3644a1f6fa.tar.zst
VIATRA-Generator-8ac747b1b84513c70f8445a7c84c6a3644a1f6fa.zip
implement ignored attribute values as a config option
-rw-r--r--Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend24
-rw-r--r--Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend33
-rw-r--r--Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig1
-rw-r--r--Domains/crossingScenario/queries/crossingScenarioQueries.vql182
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend7
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend108
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend2
7 files changed, 226 insertions, 131 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
17import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic 17import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic
18import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation 18import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
19import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml 19import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml
20import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration
20import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser 21import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser
21import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace 22import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace
22import java.io.File 23import java.io.File
23import java.util.LinkedHashMap 24import java.util.LinkedHashMap
24import java.util.LinkedList 25import java.util.LinkedList
26import java.util.Map
25import java.util.Optional 27import java.util.Optional
26import org.eclipse.core.runtime.IProgressMonitor 28import org.eclipse.core.runtime.IProgressMonitor
27import org.eclipse.emf.common.util.URI 29import 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
30import org.eclipse.xtext.xbase.lib.Functions.Function1 30import org.eclipse.xtext.xbase.lib.Functions.Function1
31import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver 31import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver
32import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.NumericSolverSelection 32import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.NumericSolverSelection
33import java.util.HashMap
33 34
34class SolverLoader { 35class 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) {
diff --git a/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig b/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig
index 1db557a9..bee56db6 100644
--- a/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig
+++ b/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig
@@ -23,6 +23,7 @@ generate {
23 log-level = none, 23 log-level = none,
24 "numeric-solver" = "dreal-local", 24 "numeric-solver" = "dreal-local",
25 "dreal-local-path" = "/home/models/dreal4/bazel-bin/dreal/dreal", 25 "dreal-local-path" = "/home/models/dreal4/bazel-bin/dreal/dreal",
26 "ignored-attributes" = "CrossingScenario.maxTime=60",
26 "scopePropagator" = "polyhedral"} 27 "scopePropagator" = "polyhedral"}
27 28
28 runs = 1 29 runs = 1
diff --git a/Domains/crossingScenario/queries/crossingScenarioQueries.vql b/Domains/crossingScenario/queries/crossingScenarioQueries.vql
index 179da874..2b67e14c 100644
--- a/Domains/crossingScenario/queries/crossingScenarioQueries.vql
+++ b/Domains/crossingScenario/queries/crossingScenarioQueries.vql
@@ -429,97 +429,97 @@ pattern define_relation_noSelfRelation(a1:Actor, a2:Actor) {
429//CollisionExists 429//CollisionExists
430///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*////// 430///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
431 431
432//@Constraint(severity="error", key={c}, message="x") 432@Constraint(severity="error", key={c}, message="x")
433//pattern collisionExists_timeWithinBound(ss:CrossingScenario, c:CollisionExists) { 433pattern collisionExists_timeWithinBound(ss:CrossingScenario, c:CollisionExists) {
434// CrossingScenario.relations(ss, c); 434 CrossingScenario.relations(ss, c);
435// CrossingScenario.maxTime(ss, maxTime); 435 CrossingScenario.maxTime(ss, maxTime);
436// CollisionExists.collisionTime(c, cTime); 436 CollisionExists.collisionTime(c, cTime);
437// check(cTime >= maxTime);} 437 check(cTime >= maxTime);}
438// 438
439//@Constraint(severity="error", key={c}, message="x") 439@Constraint(severity="error", key={c}, message="x")
440//pattern collisionExists_timeNotNegative(c:CollisionExists) { 440pattern collisionExists_timeNotNegative(c:CollisionExists) {
441// CollisionExists. collisionTime(c, cTime); 441 CollisionExists. collisionTime(c, cTime);
442// check(cTime <= 0.0);} 442 check(cTime <= 0.0);}
443// 443
444//private pattern helper_getCollExistsTime(a1:Actor, a2: Actor, cTime:java Double) { 444private pattern helper_getCollExistsTime(a1:Actor, a2: Actor, cTime:java Double) {
445// CollisionExists.source(c, a1); 445 CollisionExists.source(c, a1);
446// CollisionExists.target(c, a2); 446 CollisionExists.target(c, a2);
447// CollisionExists. collisionTime(c, cTime); 447 CollisionExists. collisionTime(c, cTime);
448//} 448}
449// 449
450//private pattern helper_getYCoords(a:Actor, l:java Double, 450private pattern helper_getYCoords(a:Actor, l:java Double,
451// yPos:java Double, ySpeed:java Double) { 451 yPos:java Double, ySpeed:java Double) {
452// 452
453// Actor.length(a, l); 453 Actor.length(a, l);
454// Actor.yPos(a, yPos); 454 Actor.yPos(a, yPos);
455// Actor.ySpeed(a, ySpeed); 455 Actor.ySpeed(a, ySpeed);
456//} 456}
457// 457
458//private pattern helper_getAllYCoords(a1:Actor, a2: Actor, 458private pattern helper_getAllYCoords(a1:Actor, a2: Actor,
459// l1:java Double, l2:java Double, yPos1:java Double, yPos2:java Double, 459 l1:java Double, l2:java Double, yPos1:java Double, yPos2:java Double,
460// ySpeed1:java Double, ySpeed2:java Double) { 460 ySpeed1:java Double, ySpeed2:java Double) {
461// 461
462// find helper_getYCoords(a1, l1, yPos1, ySpeed1); 462 find helper_getYCoords(a1, l1, yPos1, ySpeed1);
463// find helper_getYCoords(a2, l2, yPos2, ySpeed2); 463 find helper_getYCoords(a2, l2, yPos2, ySpeed2);
464//} 464}
465// 465
466//private pattern helper_getXCoords(a:Actor, l:java Double, 466private pattern helper_getXCoords(a:Actor, l:java Double,
467// xPos:java Double, xSpeed:java Double) { 467 xPos:java Double, xSpeed:java Double) {
468// 468
469// Actor.length(a, l); 469 Actor.length(a, l);
470// Actor.xPos(a, xPos); 470 Actor.xPos(a, xPos);
471// Actor.xSpeed(a, xSpeed); 471 Actor.xSpeed(a, xSpeed);
472//} 472}
473// 473
474//private pattern helper_getAllXCoords(a1:Actor, a2: Actor, 474private pattern helper_getAllXCoords(a1:Actor, a2: Actor,
475// w1:java Double, w2:java Double, xPos1:java Double, xPos2:java Double, 475 w1:java Double, w2:java Double, xPos1:java Double, xPos2:java Double,
476// xSpeed1:java Double, xSpeed2:java Double) { 476 xSpeed1:java Double, xSpeed2:java Double) {
477// 477
478// find helper_getYCoords(a1, w1, xPos1, xSpeed1); 478 find helper_getYCoords(a1, w1, xPos1, xSpeed1);
479// find helper_getYCoords(a2, w2, xPos2, xSpeed2); 479 find helper_getYCoords(a2, w2, xPos2, xSpeed2);
480//} 480}
481// 481
482//@Constraint(severity="error", key={a1}, message="x") 482@Constraint(severity="error", key={a1}, message="x")
483//pattern collisionExists_defineCollision_y1(a1:Actor, a2:Actor) { 483pattern collisionExists_defineCollision_y1(a1:Actor, a2:Actor) {
484// 484
485// find helper_getCollExistsTime(a1, a2, cTime); 485 find helper_getCollExistsTime(a1, a2, cTime);
486// find helper_getAllYCoords(a1, a2, l1, l2, yPos1, yPos2, ySpeed1, ySpeed2); 486 find helper_getAllYCoords(a1, a2, l1, l2, yPos1, yPos2, ySpeed1, ySpeed2);
487// 487
488// //check(y_1_bottom > y_2_top 488 //check(y_1_bottom > y_2_top
489// check((yPos1 + (ySpeed1 * cTime)) - (l1/2) > (yPos2 + (ySpeed2 * cTime)) + (l2/2)); 489 check((yPos1 + (ySpeed1 * cTime)) - (l1/2) > (yPos2 + (ySpeed2 * cTime)) + (l2/2));
490//} 490}
491// 491
492//@Constraint(severity="error", key={a1}, message="x") 492@Constraint(severity="error", key={a1}, message="x")
493//pattern collisionExists_defineCollision_y2(a1:Actor, a2:Actor) { 493pattern collisionExists_defineCollision_y2(a1:Actor, a2:Actor) {
494// //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1 494 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
495// 495
496// find helper_getCollExistsTime(a1, a2, cTime); 496 find helper_getCollExistsTime(a1, a2, cTime);
497// find helper_getAllYCoords(a1, a2, l1, l2, yPos1, yPos2, ySpeed1, ySpeed2); 497 find helper_getAllYCoords(a1, a2, l1, l2, yPos1, yPos2, ySpeed1, ySpeed2);
498// 498
499// //check(y_1_top < y_2_bottom) 499 //check(y_1_top < y_2_bottom)
500// check((yPos1 + (ySpeed1 * cTime)) + (l1/2) < (yPos2 + (ySpeed2 * cTime)) - (l2/2)); 500 check((yPos1 + (ySpeed1 * cTime)) + (l1/2) < (yPos2 + (ySpeed2 * cTime)) - (l2/2));
501//} 501}
502// 502
503//@Constraint(severity="error", key={a1}, message="x") 503@Constraint(severity="error", key={a1}, message="x")
504//pattern collisionExists_defineCollision_x1(a1:Actor, a2:Actor) { 504pattern collisionExists_defineCollision_x1(a1:Actor, a2:Actor) {
505// 505
506// find helper_getCollExistsTime(a1, a2, cTime); 506 find helper_getCollExistsTime(a1, a2, cTime);
507// find helper_getAllYCoords(a1, a2, w1, w2, xPos1, xPos2, xSpeed1, xSpeed2); 507 find helper_getAllYCoords(a1, a2, w1, w2, xPos1, xPos2, xSpeed1, xSpeed2);
508// 508
509// //check(x_1_left > x_2_right) 509 //check(x_1_left > x_2_right)
510// check((xPos1 + (xSpeed1 * cTime)) - (w1/2) > (xPos2 + (xSpeed2 * cTime)) + (w2/2)); 510 check((xPos1 + (xSpeed1 * cTime)) - (w1/2) > (xPos2 + (xSpeed2 * cTime)) + (w2/2));
511//} 511}
512// 512
513//@Constraint(severity="error", key={a1}, message="x") 513@Constraint(severity="error", key={a1}, message="x")
514//pattern collisionExists_defineCollision_x2(a1:Actor, a2:Actor) { 514pattern collisionExists_defineCollision_x2(a1:Actor, a2:Actor) {
515// //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1 515 //This second one is required because we do not want to enforce both a1->c->a2 and a2->c->a1
516// 516
517// find helper_getCollExistsTime(a1, a2, cTime); 517 find helper_getCollExistsTime(a1, a2, cTime);
518// find helper_getAllYCoords(a1, a2, w1, w2, xPos1, xPos2, xSpeed1, xSpeed2); 518 find helper_getAllYCoords(a1, a2, w1, w2, xPos1, xPos2, xSpeed1, xSpeed2);
519// 519
520// //check(x_1_right < x_2_left) 520 //check(x_1_right < x_2_left)
521// check((xPos1 + (xSpeed1 * cTime)) + (w1/2) < (xPos2 + (xSpeed2 * cTime)) - (w2/2)); 521 check((xPos1 + (xSpeed1 * cTime)) + (w1/2) < (xPos2 + (xSpeed2 * cTime)) - (w2/2));
522//} 522}
523 523
524 524
525///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*////// 525///////*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*//////
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend
index d2b59754..7cec6327 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend
@@ -4,8 +4,8 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
4import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput 4import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
5import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem 5import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
6import java.util.List 6import java.util.List
7import java.util.Map
7import org.eclipse.emf.ecore.EObject 8import org.eclipse.emf.ecore.EObject
8import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes
9 9
10class InstanceModel2Logic { 10class InstanceModel2Logic {
11 val InstanceModel2PartialInterpretation instanceModel2PartialInterpretation = new InstanceModel2PartialInterpretation 11 val InstanceModel2PartialInterpretation instanceModel2PartialInterpretation = new InstanceModel2PartialInterpretation
@@ -13,9 +13,10 @@ class InstanceModel2Logic {
13 13
14 public def transform( 14 public def transform(
15 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, 15 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult,
16 List<EObject> objects) 16 List<EObject> objects,
17 Map<String, Map<String, String>> ignoredAttribs)
17 { 18 {
18 val res1 = instanceModel2PartialInterpretation.transform(metamodelTranslationResult,objects,true) 19 val res1 = instanceModel2PartialInterpretation.transform(metamodelTranslationResult, ignoredAttribs, objects,true)
19 this.partialInterpretation2Logic.transformPartialIntepretation2Logic(metamodelTranslationResult.output,res1) 20 this.partialInterpretation2Logic.transformPartialIntepretation2Logic(metamodelTranslationResult.output,res1)
20 return metamodelTranslationResult//.output 21 return metamodelTranslationResult//.output
21 } 22 }
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
index 94959025..f2f43aaa 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
@@ -3,6 +3,7 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
3import com.google.common.collect.ImmutableList 3import com.google.common.collect.ImmutableList
4import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic 4import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
5import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace 5import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
6import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration
6import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput 7import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
7import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes 8import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement 9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
@@ -33,7 +34,8 @@ class InstanceModel2PartialInterpretation {
33 34
34 public def transform( 35 public def transform(
35 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, 36 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult,
36 Resource resource, 37 Map<String, Map<String, String>> ignoredAttribs,
38 Resource resource,
37 boolean withID) 39 boolean withID)
38 { 40 {
39 val objectsBuilder = ImmutableList.builder 41 val objectsBuilder = ImmutableList.builder
@@ -49,11 +51,12 @@ class InstanceModel2PartialInterpretation {
49 } 51 }
50 } 52 }
51 val objects = objectsBuilder.build 53 val objects = objectsBuilder.build
52 return transform(metamodelTranslationResult,objects,withID) 54 return transform(metamodelTranslationResult, ignoredAttribs, objects, withID)
53 } 55 }
54 56
55 public def transform( 57 public def transform(
56 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, 58 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult,
59 Map<String, Map<String, String>> ignoredAttribs,
57 List<EObject> objects, 60 List<EObject> objects,
58 boolean withID) 61 boolean withID)
59 { 62 {
@@ -63,7 +66,7 @@ class InstanceModel2PartialInterpretation {
63 val referencesUsed = ecore2Logic.allReferencesInScope(ecore2LogicTrace).toSet 66 val referencesUsed = ecore2Logic.allReferencesInScope(ecore2LogicTrace).toSet
64 val attributesUsed = ecore2Logic.allAttributesInScope(ecore2LogicTrace).toSet 67 val attributesUsed = ecore2Logic.allAttributesInScope(ecore2LogicTrace).toSet
65 68
66 val typeScope = createTypeScopesFromKnownAttributeValues(objects,attributesUsed) 69 val typeScope = createTypeScopesFromKnownAttributeValues(objects,attributesUsed, ignoredAttribs)
67 val tracedOutput = partialInterpretationInitialiser.initialisePartialInterpretation(problem, typeScope) 70 val tracedOutput = partialInterpretationInitialiser.initialisePartialInterpretation(problem, typeScope)
68 val partialInterpretation = tracedOutput.output 71 val partialInterpretation = tracedOutput.output
69 val partialInterpretationTrace = tracedOutput.trace 72 val partialInterpretationTrace = tracedOutput.trace
@@ -119,23 +122,26 @@ class InstanceModel2PartialInterpretation {
119 122
120 // Transforming the attributes 123 // Transforming the attributes
121 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) { 124 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) {
122 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute) 125 val isIgnored = checkIfIgnored(source, attribute, ignoredAttribs)
123 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation) 126 if (!isIgnored) {
124 val sourceElement = source.lookup(object2DefinedElement) 127 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute)
125 if(attribute.isMany) { 128 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation)
126 val listOfTargets = source.eGet(attribute) as List<? extends EObject> 129 val sourceElement = source.lookup(object2DefinedElement)
127 for(target : listOfTargets) { 130 if(attribute.isMany) {
128 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace) 131 val listOfTargets = source.eGet(attribute) as List<? extends EObject>
129 if(value !== null) { 132 for(target : listOfTargets) {
130 translateLink(interpretation,sourceElement,value) 133 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace)
134 if(value !== null) {
135 translateLink(interpretation,sourceElement,value)
136 }
131 } 137 }
132 } 138 } else {
133 } else { 139 val target = source.eGet(attribute)
134 val target = source.eGet(attribute) 140 if(target !== null) {
135 if(target !== null) { 141 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace)
136 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace) 142 if(value !== null) {
137 if(value !== null) { 143 translateLink(interpretation,sourceElement,value)
138 translateLink(interpretation,sourceElement,value) 144 }
139 } 145 }
140 } 146 }
141 } 147 }
@@ -144,21 +150,29 @@ class InstanceModel2PartialInterpretation {
144 150
145 return partialInterpretation 151 return partialInterpretation
146 } 152 }
147 153
148 private def createTypeScopesFromKnownAttributeValues(List<EObject> objects, Set<EAttribute> attributesUsed) { 154 private def createTypeScopesFromKnownAttributeValues(
155 List<EObject> objects,
156 Set<EAttribute> attributesUsed,
157 Map<String, Map<String, String>> ignoredAttribs)
158 {
149 val Set<Integer> integers = new HashSet 159 val Set<Integer> integers = new HashSet
150 val Set<Double> reals = new HashSet 160 val Set<Double> reals = new HashSet
151 val Set<String> strings = new HashSet 161 val Set<String> strings = new HashSet
152 for(object: objects) { 162 for (object : objects) {
153 for(attribute : object.eClass.EAllAttributes.filter[attributesUsed.contains(it)]) { 163 for (attribute : object.eClass.EAllAttributes.filter[attributesUsed.contains(it)]) {
154 val value = object.eGet(attribute) 164 val isIgnored = checkIfIgnored(object, attribute, ignoredAttribs)
155 if(value !== null) { 165
156 if(value instanceof List<?>) { 166 if(!isIgnored) {
157 for(v : value) { 167 val value = object.eGet(attribute)
158 shortValue(v,integers,reals,strings) 168 if(value !== null) {
169 if(value instanceof List<?>) {
170 for(v : value) {
171 shortValue(v,integers,reals,strings)
172 }
173 } else {
174 shortValue(value,integers,reals,strings)
159 } 175 }
160 } else {
161 shortValue(value,integers,reals,strings)
162 } 176 }
163 } 177 }
164 } 178 }
@@ -169,6 +183,40 @@ class InstanceModel2PartialInterpretation {
169 it.knownStrings += strings 183 it.knownStrings += strings
170 ] 184 ]
171 } 185 }
186 private def boolean checkIfIgnored(
187 EObject object,
188 EAttribute attribute,
189 Map<String, Map<String, String>> ignoredAttribs
190 ) {
191 val classInIgnored = ignoredAttribs.get(object.eClass.name)
192 val mayIgnored = (
193 classInIgnored !== null && classInIgnored.containsKey(attribute.name))
194
195 var isIgnored = false
196 if (mayIgnored) {
197 val specificIgnoredValue = classInIgnored.get(attribute.name)
198 if (specificIgnoredValue.equals("*"))
199 isIgnored = true
200 else {
201 val value = object.eGet(attribute)
202 if (typeof(Number).isAssignableFrom(value.class)) {
203 isIgnored = (Double.valueOf(specificIgnoredValue) == value)
204 } else {
205 isIgnored = specificIgnoredValue.equals(value)
206 }
207 }
208 }
209 // DEBUG
210// println("DEBUG BEGINNING")
211// println(object)
212// println(attribute)
213// println(value)
214//
215// println("MAYIGNORE " + mayIgnored)
216// println("ISIGNORED " + isIgnored)
217 // END DEBUG
218 return isIgnored
219 }
172 private def dispatch shortValue(Boolean value, Set<Integer> integers, Set<Double> reals, Set<String> strings) { 220 private def dispatch shortValue(Boolean value, Set<Integer> integers, Set<Double> reals, Set<String> strings) {
173 // Do nothing 221 // Do nothing
174 } 222 }
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
index 759f434b..fbcd6e1d 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
@@ -16,6 +16,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKi
16import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold 16import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold
17import java.util.LinkedList 17import java.util.LinkedList
18import java.util.List 18import java.util.List
19import java.util.Map
19import java.util.Set 20import java.util.Set
20import org.eclipse.xtext.xbase.lib.Functions.Function1 21import org.eclipse.xtext.xbase.lib.Functions.Function1
21 22
@@ -78,6 +79,7 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration {
78 public var calculateObjectCreationCosts = false 79 public var calculateObjectCreationCosts = false
79 public NumericSolverSelection numericSolverSelection = NumericSolverSelection.DREAL_DOCKER //currently defaulted to DREAL 80 public NumericSolverSelection numericSolverSelection = NumericSolverSelection.DREAL_DOCKER //currently defaulted to DREAL
80 public var drealLocalPath = "<path-to-dreal>"; 81 public var drealLocalPath = "<path-to-dreal>";
82 public var Map<String, Map<String, String>> ignoredAttributesMap = null;
81 83
82 public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( 84 public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral(
83 PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) 85 PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp)