Re: Keeping global parameters in an evaluated function

*To*: mathgroup at smc.vnet.net*Subject*: [mg113270] Re: Keeping global parameters in an evaluated function*From*: Andrea <btlgs2000 at gmail.com>*Date*: Thu, 21 Oct 2010 07:03:12 -0400 (EDT)*References*: <i9m84a$jkl$1@smc.vnet.net>

On Oct 20, 10:09 am, Davide Mancusi <d.manc... at ulg.ac.be> 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 Hi Davide,it seems to me it is better to call FindMinimum more times with function approaching the target one and initial point taken from previous run par = 1.; f[x_, par_] := (x - par)^4; FixedPoint[ (res = FindMinimum[f[x, par], {x, #[[1]]}]; par /= 2; {res[[2, 1, 2]], res[[1]]}) &, {2(*xmin*), 0(*ymin*)} ]