Skip to content

Commit

Permalink
Fix corner case of cpsat encoding :
Browse files Browse the repository at this point in the history
- when no task is consuming in resource, we don't include constraints storing the consumption of this resource, because it leads to failed model. (addMaxEquality most probably or NonOverlap are not compliant with empty list of variables)
  • Loading branch information
g-poveda committed Mar 14, 2024
1 parent 1e8aa35 commit 3166d37
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions discrete_optimization/rcpsp/solver/cpsat_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ def create_cumulative_constraint_and_used_resource(
for mode in self.problem.mode_details[task]
if self.problem.mode_details[task][mode].get(resource, 0) > 0
]
if len(task_modes_consuming) == 0:
# when empty, the constraints don't work !
return
fake_task_res = [
(
model.NewFixedSizeIntervalVar(
Expand Down Expand Up @@ -481,6 +484,9 @@ def create_cumulative_constraint_and_resource_capa(
for mode in self.problem.mode_details[task]
if self.problem.mode_details[task][mode].get(resource, 0) > 0
]
if len(task_modes_consuming) == 0:
# when empty, the constraints don't work !
return
fake_task_res = [
(
model.NewFixedSizeIntervalVar(
Expand Down

0 comments on commit 3166d37

Please sign in to comment.