aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/construction/quasitree/JoinOrderingHeuristics.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/construction/quasitree/JoinOrderingHeuristics.java')
-rw-r--r--subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/construction/quasitree/JoinOrderingHeuristics.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/construction/quasitree/JoinOrderingHeuristics.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/construction/quasitree/JoinOrderingHeuristics.java
new file mode 100644
index 00000000..0ea7c1d9
--- /dev/null
+++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/construction/quasitree/JoinOrderingHeuristics.java
@@ -0,0 +1,49 @@
1/*******************************************************************************
2 * Copyright (c) 2004-2010 Gabor Bergmann and Daniel Varro
3 * This program and the accompanying materials are made available under the
4 * terms of the Eclipse Public License v. 2.0 which is available at
5 * http://www.eclipse.org/legal/epl-v20.html.
6 *
7 * SPDX-License-Identifier: EPL-2.0
8 *******************************************************************************/
9
10package tools.refinery.viatra.runtime.rete.construction.quasitree;
11
12import java.util.Comparator;
13
14import tools.refinery.viatra.runtime.rete.util.Options;
15import tools.refinery.viatra.runtime.rete.util.OrderingCompareAgent;
16
17/**
18 * @author Gabor Bergmann
19 *
20 */
21public class JoinOrderingHeuristics implements Comparator<JoinCandidate> {
22
23 @Override
24 public int compare(JoinCandidate jc1, JoinCandidate jc2) {
25 return new OrderingCompareAgent<JoinCandidate>(jc1, jc2) {
26 @Override
27 protected void doCompare() {
28 swallowBoolean(true && consider(preferTrue(a.isTrivial(), b.isTrivial()))
29 && consider(preferTrue(a.isSubsumption(), b.isSubsumption()))
30 && consider(preferTrue(a.isCheckOnly(), b.isCheckOnly()))
31 && consider(
32 Options.functionalDependencyOption == Options.FunctionalDependencyOption.OFF ?
33 dontCare() :
34 preferTrue(a.isHeath(), b.isHeath())
35 )
36 && consider(preferFalse(a.isDescartes(), b.isDescartes()))
37
38 // TODO main heuristic decisions
39
40 // tie breaking
41 && consider(preferLess(a.getConsPrimary(), b.getConsPrimary(), TieBreaker.CONSTRAINT_LIST_COMPARATOR))
42 && consider(preferLess(a.getConsSecondary(), b.getConsSecondary(), TieBreaker.CONSTRAINT_LIST_COMPARATOR))
43 && consider(preferLess(System.identityHashCode(a), System.identityHashCode(b))));
44 }
45 }.compare();
46
47 }
48
49} \ No newline at end of file