Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duration of task should be 0 for Cumulative constraint when capacity is insufficient #3970

Closed
IgnaceBleukx opened this issue Oct 31, 2023 · 1 comment
Assignees
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: CP-SAT Solver Relates to the CP-SAT solver
Milestone

Comments

@IgnaceBleukx
Copy link

Hi,

I am trying to use the CP-SAT solver to find a solution for a Cumulative constraint where the durations are integer variables.
When the required resource of a task exceeds the total capacity I would assume the duration of the task is put to 0.
However, in the following example this is not the case and the solver does not find a solution:

from ortools.sat.python import cp_model as ort

model = ort.CpModel()
solver = ort.CpSolver()

start = [model.NewIntVar(0,4,f"start_{i}") for i in range(3)]
end = [model.NewIntVar(0,4,f"end_{i}") for i in range(3)]

dur = [model.NewIntVar(0,1,f"dur_{i}") for i in range(3)]
# dur = [1,0,1]

intervals = [model.NewIntervalVar(s,d,e,f"{s}-{d}-{e}") for s,d,e in zip(start,dur,end)]

model.AddCumulative(intervals, [1,5,1],1) # requirement of second task exceeds capacity

# solver.parameters.cp_model_presolve=False
status = solver.Solve(model)

if status == ort.INFEASIBLE:
    print("Model is UNSAT")
else:
    print("Found solution")

>> Output: 'Model is UNSAT'

By uncommenting the line forcing the durations to [1,0,1] the model becomes SAT.
Also by disabling presolve the solver finds a solution.

I am using OR-tools version 9.7.2996 on Ubuntu 22.04.

Kind regards,
Ignace

lperron added a commit that referenced this issue Nov 1, 2023
@lperron
Copy link
Collaborator

lperron commented Nov 1, 2023

Fixed on main.

Thanks for the report.

@lperron lperron closed this as completed Nov 1, 2023
@Mizux Mizux added Help Needed Modeling/Usage problem Solver: CP-SAT Solver Relates to the CP-SAT solver Lang: Python Python wrapper issue labels Nov 1, 2023
@Mizux Mizux added this to the v9.8 milestone Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: CP-SAT Solver Relates to the CP-SAT solver
Projects
None yet
Development

No branches or pull requests

3 participants