How Discretize continuous -time nonlinear differential system for MPC

2,237 views
Skip to first unread message

mohamad mahdi

unread,
Feb 17, 2014, 2:03:09 PM2/17/14
to yal...@googlegroups.com
Hello every body.
For implementing many control algorithms and estimation problems we need to have a discrete model. physical or real models are almost always continuous-time differential equations so we need to make them discrete. Specifically, i have a  continuous-time nonlinear differential system like dx/dt=f(x,u) which is describing a wind turbine model and i want to design a moving horizon estimator (MHE) and a Model Predictive Controller (MPC) and i need to derive a discrete model. A simple way is to use euler's method i.e writing    dx/dt=x(t+h)-x(t)/h   and choosing h small enough. But for many application as for my problem this simple method will not work and results in unstable system (even choosing h very small, say h=0.00001). I've heard we can use ODE solvers like 'matlab ode45' to discrete the model accurately .
1-How we can do so i.e to discrete model using ode45?
2-If we could, is the result an explicit model like x(k+1)=f(x(k),u(k)) so we can use it for MPC?

How to discrete the model and use resulting states for future steps in horizon? (I know how to do so when we have an explicit model like  x(k+1)=f(x(k),u(k))  but i'm afraid numerically discretizing would not give us future states ahead in horizon but i'm not sure)

In MPC optimization problems it's better  to write model dynamics as equality constraints and considering both x(k) and u(k) (instead of only u(k)) as independent optimization variables. What are the exact steps we need to go through one by one to implement MPC when we have a continuous-time nonlinear model using YALMIP?


mohamad mahdi

unread,
Feb 17, 2014, 2:09:38 PM2/17/14
to yal...@googlegroups.com
Just to mention, i'm insisting on using  NONLINEAR models. In the case of linear models we do so simply by c2d command in matlab.

Johan Löfberg

unread,
Feb 17, 2014, 2:21:07 PM2/17/14
to yal...@googlegroups.com
The first question you have to answer is if YALMIP is the right tool. Why not a tool for developed for optimal control instead (gpops, adaco comes to mind)

You basically have to have code which computes jacobians (linearizations) at a given state xk (and input uk). x(k+1) ~= f0 + A*(x(k)-xk) + B(u(k)-uk). From this, you setup a standard MPC problem. You can setup an optimizer problem parameterized in f0, A and B if you want, thus making it possible to get rid of almost all overhead. A generalized version where you parameterize f0/A/B-matrices along the whole future trajectory is also possible. The main computational effort will most likely be to compute the future state (integrate the differential equation) and matrices A and B, at least that was what I saw when I played with this as a small demo of optimizer. Various hacks (compared to using developed optimal control packages) would be to iterate at each time, linearizing and optimizing new trajectories iteratively.

ode45 doesn't discretize any model, it computes the solution to a differential equation, i.e., it gives you the states given inputs and initial state

Johan Löfberg

unread,
Feb 17, 2014, 2:53:42 PM2/17/14
to yal...@googlegroups.com
You should contact some of the persons involved in this course
http://www.esat.kuleuven.be/sista/event.php?id=1751

Exercise 2 does exactly what you are asking about. I gave Rien some pointers on how the optimizer framework can be used for low overhead code, and hopefully he incorporated it in the course material.

Message has been deleted

mohamad mahdi

unread,
Feb 19, 2014, 11:04:58 AM2/19/14
to yal...@googlegroups.com
Dear johan,
the link you provided (http://www.esat.kuleuven.be/sista/event.php?id=1751) works but the documents located there which includes lessons and exercises aren't accesible, that is when i'm trying to download them i get "404 Not Found" error.
I want to know your recommendation by the way. What is the more simple way? Going directly trough optimal control packages like acado toolkit or doing linearization first and set up a standard MPC in YALMIP? what is more accurate and efficient ?

Johan Löfberg

unread,
Feb 19, 2014, 11:44:11 AM2/19/14
to yal...@googlegroups.com
That's why I said you should contact one of the course leaders (Rien for instance)

A dedicated package will of course be the most efficient way for solving a real nonlinear optimal control problem. YALMIP would only be interesting as proof-of-concept code, and to learn.


Reply all
Reply to author
Forward
0 new messages