How to enter parameters for fmincon when SQP function includes a huge matrix?

4 vues (au cours des 30 derniers jours)
Maarten
Maarten le 18 Juil 2013
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 !

Réponses (2)

Matt J
Matt J le 18 Juil 2013
Modifié(e) : Matt J le 18 Juil 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);
  3 commentaires
Maarten
Maarten le 18 Juil 2013
Ok that function should be able to solve my problem. However the problem is still the same: How do I enter my objective function in the ga function? Do I have to write J = 0.5*transpose(x)*H*x + f*x in a seperate function .m file that accepts H, f and x als parameters, and call that as @J for example? Or is there a way to just enter my matrices H and f in the ga argument list (like you can with for example quadprog) ?
Thanks for your time!
Matt J
Matt J le 18 Juil 2013
Modifié(e) : Matt J le 18 Juil 2013
You can't enter H and f directly into ga's argument list, but as an alternative to a separate mfile, you could use an anonymous function,
xmin = ga(@(x) x.'*H*x+f*x, nvars, A,b)

Connectez-vous pour commenter.


Shashank Prasanna
Shashank Prasanna le 19 Juil 2013
Modifié(e) : Shashank Prasanna le 19 Juil 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.

Catégories

En savoir plus sur Nonlinear Systems dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by