Re: TNMIN limits [message #57087] |
Tue, 04 December 2007 06:56  |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
> Efficient is not the right word; when other methods work, amoeba is
> almost always slower than those other methods. The great advantage of
> amoeba isn't it's efficiency, but its reliability. It will work on
> problems that most other methods can't handle.
Right indeed.
Another method to try is simulated annealing (aka traveling salesman)
unfortunately I have never coded this up in IDL, I have used it in C
several times to great success. http://en.wikipedia.org/wiki/Simulated_annealing
This method nearly always works but again is slower, but often that
doesn't matter too much, all depended on how many times you have to do
it.
Cheers,
Brian
------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
|
|
|
|
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
|
|
|
Re: TNMIN limits [message #57116 is a reply to message #57096] |
Mon, 03 December 2007 06:36   |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
> 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
|
|
|
|
|
|
Re: TNMIN limits [message #57177 is a reply to message #57087] |
Tue, 04 December 2007 09:15  |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Dec 4, 3:56 pm, Brian Larsen <balar...@gmail.com> wrote:
>> Efficient is not the right word; when other methods work, amoeba is
>> almost always slower than those other methods. The great advantage of
>> amoeba isn't it's efficiency, but its reliability. It will work on
>> problems that most other methods can't handle.
>
> Right indeed.
>
> Another method to try is simulated annealing (aka traveling salesman)
> unfortunately I have never coded this up in IDL, I have used it in C
> several times to great success. http://en.wikipedia.org/wiki/Simulated_annealing
>
> This method nearly always works but again is slower, but often that
> doesn't matter too much, all depended on how many times you have to do
> it.
>
> Cheers,
>
> Brian
>
> ------------------------------------------------------------ --------------
> Brian Larsen
> Boston University
> Center for Space Physics
Hi Brian;
Would you please compare GA(genetic algorithm) with amoeba or SA
method? Which on is faster? Which one is reliable? Is in the amoeba
method any divergence problems exist like in GA or SA?
Cheers
Dave
|
|
|