aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/generator
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/generator
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/generator')
-rw-r--r--subprojects/generator/src/main/java/tools/refinery/generator/ModelGeneratorFactory.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/subprojects/generator/src/main/java/tools/refinery/generator/ModelGeneratorFactory.java b/subprojects/generator/src/main/java/tools/refinery/generator/ModelGeneratorFactory.java
index ec273cf4..877db0bb 100644
--- a/subprojects/generator/src/main/java/tools/refinery/generator/ModelGeneratorFactory.java
+++ b/subprojects/generator/src/main/java/tools/refinery/generator/ModelGeneratorFactory.java
@@ -25,6 +25,8 @@ import tools.refinery.store.util.CancellationToken;
25import java.util.Collection; 25import java.util.Collection;
26import java.util.Set; 26import java.util.Set;
27 27
28// This class is used as a fluent builder, so it's not necessary to use the return value of all of its methods.
29@SuppressWarnings("UnusedReturnValue")
28public final class ModelGeneratorFactory { 30public final class ModelGeneratorFactory {
29 @Inject 31 @Inject
30 private Provider<ModelInitializer> initializerProvider; 32 private Provider<ModelInitializer> initializerProvider;
@@ -38,6 +40,8 @@ public final class ModelGeneratorFactory {
38 40
39 private boolean partialInterpretationBasedNeighbourhoods; 41 private boolean partialInterpretationBasedNeighbourhoods;
40 42
43 private int stateCoderDepth = NeighbourhoodCalculator.DEFAULT_DEPTH;
44
41 public ModelGeneratorFactory cancellationToken(CancellationToken cancellationToken) { 45 public ModelGeneratorFactory cancellationToken(CancellationToken cancellationToken) {
42 this.cancellationToken = cancellationToken; 46 this.cancellationToken = cancellationToken;
43 return this; 47 return this;
@@ -48,8 +52,15 @@ public final class ModelGeneratorFactory {
48 return this; 52 return this;
49 } 53 }
50 54
51 public void partialInterpretationBasedNeighbourhoods(boolean partialInterpretationBasedNeighbourhoods) { 55 public ModelGeneratorFactory partialInterpretationBasedNeighbourhoods(
56 boolean partialInterpretationBasedNeighbourhoods) {
52 this.partialInterpretationBasedNeighbourhoods = partialInterpretationBasedNeighbourhoods; 57 this.partialInterpretationBasedNeighbourhoods = partialInterpretationBasedNeighbourhoods;
58 return this;
59 }
60
61 public ModelGeneratorFactory stateCoderDepth(int stateCoderDepth) {
62 this.stateCoderDepth = stateCoderDepth;
63 return this;
53 } 64 }
54 65
55 public ModelGenerator createGenerator(Problem problem) { 66 public ModelGenerator createGenerator(Problem problem) {
@@ -68,7 +79,7 @@ public final class ModelGeneratorFactory {
68 initializer.configureStoreBuilder(storeBuilder); 79 initializer.configureStoreBuilder(storeBuilder);
69 var store = storeBuilder.build(); 80 var store = storeBuilder.build();
70 return new ModelGenerator(initializer.getProblemTrace(), store, initializer.getModelSeed(), 81 return new ModelGenerator(initializer.getProblemTrace(), store, initializer.getModelSeed(),
71 solutionSerializerProvider); 82 solutionSerializerProvider);
72 } 83 }
73 84
74 private Collection<Concreteness> getRequiredInterpretations() { 85 private Collection<Concreteness> getRequiredInterpretations() {
@@ -78,7 +89,8 @@ public final class ModelGeneratorFactory {
78 } 89 }
79 90
80 private StateCodeCalculatorFactory getStateCoderCalculatorFactory() { 91 private StateCodeCalculatorFactory getStateCoderCalculatorFactory() {
81 return partialInterpretationBasedNeighbourhoods ? PartialNeighbourhoodCalculator.FACTORY : 92 return partialInterpretationBasedNeighbourhoods ?
82 NeighbourhoodCalculator::new; 93 PartialNeighbourhoodCalculator.factory(Concreteness.PARTIAL, stateCoderDepth) :
94 NeighbourhoodCalculator.factory(stateCoderDepth);
83 } 95 }
84} 96}