botorch icon indicating copy to clipboard operation
botorch copied to clipboard

Add a minimize_with_timeout wrapper for scipy.optimize.minimize

Open Balandat opened this issue 3 years ago • 4 comments

Summary: Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around scipy.optimize.minimize to achieve this.

The new minimize_with_timeout method calls scipy.optimize.minimize with all arguments forwarded verbatim. The only difference is that if provided a timeout_sec setting in the options dict, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the scipy.optimize.minimize call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

Balandat avatar Sep 15 '22 03:09 Balandat

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Sep 15 '22 03:09 facebook-github-bot

Codecov Report

Merging #1403 (f3cb4eb) into main (02ec731) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main     #1403   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          153       154    +1     
  Lines        13686     13730   +44     
=========================================
+ Hits         13686     13730   +44     
Impacted Files Coverage Δ
botorch/exceptions/__init__.py 100.00% <ø> (ø)
botorch/exceptions/errors.py 100.00% <100.00%> (ø)
botorch/optim/utils/__init__.py 100.00% <100.00%> (ø)
botorch/optim/utils/timeout.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Sep 15 '22 03:09 codecov[bot]

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Sep 16 '22 05:09 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Sep 18 '22 19:09 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Dec 14 '22 02:12 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Dec 14 '22 05:12 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Dec 14 '22 17:12 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D39529835

facebook-github-bot avatar Dec 28 '22 06:12 facebook-github-bot

This pull request has been merged in pytorch/botorch@b88560983719817da39d9461f2ae4dbcacfedd70.

facebook-github-bot avatar Dec 28 '22 22:12 facebook-github-bot