Prev: function outputs
Next: Autocorrelation Function plot
From: Ivan Werning on 28 Feb 2010 16:28 Often the solution to an ODE with x(0) given requires solving x'(t)=f(x(t),u(t),t) where we compute u(t) from some function u(t)=g(x(t),t). An example is the maximum principle in optimal control: here x(t) includes the states and co-states of the system and u(t) is the control, and g= argmin of the Hamiltonian function. When I use ode45 to solve such a system I am able to compute the solution x(t) at given points or save it as a structure. This is very convenient. But often the object of interest is u(t) itself. So, is there a way to save u(t) similarly, during the ODE solution? Or must I re-evaluate g(x(t),t) myself, once the solution x(t) is computed? The latter seems wasteful; especially in the optimal control context when g is computed by minimizing the Hamiltonian using fmincon or similar. Moreover, it doesn't give me u(t) in the convenient (and fast to evaluate) structure output. -Ivan
From: Roy on 19 Mar 2010 13:37 On Feb 28, 5:28 pm, "Ivan Werning" <iwerni...(a)yahoo.com> wrote: > Often the solution to an ODE with x(0) given requires solving > x'(t)=f(x(t),u(t),t) > where we compute u(t) from some function > u(t)=g(x(t),t). > > An example is the maximum principle in optimal control: here x(t) includes the states and co-states of the system and u(t) is the control, and g= argmin of the Hamiltonian function. > > When I use ode45 to solve such a system I am able to compute the solution x(t) at given points or save it as a structure. This is very convenient. > > But often the object of interest is u(t) itself. So, is there a way to save u(t) similarly, during the ODE solution? Or must I re-evaluate g(x(t),t) myself, once the solution x(t) is computed? The latter seems wasteful; especially in the optimal control context when g is computed by minimizing the Hamiltonian using fmincon or similar. Moreover, it doesn't give me u(t) in the convenient (and fast to evaluate) structure output. > > -Ivan The problem is that ode45 is going to call f.m many more times than are going to be used in the final answer, for reasons two reasons: - ode45 is using runge kutta and therefore evaluating f.m several times per accepted time step - for purposes of adaptive stepsize control, ode45 often computes values that are discarded as the step size is adjusted.
|
Pages: 1 Prev: function outputs Next: Autocorrelation Function plot |