-
Notifications
You must be signed in to change notification settings - Fork 2.4k
CP-SAT model that most of the time solved to optimality, but in rare cases it is determined to be infeasible #4839
Description
What version of OR-Tools and what language are you using?
Version: 9.14.6206
Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT
What operating system (Linux, Windows, ...) and version?
MacOS 26.0
What did you do?
I'm running an optimization of the same model from a protobuf file. As the issue cannot be deterministically reproduced, I'm running the optimization few thousand times and I hope that it will happen in at least one of those runs.
from ortools.sat.python import cp_model
from google.protobuf import text_format
# Issue cannot be reproduced deterministically.
for _ in range(10000):
# Read the CP model from protobuf file
model = cp_model.CpModel()
with open("model.txt", "r") as file:
text_format.Parse(file.read(), model.Proto())
# Solve the model using multiple threads.
solver = cp_model.CpSolver()
solver.parameters.num_workers = 16
status = solver.solve(model)
# Correct behavior: model is optimal or feasible. Happens most of the time.
# Incorrect behavior: model is infeasible. Happens only a handful of times.
if (status == 3):
print("infeasible")The protobuf model
model.txt .
In summary, it is a 2D bin-packing model with the objective to minimize the number of bins. Due to reasons that are out-of-scope, the objective in the model is actually defined as max totalNumBins - usedNumBins. The instance is created in such a way, that there is an optimal solution using two bins (i.e., objective value of 0).
What did you expect to see
I expect to see no output, as this model is feasible and easily solvable to optimality.
What did you see instead?
Instead, in few runs the solver says that the model is infeasible. The actual output on my machine is
infeasible 3
infeasible 3
infeasible 3
infeasible 3
infeasible 3
infeasible 3
infeasible 3
infeasible 3
infeasible 3What I have tried
- downgrading to 9.11.4210: the issue does not occur
- keeping the latest OR tools version but setting
num_workers=1: the issue does not occur
Anything else we should know about your project / environment