chocoteam / chocoteam/choco-solver

Improve Expression Compilation

Open
#953 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
779
Forks
159
Avg merge
6d 9h
Merged PRs (30d)
10

Description

Hi choco team,

I hope that you are doing well.

**Is your feature request related to a problem? Please describe.**

Choco provides a convenient expression builder that is then compiled into a set of constraints.
It is a complicated task, but some improvements seems possible.
For instance, reification is not needed when there is a simple conjunction of constraint.

Let us consider the following model.

```java
Model model = new Model();
IntVar x = model.intVar("x", 1, 9);
IntVar y = model.intVar("y", 0, 9);
IntVar z = model.intVar("z", 0, 9);

x.le(y).and(z.ge(x)).post();
// x.le(y).and(z.ge(x)).decompose().post(); // do not change anything here
System.out.println(model);
```
The output is the following.
```
satisfaction : undefined
== variables ==
x = {1..9}
y = {0..9}
z = {0..9}
LE_exp_1 = [0,1]
GE_exp_2 = [0,1]
cste -- 2 = 2
== constraints ==
BASIC_REIF ([(x < y + 1) <=> LE_exp_1])
BASIC_REIF ([(x < z + 1) <=> GE_exp_2])
ARITHM ([LE_exp_1 = [0,1] + GE_exp_2 = [0,1] = 2])
```

**Describe the solution you'd like**
I want the conjunction to be posted as independent constraints.
```java
x.le(y).post()
z.ge(x)).post();
```

**Describe alternatives you've considered**

The immediate answer is to post multiple constraints, but, in my case, the expression is also built automatically.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.