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