aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2023-09-14 19:29:36 +0200
committerLibravatar GitHub <noreply@github.com>2023-09-14 19:29:36 +0200
commit98ed3b6db5f4e51961a161050cc31c66015116e8 (patch)
tree8bfd6d9bc8d6ed23b9eb0f889dd40b6c24fe8f92 /subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java
parentMerge pull request #38 from nagilooh/design-space-exploration (diff)
parentMerge remote-tracking branch 'upstream/main' into partial-interpretation (diff)
downloadrefinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.gz
refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.zst
refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.zip
Merge pull request #39 from kris7t/partial-interpretation
Implement partial interpretation based model generation
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java')
-rw-r--r--subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java51
1 files changed, 46 insertions, 5 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java
index fd05158b..9a0c2b0f 100644
--- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java
+++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java
@@ -8,21 +8,26 @@ package tools.refinery.store.reasoning.translator.typehierarchy;
8import tools.refinery.store.reasoning.representation.PartialRelation; 8import tools.refinery.store.reasoning.representation.PartialRelation;
9 9
10import java.util.Collections; 10import java.util.Collections;
11import java.util.Objects;
11import java.util.Set; 12import java.util.Set;
12 13
13record InferredType(Set<PartialRelation> mustTypes, Set<PartialRelation> mayConcreteTypes, 14public final class InferredType {
14 PartialRelation currentType) {
15 public static final InferredType UNTYPED = new InferredType(Set.of(), Set.of(), null); 15 public static final InferredType UNTYPED = new InferredType(Set.of(), Set.of(), null);
16 private final Set<PartialRelation> mustTypes;
17 private final Set<PartialRelation> mayConcreteTypes;
18 private final PartialRelation candidateType;
19 private final int hashCode;
16 20
17 public InferredType(Set<PartialRelation> mustTypes, Set<PartialRelation> mayConcreteTypes, 21 public InferredType(Set<PartialRelation> mustTypes, Set<PartialRelation> mayConcreteTypes,
18 PartialRelation currentType) { 22 PartialRelation candidateType) {
19 this.mustTypes = Collections.unmodifiableSet(mustTypes); 23 this.mustTypes = Collections.unmodifiableSet(mustTypes);
20 this.mayConcreteTypes = Collections.unmodifiableSet(mayConcreteTypes); 24 this.mayConcreteTypes = Collections.unmodifiableSet(mayConcreteTypes);
21 this.currentType = currentType; 25 this.candidateType = candidateType;
26 hashCode = Objects.hash(mustTypes, mayConcreteTypes, candidateType);
22 } 27 }
23 28
24 public boolean isConsistent() { 29 public boolean isConsistent() {
25 return currentType != null || mustTypes.isEmpty(); 30 return candidateType != null || mustTypes.isEmpty();
26 } 31 }
27 32
28 public boolean isMust(PartialRelation partialRelation) { 33 public boolean isMust(PartialRelation partialRelation) {
@@ -32,4 +37,40 @@ record InferredType(Set<PartialRelation> mustTypes, Set<PartialRelation> mayConc
32 public boolean isMayConcrete(PartialRelation partialRelation) { 37 public boolean isMayConcrete(PartialRelation partialRelation) {
33 return mayConcreteTypes.contains(partialRelation); 38 return mayConcreteTypes.contains(partialRelation);
34 } 39 }
40
41
42 public Set<PartialRelation> mustTypes() {
43 return mustTypes;
44 }
45
46 public Set<PartialRelation> mayConcreteTypes() {
47 return mayConcreteTypes;
48 }
49
50 public PartialRelation candidateType() {
51 return candidateType;
52 }
53
54 @Override
55 public boolean equals(Object o) {
56 if (this == o) return true;
57 if (o == null || getClass() != o.getClass()) return false;
58 InferredType that = (InferredType) o;
59 return Objects.equals(mustTypes, that.mustTypes) &&
60 Objects.equals(mayConcreteTypes, that.mayConcreteTypes) &&
61 Objects.equals(candidateType, that.candidateType);
62 }
63
64 @Override
65 public int hashCode() {
66 return hashCode;
67 }
68
69 @Override
70 public String toString() {
71 return "InferredType[" +
72 "mustTypes=" + mustTypes + ", " +
73 "mayConcreteTypes=" + mayConcreteTypes + ", " +
74 "candidateType=" + candidateType + ']';
75 }
35} 76}