Choco-solver is an open-source Java library for Constraint Programming.
Choco-solver is not the continuation of Choco2, but a completely rewritten version and there is no backward compatibility.
Current stable version is 4.0.0.a (13 Jun 2016).
Choco-solver comes with:
- various type of variables (integer, boolean, set, graph and real),
- various state-of-the-art constraints (alldifferent, count, nvalues, etc.),
- various search strategies, from basic ones (first_fail, smallest, etc.) to most complex (impact-based and activity-based search),
- explanation-based engine, that enables conflict-based back jumping, dynamic backtracking and path repair,
But also, facilities to interact with the search loop, factories to help modelling, many samples, etc.
Choco-solver is distributed under BSD 4-Clause License (Copyright (c) 1999-2016, Ecole des Mines de Nantes).
Contact: choco@mines-nantes.fr
// 1. Create a Model
Model model = new Model("my first problem");
// 2. Create variables
IntVar x = model.intVar("X", 0, 5);
IntVar y = model.intVar("Y", 0, 5);
// 3. Create and post constraints by using constraint factories
x.add(y).lt(5).post();
// 4. Define the search strategy
model.getSolver().setSearch(Search.inputOrderLBSearch(x, y));
// 5. Launch the resolution process
model.getSolver().solve();
// 6. Print search statistics
model.getSolver().printStatistics();
The archive file downloaded from the official website contains both the user guide (pdf) and the apidocs (zip).
You can get help on our forum. Most support requests are answered very fast.
Use the issue tracker here on GitHub to report issues. As far as possible, provide a Minimal Working Example.
Anyone can contribute to the project, from the source code to the documentation. In order to ease the process, we established a contribution guide that should be reviewed before starting any contribution as it lists the requirements and good practices to ease the contribution process.
Following are code snippets to add on your website to help us promoting Choco-solver.
html:
<a href="http://choco-solver.org/?utm_source=badge&utm_medium=badge&utm_campaign=badge">
<img border="0" alt="Choco-solver" src="http://choco-solver.org/sites/default/files/banner.svg" width="160" height="18">
</a>
Markdown:
[](http://choco-solver.org/?utm_source=badge&utm_medium=badge&utm_campaign=badge)
And thank you for giving back to choco-solver. Please meet our team of cho-coders :
Requirements:
- JDK 8+
- maven 3+
Choco-solver is available on Maven Central Repository, or directly from the official website.
Snapshot releases are also available for curious.
In the following, we distinguish two usages of Choco:
- as a standalone application: the jar file includes all required dependencies,
- as a library: the jar file excludes all dependencies.
The name of the jar file terms the packaging: choco-solver-4.0.0.a-with-dependencies.jar
or choco-solver-4.0.0.a.jar
.
A Changelog file is maintained for each release.
Choco is available on Maven Central Repository.
So you only have to edit your pom.xml
to declare the following library dependency:
<dependency>
<groupId>org.choco-solver</groupId>
<artifactId>choco-solver</artifactId>
<version>4.0.0.a</version>
</dependency>
Note that if you want to test snapshot release, you should update your pom.xml
with :
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
The jar file contains all required dependencies. The next step is simply to add the jar file to your classpath of your application. Note that if your program depends on dependencies declared in the jar file, you should consider using choco as a library.
The jar file does not contains any dependencies, as of being used as a dependency of another application. The next step is to add the jar file to your classpath of your application and also add the required dependencies.
The required dependencies for compilation are:
dk.brics.automaton:automaton:1.11-8
args4j:args4j:2.33
org.javabits.jgrapht:jgrapht-core:0.9.3
com.github.cp-profiler:cpprof-java:1.1.0
org.choco-solver:choco-sat:1.0.2
net.sf.trove4j:trove4j:3.0.3
org.zeromq:jeromq:0.3.4
com.google.protobuf:protobuf-java:2.6.1
They are available on Maven Repository (http://mvnrepository.com/).
The source of the released versions are directly available in the Tag
section.
You can also download them using github features.
Once downloaded, move to the source directory then execute the following command
to make the jar:
$ mvn clean package -DskipTests
If the build succeeded, the resulting jar will be automatically
installed in your local maven repository and available in the target
sub-folders.
=================== The Choco-solver dev team.