       Re: Keeping global parameters in an evaluated function

• To: mathgroup at smc.vnet.net
• Subject: [mg113264] Re: Keeping global parameters in an evaluated function
• From: Davide Mancusi <d.mancusi at ulg.ac.be>
• Date: Thu, 21 Oct 2010 07:02:05 -0400 (EDT)

```On Wed, 20 Oct 2010 10:47:37 -0500, Daniel Lichtblau <danl at wolfram.com>
wrote:

> Davide Mancusi wrote:
> > Hello everyone,
> >
> > I have a function that depends on some variables and a parameter
> > (say c). My goal is to find the global minimum of the function for
> > a given value of the parameter, say c==0. However, the function has
> > a lot of local minima for c==0, and is thus very difficult to hit
> > the global one. For c==1, however, the function is much smoother,
> > and the minimization algorithms work pretty well.
> >
> > What I'm trying to do is to change the value of the parameter
> > continuously while Mathematica minimizes the function. By doing so I
> > hope to trap the minimization algorithms close to the global minimum
> > using the smooth version of the function, and then slowly let c go
> > to 0.
> >
> > I have come up with the following toy model (I use NMinimize in the
> > real problem, but that shouldn't be important):
> >   f[x_] :== (x - c)^4
> >   c==1;
> >   iterations==1;
> >   FindMinimum[ f[x], {x, 1001}, StepMonitor :> {c == c/2; iterations+
> > +} ]
> >   Print[{c // N,iterations}]
> > If I run this I get
> >   {4.48416*10^-32, {x -> 1.}}
> >   {1.45519*10^-11,37}
> > The algorithm finds the minimum at x====1 while I would like it to
> > find it close to 1.45519*10^-11.
> >
> > I think the problem lies in the fact that f[x] is evaluated only
> > once, at the beginning of the minimization algorithm, and the
> > global value of c gets substituted. Thus, even if I change c later,
> > that doesn't affect the function being minimized.
> >
> > Can anyone suggest a way to update c from within the minimization
> > routine?
> >
> > Thanks in advance,
> > Davide
>
> Could instead run a loop of FindMinimum or NMinimize, using the
> result from the previous run to initialize the start point for the
> next. Below is your example done in this manner.
>
> In:== f[x_] :== (x - c)^4
> c == 1;
> prev == 1001;
> Last[Table[min == FindMinimum[f[x], {x, prev}];
>    prev == x /. min[]; c /== 2; min, {i, 40}]]
>
> Out== {7.15727*10^-32, {x -> 1.63582*10^-8}}

(Posting back to the list...)

solution, but it is not so straightforward to do that with NMinimize,
since most (all?) of the Methods use many-point internal states. I
can't see how to use the solution of one step as input for the next one
in a simple way.

--
---------------------------
Davide Mancusi, Ph.D.

Fundamental Interactions in
Physics and Astrophysics
University of Li=C3=A8ge
all=C3=A9e du 6 ao=C3=BBt, 17
B-4000 Li=C3=A8ge 1
Belgium
tel.: +32 (0)4 366 3642
---------------------------

```

• Prev by Date: Re: Keeping global parameters in an evaluated function
• Next by Date: Re: Special permutation pattern ascending groups sum
• Previous by thread: Re: Keeping global parameters in an evaluated function
• Next by thread: Using ReplaceAll (/.) on numerical digits