diff options
author | 2019-05-18 14:25:00 -0400 | |
---|---|---|
committer | 2019-05-18 14:25:00 -0400 | |
commit | 1f60bda44172f1dedaf30785c88163ba6c36a0b9 (patch) | |
tree | c76b0529f2ec3a8fec66677dd9d9d86ab222d754 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/aggregators/intervalHull.xtend | |
parent | Model generator for CPS case study (diff) | |
download | VIATRA-Generator-1f60bda44172f1dedaf30785c88163ba6c36a0b9.tar.gz VIATRA-Generator-1f60bda44172f1dedaf30785c88163ba6c36a0b9.tar.zst VIATRA-Generator-1f60bda44172f1dedaf30785c88163ba6c36a0b9.zip |
Interval hull aggregation operator
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/aggregators/intervalHull.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/aggregators/intervalHull.xtend | 74 |
1 files changed, 74 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/aggregators/intervalHull.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/aggregators/intervalHull.xtend new file mode 100644 index 00000000..72605f57 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/interval/aggregators/intervalHull.xtend | |||
@@ -0,0 +1,74 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval.aggregators | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval.Interval | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval.IntervalHullAggregatorOperator | ||
5 | import java.math.BigDecimal | ||
6 | import java.math.BigInteger | ||
7 | import java.math.MathContext | ||
8 | import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.AggregatorType | ||
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.BoundAggregator | ||
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IAggregatorFactory | ||
11 | |||
12 | @AggregatorType(parameterTypes=#[BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short], returnTypes=#[ | ||
13 | Interval, Interval, Interval, Interval, Interval, Interval, Interval, Interval]) | ||
14 | class intervalHull implements IAggregatorFactory { | ||
15 | |||
16 | override getAggregatorLogic(Class<?> domainClass) { | ||
17 | new BoundAggregator(getAggregationOperator(domainClass), domainClass, Interval) | ||
18 | } | ||
19 | |||
20 | private def getAggregationOperator(Class<?> domainClass) { | ||
21 | switch (domainClass) { | ||
22 | case BigDecimal: | ||
23 | new IntervalHullAggregatorOperator<BigDecimal>() { | ||
24 | override protected toBigDecimal(BigDecimal value, MathContext mc) { | ||
25 | value.round(mc) | ||
26 | } | ||
27 | } | ||
28 | case BigInteger: | ||
29 | new IntervalHullAggregatorOperator<BigInteger>() { | ||
30 | override protected toBigDecimal(BigInteger value, MathContext mc) { | ||
31 | new BigDecimal(value, mc) | ||
32 | } | ||
33 | } | ||
34 | case Byte: | ||
35 | new IntervalHullAggregatorOperator<Byte>() { | ||
36 | override protected toBigDecimal(Byte value, MathContext mc) { | ||
37 | new BigDecimal(value, mc) | ||
38 | } | ||
39 | } | ||
40 | case Double: | ||
41 | new IntervalHullAggregatorOperator<Double>() { | ||
42 | override protected toBigDecimal(Double value, MathContext mc) { | ||
43 | new BigDecimal(value, mc) | ||
44 | } | ||
45 | } | ||
46 | case Float: | ||
47 | new IntervalHullAggregatorOperator<Float>() { | ||
48 | override protected toBigDecimal(Float value, MathContext mc) { | ||
49 | new BigDecimal(value, mc) | ||
50 | } | ||
51 | } | ||
52 | case Integer: | ||
53 | new IntervalHullAggregatorOperator<Integer>() { | ||
54 | override protected toBigDecimal(Integer value, MathContext mc) { | ||
55 | new BigDecimal(value, mc) | ||
56 | } | ||
57 | } | ||
58 | case Long: | ||
59 | new IntervalHullAggregatorOperator<Long>() { | ||
60 | override protected toBigDecimal(Long value, MathContext mc) { | ||
61 | new BigDecimal(value, mc) | ||
62 | } | ||
63 | } | ||
64 | case Short: | ||
65 | new IntervalHullAggregatorOperator<Short>() { | ||
66 | override protected toBigDecimal(Short value, MathContext mc) { | ||
67 | new BigDecimal(value, mc) | ||
68 | } | ||
69 | } | ||
70 | default: | ||
71 | throw new IllegalArgumentException("Unknown domain class: " + domainClass) | ||
72 | } | ||
73 | } | ||
74 | } | ||