MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: simulated annealing and gradient descent

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40798] Re: [mg40755] simulated annealing and gradient descent
  • From: sean kim <shawn_s_kim at yahoo.com>
  • Date: Thu, 17 Apr 2003 23:17:27 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

hello daniel 

thank you for the response and suggestion. 

unfortunately, I don't own a new mathemtica 4.2. I
could find a machine that has the nwe version
installed in my school, but for right now, it will
actually be easier to implement my own version( for
more than reason of optimizing and personal
gratification)

as I was saying in my earlier post,  I think my
problem is the parameter update. 

if I may provide more details,  take for instace the
differential equation in the form of


Derivative[3][y][x] + Derivative[2][y][x] +
Derivative[1][y][x]  == -y[x]^3


now the solution of above as following,



targetsoln = 
  NDSolve[{Derivative[3][y][x] + Derivative[2][y][x] +

          Derivative[1][y][x]  == -y[x]^3 , y[0] == 1,

      Derivative[1][y][0] == Derivative[2][y][0] ==
0}, y[x], {x, 0, 20}]


using this as the target, I have been trying to
optimize the parameters or the coefficients ( shown
below as the k's) by initializing them at some random
values and givign them a small range. 


k1 Derivative[3][y][x] + k2 Derivative[2][y][x] + k3
Derivative[1][y][x] == -k4 y[x]^3


these are the parameters or the coeficients that I'm
trying to optimize to the target( normally the target
wouldn't be known exactly) 

I am sampling from the range of the parameters using
boltzman distribution (which is equivalent to saying
I'm using the metropolis update?) as follows. 


If[Exp[(-1)(scorerandom - scoreold)/Temp] >
Random[Real, {0, 1}], {scoreold = scorerandom,
oldparam = randomparam, accepted = accepted+1}


scorerandom is the difference between the solution of
target( as defined previously above) and the solution
of the original equation with randomly chosen
parameters. as the system is updated the scorerandom
becomes the scoreold.

the way I'm keeping track of the acceptance ratio of
the metropolis is to add it as a argument for the if
statement as shown above. and then  immediately
outside the if loop, I have a statement saying 

/alpha = accepted/ 100

this /alpha is then used in update of the parameters
as follows and I think this is one of the places I'm
not doing well. 0.44 is the desired acceptance ratio
according to the delosme paper. 

rpset = {k1r = 
k1 + Random[Real, {-1 + (\[Alpha] - 0.44), 1 +
(\[Alpha] - 0.44)}],
k2r = k2 + Random[Real, {-1 + (\[Alpha] - 0.44), 1 +
(\[Alpha] - 0.44)}],
k3r = k3 + Random[Real, {-1 + (\[Alpha] - 0.44), 1 +
(\[Alpha] - 0.44)}], 
k4r = k4 + Random[Real, {-1 + (\[Alpha] - 0.44), 1 +
(\[Alpha] - 0.44)}]};


This is the part I'm shaky on. I can't figure out how
to update the parameters according the acceptance
ratios. The idea is to make big moves when you're far
from the minimum, and make smaller moves as you move
closer to the global minimum. 

and the acceptance ratio... is that the total
acceptance ratio or the acceptance ratio just from the
metropolis update? 

perhaps it's a good idea to post the whole notebook or
perhaps email it to ones who are interested in seeing
it? 

thank you all for any helpful suggestions or comments.


sean from UCIrvine



--- Daniel Lichtblau <danl at wolfram.com> wrote:
> sean kim wrote:
> > 
> > hello group.
> > 
> > I'have been trying to implement simulated
> annealing
> > and gradient descent for my system of differential
> > equations which has second order spatial
> derivative as
> > well as time derivatives and i'm discretizing the
> > spatial term.
> > 
> > I have noticed some odd behaviours in my simulated
> > annealing, and i'm starting to think the problem
> may
> > lie with the parameter updating and annealing
> > schedule.
> > 
> > does anyone have experiences with the
> implementation
> > of simulated annealing within mathematica?  There
> > seems to be one post in the past asking if anyone
> has
> > ingeber's asa implemented in mathematica but no
> one
> > seems to have replied. I'm having problems with
> > implementing the parameter update that will depend
> on
> > the acceptance ratios. it will help tremendously
> if I
> > see some working code.
> > 
> > also, it seems to me that i'm in a similar
> situation
> > as one of the other user in that i'm not a
> > mathmatician, but working with pde's.  there were
> two
> > comments in the past dealing with using the method
> of
> > lines to approximate second order derivatives.
> > neither has any discussions of truncation errors.
> Does
> > anyone have experiences in that matter and willing
> to
> > comment with some codes?
> > 
> > thank you all.
> > 
> > sean
> > 
> > =====
> >
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > when riding a dead horse,  some dismount.
> > 
> > while others...
> > 
> > buys a new whip.
> > 
> > __________________________________________________
> > Do you Yahoo!?
> > The New Yahoo! Search - Faster. Easier. Bingo
> > http://search.yahoo.com
> 
> There is simulated annealing code in the standard
> add-on package
> NumericalMath`NMinimize.
> 
> Daniel Lichtblau
> Wolfram Research


=====
when riding a dead horse,  some dismount.

while others... 
buy a new whip.

which one might you be?

__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com


  • Prev by Date: Re: Plot backwards ==> SOLVED, THANK YOU.
  • Next by Date: Re: HELP!!! Newbie question
  • Previous by thread: simulated annealing and gradient descent
  • Next by thread: Why are AppendTo/PrependTo so slow?