Skip to content

Commit f28bd85

Browse files
committed
merge dev_lcg into master
2 parents d4442f0 + cec9dbc commit f28bd85

File tree

263 files changed

+33084
-13941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+33084
-13941
lines changed

.github/workflows/maven-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
java-version: '11'
2020
distribution: 'temurin'
2121
cache: 'maven'
22-
22+
2323
# Install Ibex
2424
- name: Install ibex
2525
run: |
@@ -28,14 +28,14 @@ jobs:
2828
# Regression tests
2929
- name: Test Ibex
3030
run: mvn --file pom.xml test -Pcoverage -DtestFailureIgnore=true -Dgroups=ibex
31-
31+
3232
test-solver:
3333
runs-on: ubuntu-latest
3434
# Tests matrix
3535
strategy:
3636
#fail-fast: false
3737
matrix:
38-
group: [ "1s", "10s", "checker" ]
38+
group: [ "1s", "10s", "checker", "lcg" ]
3939

4040
# The different steps
4141
steps:
@@ -52,7 +52,7 @@ jobs:
5252
# Regression tests
5353
- name: Test ${{ matrix.group }}
5454
run: mvn --file pom.xml test -Pcoverage -DtestFailureIgnore=true -Dgroups=${{ matrix.group }}
55-
55+
5656
test-parser:
5757
needs: [ test-solver ]
5858
runs-on: ubuntu-latest

CHANGES.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,39 @@ Choco Solver ChangeLog
44
This file is dedicated to sum up the new features added and bugs fixed in Choco-solver since the version, 4.0.0.
55
**Note**: double-space is replaced by "\t" character on release process. Make sure the format is ok.
66

