Providing gradient using fmincon in an Model Predictive Control context

3 views (last 30 days)
Hello
I've set up a nonlinear MPC problem in Matlab. I'm using Fmincon as the solver which is extremely slow. Looking at the time and run profiler I see that we spend most amount of calculation time in calculating finite differences. So I'm now trying to provide the gradient for fmincon.
Now, the nonlinear constraints are on the states while the optimisation variable is the input u. So the gradient of the constraint function should be zero? (well, zeros to cover the whole horizon). But using the 'CheckGradients' true option throws an error saying that my provided gradient value is not that of the calculated by fmincon. So my question is, how can the gradient be anything other than zero?

Answers (1)

Matt J
Matt J on 25 Apr 2017
Edited: Matt J on 25 Apr 2017
Now, the nonlinear constraints are on the states while the optimisation variable is the input u. So the gradient of the constraint function should be zero?
No, the states are functions of u and so the constraints will also depend on u. MPC is not my field, but I suspect that if you have constraints as a function of the states, then using the chain rule together with the state equations, you can calculate their gradients with respect to u.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!