-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
BugLang: PythonPython wrapper issuePython wrapper issueSolver: CP-SAT SolverRelates to the CP-SAT solverRelates to the CP-SAT solver
Milestone
Description
What version of OR-Tools and what language are you using?
Version: main/9.15.6755
Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT
With the latest release of the Python API, there seem to have been an unintended breaking change to the CpSolver.Solve() arguments. .Solve() has been marked deprecated in favor of .solve(), with the former still forwarding the calls to the latter. But it seems like a mistake has been made here, accidentally renaming argument solution_callback to callback.
Minimal reproducible example:
from ortools.sat.python.cp_model import CpModel, CpSolver, CpSolverSolutionCallback
class MyCallback(CpSolverSolutionCallback):
def on_solution_callback(self):
print("Solution found!")
# Create model
model = CpModel()
x = model.new_int_var(0, 5, 'x')
y = model.new_int_var(0, 5, 'y')
model.add(x < y)
# Solve with callback
solver = CpSolver()
solver.parameters.enumerate_all_solutions = True
solver.Solve(model, solution_callback=MyCallback()) # <- instead of a deprecation warning, has become a breaking change
solver.solve(model, solution_callback=MyCallback()) # <- still works fineTypeError: CpSolver.Solve() got an unexpected keyword argument 'solution_callback'Metadata
Metadata
Labels
BugLang: PythonPython wrapper issuePython wrapper issueSolver: CP-SAT SolverRelates to the CP-SAT solverRelates to the CP-SAT solver