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

Home » Public Forums » archive » Re: Optimization "AMOEBA"
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Optimization "AMOEBA" [message #68097 is a reply to message #68096] Fri, 18 September 2009 04:45 Go to previous messageGo to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Fri, 18 Sep 2009 02:53:29 -0700 (PDT), Nicki
<nickireiter87@yahoo.de> wrote:

> Hey!
>
> I need some help with amoeba (i'm a total IDL beginner...). For a
> start (get to understand how it works) I want to solve a pretty
> simple, 1-dim. problem. I'm having a parabola -x^2+4x+9 and I want to
> get the maximum with the help of AMOEBA. How do I do that? (Let's say
> starting point P0=5 and scale is 4).
> This is what it looks like now:
>
>
>
> FUNCTION FUNC, P
> x=P[0]
> y=-x^2.+4.*x+5.
> ydes=9.1
> RETURN, MIN(ydes^2-y^2)
> END
>
> R=AMOEBA(1.0e-1, SCALE=5, P0=0.05, FUNCTION_VALUE=fval)
>
> PRINT, 'x_Value:', r, $
> 'error:', fval[0]
>
> END
>
> As a result i get for the x_value -1 and for the error - Inf.... But
> why?! I mean the maximum of the function is at x=2 and this is within
> the scale...
> Maybe somebody can give me some help


It should be more like the code below. I never used this, but AMOEBA
seems to search for the minimum of a scalar field f(x,y,z,...).

In your example:
f(x) = -x^2.+4.*x+5.

If "FUNC" returns -f(x) it will search for the minimum of -f(x) which
is the same as finding the maximum of f(x).



FUNCTION FUNC, P
x=P[0]
y=-x^2.+4.*x+5.
RETURN, -y[0]
END

pro test
R=AMOEBA(1.0e-1,SCALE=10,P0=[0.01], FUNCTION_VALUE=fval)
xmax=r[0]
ymax=-fval[0]

PRINT, 'x_Value:', xmax
PRINT, 'maximum:', ymax

window
x=0.1*findgen(80)-2
y=-x^2.+4.*x+5.
plot,x,y
plots,xmax[[0,0]],[!y.crange[0],ymax],psym=-2
plots,[!x.crange[0],xmax],ymax[[0,0]],psym=-2
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDLDE and java crashes
Next Topic: Nearest neighbors

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

Current Time: Sat Oct 11 11:38:05 PDT 2025

Total time taken to generate the page: 1.28412 seconds