Skip to content

CP-SAT model that most of the time solved to optimality, but in rare cases it is determined to be infeasible #4839

Closed

Description

@istvan-modos

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  3

What 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

Activity

  1. added this to the Backlog milestone on Sep 24, 2025
  2. lperron commented on Sep 25, 2025

    @lperron
    Collaborator

    Thanks, we can reproduce and we are investigating.

  3. lperron commented on Sep 25, 2025

    @lperron
    Collaborator

    as a workaround, parameter symmetry_level:0 should remove the problem

  4. istvan-modos commented on Sep 25, 2025

    @istvan-modos
    Author

    as a workaround, parameter symmetry_level:0 should remove the problem

    I confirm that by disabling symmetry detection the problem does not occur. I also tried doing symmetry detection only in presolve (levels 1 and 4) and for those settings, it also seems to work well.

  5. added a commit that references this issue on Sep 26, 2025
    a796904
  6. added a commit that references this issue on Oct 1, 2025
    5d85f84
  7. modified the milestones: Backlog, v10.0 on Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions