KULL-Centre / BME

Integrating Molecular Simulation and Experimental Data
GNU General Public License v3.0
21 stars 7 forks source link

trust-constr not implemented #5

Closed sbottaro closed 5 years ago

sbottaro commented 5 years ago

Trust region method is not working when using bounds. I was not able to fix this, so L_BFGS is used when bounds are present. Would be nice to have trust-constr implemented as it should be faster.

rcrehuet commented 5 years ago

Funny... Could you tell me which test failed? Or an example that fails?

sbottaro commented 5 years ago

Hi Ramon,

Thanks. I had troubles running test_03:

I get the following error:

File "/Users/sandrobottaro/Software/crap/BME/test/test_03.py", line 38, in test chib,chia, srel = rew.optimize(theta=2) File "/Users/sandrobottaro/Software/crap/BME/bme_reweight.py", line 455, in optimize bounds=self.bounds) File "/Users/sandrobottaro/anaconda/lib/python2.7/site-packages/scipy/optimize/_minimize.py", line 615, in minimize callback=callback, **options) File "/Users/sandrobottaro/anaconda/lib/python2.7/site-packages/scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py", line 506, in _minimize_trustregion_constr factorization_method)

File "/Users/sandrobottaro/anaconda/lib/python2.7/site-packages/scipy/optimize/_trustregion_constr/tr_interior_point.py", line 309, in tr_interior_point constr_eq0, jac_eq0)

File "/Users/sandrobottaro/anaconda/lib/python2.7/site-packages/scipy/optimize/_trustregion_constr/tr_interior_point.py", line 56, in init self.jac0 = self._compute_jacobian(jac_eq0, jac_ineq0, s0) File "/Users/sandrobottaro/anaconda/lib/python2.7/site-packages/scipy/optimize/_trustregion_constr/tr_interior_point.py", line 164, in _compute_jacobian [J_ineq, S]])) File "/Users/sandrobottaro/anaconda/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", line 1237, in bmat arr_rows.append(concatenate(row, axis=-1)) ValueError: all the input array dimensions except for the concatenation axis must match exactly

rcrehuet commented 5 years ago

I have run test_03.py and I don't get an error. Maybe it is a scipy version issue? I am using scipy version 1.2.1. on python 3.6.8. And you?

Having said that, trust-constr is much slower than L-BFGS-B for test_03. In my laptop, L-BFGS-B takes 6 seconds and trust-constr more than 60. So to avoid compatibility issues I recommend we fall back to L-BFGS-B.

sbottaro commented 5 years ago

Ah-ha. Right. With python3.7 works (and not with Python 2.7, which is not supported anyway).

Thanks!

Sandro