botorch
botorch copied to clipboard
Add a minimize_with_timeout wrapper for scipy.optimize.minimize
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
This pull request was exported from Phabricator. Differential Revision: D39529835
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
This pull request was exported from Phabricator. Differential Revision: D39529835
This pull request was exported from Phabricator. Differential Revision: D39529835
This pull request was exported from Phabricator. Differential Revision: D39529835
This pull request was exported from Phabricator. Differential Revision: D39529835
This pull request was exported from Phabricator. Differential Revision: D39529835
This pull request was exported from Phabricator. Differential Revision: D39529835
This pull request has been merged in pytorch/botorch@b88560983719817da39d9461f2ae4dbcacfedd70.