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

Home » Public Forums » archive » Amoeba function
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
Amoeba function [message #68678] Wed, 18 November 2009 17:18 Go to next message
Nicki is currently offline  Nicki
Messages: 14
Registered: September 2009
Junior Member
I have the following problem with my amoeba code: It does not do its
job ;) (Probably because i didn't write it right). It's supposed to
find the minimum. But it only finds a local minimum (I guess) not a
global one.

This is the code:

FUNCTION CONSTRAINT,Pin
COMMON FUNC_XY, P0, dP
return,P0+2*dP/!pi*atan(Pin)
END
FUNCTION FUNC, Pin, NOCONSTR=NOCONSTR
if keyword_set(NOCONSTR) then P=Pin $
else P=CONSTRAINT(Pin)
nrows=1. ;number of rows
mu=438.689 ;attenuation coefficient
r_tot=1.5 ;target resolution
r_i=P[3] ;detector intrinsic resolution
rad=P[0] ;distance 'centre of source'-pinhole
wdet=P[1] ;detector width
dfov=P[2] ;diameter of the field-of-view
a=180/!pi*2*asin(dfov/2/rad) ;pinhole opening angle
f=wdet/2/(tan(a/2/180*!pi)) ;distance pinhole-detector
N=2.*!pi*(rad+f)/(1.1*wdet)*Nrows ;number of pinholes/detectors
d=sqrt(R_tot^2-(rad/f)^2*(R_i)^2)/((rad/f)+1.)-alog(2)/mu*ta n(a/2*!pi/
180) ;pinhole diameter
deffs=sqrt(d^2+2/mu*d*tan(a/2*!pi/180)+2/(mu^2)*(tan(a/2/180 *!pi))
^2) ;effective diameter (Sensitivity)
S=N*deffs^2/16/(rad^2)*100 ;Sensitivity
if ~finite(s) then stop
RETURN, -S
END

pro numerical
COMMON FUNC_XY, P0, dP
P0=[60., 80., 80., 0.45] ;initial starting point
dP=[27., 20., 20., 0.4] ;scale
R=AMOEBA(1.0e-5,SCALE=dP, P0=P0, FUNCTION_VALUE=fval) ;result
if r[0] eq -1 then begin
print,'No minimum found.'
return
endif
xmax=CONSTRAINT(r)
ymax=-fval[0]
END
_______________________________________________
It gives me a minimum (or in this case actually maximum, but
anyway...) for R_i=0.05 and w_det=100. S_max is then 0.0088 or s.th
like that. However, if i remove R_i and w_det from the constraint and
put them into the input, as R_i=0.05 and w_det=100,
________________________
..............
r_i=0.05 ;detector intrinsic resolution
rad=P[0] ;distance 'centre of source'-pinhole
wdet=100. ;detector width
dfov=P[1] ;diameter of the field-of-view
a=180/!pi*2*asin(dfov/2/rad) ;pinhole opening angle
f=wdet/2/(tan(a/2/180*!pi)) ;distance pinhole-detector
N=2.*!pi*(rad+f)/(1.1*wdet)*Nrows ;number of pinholes/detectors
d=sqrt(R_tot^2-(rad/f)^2*(R_i)^2)/((rad/f)+1.)-alog(2)/mu*ta n(a/2*!pi/
180) ;pinhole diameter
deffs=sqrt(d^2+2/mu*d*tan(a/2*!pi/180)+2/(mu^2)*(tan(a/2/180 *!pi))
^2) ;effective diameter (Sensitivity)
S=N*deffs^2/16/(rad^2)*100 ;Sensitivity
if ~finite(s) then stop
RETURN, -S
END
pro numerical
COMMON FUNC_XY, P0, dP
P0=[60., 80.] ;initial starting point
dP=[27., 20.]
........................
__________________________________________________
i get a much higher S_max of 0.012, which is pretty weird. Does
anybody get what i mean and can maybe help me out???
Re: Amoeba function [message #68745 is a reply to message #68678] Thu, 19 November 2009 15:25 Go to previous message
b_gom is currently offline  b_gom
Messages: 105
Registered: April 2003
Senior Member
I suspect most readers will not have the time to go through your code
and optimize it for you :), in fact I gave up trying to do a quick
read through to find out what the form of the equation is you are
trying to minimize. I can give you some of my experience with Amoeba,
however. Amoeba cannot and does not guarantee that it will find the
global minimum. The amoeba that the function is named after crawls its
way down the slope of your minimization function until it finds a
hollow to settle in. The depth of this hollow is related to the
characteristic length scale that you tell Amoeba to use, and the
starting guess for the parameters. In practice, you ultimately bear
the responsibility of judging whether Amoeba has found the best of all
possible minima.

Amoeba is a fast and useful routine for minimizing ugly complicated
data sets or functions that do not have analytical derivatives. If you
have a simple equation that you are trying to fit to a data set (even
if it doesn't have analytical derivatives), you might find other
fitting routines like MPFIT\MPFITFUN more predictable.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Add SCOPE_TRACEBACK output, other tags into PostScript files
Next Topic: Re: Add SCOPE_VARFETCH output, other tags into PostScript files

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

Current Time: Wed Oct 08 11:41:37 PDT 2025

Total time taken to generate the page: 0.00529 seconds