How to enter parameters for fmincon when SQP function includes a huge matrix?
4 views (last 30 days)
Show older comments
Hello everybody,
I am modelling a model predictive controller, and therefore I have an objective function to minimize:
J = 0.5*transpose(x)*H*x + f*x where H is say a 100x100 matrix (so impossible to write out all the equations myself). H changes every optimization moment.
I have two sets of constraints: Ax <= b and then constraints that some of the elements of x are integer (0 or 1), so tat constraint would take the same form as the cost function (something like 0.5*transpose(x)*D*x + q*x = b)
I want to use fmincon to optimise this sequential quadratic programming problem, however I cannot get this to work. Can I just enter the matrices H, f, D, q, ... in fmincon like I can with quadprog, or can't I?
Thanks a lot !
0 Comments
Answers (2)
Matt J
on 18 Jul 2013
Edited: Matt J
on 18 Jul 2013
constraints that some of the elements of x are integer (0 or 1)
Mixed integer constraints cannot be handled by anything in the Optimization Toolbox. Look into GA in the Global Optimization Toolbox instead.
H changes every optimization moment.
That's not clear. You mean H is really a function of x and therefore changes with iteration?
H is say a 100x100 matrix (so impossible to write out all the equations myself)
You generate large matrices in MATLAB by finding vectorized statements to express them, e.g.
H=eye(100)+ones(100,1)*rand(1,100);
Shashank Prasanna
on 19 Jul 2013
Edited: Shashank Prasanna
on 19 Jul 2013
Maarten, this is very well explained in the documentation of fmincon and GA There are examples in the page that show you how to pass the objective function. In short NO you cannot pass f H. You will have to create the objective function as shown above by Matt J. Quadprog is designed to solve quadratic problem and nothing else, that's the reason it can take in H and f, FMINCON is a generic solver and you will have to provide your own objective function.
Note on MPC:
GA is a terrible idea for model predictive control. Based on what you said if you have 100 variables, there is no way GA will solve that problem in a reasonable time step. In fact GA doesn't scale well beyond 10 dimensions. What is your target sampling time? How slow is your plant dynamics? For MPC you will need to solve the optimization before the target sampling time.
Ideally you should stick to quadprog if you can. It is fast and even used by the model predictive control toolbox. hth.
0 Comments
See Also
Categories
Find more on Nonlinear Systems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!