gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

POWELL implementation #1697

Open dartemo1 opened 10 months ago

dartemo1 commented 10 months ago

gdl 1.0.0-rc.3 MAC-OS 13.6.1 Ventura POWELL is definitely misbehaving! ITER and ITMAX are not updated or have any effect. Xi initial/final set of directions is not updated.
Optimization quality is very low compared to native idl or python "scipy.optimize.minimize(powell)". Used a simple program to test:

;test function for gdl powell optimization ;12.18.2023 FUNCTION t1,X COMMON TT1, x0, ind0 ind0++ RETURN,total(abs(x-x0)) END ;main program COMMON TT1, x0, ind0 TIC ind0=0L N=512 x0=findgen(N) ftol=1e-4 xi=fltarr(N,N) xi(indgen(N),indgen(N))=1.0 P=fltarr(N)+10.0 POWELL,P,xi,ftol,fmin,"t1",ITER=niter TOC END

resulting fmin=13793 compared to 3.3E-4 for idl and 1.3E-9 python. Would be great if someone has a fix! Thank you.

alaingdl commented 10 months ago

Thanks you for the feedback, it is interesting because other test cases we have were as fast as IDL ! We will see. I also realize that some tests we have are not OK in IDL.

GillesDuvert commented 10 months ago

Hi, I confirm the reported behaviour (slow and false), thanks again. For the record, POWELL is not at all the routine "powell" described in section 10.5 of Numerical Recipes in C, as we cannot use Numerical Recipes codes for copyright reasons. GDL's POWELL has been written without any other test as the example in the IDL doc (this one passes). GDL's POWELL uses R. Brent's "praxis" implementation of its own solver (see reference at end of this wikipedia page ). As the method has no 'iter' return, ITER cannot be updated and is set to 1. IMHO our POWELL implementation should be replaced by some excerpt from minpack, would this be a solution ?

dartemo1 commented 10 months ago

Dear Gillies and Alain thank you for the prompt response. It looks like currently AMOEBA is the only functioning method for nonlinear optimization without explicit derivatives. Nonlinear solvers BROYDEN and NEWTON are not available, so minpack HYBRD would be a welcome solution!

alaingdl commented 10 months ago

Why do you say BROYDEN and NEWTON are not available, I just used them too & working fine on my tests. See at : test_multiroots.pro & test_fx_root.pro

dartemo1 commented 10 months ago

Sorry, my fault. Have not y used them.

GillesDuvert commented 10 months ago

Please note that amoeba in written in C in GDL, not as a procedure as IDL does. It should be quicker than its IDL equivalent, which is deemed slow. Anyway, it would be great to have an idea of the comparative speed and overall quality of the GDL minimization code (OK, POWELL is broken) wrt. the IDL equivalent. FTR GDL contains "NEWTON", "BROYDEN" for nonlinear equations, and "AMOEBA", "DFPMIN", "POWELL" and "SIMPLEX" for optimization.