comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: TNMIN limits
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: TNMIN limits [message #57087] Tue, 04 December 2007 06:56 Go to next message
Brian Larsen is currently offline  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 #57092 is a reply to message #57087] Tue, 04 December 2007 05:22 Go to previous messageGo to next message
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
biophys wrote:
> 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.

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.
Re: TNMIN limits [message #57096 is a reply to message #57092] Mon, 03 December 2007 23:27 Go to previous messageGo to next message
biophys is currently offline  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 Go to previous messageGo to next message
Brian Larsen is currently offline  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 #57117 is a reply to message #57116] Mon, 03 December 2007 05:43 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Dec 3, 2:12 pm, Brian Larsen <balar...@gmail.com> wrote:
> And here is a great discussion of ameoba and how it works...http://solar.physics.montana.edu/kankel/ph567/exampl es/minimization/a...
>
> Cheers,
>
> Brian
>
> ------------------------------------------------------------ --------------
> Brian Larsen
> Boston University
> Center for Space Physics

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.
Thanks in advance
Cheers
Re: TNMIN limits [message #57118 is a reply to message #57117] Mon, 03 December 2007 05:12 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
And here is a great discussion of ameoba and how it works...
http://solar.physics.montana.edu/kankel/ph567/examples/minim ization/amoeba/Notes.pdf


Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: TNMIN limits [message #57119 is a reply to message #57118] Mon, 03 December 2007 05:08 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
While admittedly I have not used TNMIN before, it is often good
practice to use several different methods of function minimization on
the given problem. There are issues associated with each solver, what
it requires ad what it can handle. For instance there is a class of
solvers that require derivatives and a class that don't. If your
function has regions that are not differential then that method will
have issues... there is a list in idl of built-in minimization
routines (there are 5-6). Everyone has their own favorite but I often
use ameoba() first, it doesn't need derivatives and seems to work well
and fast. The function that you are minimizing has to be written to
enforce limits on variables but thats not too bad to do,

a few web resources:
ameoba (a c code base but lots of good information)
http://solar.physics.montana.edu/kankel/ph567/examples/minim ization/
conjugate-gradient:
http://solar.physics.montana.edu/kankel/ph567/resources/conj ugate_gradient/


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 Go to previous message
d.poreh is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 6.4 seg-faults when drawing (Solaris-8)
Next Topic: TNMIN limits

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:47:27 PDT 2025

Total time taken to generate the page: 0.00683 seconds