diff options
author | 2023-08-08 20:19:03 +0200 | |
---|---|---|
committer | 2023-08-08 20:19:03 +0200 | |
commit | e2268925741bd4c68dcead708b211bf5fd99440c (patch) | |
tree | 194b1a1a0a95be71180f39020489e2368937f403 /subprojects/store | |
parent | Unused condition simplified. (diff) | |
download | refinery-e2268925741bd4c68dcead708b211bf5fd99440c.tar.gz refinery-e2268925741bd4c68dcead708b211bf5fd99440c.tar.zst refinery-e2268925741bd4c68dcead708b211bf5fd99440c.zip |
Added test for StateEquivalenceChecker Unknown outcome.
Diffstat (limited to 'subprojects/store')
2 files changed, 44 insertions, 1 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/statecoding/stateequivalence/StateEquivalenceCheckerImpl.java b/subprojects/store/src/main/java/tools/refinery/store/statecoding/stateequivalence/StateEquivalenceCheckerImpl.java index 34dba34e..ef0d76a7 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/statecoding/stateequivalence/StateEquivalenceCheckerImpl.java +++ b/subprojects/store/src/main/java/tools/refinery/store/statecoding/stateequivalence/StateEquivalenceCheckerImpl.java | |||
@@ -58,7 +58,11 @@ public class StateEquivalenceCheckerImpl implements StateEquivalenceChecker { | |||
58 | tried++; | 58 | tried++; |
59 | } while (hasNext); | 59 | } while (hasNext); |
60 | 60 | ||
61 | return EquivalenceResult.DIFFERENT; | 61 | if(permutations == EquivalenceResult.UNKNOWN) { |
62 | return EquivalenceResult.UNKNOWN; | ||
63 | } else { | ||
64 | return EquivalenceResult.DIFFERENT; | ||
65 | } | ||
62 | } | 66 | } |
63 | 67 | ||
64 | private LongObjectHashMap<IntHashSet> indexByHash(ObjectCode code, IntSet individuals) { | 68 | private LongObjectHashMap<IntHashSet> indexByHash(ObjectCode code, IntSet individuals) { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/statecoding/EquivalenceTest.java b/subprojects/store/src/test/java/tools/refinery/store/statecoding/EquivalenceTest.java index 8a9c0e9b..3c35849e 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/statecoding/EquivalenceTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/statecoding/EquivalenceTest.java | |||
@@ -10,6 +10,7 @@ import tools.refinery.store.map.Version; | |||
10 | import tools.refinery.store.model.Model; | 10 | import tools.refinery.store.model.Model; |
11 | import tools.refinery.store.model.ModelStore; | 11 | import tools.refinery.store.model.ModelStore; |
12 | import tools.refinery.store.representation.Symbol; | 12 | import tools.refinery.store.representation.Symbol; |
13 | import tools.refinery.store.statecoding.neighbourhood.ObjectCodeImpl; | ||
13 | import tools.refinery.store.tuple.Tuple; | 14 | import tools.refinery.store.tuple.Tuple; |
14 | 15 | ||
15 | import static org.junit.jupiter.api.Assertions.assertEquals; | 16 | import static org.junit.jupiter.api.Assertions.assertEquals; |
@@ -175,4 +176,42 @@ class EquivalenceTest { | |||
175 | 176 | ||
176 | assertEquals(StateEquivalenceChecker.EquivalenceResult.ISOMORPHIC, stateCoder.checkEquivalence(v2, v4)); | 177 | assertEquals(StateEquivalenceChecker.EquivalenceResult.ISOMORPHIC, stateCoder.checkEquivalence(v2, v4)); |
177 | } | 178 | } |
179 | |||
180 | @Test | ||
181 | void largeUnknownTest() { | ||
182 | final int limit = 100; | ||
183 | |||
184 | StateCodeCalculator calculator = () -> { | ||
185 | var code = new ObjectCodeImpl(); | ||
186 | for (int i = 0; i < limit; i++) { | ||
187 | code.set(i, 1); | ||
188 | } | ||
189 | return new StateCoderResult(1, code); | ||
190 | }; | ||
191 | |||
192 | ModelStore store = ModelStore.builder() | ||
193 | .symbols(person, age, friend, parents, population) | ||
194 | .with(StateCoderAdapter.builder() | ||
195 | .stateCodeCalculatorFactory((p1, p2) -> calculator)) | ||
196 | .build(); | ||
197 | |||
198 | var stateCoder = store.getAdapter(StateCoderStoreAdapter.class); | ||
199 | Model model = createStore().createEmptyModel(); | ||
200 | |||
201 | var personI = model.getInterpretation(person); | ||
202 | var friendI = model.getInterpretation(friend); | ||
203 | |||
204 | for (int i = 0; i < limit; i++) { | ||
205 | personI.put(Tuple.of(i), true); | ||
206 | } | ||
207 | |||
208 | friendI.put(Tuple.of(11,12),true); | ||
209 | var v1 = model.commit(); | ||
210 | |||
211 | friendI.put(Tuple.of(11,12),false); | ||
212 | friendI.put(Tuple.of(21,22),false); | ||
213 | var v2 = model.commit(); | ||
214 | |||
215 | assertEquals(StateEquivalenceChecker.EquivalenceResult.UNKNOWN, stateCoder.checkEquivalence(v1,v2)); | ||
216 | } | ||
178 | } | 217 | } |