Skip to content
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

optimize.minimize(method=trust-constr) result dict does not contain success #9044

Closed
pv opened this issue Jul 16, 2018 · 1 comment
Closed
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.optimize
Milestone

Comments

@pv
Copy link
Member

pv commented Jul 16, 2018

The result dictionary from all optimizers is supposed to be uniform and contain e.g. a success boolean flag.

The success flag is missing for method='trust-constr'.
The result nit is called niter in the result dict.

Reproducing code example:

from scipy.optimize import minimize
sol = minimize(lambda x: x**2, [0], jac=lambda x: 2*x, 
    hess=lambda x: 2, method='trust-constr')
print(sorted(sol.keys()))
assert sol.success

Error message:

['cg_niter', 'cg_stop_cond', 'constr', 'constr_nfev', 'constr_nhev', 
 'constr_njev', 'constr_penalty', 'constr_violation', 'execution_time', 
 'fun', 'grad', 'jac', 'lagrangian_grad', 'message', 'method', 'nfev', 
 'nhev', 'niter', 'njev', 'optimality', 'status', 'tr_radius', 'v', 'x']
Traceback (most recent call last):
  File "<ipython-input-13-492cf8a99d03>", line 3, in <module>
    assert sol.success
  File "/home/pauli/.local/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 116, in __getattr__
    raise AttributeError(name)
AttributeError: success

Scipy/Numpy/Python version information:

1.1.0 1.14.5 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
and
1.2.0.dev0+7e41406 1.14.5 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
@rgommers
Copy link
Member

rgommers commented Sep 4, 2018

fixed in gh-9217

@rgommers rgommers closed this as completed Sep 4, 2018
@rgommers rgommers added this to the 1.2.0 milestone Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.optimize
Projects
None yet
Development

No branches or pull requests

2 participants