diff options
Diffstat (limited to 'subprojects/generator')
-rw-r--r-- | subprojects/generator/src/main/java/tools/refinery/generator/ModelGeneratorFactory.java | 20 |
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; | |||
25 | import java.util.Collection; | 25 | import java.util.Collection; |
26 | import java.util.Set; | 26 | import 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") | ||
28 | public final class ModelGeneratorFactory { | 30 | public 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 | } |