How can i solve this optimization problem?

조회 수: 1 (최근 30일)
Volkan Yangin
Volkan Yangin 2021년 8월 31일
댓글: Bjorn Gustavsson 2021년 8월 31일
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,

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 8월 31일
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
Volkan Yangin
Volkan Yangin 2021년 8월 31일
Finally, i want to ask another question. If we have constraints, is there any alternative way instead of fminsearch?
Bjorn Gustavsson
Bjorn Gustavsson 2021년 8월 31일
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).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by