-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
performance regression at 9.11.4210 #4376
Comments
ah, perhaps this is the same as: As in that one - if I do not provide the solution printer to the model then the code finishes quickly. |
Just piggybacking on this issue to confirm that we've also noticed large performance regressions in our test suite for 9.11 using the python CP SAT API. Toy models that used to finish instantly are now taking up the entire |
We have a bug in our code. Call StopSearch() after the first solution to exit as a workaround |
does this happen with optimization models too ? |
Yep. Our models define a maximization objective, we do register a solution callback but only for logging purposes. I can confirm on our end that removing this callback resolves the performance regression issue. |
can you send me a python code that exhibits the issue ? |
Here's a code that exhibits the issue on this model (ORtools 9.11, windows 11): from google.protobuf.text_format import Parse
from ortools.sat.python import cp_model
from ortools.sat.python.cp_model import CpSolverSolutionCallback
class SolutionLogger(CpSolverSolutionCallback):
def __init__(self) -> None:
CpSolverSolutionCallback.__init__(self)
self.soln_n = 0
def OnSolutionCallback(self):
self.soln_n += 1
file_path = "model9p11.txt"
with open(file_path, "r") as file:
s = file.read()
model = cp_model.CpModel()
Parse(s, model.Proto())
print("Model has an objective:", model.has_objective())
solver = cp_model.CpSolver()
status = solver.Solve(model)
print(
f"No callback: Solved the model with status {status} in {solver.WallTime()} seconds"
)
status = solver.Solve(model, solution_callback=SolutionLogger())
print(
f"With callback: Solved the model with status {status} in {solver.WallTime()} seconds"
) I confirmed that the issue is not present in ORtools 9.9 (although the model that gets written to file is slightly different for 9.9) |
^ if you take the above code and slightly modify it to have a max runtime solver = cp_model.CpSolver()
status = solver.Solve(model)
print(
f"No callback: Solved the model with status {solver.StatusName(status)} in {solver.WallTime()} seconds"
)
solver.parameters.max_time_in_seconds = 10
status = solver.Solve(model, solution_callback=SolutionLogger())
print(
f"With callback: Solved the model with status {solver.StatusName(status)} in {solver.WallTime()} seconds"
) You should get it to terminate with something similar to this:
|
what parameters ? |
is there anything you're looking for that isn't in the model proto dump? @aleberr and I's model construction is difficult to turn into a shareable example so we hoped that sharing the protobuf would be enough |
What is happening is that search finishes normally, then it waits until the time limit is crossed. I am debugging. |
Fixed. Thanks for the report. |
ortools-regression.tar.gz
the attached code (one python file and one input file) is solving a toy puzzle about tiling a board with 2x2 pieces, where each corner of each 2x2 piece has a label and labels on touching pieces have to match up
at 9.10.4067 it finds the unique solution in about 3 seconds and then is done, presumably having proved that there are no further solutions
at 9.11.4210 it quickly spits out that same solution - four times - and then sits around burning CPU for I dont know how long.
Maybe it is not a performance regression as such but a plain bug getting stuck in a tight loop somewhere.
The text was updated successfully, but these errors were encountered: