nonlinear programming with differential-algebraic constraints (2)

*To*: mathgroup at smc.vnet.net*Subject*: [mg52084] nonlinear programming with differential-algebraic constraints (2)*From*: Joerg Schaber <schaber at molgen.mpg.de>*Date*: Wed, 10 Nov 2004 04:45:25 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

I made a little example to illustrate the problem: I want to fit a model which is stated as a system of differenttial equations to some data. (* curve to be fitted *) f[t_]:=Exp[-0.1*t]+Random[Real,{0,0.1}]; data={#,Evaluate[f[#]]}&/@Table[t,{t,0,10,1}]; ListPlot[data,PlotStyle\[Rule]{RGBColor[0,0.2,0.8],PointSize[0.02]}]; (* the parameter 0.1 is to be found *) (* the model as a differential equations *) model:=NDSolve[{y'[t]==-a*y[t],y[0]==1}/.a->0.05,y,{t,0,10}]; (* minimizing sum of squares *) NMinimize[{squares=Plus@@Table[(Table[{#,y[t]/.Evaluate[model][[1]]/.t->#}&/@ Table[t,{t, 0, 10, 1}]][[i, 2]]-data[[i,2]])^2, {i, Length[data]}], a > 0}, a, Method -> {"DifferentialEvolution"}, StepMonitor :> Print[squares, a], WorkingPrecision -> 8] The main problem seems to be that the differential equation does not get evaluated in each step but only once. So if anybody could make this example work that would be great. best, joerg

**Follow-Ups**:**Re: nonlinear programming with differential-algebraic constraints (2)***From:*DrBob <drbob@bigfoot.com>