You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! this is Mateo from last year's DSE Summer School. I'm starting to use estimagic and it is just, well, magical! Thank you!
I've run into this small bug.
Bug description
Least squares algorithms appear not to work with multistarts. I think the issue is that some updating step of multistarts is looking for the best criterion value in a list where the least-squares algo has stored the vector of residuals instead.
To Reproduce
import estimagic as em
import numpy as np
def loss(params):
resid = np.array([params['x'], params['y']])
out = {
"root_contributions": resid,
"contributions": np.square(resid),
"value": np.sum(np.square(resid)),
}
return out
est = em.minimize(
criterion=loss,
params={'x': -1.0, 'y': 1.0},
lower_bounds={'x': -10, 'y': -10},
upper_bounds={'x': 10, 'y': 10},
algorithm='scipy_ls_trf',
multistart=True,
multistart_options={
"n_samples": 3,
"share_optimizations": 1.0
}
)
print(est)
Expected behavior
I'd expect the above code to perform three starts.
Screenshots/Error messages
Instead, it raises the following error after the first start
Traceback (most recent call last):
File "/home/mvg/em_fail.py", line 16, in <module>
est = em.minimize(
File "/usr/local/Anaconda3/lib/python3.9/site-packages/estimagic/optimization/optimize.py", line 403, in minimize
return _optimize(
File "/usr/local/Anaconda3/lib/python3.9/site-packages/estimagic/optimization/optimize.py", line 766, in _optimize
raw_res = run_multistart_optimization(
File "/usr/local/Anaconda3/lib/python3.9/site-packages/estimagic/optimization/tiktak.py", line 168, in run_multistart_optimization
state, is_converged = update_convergence_state(
File "/usr/local/Anaconda3/lib/python3.9/site-packages/estimagic/optimization/tiktak.py", line 471, in update_convergence_state
if valid_new_y[best_index] <= best_y:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
System
OS: Ubuntu 18.04
The text was updated successfully, but these errors were encountered:
Hi Mateo (@Mv77), thanks a lot for this very nice bug report. It helped me to localize the error quickly.
I will fix this in #411 and add your example as a unit test. We will merge today and make a new release. The new version will be on conda-forge tomorrow or on Monday.
Hi! this is Mateo from last year's DSE Summer School. I'm starting to use estimagic and it is just, well, magical! Thank you!
I've run into this small bug.
Bug description
Least squares algorithms appear not to work with multistarts. I think the issue is that some updating step of multistarts is looking for the best criterion value in a list where the least-squares algo has stored the vector of residuals instead.
To Reproduce
Expected behavior
I'd expect the above code to perform three starts.
Screenshots/Error messages
Instead, it raises the following error after the first start
System
The text was updated successfully, but these errors were encountered: