diff options
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/base/BaseDecisionInterpretation.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/base/BaseDecisionInterpretation.java | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/base/BaseDecisionInterpretation.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/base/BaseDecisionInterpretation.java new file mode 100644 index 00000000..b703f142 --- /dev/null +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/base/BaseDecisionInterpretation.java | |||
@@ -0,0 +1,88 @@ | |||
1 | package tools.refinery.store.reasoning.translator.base; | ||
2 | |||
3 | import tools.refinery.store.map.Cursor; | ||
4 | import tools.refinery.store.model.Interpretation; | ||
5 | import tools.refinery.store.query.ResultSet; | ||
6 | import tools.refinery.store.reasoning.MergeResult; | ||
7 | import tools.refinery.store.reasoning.PartialInterpretation; | ||
8 | import tools.refinery.store.reasoning.ReasoningAdapter; | ||
9 | import tools.refinery.store.reasoning.representation.PartialRelation; | ||
10 | import tools.refinery.store.representation.TruthValue; | ||
11 | import tools.refinery.store.tuple.Tuple; | ||
12 | |||
13 | public class BaseDecisionInterpretation implements PartialInterpretation<TruthValue, Boolean> { | ||
14 | private final ReasoningAdapter reasoningAdapter; | ||
15 | private PartialRelation partialRelation; | ||
16 | private final ResultSet<Boolean> mustResultSet; | ||
17 | private final ResultSet<Boolean> mayResultSet; | ||
18 | private final ResultSet<Boolean> errorResultSet; | ||
19 | private final ResultSet<Boolean> currentResultSet; | ||
20 | private final Interpretation<TruthValue> interpretation; | ||
21 | |||
22 | public BaseDecisionInterpretation(ReasoningAdapter reasoningAdapter, ResultSet<Boolean> mustResultSet, | ||
23 | ResultSet<Boolean> mayResultSet, ResultSet<Boolean> errorResultSet, | ||
24 | ResultSet<Boolean> currentResultSet, Interpretation<TruthValue> interpretation) { | ||
25 | this.reasoningAdapter = reasoningAdapter; | ||
26 | this.mustResultSet = mustResultSet; | ||
27 | this.mayResultSet = mayResultSet; | ||
28 | this.errorResultSet = errorResultSet; | ||
29 | this.currentResultSet = currentResultSet; | ||
30 | this.interpretation = interpretation; | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public ReasoningAdapter getAdapter() { | ||
35 | return reasoningAdapter; | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public int countUnfinished() { | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public int countErrors() { | ||
45 | return errorResultSet.size(); | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public PartialRelation getPartialSymbol() { | ||
50 | return partialRelation; | ||
51 | } | ||
52 | |||
53 | @Override | ||
54 | public TruthValue get(Tuple key) { | ||
55 | return null; | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | public Cursor<Tuple, TruthValue> getAll() { | ||
60 | return null; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public MergeResult merge(Tuple key, TruthValue value) { | ||
65 | TruthValue newValue; | ||
66 | switch (value) { | ||
67 | case UNKNOWN -> { | ||
68 | return MergeResult.UNCHANGED; | ||
69 | } | ||
70 | case TRUE -> newValue = mayResultSet.get(key) ? TruthValue.TRUE : TruthValue.ERROR; | ||
71 | case FALSE -> newValue = mustResultSet.get(key) ? TruthValue.ERROR : TruthValue.FALSE; | ||
72 | case ERROR -> newValue = TruthValue.ERROR; | ||
73 | default -> throw new IllegalArgumentException("Unknown truth value: " + value); | ||
74 | } | ||
75 | var oldValue = interpretation.put(key, newValue); | ||
76 | return oldValue == TruthValue.ERROR ? MergeResult.UNCHANGED : MergeResult.REFINED; | ||
77 | } | ||
78 | |||
79 | @Override | ||
80 | public Boolean getConcrete(Tuple key) { | ||
81 | return currentResultSet.get(key); | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Cursor<Tuple, Boolean> getAllConcrete() { | ||
86 | return null; | ||
87 | } | ||
88 | } | ||