aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2024-06-20 21:07:52 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2024-06-20 21:07:52 +0200
commit1140488673066f8e42362f26318b644c82cbd261 (patch)
treef7b111ce357003f3ccd1435150a70d81cdf33532 /subprojects/store/src
parentrefactor(logic): fix Sonar error (diff)
downloadrefinery-1140488673066f8e42362f26318b644c82cbd261.tar.gz
refinery-1140488673066f8e42362f26318b644c82cbd261.tar.zst
refinery-1140488673066f8e42362f26318b644c82cbd261.zip
refactor(dse): expose state coder parameters
Diffstat (limited to 'subprojects/store/src')
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/statecoding/internal/StateCoderBuilderImpl.java2
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/AbstractNeighbourhoodCalculator.java6
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/NeighbourhoodCalculator.java18
3 files changed, 20 insertions, 6 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/statecoding/internal/StateCoderBuilderImpl.java b/subprojects/store/src/main/java/tools/refinery/store/statecoding/internal/StateCoderBuilderImpl.java
index eed591e7..36d7d4c7 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/statecoding/internal/StateCoderBuilderImpl.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/statecoding/internal/StateCoderBuilderImpl.java
@@ -27,7 +27,7 @@ public class StateCoderBuilderImpl extends AbstractModelAdapterBuilder<StateCode
27 implements StateCoderBuilder { 27 implements StateCoderBuilder {
28 private final Set<AnySymbol> excluded = new HashSet<>(); 28 private final Set<AnySymbol> excluded = new HashSet<>();
29 private final MutableIntSet individuals = IntSets.mutable.empty(); 29 private final MutableIntSet individuals = IntSets.mutable.empty();
30 private StateCodeCalculatorFactory calculator = NeighbourhoodCalculator::new; 30 private StateCodeCalculatorFactory calculator = NeighbourhoodCalculator.factory();
31 private StateEquivalenceChecker checker = new StateEquivalenceCheckerImpl(); 31 private StateEquivalenceChecker checker = new StateEquivalenceCheckerImpl();
32 32
33 @Override 33 @Override
diff --git a/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/AbstractNeighbourhoodCalculator.java b/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/AbstractNeighbourhoodCalculator.java
index 5bfc4725..a4060e74 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/AbstractNeighbourhoodCalculator.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/AbstractNeighbourhoodCalculator.java
@@ -20,6 +20,7 @@ import java.util.*;
20public abstract class AbstractNeighbourhoodCalculator<T> implements StateCodeCalculator { 20public abstract class AbstractNeighbourhoodCalculator<T> implements StateCodeCalculator {
21 private final Model model; 21 private final Model model;
22 private final IntSet individuals; 22 private final IntSet individuals;
23 private final int depth;
23 private List<T> nullImpactValues; 24 private List<T> nullImpactValues;
24 private LinkedHashMap<T, long[]> impactValues; 25 private LinkedHashMap<T, long[]> impactValues;
25 private MutableIntLongMap individualHashValues; 26 private MutableIntLongMap individualHashValues;
@@ -28,9 +29,10 @@ public abstract class AbstractNeighbourhoodCalculator<T> implements StateCodeCal
28 29
29 protected static final long PRIME = 31; 30 protected static final long PRIME = 31;
30 31
31 protected AbstractNeighbourhoodCalculator(Model model, IntSet individuals) { 32 protected AbstractNeighbourhoodCalculator(Model model, IntSet individuals, int depth) {
32 this.model = model; 33 this.model = model;
33 this.individuals = individuals; 34 this.individuals = individuals;
35 this.depth = depth;
34 } 36 }
35 37
36 protected Model getModel() { 38 protected Model getModel() {
@@ -64,7 +66,7 @@ public abstract class AbstractNeighbourhoodCalculator<T> implements StateCodeCal
64 nextObjectCode = tempObjectCode; 66 nextObjectCode = tempObjectCode;
65 nextObjectCode.clear(); 67 nextObjectCode.clear();
66 rounds++; 68 rounds++;
67 } while (rounds <= 7 && rounds <= previousObjectCode.getEffectiveSize()); 69 } while (rounds <= depth && rounds <= previousObjectCode.getEffectiveSize());
68 70
69 long result = calculateLastSum(previousObjectCode); 71 long result = calculateLastSum(previousObjectCode);
70 return new StateCoderResult((int) result, previousObjectCode); 72 return new StateCoderResult((int) result, previousObjectCode);
diff --git a/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/NeighbourhoodCalculator.java b/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/NeighbourhoodCalculator.java
index f6071c5b..5859ccc2 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/NeighbourhoodCalculator.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/statecoding/neighbourhood/NeighbourhoodCalculator.java
@@ -9,16 +9,19 @@ import org.eclipse.collections.api.set.primitive.IntSet;
9import tools.refinery.store.map.Cursor; 9import tools.refinery.store.map.Cursor;
10import tools.refinery.store.model.Interpretation; 10import tools.refinery.store.model.Interpretation;
11import tools.refinery.store.model.Model; 11import tools.refinery.store.model.Model;
12import tools.refinery.store.statecoding.StateCodeCalculatorFactory;
12import tools.refinery.store.tuple.Tuple; 13import tools.refinery.store.tuple.Tuple;
13 14
14import java.util.List; 15import java.util.List;
15 16
16public class NeighbourhoodCalculator extends AbstractNeighbourhoodCalculator<Interpretation<?>> { 17public class NeighbourhoodCalculator extends AbstractNeighbourhoodCalculator<Interpretation<?>> {
18 public static final int DEFAULT_DEPTH = 7;
19
17 private final List<Interpretation<?>> interpretations; 20 private final List<Interpretation<?>> interpretations;
18 21
19 public NeighbourhoodCalculator(Model model, List<? extends Interpretation<?>> interpretations, 22 protected NeighbourhoodCalculator(Model model, List<? extends Interpretation<?>> interpretations,
20 IntSet individuals) { 23 IntSet individuals, int depth) {
21 super(model, individuals); 24 super(model, individuals, depth);
22 this.interpretations = List.copyOf(interpretations); 25 this.interpretations = List.copyOf(interpretations);
23 } 26 }
24 27
@@ -41,4 +44,13 @@ public class NeighbourhoodCalculator extends AbstractNeighbourhoodCalculator<Int
41 protected Cursor<Tuple, ?> getCursor(Interpretation<?> interpretation) { 44 protected Cursor<Tuple, ?> getCursor(Interpretation<?> interpretation) {
42 return interpretation.getAll(); 45 return interpretation.getAll();
43 } 46 }
47
48 public static StateCodeCalculatorFactory factory(int depth) {
49 return (model, interpretations, individuals) -> new NeighbourhoodCalculator(model, interpretations,
50 individuals, depth);
51 }
52
53 public static StateCodeCalculatorFactory factory() {
54 return factory(DEFAULT_DEPTH);
55 }
44} 56}