MATLAB Answers

How can i solve this optimization problem?

2 views (last 30 days)
Hi,
My cost function is:
clear all
clc
syms delta_Uk
F = rand(4,5);
Xf = rand(5,1);
phi = rand(4,2);
Q = rand(4,4);
R_bar = rand(2,2);
Rs = rand(4,1);
YY = F * Xf + phi * delta_Uk;
J = (transpose(Rs - YY)) * Q * (Rs - YY) + (transpose(delta_Uk)) * R_bar * delta_Uk;
Which command / optimization technique may be used to find delta_Uk which make J minimum? There is no contraint on this problem.
Thanks,

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 31 Aug 2021
Best route might be to properly differentiate J with respect to delta_Uk and solve the normal equations and find an analytical solution to that system of equations, and check/verify that it is the global minimum - this is after all some kind of 2-D quadratic equation. It should be possible to solve with the symbolic tools available too for general forms of the constant matrices if you define those variables as arrays:
syms F [4 5]
and so on. For a numerical solution you simply have to define YY and J as functions which you can do like this:
F = rand(4,5);
Xf = rand(5,1);
phi = rand(4,2);
Q = rand(4,4);
R_bar = rand(2,2);
Rs = rand(4,1);
YY = @(delta_Uk) F * Xf + phi * delta_Uk;
J = @(dUk) (transpose(Rs - YY(dUk))) * Q * (Rs - YY(dUk)) + (transpose(dUk)) * R_bar * dUk;
This gives you your cost-function J as a function-handle which you can treat pretty much identically like ordinary matlab-function. To minimize it you can simply call fminsearch:
best_dUk = fminsearch(J,[1;2])
Which should give you the optimal value for delta_Uk.
HTH
  3 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 31 Aug 2021
My pleasure.
You have at least two FEX-submissions that helps you with that problem: fminsearchbnd and minimize. Then you have the optimisation-toolbox functions fmincon (and possibly lsqnonlin if you can differentiate your quadratic equation into normal-equations).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by