MathGroup Archive 2004

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

Search the Archive

NMininimize vs. FIndMinimum with NDSolve?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51135] NMininimize vs. FIndMinimum with NDSolve?
  • From: Manuel Morales <Manuel.A.Morales at williams.edu>
  • Date: Tue, 5 Oct 2004 04:37:45 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Is it possible to use NMinimize to estimate parameters for a
differential equation solved with NDSolve? I *am* able to use
FindMinimum, but NMinimize doesn't seem to work...

Here is what I am doing using FindMinimum:

sse[r_?NumberQ, q_?NumberQ] := Block[{sol, f},

       Plus @@ Table[
           sol = NDSolve[{f'[t] == r f[t] + q f[t]^2,
                   f[0] == data[[i]][[1]][[2]]},
                      f, {t, 0, 10}][[1]];
        Plus @@ Apply[(f[#1]  - #2)^2  &, data[[i]], {1}] /. sol, {i, 1,
             Length[data]}]];
params = FindMinimum[sse[r, q], {r, .1, .2}, {q, -.001, -.002}]

However, using NMinimize to estimate doesn't work. That is, if I replace
the last line with:

params = NMinimize[sse[r, q], {r, q}]

I get a bunch of error messages.

Thanks for any help. If anyone wants to try this, you can generate a
test data set below:

Block[{r, q},
   r = .5; q = -.001;
   data = Table[
       sol = NDSolve[{f'[t] == r f[t] + q f[t]^2, f[0] == j},
                      f, {t, 0, 10}][[1]];
       Table[{i, f[i] /. sol}, {i, 0, 10, 2}],
       {j, 1, 301, 150}]
   ]

Manuel


  • Prev by Date: MathLink error
  • Next by Date: Re: A way around the limitations of Re[] and Im[]
  • Previous by thread: MathLink error
  • Next by thread: Conveniently Restarting Notebooks