-
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
BOP solver unresponsive, disrespects time limit #1886
Comments
AFAIK, since the solver is in C++ and we only swig wrap it in python, signal are not forwarded to the underlying libraries solver. For timeout not respected need to find some information internally.... |
Is this a confirmed bug (on your side), and if so will it be added to a milestone? Can I somehow further help you? |
Is there any update on this? I have also noticed that ortools is not responding to signals, which is a problem especially if it is the SIGTERM signal |
Use the SAT solver. It answers to SIGTERM and honor the time limit :-)
Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53
00
Le mar. 15 déc. 2020 à 12:22, Julian Brendl <notifications@github.com> a
écrit :
… Is there any update on this? I have also noticed that ortools is not
responding to signals, which is a problem especially if it is the SIGTERM
signal
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1886 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3PRQRKG3FCNELH7EJ3SU5BI3ANCNFSM4KXET7LA>
.
|
Thanks for your quick reply, but I found that not to be true. I have created a little example below that demonstrates this. As soon as the code enters the "start solving" step, i.e. the search for solutions begins, the CP-SAT solver also no longer replies to SIGTERM. You can see this is if you run this in your terminal and press Here is the code that reproduces this, it's just a very simple solver that solves the subset-sum problem: from ortools.sat.python import cp_model
import random
class VarArraySolutionPrinter(cp_model.CpSolverSolutionCallback):
"""Print intermediate solutions."""
def __init__(self, variables):
cp_model.CpSolverSolutionCallback.__init__(self)
self.__variables = variables
self.__solution_count = 0
def on_solution_callback(self):
self.__solution_count += 1
for v in self.__variables:
print('%i' % (self.Value(v)), end=' ')
print()
def solution_count(self):
return self.__solution_count
def SearchForAllSolutionsSampleSat(values, total_sum):
"""Showcases calling the solver to search for all solutions."""
# Creates the model.
model = cp_model.CpModel()
num_values = len(values)
subsets = [model.NewIntVar(0, num_values, f'{i}') for i in range(num_values)]
subset_sum = model.NewIntVar(0, num_values, 'sum')
# add constraints on each variable to ensure it is only used at most once
[model.Add(subset <= 1) for subset in subsets]
model.Add(subset_sum == cp_model.LinearExpr.Sum(subsets))
model.Add(total_sum == cp_model.LinearExpr.ScalProd(subsets, values))
# create a solver and solve.
solver = cp_model.CpSolver()
solution_printer = VarArraySolutionPrinter(subsets)
print('start solving')
status = solver.SearchForAllSolutions(model, solution_printer)
print('Status = %s' % solver.StatusName(status))
print('Number of solutions found: %i' % solution_printer.solution_count())
print('generate data')
s = [random.randint(1, 100) for _ in range(2000000)]
print('enter solver')
SearchForAllSolutionsSampleSat(s, 452343) |
What version of OR-tools and what language are you using?
Version: 7.5.7466
Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
BOP
What operating system (Linux, Windows, ...) and version?
Ubuntu 18.04.3 LTS (Google Colab)
What did you do?
Steps to reproduce the behavior:
I set the time limit to 5 min.
What did you expect to see
I expected the solver to terminate after ~5 min, or respond to a cell interrupt command.
What did you see instead?
The solver doesn't terminate after the time limit, and is unresponsive to interrupt. I had to manually restart the kernel.
Anything else we should know about your project / environment
I ran it on Google Colab. Sometimes ~2x smaller instances exhibit the same behavior although I cannot reproduce it consistently. I attached the model that fails every time.
model_lp.zip
The text was updated successfully, but these errors were encountered: