Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
6ea8118
Add decomposition of AllDifferentExcept0 and AllDifferentExceptValues…
cprudhom Feb 25, 2025
18e0976
Fix error in XCSP groups declaration.
cprudhom Feb 25, 2025
8e13668
Reduce the extension fallback threshold to 100_000 instead of 2147483
cprudhom Feb 25, 2025
b6e5bc2
Add new lzma files
cprudhom Mar 11, 2025
ff9a26a
Add seed as new parameter in PickOnDom and PickOnFil
cprudhom Mar 11, 2025
90562c8
Update BlackBoxConfigurator#setRefinedPartialAssignmentGeneration to …
cprudhom Mar 11, 2025
3f7f551
Add MetaStrategy abstract class
cprudhom Mar 11, 2025
473c313
Remove PropSat from failure-based search strategy because the "explan…
cprudhom Mar 13, 2025
5077bce
Fix error when getting the group of variables and some are null (XCSP3)
cprudhom Mar 13, 2025
279b868
Change conditions for choosing between extension or decomposition for…
cprudhom Mar 13, 2025
cc8f328
Simplify PropSTR2 to avoid storing the Tuples object
cprudhom Mar 13, 2025
089a9cc
Cache matrix (using SoftReference) in the Tuples object to reduce mem…
cprudhom Mar 13, 2025
dde2edd
Cache tuples (using WeakHashMap) in XCSPParser to reduce memory footp…
cprudhom Mar 13, 2025
d300c5a
Add a RoundRobin strategy based on Group
cprudhom Mar 21, 2025
9e01cc5
Remove assert k > 0 for LastConflict to allow dummy meta strategy dec…
cprudhom Mar 21, 2025
1bac37a
AbstractCriterionBasedVariableSelector now interpert seed = -1 as lex…
cprudhom Mar 21, 2025
a1aa164
Add NextModuloN policy for MAB (= round robin)
cprudhom Mar 21, 2025
595ca4a
Update Search#roundRobinSearch and create Search#adaptiveRoundRobinSe…
cprudhom Mar 21, 2025
db8cb2d
Fix java compatibility
cprudhom Mar 21, 2025
0f7298e
Define a default search strategy for XCSP3
cprudhom Mar 21, 2025
898291e
support regular with negative values
jgFages Mar 22, 2025
69d1e6b
faster isInScope method + bugfix conflictOrderingSearch
jgFages Mar 25, 2025
4a5d207
search simplification
jgFages Mar 25, 2025
1c62aeb
update changes.md
jgFages Mar 25, 2025
e5b5b44
fix tests
jgFages Mar 25, 2025
3504d0f
fix test
jgFages Mar 25, 2025
6349fd1
Add Javadoc
cprudhom Mar 26, 2025
7ca5d1c
support regular with negative values
jgFages Mar 26, 2025
44b4b6c
Move MapVal and ArrayVal to IVal inner classes.
cprudhom Mar 27, 2025
d8e4d0d
Create Weightable class and its two inner classes.
cprudhom Mar 27, 2025
9cdaaf5
Correction of ConflictHistorySearch
cprudhom Mar 27, 2025
aa7b7ba
Revamp AbstractCriterionBasedVariableSelector.
cprudhom Mar 27, 2025
e73fe7b
Fix https://github.com/chocoteam/choco-solver/pull/1154#discussion_r2…
cprudhom Mar 28, 2025
05e0ab5
Remove PickOnFil.java
cprudhom Mar 28, 2025
eeb1718
Adapt the philosophy of PickOnDom to constraint-oriented prop engine.…
cprudhom Mar 28, 2025
344dc99
Remove Weightable and replace the Array implementation by IdentityToD…
cprudhom Mar 28, 2025
60d4659
Move IVal to inner class of ActivityBased and change its name to Valu…
cprudhom Mar 28, 2025
829ae83
AbstractCriterionBasedVariableSelector now interpert seed = -1 as lex…
cprudhom Mar 21, 2025
7c7243f
Cache transitions for MDDs in XCSP3
cprudhom Apr 16, 2025
4b7a2f2
Change priority of STR2+
cprudhom Apr 16, 2025
4f69c42
Remove automatic conversion of scalar to table
cprudhom Apr 16, 2025
df2e900
Better (correct) conditions for propagating half-reified constraint
cprudhom Apr 16, 2025
4b1bcb3
Fix error in allDifferentExceptValues
cprudhom Apr 16, 2025
2c43ad9
Fix issue related to `in`
cprudhom May 6, 2025
11a01fa
Fix filtering weakness in atLeastNValues
cprudhom May 6, 2025
f0df118
Check view by default
cprudhom May 21, 2025
9df2b67
Model is not final anymore
cprudhom May 21, 2025
9a7bc71
`abs` (fake) view does not force the type of domain of the resulting var
cprudhom May 21, 2025
57dec88
Fix error when using range with views
cprudhom May 21, 2025
ecd624f
Does not consider constants as variables when collecting variables fr…
cprudhom May 21, 2025
ade52f1
Recognize x.dist(y).eq(z) from expression like x.sub(y).abs().eq(z)
cprudhom May 21, 2025
b6b32a9
Improvement of CT:
cprudhom May 21, 2025
b65b9c4
Replace TIntSet with BitSet in PropLargeMDDC
cprudhom May 21, 2025
abde1ca
Add methods in TuplesFactory to sample positive tuples based on varia…
cprudhom May 21, 2025
9b5b37f
Test non uniqueness of a variable in table constraint
cprudhom May 21, 2025
807d05d
Change the way STAR value is set in Tuples
cprudhom May 21, 2025
0c5ce92
Correct IIntDeltaMonitor#sizeApproximation()
cprudhom May 21, 2025
680877a
CompactTable: sparse domains are now managed with dedicated support s…
cprudhom May 27, 2025
dabc225
Fix error in T_solve_goal#testNestedSeq model definition (related to …
cprudhom May 27, 2025
4257cd6
Correct wrong domain definition for abs expression
cprudhom May 28, 2025
ea8065f
Downgrade slf4j-nop version to remove message with XCSP
cprudhom Jun 11, 2025
c696e06
Update Makefile with ISO 8601 format for Welcome message in XCSP and …
cprudhom Jun 11, 2025
7c8e002
Remove SatDecorator#removeDominated(cr) call on learnClause(...) beca…
cprudhom Jun 11, 2025
8b8dde1
NogoodFromRestarts better handle BoolVar
cprudhom Jun 11, 2025
64a8bf8
All implementations of ArExpression override #getExpressionChild()
cprudhom Jun 11, 2025
c5d5c4c
Passing -1 as a seed to FailureBased search breaks tie with input order
cprudhom Jun 11, 2025
3f947a9
Fix the way FutVars are managed in Dom/Wdeg and refined
cprudhom Jun 11, 2025
beb2f1b
Operator of LoExpression are accessible
cprudhom Jun 11, 2025
2bc2eee
Fix issue related to IntVarLazyLit and getLit(v,LR_EQ)
cprudhom Jun 20, 2025
1212b43
Remove IntDomainRandomBound.java and add new parameter to IntDomainRa…
cprudhom Jun 20, 2025
461f2e5
Fix bug related to wrong conversion to long in PropTimesNaiveWithLong
cprudhom Jul 8, 2025
b0fe60e
Improve Clause#reduceOs
cprudhom Jul 8, 2025
c2ee5a4
Bind r(int... ps) to r(int) and r(int, int)
cprudhom Jul 8, 2025
bc6845e
Simplification of BoolEvtScheduler
cprudhom Jul 8, 2025
c1c16c1
Fix incorrect management of reification when views are implied
cprudhom Jul 8, 2025
f415631
Fix incorrect creation of univ value for IfThenElse
cprudhom Jul 8, 2025
d6e5e9e
Update Docker.dms
cprudhom Jul 9, 2025
509674e
Update the docker command of Makefile to generate two images, one wit…
cprudhom Jul 9, 2025
1003399
Change parameters of RegParser
cprudhom Jul 9, 2025
f1418da
Add decomposition of Disjunctive
cprudhom Jul 9, 2025
b39dfc4
Turn scalar into table in the decomposition of 2D-Element
cprudhom Jul 9, 2025
027ff78
Declare third-party licenses in uberjar/META-INF
cprudhom Aug 14, 2025
74f2cfe
Update maven configuration to central sonatype prerequisites
cprudhom Aug 14, 2025
17b5e22
Fix raw uses of Decision
cprudhom Aug 14, 2025
723e7b5
Deal with NE operator in NaReExpression
cprudhom Aug 14, 2025
ad6fe4e
UnArExpression: disable distance recognition when LCG is on
cprudhom Aug 14, 2025
f7acb92
LCG: dedicated propagators for div and abs
cprudhom Aug 14, 2025
68acf21
Table: simplify default algo selection, now CT is the unique falling …
cprudhom Aug 14, 2025
f982dc9
Preprocessing: move the class and add new actions
cprudhom Aug 14, 2025
37b090e
Flatzinc : clean up cumulative decomp option
cprudhom Aug 14, 2025
81fdaa7
XCSP3: adapt restart and nogood recording to LCG option
cprudhom Aug 14, 2025
c372800
BBox search conf: use 'restartOnSolution' option
cprudhom Aug 14, 2025
93164eb
Bbox searches: set flush threshold to 20 restarts by default + allow …
cprudhom Aug 14, 2025
5a85f63
MetaStrategy: declare abstract class for more flexibility
cprudhom Aug 14, 2025
288098c
IntValueSelection: add sticky
cprudhom Aug 14, 2025
6b565c1
Search: update RoundRobin
cprudhom Aug 14, 2025
3b375f2
Expression: add 'embody' method that decides whether to decompose the…
cprudhom Aug 14, 2025
f304f85
ParallelPortfolio : delete 'searchAutoConf' parameter, now each model…
cprudhom Aug 14, 2025
f334bed
XCSP3: update parsing
cprudhom Aug 14, 2025
729e69c
int_div: add missing (and obvious) filtering for the light version
cprudhom Aug 14, 2025
0b063a3
at_least_nvalues: rollback #5b8d7ab4 (incorrect)
cprudhom Aug 14, 2025
5edf01d
int_div: capture unsatisfiable cases
cprudhom Aug 14, 2025
d23fa14
Tests: update tests for explanations
cprudhom Aug 14, 2025
684e71c
XCSP3: move to xcsp3-tools v2.5
cprudhom Aug 14, 2025
fc1a7b2
Fix last commits
cprudhom Aug 14, 2025
d36d6ff
abs: better deal with constants
cprudhom Aug 14, 2025
6b77919
div: catch unsupported cases of light version and fall back to full v…
cprudhom Aug 18, 2025
abb58d9
fix tests wrt to commit #3f947a97 which change the behavior of the de…
cprudhom Aug 18, 2025
3500d0f
fix commit #c5d5c4c1 : accidental change in the scope of the variable…
cprudhom Aug 18, 2025
9cf840e
revert commit #4f69c42b (not justified enough)
cprudhom Aug 18, 2025
e86270e
Table: adapt priority of CT wrt the number of variables involved
cprudhom Aug 18, 2025
62bc705
Expr : fix seed in sampling for conversion to extensional constraint
cprudhom Aug 18, 2025
68b61f4
XCCSP: update tests wrt to changes related to competition preparation
cprudhom Aug 18, 2025
e92e588
Table: fix test wrt commuit #e86270e7
cprudhom Aug 18, 2025
280c584
Merge branch 'develop' into xcsp
cprudhom Aug 19, 2025
5f78220
fix commit #280c5848 (merge manually on github)
cprudhom Aug 19, 2025
8505628
LCG: prevent prohibiting-solution clauses from being removed on calls…
cprudhom Aug 26, 2025
7d94505
LCG: fix a bug that occurs when some constraints are reified. Some ev…
cprudhom Aug 27, 2025
6c7d05f
CPProfiler: display modifications
cprudhom Aug 28, 2025
b3ecbd8
Flatzinc: set complementary search by default (not only output variab…
cprudhom Aug 28, 2025
839c644
X+Y=Z: removal of `PropXplusYeqZ`, fall back propagator is `PropSum`
cprudhom Sep 4, 2025
d8faa17
Table: when the memory estimation is too big STR2+ is selected instea…
cprudhom Sep 9, 2025
12f6c52
LCG : constants are now managed as a specific case of IntVarEagerLit
cprudhom Sep 12, 2025
55e0c1d
LCG : add new assertion when enqueuing literal in MiniSat
cprudhom Sep 12, 2025
ca30903
MiniSat: move Clause#allFalseButOne to MiniSat#isAssertingClause
cprudhom Sep 12, 2025
674e0e4
Javadoc : update
cprudhom Sep 16, 2025
89c999d
Replace Cumulative implementation by state-of-the-art implementation …
ArthurGodet Oct 28, 2025
f29f80f
Update CHANGES.md
ArthurGodet Oct 28, 2025
422901b
Explained Bimodal AllDifferent (#1173)
NelusBreizh Nov 21, 2025
f77428e
IntVar no longer extends Iterable (#1177)
jgFages Dec 1, 2025
8d20469
LCG : fix incomplete initialisation of sparse domain lit-based variable
cprudhom Jan 5, 2026
6ffb3db
MiniSat : fix ccmin_mode 1 and 2 (should be evaluated though)
cprudhom Jan 5, 2026
722ee85
LCG : allow sorting literals on solution or failure (disabled by defa…
cprudhom Jan 5, 2026
39e9c05
LCG : disabling additional clauses posting when at least one variable…
cprudhom Jan 8, 2026
b814d83
CT : add invariant check when CT* is used
cprudhom Jan 8, 2026
868bb5e
Performance improvement in PropXPlusYEqZ and PropAbsolute (#1178)
jgFages Jan 15, 2026
d0f2635
Merge pull request #1179
jgFages Jan 23, 2026
00405ce
Fix tests related to PR #1179
cprudhom Jan 23, 2026
74b16b4
CT : change the way estimated memory for CT is computed
cprudhom Jan 23, 2026
0acf1a9
Tests : increase timeOut of testReifiedConnectivity
cprudhom Jan 26, 2026
b283f9f
Flatzinc : deal with unary table constraints + expression-based setvar
cprudhom Jan 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/maven-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on: [push, pull_request]

jobs:
test-ibex:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
# The different steps
steps:
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,9 @@ jobs:

# Regression tests
- name: Test Ibex
run: mvn --file pom.xml test -Pcoverage -DtestFailureIgnore=true -Dgroups=ibex
run: |
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/ibex/3rd
mvn --file pom.xml test -Pcoverage -DtestFailureIgnore=true -Dgroups=ibex

test-solver:
runs-on: ubuntu-latest
Expand Down
23 changes: 6 additions & 17 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ NEXT MILESTONE
### Other closed issues and pull requests:
See [milestone 5.0.0-beta.2](https://github.com/chocoteam/choco-solver/milestone/41)

- Performance improvement in PropXPlusYEqZ and PropAbsolute
- Fix bug in ConflictOrderingSearch (monitor not plugged)
- Performance improvement for LastConflict, ConflictOrderingSearch and StrategySequencer.
- Fix bug : regular constraints parsed from XCSP now support negative values
- Fix bug : Unexpected behavior when using Task with scalar (#1114)
- Replace Cumulative implementation by state-of-the-art implementation of TimeTabling and OverloadChecking
- Fix bug : IntVar no longer extends Iterable to avoid errors in nested loops
- Fix bug : Fix iterator issue when using ISet, especially within graph variables (#1174 and #1175)

#### Contributors to this release:
- [Charles Prud'homme](https://github.com/cprudhom) (@cprudhom)
- [Jean-Guillaume Fages](https://github.com/jgFages) (@jgFages)
- [Arthur Godet](https://github.com/ArthurGodet) (@ArthurGodet)


**Full Changelog**: https://github.com/chocoteam/choco-solver/compare/v5.0.0-beta.1...v5.0.0-beta.2
Expand Down Expand Up @@ -70,23 +76,6 @@ See [milestone 5.0.0](https://github.com/chocoteam/choco-solver/milestone/40)

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

4.10.17 - 23 Sep 2024
-------------------

### Hotfix
- Fix bug in `PropHybridTable` (#1102)

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

4.10.16 - 12 Sep 2024
-------------------

### Hotfix
- Fix bug in `IntAffineView` (#1101)

**Full Changelog**: https://github.com/chocoteam/choco-solver/compare/v4.10.15...v4.10.16


4.10.17 - 23 Sep 2024
-------------------

Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# like running test suites

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

Expand Down Expand Up @@ -53,8 +53,8 @@ tests : 1s 10s ibex checker mzn xcsp mps dimacs expl lcg
mvn test -DtestFailureIgnore=true -Dgroups="$@"

update_date:
@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
@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
@sed -i '' 's|\s*System.out.printf("c Choco.*|System.out.printf("c Choco-solver%s ($(CURRENT_VERSION), $(PRETTY_DATE))\\n", lcg? " with LCG" : "");|' parsers/src/main/java/org/chocosolver/parser/xcsp/XCSP.java
@sed -i '' 's|\s*System.out.printf("%% Choco.*|System.out.printf("%% Choco-solver%s ($(CURRENT_VERSION), $(PRETTY_DATE))\\n", lcg? " with LCG" : "");|' parsers/src/main/java/org/chocosolver/parser/flatzinc/Flatzinc.java

compet: update_date clean package

Expand All @@ -70,6 +70,11 @@ delmsc:
@rm ~/.minizinc/solvers/choco-$(VERSION).msc

docker: compet
# add an image with LCG support
@sed -i '' 's|python3.*|python3 "$$(dirname "$$0")/fzn-choco.py" "$$@" "-lcg"|' parsers/src/main/minizinc/fzn-choco.sh
@docker build -f $(ROOT_DIR)/parsers/src/main/minizinc/docker/Dockerfile.dms -t chocoteam/choco-solver-mzn:$(CURRENT_VERSION)-X $(ROOT_DIR)
# add an image without LCG support
@sed -i '' 's|python3.*|python3 "$$(dirname "$$0")/fzn-choco.py" "$$@"|' parsers/src/main/minizinc/fzn-choco.sh
@docker build -f $(ROOT_DIR)/parsers/src/main/minizinc/docker/Dockerfile.dms -t chocoteam/choco-solver-mzn:$(CURRENT_VERSION) $(ROOT_DIR)

antlr:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void test(){
CostasArrays ca = new CostasArrays();
ca.execute();
Assert.assertEquals(ca.getModel().getSolver().getSolutionCount(), 1);
Assert.assertEquals(ca.getModel().getSolver().getNodeCount(), 6539);
Assert.assertEquals(ca.getModel().getSolver().getNodeCount(), 8_987);
}

@Test(groups = "10s", timeOut = 60000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testOPT13() throws IOException, SetUpException {
ks.solveIt(s, true);
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 2657, "obj val");
Assert.assertEquals(s.getSolver().getSolutionCount(), 3, "nb sol");
Assert.assertEquals(s.getSolver().getNodeCount(), 60, "nb nod");
Assert.assertEquals(s.getSolver().getNodeCount(), 59, "nb nod");
}

@Test(groups = "1s", timeOut = 60000)
Expand Down
32 changes: 31 additions & 1 deletion parsers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>org.xcsp</groupId>
<artifactId>xcsp3-tools</artifactId>
<version>2.4</version>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
Expand Down Expand Up @@ -114,11 +114,41 @@
<exclude>org/apache/fontbox/**</exclude>
</excludes>
</filter>
<filter>
<artifact>junit:junit</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-licenses</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/META-INF</outputDirectory>
<resources>
<resource>
<directory>../target/classes/META-INF</directory>
<includes>
<include>THIRD-PARTY-LICENSES.txt</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
Expand Down
6 changes: 3 additions & 3 deletions parsers/src/main/java/org/chocosolver/parser/RegParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public abstract class RegParser implements IParser {

@Option(name = "-flush",
forbids = {"-varsel"},
usage = "Autoflush weights on black-box strategies (default: 32).")
protected int flushRate = 32;
usage = "Autoflush weights on black-box strategies (default: 20).")
protected int flushRate = 20;

@Option(name = "-varsel",
handler = VarSelHandler.class,
Expand Down Expand Up @@ -166,7 +166,7 @@ public abstract class RegParser implements IParser {
protected int nb_cores = 1;

@Option(name = "-seed", usage = "Set the seed for random number generator. ")
protected long seed = 0L;
protected long seed = 1_000_000_007L;

@Option(name = "--cp-profiler", usage = "Connect to CP-Profiler. Two comma-separated values are expected: the execution id and the port.")
public String cpProfiler = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public enum CompleteSearch{
protected boolean oss = false;

@Option(name = "-ocs", usage = "Opens the complementary search to all variables of the problem\n" +
"(default: OUTPUT, i.e., restricted to the variables declared in output).")
protected CompleteSearch ocs = CompleteSearch.OUTPUT;
"(default: ALL, i.e., complete the search with a search on all variables.).")
protected CompleteSearch ocs = CompleteSearch.ALL;

//***********************************************************************************
// VARIABLES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.chocosolver.solver.expression.discrete.logical.NaLoExpression;
import org.chocosolver.solver.variables.*;
import org.chocosolver.util.objects.setDataStructures.iterable.IntIterableRangeSet;
import org.chocosolver.util.tools.ArrayUtils;
import org.chocosolver.util.tools.VariableUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -752,25 +753,7 @@ public void build(Model model, Datas datas, String id, List<Expression> exps, Li

IntVar[] vars = exps.get(0).toIntVarArray(model);
if (vars.length > 1) {
if(model.getSettings().isLCG()){
if (model.getSettings().warnUser()) {
model.getSolver().log().white().println(
"Warning: fzn_alldifferent_except_0 constraint is decomposed (due to LCG).");
}
IntIterableRangeSet values = new IntIterableRangeSet();
for(int i = 0; i < vars.length; i++){
values.addAll(vars[i]);
}
values.add(0);
int[] valuesArray = values.toArray();
IntVar[] occurrences = new IntVar[valuesArray.length];
for(int i = 0; i < valuesArray.length; i++){
occurrences[i] = model.intVar(0, valuesArray[i] == 0?vars.length:1);
}
model.globalCardinality(vars, valuesArray, occurrences, true).post();
}else {
model.allDifferentExcept0(vars).post();
}
model.allDifferentExcept0(vars).post();
}

}
Expand Down Expand Up @@ -1079,21 +1062,11 @@ public void build(Model model, Datas datas, String id, List<Expression> exps, Li
final IntVar[] resources = exps.get(2).toIntVarArray(model);
final IntVar limit = exps.get(3).intVarValue(model);
String decomp = (String) model.getHook("CUMULATIVE");
if (decomp == null) {
decomp = "GLB"; // TODO: make it configurable
}
int n = starts.length;
switch (decomp) {
case "GLB":
final IntVar[] ends = new IntVar[n];
Task[] tasks = new Task[n];
for (int i = 0; i < n; i++) {
ends[i] = model.intVar(starts[i].getName() + "_" + durations[i].getName(),
starts[i].getLB() + durations[i].getLB(),
starts[i].getUB() + durations[i].getUB(),
true);
assert durations[i].getUB() >= 0 && resources[i].getUB() >= 0;
tasks[i] = new Task(starts[i], durations[i], ends[i]);
}
model.cumulative(tasks, resources, limit, true/*, Cumulative.Filter.NAIVETIME*/).post();
break;
case "MZN":
model.cumulativeTimeDec(starts,
Arrays.stream(durations).mapToInt(IntVar::getUB).toArray(),
Expand Down Expand Up @@ -1178,6 +1151,20 @@ public void build(Model model, Datas datas, String id, List<Expression> exps, Li
-resources[i].getValue() + limit.getValue()).post();
}
break;
case "GLB":
default:
final IntVar[] ends = new IntVar[n];
Task[] tasks = new Task[n];
for (int i = 0; i < n; i++) {
ends[i] = model.intVar(starts[i].getName() + "_" + durations[i].getName(),
starts[i].getLB() + durations[i].getLB(),
starts[i].getUB() + durations[i].getUB(),
true);
assert durations[i].getUB() >= 0 && resources[i].getUB() >= 0;
tasks[i] = new Task(starts[i], durations[i], ends[i]);
}
model.cumulative(tasks, resources, limit/*, Cumulative.Filter.NAIVETIME*/).post();
break;
}
}
},
Expand Down Expand Up @@ -1716,6 +1703,9 @@ public void build(Model model, Datas datas, String id, List<Expression> exps, Li
for (int[] couple : t) {
tuples.add(couple);
}
if(x.length == 1) {
model.member(x[0], ArrayUtils.flatten(tuples.toMatrix())).post();
} else
if (x.length == 2) {
model.table(x[0], x[1], tuples).post();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,24 @@ private static IntVar buildOnExpression(String name, Expression expression, Data
private static SetVar buildWithSet(String name, DSet type, Expression expression, Datas datas, Model model) {
Declaration what = type.getWhat();
SetVar sv = null;
if(expression != null){
Exit.log("Unknown expression");
int[] ub = null;
if(expression != null) {
switch (expression.getTypeOf()) {
case SET_B:
DInt2 bounds = (DInt2) what;
ub = new int[bounds.getUpp() - bounds.getLow() + 1];
for (int i = 0; i < ub.length; i++) {
ub[i] = i + bounds.getLow();
}
break;
case SET_L:
DManyInt mint = (DManyInt) what;
ub = mint.getValues();
break;
default:
Exit.log("Unknown expression");
}
}else {
int[] ub = null;
switch (what.typeOf) {
case INT2:
DInt2 bounds = (DInt2) what;
Expand All @@ -269,9 +283,9 @@ private static SetVar buildWithSet(String name, DSet type, Expression expression
Exit.log("Unknown set type");
break;
}
if(ub != null){
sv = model.setVar(DEBUG ? name : NO_NAME, new int[]{}, ub);
}
}
if(ub != null){
sv = model.setVar(DEBUG ? name : NO_NAME, new int[]{}, ub);
}
datas.register(name, sv);
return sv;
Expand Down
20 changes: 19 additions & 1 deletion parsers/src/main/java/org/chocosolver/parser/xcsp/XCSP.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.chocosolver.solver.Model;
import org.chocosolver.solver.ResolutionPolicy;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.search.restart.InnerOuterCutoff;
import org.chocosolver.solver.search.restart.Restarter;
import org.chocosolver.solver.search.strategy.BlackBoxConfigurator;
import org.chocosolver.solver.search.strategy.Search;
import org.chocosolver.solver.search.strategy.SearchParams;
Expand Down Expand Up @@ -134,7 +136,17 @@ public void buildModel() {
public void parse(Model target, XCSPParser parser) throws Exception {
parser.model(target, instance);
// and define a search strategy
freesearch(target.getSolver());
BlackBoxConfigurator bb = BlackBoxConfigurator.init();
// variable selection
bb.setIntVarStrategy(Search::roundRobinSearch)
.setRestartPolicy(s -> new Restarter(new InnerOuterCutoff(50, 1.01, 1.01),
c -> s.getFailCount() >= c, 50_000, true))
.setNogoodOnRestart(!lcg)
.setRestartOnSolution(lcg)
.setRefinedPartialAssignmentGeneration(false)
.setExcludeObjective(true)
.setExcludeViews(false);
bb.make(target);
}


Expand Down Expand Up @@ -264,6 +276,9 @@ private void onSolution(Solver solver, XCSPParser parser) {
try {
output.insert(0, "s SATISFIABLE\n");
new SolutionChecker(true, instance, new ByteArrayInputStream(output.toString().getBytes()));
// new SolutionChecker(instance, new ByteArrayInputStream(output.toString().getBytes()),
// solver.getObjectiveManager().isOptimization() ? solver.getObjectiveManager().getBestSolutionValue().longValue() : null,
// null, true);
} catch (Exception e) {
throw new RuntimeException("wrong solution found twice");
}
Expand Down Expand Up @@ -329,6 +344,9 @@ private void finalOutPut(Solver solver) {
if (cs) {
try {
new SolutionChecker(true, instance, new ByteArrayInputStream(output.toString().getBytes()));
// new SolutionChecker(instance, new ByteArrayInputStream(output.toString().getBytes()),
// solver.getObjectiveManager().isOptimization() ? solver.getObjectiveManager().getBestSolutionValue().longValue() : null,
// null, true);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Loading
Loading