Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Commit 56b9055

Browse files
Changed order of the pruning rules
1 parent f45da8b commit 56b9055

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

sansa-inference-common/src/main/scala/net/sansa_stack/inference/rules/minimizer/RuleDependencyGraphMinimizer.scala

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
3333
def batches: Seq[Batch] = Seq(
3434
Batch("Default Minimization", Once,
3535
RemoveLoops,
36-
RemoveCyclesInBothDirections,
37-
RemoveCyclesIfPredicateIsTC,
38-
RemoveEdgesWithCycleOverTCNode,
39-
RemoveEdgesWithPredicateAlreadyTC,
40-
RemoveEdgeIfLongerPathToSameNodeExists))
36+
RemoveEdgesWithCycleOverTCNode,
37+
RemoveEdgesWithPredicateAlreadyTC,
38+
RemoveEdgeIfLongerPathToSameNodeExists,
39+
RemoveCyclesInBothDirections
40+
// RemoveCyclesIfPredicateIsTC,
41+
42+
))
4143

4244
object RemoveLoops extends MinimizationRule {
4345
def apply(graph: RuleDependencyGraph): RuleDependencyGraph = {
4446
debug("removing non-TC loops")
4547
var edges2Remove = Seq[Graph[Rule, LDiEdge]#EdgeT]()
4648

4749
graph.nodes.toSeq.foreach(node => {
50+
debug(s"node " + node.value.getName)
4851

4952
val loopEdge = node.outgoing.find(_.target == node)
5053

@@ -284,19 +287,20 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
284287
val allCycles = cycleDetector2.findSimpleCycles()
285288

286289
graph.nodes.toSeq.foreach(node => {
287-
debug(s"NODE ${node.value}")
290+
debug(s"NODE ${node.value.getName}")
288291

289292
// get cycles of length 3
290-
val cycles = cycleDetector.findCyclesContainingVertex(node.value)
291-
debug(cycles.asScala.mkString(","))
293+
// val cycles = cycleDetector.findCyclesContainingVertex(node.value)
294+
// debug(cycles.asScala.mkString(","))
292295

293296
// cycles that contain the current node
294297
val cyclesWithNode: Buffer[Buffer[Rule]] = allCycles.asScala.filter(cycle => cycle.contains(node.value)).map(cycle => cycle.asScala)
298+
debug("Cycles: " + cyclesWithNode.map(c => c.map(r => r.getName)).mkString(","))
295299

296300
// cycles that use the same property
297301
val cyclesWithNodeSameProp: Map[Node, scala.List[Buffer[graph.EdgeT]]] = cyclesWithNode.map(cycle => {
298302

299-
debug("Cycle: " + cycle.mkString(", "))
303+
debug("Cycle: " + cycle.map(r => r.getName).mkString(", "))
300304

301305
// pairs of rules (r1, r2)
302306
var pairsOfRules = cycle zip cycle.tail
@@ -367,6 +371,8 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
367371

368372
new RuleDependencyGraph(newNodes, newEdges)
369373
}
374+
375+
override def debug(msg: => String): Unit = println(msg)
370376
}
371377

372378
object RemoveEdgeIfLongerPathToSameNodeExists extends MinimizationRule {
@@ -448,4 +454,5 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
448454

449455

450456

457+
451458
}

0 commit comments

Comments
 (0)