Skip to content

Timeout on Tuner not properly enforced #751

@ElFosco

Description

@ElFosco

The timeout is not correctly enforced in both ParameterTuner and GridSearchTuner, which can lead to errors or unexpected behaviour.


Problem 1: Init solver call not constrained by timeout

Both tuners perform an Init solver call without applying the timeout:

# Init solver
solver = SolverLookup.get(self.solvername, self.model)
solver.solve(**self.best_params)

Problem 2: Negative timeout values

When checking if the algorithm has exceeded the time limit, the computed time_limit - (time.time() - start_time) can become negative, which is not supported by OR-Tools:

timeout = self.best_runtime
# set timeout depending on time budget
if time_limit is not None:
    timeout = min(timeout, time_limit - (time.time() - start_time))
# run solver
solver.solve(**params_dict, time_limit=timeout)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions