chocoteam / chocoteam/choco-solver
[BUG] Start and end of tasks are always enforced at root
- Dominant language
- Java
- Stars
- 779
- Forks
- 159
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 10
Description
Hi,
I'm attempting to model a half-reified Cumulative constraint (see sample code below).
However, while the "non-overlapness" of the Cumulative constraints is correctly reified, the link between start and end variables in the tasks is not reified with it.
E.g., the model with constraints `[e == 1, bv -> Cumulative([s], [3], [e], [1],[1])]` should be satisfied when the Boolean variable is set to False.
However, as the task is created at the toplevel of the constraint model, it will fail because of the `e == 1` assignment.
Is this considered the expected behaviour of the tasks-constructor? And if so, how should I modify my model to properly reflect a truely half-reified Cumulative constraint?
```java
import org.chocosolver.solver.Model;
import org.chocosolver.solver.variables.IntVar;
import org.chocosolver.solver.variables.BoolVar;
import org.chocosolver.solver.variables.Task;
public class CumulativeModel {
public static void main(String[] args) {
// Create a Choco model
Model model = new Model("Cumulative Scheduling Model");
// Define variables
IntVar[] start = new IntVar[3];
IntVar[] end = new IntVar[3];
int[] duration = {3, 3, 3};
IntVar[] demand = new IntVar[3];
IntVar capacity = model.intVar("cap", 1,1);
for (int i = 0; i < 3; i++) {
start[i] = model.intVar("start[" + i + "]", 0, 5);
end[i] = model.intVar("end[" + i + "]", 0, 5);
demand[i] = model.intVar("demand[" + i +"]", 1,1);
}
// Make the tasks
Task[] tasks = new Task[3];
for (int i = 0; i < 3; i++) {
tasks[i] = new Task(start[i], duration[i], end[i]);
}
// Define the Boolean variable
BoolVar bv = model.boolVar("bv");
// Add cumulative constraint wrapped in implication
model.cumulative(tasks, demand, capacity).impliedBy(bv);
// Add the constraint end[0] == 1
model.arithm(end[0], "=", 1).post(); // This makes the model UNSAT
// Solve the model
if (model.getSolver().solve()) {
System.out.println("Solution found:");
for (int i = 0; i < 3; i++) {
System.out.println("start[" + i + "] = " + start[i].getValue());
System.out.println("end[" + i + "] = " + end[i].getValue());
}
} else {
System.out.println("No solution found.");
}
}
}
```
I'm running on the latest release (v4.10.17)
Kind regards,
Ignace
Contributor guide
Research direction
Start by reproducing the provided Java model with Choco v4.10.17, then inspect the Task constructor and the cumulative constraint's impliedBy behavior. Determine whether the start/end relationship is intentionally enforced outside the implication and document or correct the behavior so the reported half-reified case has a clear resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100