diff options
author | 2019-05-09 20:24:56 -0400 | |
---|---|---|
committer | 2019-05-09 20:24:56 -0400 | |
commit | ba167247757d76df603a6527d9ad51c3d9f150b9 (patch) | |
tree | 394c7a762e65f91eae1c8a3aacee4fa1805c8215 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/IntervalAggregationMode.java | |
parent | Fix interval join (diff) | |
download | VIATRA-Generator-ba167247757d76df603a6527d9ad51c3d9f150b9.tar.gz VIATRA-Generator-ba167247757d76df603a6527d9ad51c3d9f150b9.tar.zst VIATRA-Generator-ba167247757d76df603a6527d9ad51c3d9f150b9.zip |
Interval aggregation operators
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/IntervalAggregationMode.java')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/IntervalAggregationMode.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/IntervalAggregationMode.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/IntervalAggregationMode.java new file mode 100644 index 00000000..f5bd2efc --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/IntervalAggregationMode.java | |||
@@ -0,0 +1,66 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval; | ||
2 | |||
3 | import java.util.function.BinaryOperator; | ||
4 | |||
5 | public enum IntervalAggregationMode implements BinaryOperator<Interval> { | ||
6 | SUM("intervalSum", "Sum a set of intervals") { | ||
7 | @Override | ||
8 | public IntervalRedBlackNode createNode(Interval interval) { | ||
9 | return new IntervalRedBlackNode(interval) { | ||
10 | public boolean isMultiplicitySensitive() { | ||
11 | return true; | ||
12 | } | ||
13 | |||
14 | public Interval multiply(Interval interval, int count) { | ||
15 | return interval.operator_multiply(count); | ||
16 | }; | ||
17 | |||
18 | @Override | ||
19 | public Interval op(Interval left, Interval right) { | ||
20 | return left.operator_plus(right); | ||
21 | } | ||
22 | }; | ||
23 | } | ||
24 | }, | ||
25 | |||
26 | JOIN("intervalJoin", "Calculate the smallest interval containing all the intervals in a set") { | ||
27 | @Override | ||
28 | public IntervalRedBlackNode createNode(Interval interval) { | ||
29 | return new IntervalRedBlackNode(interval) { | ||
30 | @Override | ||
31 | public Interval op(Interval left, Interval right) { | ||
32 | return left.join(right); | ||
33 | } | ||
34 | }; | ||
35 | } | ||
36 | }; | ||
37 | |||
38 | private final String modeName; | ||
39 | private final String description; | ||
40 | private final IntervalRedBlackNode empty; | ||
41 | |||
42 | IntervalAggregationMode(String modeName, String description) { | ||
43 | this.modeName = modeName; | ||
44 | this.description = description; | ||
45 | empty = createNode(null); | ||
46 | } | ||
47 | |||
48 | public String getModeName() { | ||
49 | return modeName; | ||
50 | } | ||
51 | |||
52 | public String getDescription() { | ||
53 | return description; | ||
54 | } | ||
55 | |||
56 | public IntervalRedBlackNode getEmpty() { | ||
57 | return empty; | ||
58 | } | ||
59 | |||
60 | @Override | ||
61 | public Interval apply(Interval left, Interval right) { | ||
62 | return empty.op(left, right); | ||
63 | } | ||
64 | |||
65 | public abstract IntervalRedBlackNode createNode(Interval interval); | ||
66 | } | ||