initSolver) {
- this.initSolver = initSolver;
- return this;
- }
-
- @Override
- public byte enableHybridizationOfPropagationEngine() {
- return hybridEngine;
- }
-
- @Override
- public Settings setHybridizationOfPropagationEngine(byte hybrid) {
- this.hybridEngine = hybrid;
- return this;
- }
-
- @Override
- public int getNbMaxLearntClauses() {
- return nbMaxLearnt;
- }
-
- @Override
- public Settings setNbMaxLearntClauses(int n) {
- this.nbMaxLearnt = n;
- return this;
- }
-
- @Override
- public float getRatioForClauseStoreReduction() {
- return this.clauseReductionRatio;
- }
-
- @Override
- public Settings setRatioForClauseStoreReduction(float f) {
- this.clauseReductionRatio = f;
- return this;
- }
-
- @Override
- public int getMaxLearntClauseCardinality() {
- return maxLearntCardinlity;
- }
-
- @Override
- public Settings setMaxLearntClauseCardinality(int n) {
- maxLearntCardinlity = n;
- return this;
- }
-
- @Override
- public int getLearntClausesDominancePerimeter() {
- return dominancePerimeter;
- }
-
- @Override
- public Settings setLearntClausesDominancePerimeter(int n) {
- this.dominancePerimeter = n;
- return this;
- }
-
- @Override
- public boolean explainGlobalFailureInSum() {
- return explainGlobalFailureInSum;
- }
-
- @Override
- public Settings explainGlobalFailureInSum(boolean b) {
- this.explainGlobalFailureInSum = b;
- return this;
- }
-
- @Override
- public double getIbexContractionRatio() {
- return ibexContractionRatio;
- }
-
- @Override
- public void setIbexContractionRatio(double ibexContractionRatio) {
- this.ibexContractionRatio = ibexContractionRatio;
- }
-
- @Override
- public void setIbexRestoreRounding(boolean ibexRestoreRounding) {
- this.ibexRestoreRounding = ibexRestoreRounding;
- }
-
- @Override
- public boolean getIbexRestoreRounding() {
- return ibexRestoreRounding;
- }
-
-}
diff --git a/src/main/java/zebra4j/Attributes.java b/src/main/java/zebra4j/Attributes.java
index be99c56..7fb01c8 100644
--- a/src/main/java/zebra4j/Attributes.java
+++ b/src/main/java/zebra4j/Attributes.java
@@ -45,8 +45,8 @@ public interface Attributes {
*
*
* Defining attributes as an enum allows for value-dependent implementation of
- * methods like {@link AttributeType#questionSentencePart()} or
- * {@link Attribute#description()} .
+ * methods like {@link AttributeType#questionSentencePart} or
+ * {@link Attribute#description} .
*/
public static final AttributeType CLOTHES = Clothes.TYPE;
public static final AttributeType AT_HOUSE = AtHouse.TYPE;
diff --git a/src/main/java/zebra4j/PuzzleSolver.java b/src/main/java/zebra4j/PuzzleSolver.java
index adbb7e7..65ce275 100644
--- a/src/main/java/zebra4j/PuzzleSolver.java
+++ b/src/main/java/zebra4j/PuzzleSolver.java
@@ -28,24 +28,32 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.chocosolver.solver.DefaultSettings;
import org.chocosolver.solver.Model;
+import org.chocosolver.solver.Settings;
import org.chocosolver.solver.Solution;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.variables.IntVar;
-import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import zebra4j.fact.Fact;
/**
* Solver for {@link Puzzle}
*/
-@AllArgsConstructor
+@RequiredArgsConstructor
@Slf4j
public class PuzzleSolver {
private final Puzzle puzzle;
+ @Getter
+ @Setter
+ private Settings chocoSettings = new DefaultSettings();
+
/**
* @param zebraModel
* @return a list of choco-solver solutions; useful to count solutions
@@ -100,7 +108,7 @@ private List retrieveVars(Solution choco) {
}
private ZebraModel toModel() {
- ZebraModel model = new ZebraModel();
+ ZebraModel model = new ZebraModel(chocoSettings);
for (Entry> entry : puzzle.getAttributeSets().entrySet()) {
entry.getKey().addToModel(model, entry.getValue(), puzzle.numPeople());
}
diff --git a/src/main/java/zebra4j/ZebraModel.java b/src/main/java/zebra4j/ZebraModel.java
index baa8123..3e25fc4 100644
--- a/src/main/java/zebra4j/ZebraModel.java
+++ b/src/main/java/zebra4j/ZebraModel.java
@@ -25,8 +25,8 @@
import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
-import org.chocosolver.solver.ChocoSettings;
import org.chocosolver.solver.Model;
+import org.chocosolver.solver.Settings;
import org.chocosolver.solver.variables.IntVar;
import lombok.Getter;
@@ -37,7 +37,11 @@
public class ZebraModel {
@Getter
- private final Model chocoModel = new Model(UUID.randomUUID().toString(), new ChocoSettings());
+ private final Model chocoModel;
+
+ public ZebraModel(Settings chocoSettings) {
+ chocoModel = new Model(UUID.randomUUID().toString(), chocoSettings);
+ }
private final BidiMap uniqueAttributeVariables = new DualHashBidiMap();
diff --git a/src/test/java/zebra4j/ZebraModelTest.java b/src/test/java/zebra4j/ZebraModelTest.java
index ca7955b..3deeb84 100644
--- a/src/test/java/zebra4j/ZebraModelTest.java
+++ b/src/test/java/zebra4j/ZebraModelTest.java
@@ -20,6 +20,7 @@
*/
package zebra4j;
+import org.chocosolver.solver.DefaultSettings;
import org.chocosolver.solver.variables.IntVar;
import org.junit.Assert;
import org.junit.Test;
@@ -28,7 +29,7 @@ public class ZebraModelTest {
@Test
public void testToOptionalAttribute() {
- ZebraModel model = new ZebraModel();
+ ZebraModel model = new ZebraModel(new DefaultSettings());
IntVar x = model.createUniqueVariable(PersonName.GEORGE, 4);
Assert.assertEquals(PersonName.GEORGE, model.toOptionalAttribute(x).get());
}