MathGroup Archive 2004

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

Search the Archive

NMininimize vs. FIndMinimum with NDSolve?


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