Re: TNMIN limits [message #57096 is a reply to message #57092] |
Mon, 03 December 2007 23:27   |
biophys
Messages: 68 Registered: July 2004
|
Member |
|
|
Hi, Brain
Thanks for bringing my attention to amoeba. The function I'm
minimizing contains infinite summation of integral terms containing
Gamma functions and Bessel functions etc. My TNMIN minimization
converges better with derivatives provided than without. But it is
definitely worth to give it a shot with amoeba. Its reflection
contraction scheme seems to be a very efficient way of marching toward
convergence.
BTW: I really like your imagesc "clone"! Very useful indeed!
Best,
BP
On Dec 3, 6:36 am, Brian Larsen <balar...@gmail.com> wrote:
>> Hi Brian;
>> Would you please specify this method with a simple example in IDL? I'm
>> interesting in this method but I can't make the head and tail of it.
>
> Sure,
>
> the example in help is not to bad either, I use it every time I go to
> use the routine.
>
> save this toy example as amoeba_test.pro then just .run amoeba_test
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; .run amoeba_test
>
> FUNCTION min_me, P
> ;; function is the negative of the dist function
> RETURN, -(dist(100))[p[0],p[1]]
> ;; probably should have put in some error checking as this will error
> if p<0 or p>99
> END
>
> ; we start at P0
> p0 = [67,45] ; random guess
> ;; you have to play with scale, it is in some sense the step size that
> ;; the amoeba uses, the smaller the closer to the answer but the
> ;; bigger chance of getting lost and taking forever
> ans = amoeba(1e-5, p0=p0, scale=5, FUNCTION_name='min_me')
> print, ans, -(dist(100))[ans[0], ans[1]]
> ;; lets check the answer
> print, min(-dist(100))
> ;; which should be the right answer
> end
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> IDL> .run amoeba_test
> % Compiled module: MIN_ME.
> % Compiled module: $MAIN$.
> 50.4927 50.1697
> -70.7107
> -70.7107
>
> So we get the right answer. Great routine.
>
> I will probably write something up and post it along with the
> description from Charles Kankelborg (assuming he gives me the ok) on
> my idl tips site, not as good as David Fanning's or Michael Galloy's
> but just trying to be mathy and let them do coding and especially
> graphics.http://people.bu.edu/balarsen/Home/IDL/IDL.html
>
> Ask away if you have any more issues, I have a lot of experience in
> beating this routine into submission. Forcing limits on the input
> variables happens in the function, you need to do something like if
> the value to too big or too small then return a large number so the
> amoeba will step away from that.
>
> Cheers,
>
> Brian
>
> ------------------------------------------------------------ --------------
> Brian Larsen
> Boston University
> Center for Space Physics
|
|
|