# Choco Solver

### My Hello World in Choco Solver 4.0

In this example, we create a very simple problem : two integers of different domains, a and b, must satisfy the following equation : `a + b < 8`

``````/*
* Copyright (C) 2017 COSLING S.A.S.
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
*/

import org.chocosolver.solver.Model;
import org.chocosolver.solver.variables.IntVar;

/**
* Simple Hello World in Choco Solver
* @author Jean-Guillaume FAGES (cosling)
* @version choco-solver-4.0.4
*/
public class HelloWorld {

public static void main(String[] args) {
// The model is the main component of Choco Solver
Model model = new Model("Choco Solver Hello World");
// Integer variables
IntVar a = model.intVar("a", new int[]{4, 6, 8}); // takes value in { 4, 6, 8 }
IntVar b = model.intVar("b", 0, 2); // takes value in [0, 2]

// Add an arithmetic constraint between a and b
// BEWARE : do not forget to call post() to force this constraint to be satisfied
model.arithm(a, "+", b, "<", 8).post();

int i = 1;
// Computes all solutions : Solver.solve() returns true whenever a new feasible solution has been found
while (model.getSolver().solve()) {
System.out.println("Solution " + i++ + " found : " + a + ", " + b);
}
}
}
```
```

Choco Solver finds the following solutions :

```            ```
Solution 1 found : a = 4, b = 0
Solution 2 found : a = 4, b = 1
Solution 3 found : a = 4, b = 2
Solution 4 found : a = 6, b = 0
Solution 5 found : a = 6, b = 1
```
```