7+
5.0.0-beta.1 - 17 Feb 2025
8+
--------------------------
9+
10+
### Major features:
11+
12+
This version introduces CP-SAT in Choco-solver which
13+
replaces the previous explanation framework.
14+
The Lazy Clause Generation (LCG) is a technique that allows the solver to generate clauses during search.
15+
The current implementation is inspired by Chuffed
16+
and "Lazy Clause Generation Reengineered" - Feydy, T., Stuckey, P.J. (2009).
17+
This new version has necessitated a rather intrusive revision of the way propagators filter.
18+
19+
By default, LCG is not enabled. The following code shows how to enable it:
20+
```java
21+
Model model = new Model(Settings.init().setLCG(true));
22+
```
23+
24+
At this stage, this is a [beta version](https://github.com/orgs/chocoteam/projects/1).
25+
First, only integer and boolean variables are supported.
26+
Second, some constraints are explained with dedicated functions and
27+
others are decomposed into explained ones.
28+
More importantly, others are neither explained nor decomposed (for the moment).
29+
In the latter case, an exception is raised to inform the user of the situation.
30+
31+
32+
### Other closed issues and pull requests:
33+
See [milestone 5.0.0](https://github.com/chocoteam/choco-solver/milestone/40)
34+
35+
#### Contributors to this release:
36+
- [Charles Prud'homme](https://github.com/cprudhom) (@cprudhom)
37+
38+
**Full Changelog**: https://github.com/chocoteam/choco-solver/compare/v4.10.18...v5.0.0-beta.1
39+
740
4.10.18 - 27 Jan 2025
841
---------------------
942

@@ -16,23 +49,6 @@ This file is dedicated to sum up the new features added and bugs fixed in Choco-
1649

1750
**Full Changelog**: https://github.com/chocoteam/choco-solver/compare/v4.10.17...v4.10.18
1851

19-
4.10.17 - 23 Sep 2024
20-
-------------------
21-
22-
### Hotfix
23-
- Fix bug in `PropHybridTable` (#1102)
24-
25-
**Full Changelog**: https://github.com/chocoteam/choco-solver/compare/v4.10.16...v4.10.17
26-
27-
4.10.16 - 12 Sep 2024
28-
-------------------
29-
30-
### Hotfix
31-
- Fix bug in `IntAffineView` (#1101)
32-
33-
**Full Changelog**: https://github.com/chocoteam/choco-solver/compare/v4.10.15...v4.10.16
34-
35-
3652
4.10.17 - 23 Sep 2024
3753
-------------------
3854

Makefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# like running test suites
33

44
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
5-
DATE := $(shell date +'%y%m%d_%H:%M')
5+
PRETTY_DATE := $(shell date +'%m/%d/%Y %H:%M')
6+
DATE := $(shell date +'%y%m%d_%H%M')
67
CURRENT_VERSION := $(shell mvn help:evaluate -Dexpression=project.version | grep -v "\[INFO\]" | grep -v "\[WARNING\]")
78

89
.PHONY: all clean compile tests 1s 10s ibex checker mzn xcsp mps dimacs expl update_date compet msc delmsc help
@@ -25,6 +26,7 @@ help:
2526
@echo " mps to run all tests with mps"
2627
@echo " dimacs to run all tests with dimacs"
2728
@echo " expl to run all tests with expl"
29+
@echo " lcg to run all tests with lcg"
2830
@echo " update_date to update the date in the parsers"
2931
@echo " compet to update the date, clean and package the project"
3032
@echo " msc for MiniZincIDE, to install the msc file in ~/.minizinc/solvers"
@@ -45,23 +47,23 @@ clean:
4547
compile:
4648
mvn -q compile -DskipTests
4749

48-
tests : 1s 10s ibex checker mzn xcsp mps dimacs expl
50+
tests : 1s 10s ibex checker mzn xcsp mps dimacs expl lcg
4951

50-
1s 10s ibex checker mzn xcsp mps dimacs : compile
52+
1s 10s ibex checker mzn xcsp mps dimacs lcg: compile
5153
mvn -q test -DtestFailureIgnore=true -Dgroups="$@"
5254

5355
update_date:
54-
@sed -i '' 's| System.out.println("c Choco .*| System.out.println("c Choco $(DATE)");|' parsers/src/main/java/org/chocosolver/parser/xcsp/XCSP.java
55-
@sed -i '' 's| System.out.println("%% Choco .*| System.out.println("%% Choco $(DATE)");|' parsers/src/main/java/org/chocosolver/parser/flatzinc/Flatzinc.java
56+
@sed -i '' 's|\s*System.out.printf("c Choco.*|System.out.printf("c Choco%s ($(PRETTY_DATE))\\n", lcg? " with LCG" : "");|' parsers/src/main/java/org/chocosolver/parser/xcsp/XCSP.java
57+
@sed -i '' 's|\s*System.out.printf("%% Choco%s (.*|System.out.printf("%% Choco%s ($(PRETTY_DATE))\\n", lcg? " with LCG" : "");|' parsers/src/main/java/org/chocosolver/parser/flatzinc/Flatzinc.java
5658

5759
compet: update_date clean package
5860

5961
msc: compet
60-
@sed -i '' 's| "version": .*| "version" : "$(CURRENT_VERSION)",|' parsers/src/main/minizinc/choco.msc
62+
@sed -i '' 's| "version" : .*| "version" : "$(CURRENT_VERSION)",|' parsers/src/main/minizinc/choco.msc
6163
@sed -i '' 's|SNAPSHOT|$(DATE)|g' parsers/src/main/minizinc/choco.msc
62-
@sed -i '' 's| "mznlib": .*| "mznlib" : "$(ROOT_DIR)/parsers/src/main/minizinc/mzn_lib/",|' parsers/src/main/minizinc/choco.msc
63-
@sed -i '' 's| "executable": .*| "executable" : "$(ROOT_DIR)/parsers/src/main/minizinc/fzn-choco",|' parsers/src/main/minizinc/choco.msc
64-
@sed -i '' 's|^[^ ]*CHOCO_JAR=.*|CHOCO_JAR=$(ROOT_DIR)/parsers/target/choco-parsers-$(CURRENT_VERSION)-light.jar|' parsers/src/main/minizinc/fzn-choco
64+
@sed -i '' 's| "mznlib" : .*| "mznlib" : "$(ROOT_DIR)/parsers/src/main/minizinc/mzn_lib/",|' parsers/src/main/minizinc/choco.msc
65+
@sed -i '' 's| "executable" : .*| "executable" : "$(ROOT_DIR)/parsers/src/main/minizinc/fzn-choco",|' parsers/src/main/minizinc/choco.msc
66+
@sed -i '' 's|^[^ ]*JAR_FILE=.*|JAR_FILE="$(ROOT_DIR)/parsers/target/choco-parsers-$(CURRENT_VERSION)-light.jar"|' parsers/src/main/minizinc/fzn-choco.py
6567
@cp $(ROOT_DIR)/parsers/src/main/minizinc/choco.msc ~/.minizinc/solvers/choco-$(CURRENT_VERSION)-$(DATE).msc
6668

6769
delmsc:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
Choco-solver is an open-source Java library for Constraint Programming.
1919

20-
Current stable version is 4.10.18 (27 Jan 2025).
20+
Current stable version is 5.0.0-beta.1 (17 Feb 2025).
2121

2222
Choco-solver comes with:
2323
- various type of variables (integer, boolean, set, graph and real),
@@ -124,7 +124,7 @@ So you only have to edit your `pom.xml` to declare the following library depende
124124
<dependency>
125125
<groupId>org.choco-solver</groupId>
126126
<artifactId>choco-solver</artifactId>
127-
<version>4.10.18</version>
127+
<version>5.0.0-beta.1</version>
128128
</dependency>
129129
```
130130

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>org.choco-solver</groupId>
1919
<artifactId>choco</artifactId>
20-
<version>4.10.18</version>
20+
<version>5.0.0-beta.1</version>
2121
</parent>
2222
<artifactId>examples</artifactId>
2323
<packaging>jar</packaging>

examples/src/test/java/org/chocosolver/examples/integer/KnapsackTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void testALL10() throws IOException, SetUpException {
120120
ks.solveIt(s, true);
121121
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 1078, "obj val");
122122
Assert.assertEquals(s.getSolver().getSolutionCount(), 1, "nb sol");
123-
Assert.assertEquals(s.getSolver().getNodeCount(), 18, "nb nod");
123+
Assert.assertEquals(s.getSolver().getNodeCount(), 3, "nb nod");
124124
}
125125
}
126126

@@ -130,8 +130,8 @@ public void testOPT13() throws IOException, SetUpException {
130130
Model s = ks.modelIt("k20", 13);
131131
ks.solveIt(s, true);
132132
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 2657, "obj val");
133-
Assert.assertEquals(s.getSolver().getSolutionCount(), 1, "nb sol");
134-
Assert.assertEquals(s.getSolver().getNodeCount(), 18, "nb nod");
133+
Assert.assertEquals(s.getSolver().getSolutionCount(), 3, "nb sol");
134+
Assert.assertEquals(s.getSolver().getNodeCount(), 60, "nb nod");
135135
}
136136

137137
@Test(groups = "1s", timeOut = 60000)
@@ -141,7 +141,7 @@ public void testOPT14() throws IOException, SetUpException {
141141
ks.solveIt(s, true);
142142
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 2657, "obj val");
143143
Assert.assertEquals(s.getSolver().getSolutionCount(), 1, "nb sol");
144-
Assert.assertEquals(s.getSolver().getNodeCount(), 26, "nb nod");
144+
Assert.assertEquals(s.getSolver().getNodeCount(), 30, "nb nod");
145145
}
146146

147147
@Test(groups = "1s", timeOut = 60000)
@@ -151,7 +151,7 @@ public void testOPT15() throws IOException, SetUpException {
151151
ks.solveIt(s, true);
152152
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 2657, "obj val");
153153
Assert.assertEquals(s.getSolver().getSolutionCount(), 1, "nb sol");
154-
Assert.assertEquals(s.getSolver().getNodeCount(), 29, "nb nod");
154+
Assert.assertEquals(s.getSolver().getNodeCount(), 47, "nb nod");
155155
}
156156

157157
}

parsers/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>org.choco-solver</groupId>
1919
<artifactId>choco</artifactId>
20-
<version>4.10.18</version>
20+
<version>5.0.0-beta.1</version>
2121
</parent>
2222
<artifactId>choco-parsers</artifactId>
2323
<packaging>jar</packaging>

parsers/src/main/java/org/chocosolver/parser/RegParser.java

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.chocosolver.solver.ParallelPortfolio;
1919
import org.chocosolver.solver.Settings;
2020
import org.chocosolver.solver.Solver;
21-
import org.chocosolver.solver.learn.XParameters;
2221
import org.chocosolver.solver.search.strategy.BlackBoxConfigurator;
2322
import org.chocosolver.solver.search.strategy.Search;
2423
import org.chocosolver.solver.search.strategy.SearchParams;
@@ -169,15 +168,15 @@ public abstract class RegParser implements IParser {
169168
@Option(name = "-seed", usage = "Set the seed for random number generator. ")
170169
protected long seed = 0L;
171170

172-
@Option(name = "-exp", usage = "Plug explanation in (default: false).")
173-
public boolean exp = false;
174-
175-
@Option(name = "-dfx", usage = "Force default explanation algorithm.")
176-
public boolean dftexp = false;
177-
178171
@Option(name = "--cp-profiler", usage = "Connect to CP-Profiler. Two comma-separated values are expected: the execution id and the port.")
179172
public String cpProfiler = null;
180173

174+
@Option(name = "-lcg", usage = "Set Lazy Clause Generation (LCG) on. ")
175+
protected boolean lcg = false;
176+
177+
@Option(name = "--disable-shutdown-hook", usage = "Disable the shutdown hook.")
178+
protected boolean disableShutdownHook = false;
179+
181180
/**
182181
* Default settings to apply
183182
*/
@@ -214,7 +213,7 @@ protected RegParser(String parser_cmd) {
214213
}
215214

216215
public void createSettings() {
217-
defaultSettings = Settings.prod();
216+
defaultSettings = Settings.prod().setLCG(lcg);
218217
}
219218

220219
public final Settings getSettings() {
@@ -265,7 +264,9 @@ public final boolean setUp(String... args) throws SetUpException {
265264
valsel = new SearchParams.ValSelConf(valH, best, bestRate, last);
266265
}
267266
createSettings();
268-
Runtime.getRuntime().addShutdownHook(statOnKill);
267+
if (!disableShutdownHook) {
268+
Runtime.getRuntime().addShutdownHook(statOnKill);
269+
}
269270
return true;
270271
}
271272

@@ -301,22 +302,6 @@ public void configureSearch() {
301302
solver.verboseSolving(1000);
302303
}
303304
if (nb_cores == 1) {
304-
if (exp) {
305-
if (level.isLoggable(Level.INFO)) {
306-
solver.log().white().println("exp is on");
307-
}
308-
solver.setLearningSignedClauses();
309-
// THEN PARAMETERS
310-
XParameters.DEFAULT_X = dftexp;
311-
XParameters.PROOF = XParameters.FINE_PROOF = false;
312-
XParameters.PRINT_CLAUSE = false;
313-
XParameters.ASSERT_UNIT_PROP = true; // todo : attention aux clauses globales
314-
XParameters.ASSERT_NO_LEFT_BRANCH = false;
315-
XParameters.INTERVAL_TREE = true;
316-
if (solver.hasObjective()) {
317-
solver.setRestartOnSolutions();
318-
}
319-
}
320305
if (free) {
321306
freesearch(solver);
322307
}

parsers/src/main/java/org/chocosolver/parser/flatzinc/Flatzinc.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ public Flatzinc(boolean all, boolean free, int nb_cores) {
101101
public void createSettings() {
102102
defaultSettings = Settings.prod()
103103
.setMinCardinalityForSumDecomposition(256)
104-
.setLearntClausesDominancePerimeter(0)
105-
.setNbMaxLearntClauses(Integer.MAX_VALUE)
106-
.setRatioForClauseStoreReduction(.66f)
107-
.set("adhocReification", true);
104+
.setLCG(lcg)
105+
.setNbMaxLearntClauses(100_000)
106+
//.setIntVarLazyLitWithWeakBounds(false)
107+
.set("adhocReification", true)
108+
.setWarnUser(false)
109+
;
108110
}
109111

110112
@Override
@@ -126,7 +128,7 @@ public Thread actionOnKill() {
126128
@Override
127129
public void createSolver() {
128130
if (level.isLoggable(Level.COMPET)) {
129-
System.out.println("%% Choco 250127_16:13");
131+
System.out.printf("%% Choco-solver%s (5.0.0-beta.1, 250217_17:45)\n", lcg? " with LCG" : "");
130132
}
131133
super.createSolver();
132134
datas = new Datas[nb_cores];

0 commit comments

Comments
 (0)