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

Inverse constraint crashes presolve #4072

Open
IgnaceBleukx opened this issue Jan 31, 2024 · 2 comments
Open

Inverse constraint crashes presolve #4072

IgnaceBleukx opened this issue Jan 31, 2024 · 2 comments
Assignees
Labels
Bug Solver: CP-SAT Solver Relates to the CP-SAT solver
Milestone

Comments

@IgnaceBleukx
Copy link

IgnaceBleukx commented Jan 31, 2024

Hi,

I was trying to generate some random problems involving Inverse constraints and found OR-tools crashing on some of the instances.
Below, is a minimal example in Python:

from ortools.sat.python import cp_model as ort

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

x = [model.NewIntVar(0,1,name=f"x_{i}") for i in range(4)]
rev1 = [model.NewIntVar(0,1,name=f"rev1_{i}") for i in range(2)]
rev2 = [model.NewIntVar(0, 1, name=f"rev2_{i}") for i in range(2)]
rev3 = [model.NewIntVar(0, 1, name=f"rev3_{i}") for i in range(2)]

model.AddInverse([x[0], x[3]], rev1)
model.AddInverse([x[0], x[1]], rev2)
model.AddInverse([x[2], x[0]], rev3)

# solver.parameters.cp_model_presolve=False # EDIT: uncommenting this makes the model run fine
status = solver.Solve(model)

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

>> Output: 
Check failed: FixFromAssignment(sat_solver->Assignment(), new_to_old_index, context_) 
*** Check failure stack trace: ***

By disabling presolve the solver does find a solution.

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

Kind regards,
Ignace

@lperron
Copy link
Collaborator

lperron commented Jan 31, 2024

Actually no, it works fine with presolve, and crashes without it.

@IgnaceBleukx
Copy link
Author

Oh it seems I forgot to comment in the solver.parameters.cp_model_presolve = False line in the code snippet.
I fixed it now to reflect the actual output : )

@Mizux Mizux added this to the v10.0 milestone Feb 12, 2024
@Mizux Mizux added Bug Solver: CP-SAT Solver Relates to the CP-SAT solver labels Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Solver: CP-SAT Solver Relates to the CP-SAT solver
Projects
None yet
Development

No branches or pull requests

3 participants