How write these equation in Matlab for optimization

조회 수: 3 (최근 30일)
Dear Friends,
I want to write this optimization problem in matlab.
Anybody here to help me write thi in Matlab please.
the only one decision variable is

채택된 답변

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 7월 5일
First you don't need the variable w, your problem is to maximize corr(Q,S), which is a unconstrained problem in x. Second, by your problem definition, Q is a single value, and correlation between single values doesn't make much sense, so I believe what you mean by corr is that the values should be equal or Q is a vector and you forgot a summation index. Considering the second hypothesis an example of how to do it could be seen here:
% Random data
S = 1:100;
c = randn(100,4);1
% Function to minimize
f = @(x,S,c)-min(min((corrcoef(S', (x*c')/sum(x) )) )); % Negative so min = max. Two min's since corrcoef gives a matrix as output
% Minimizer
[x,fval] = fminsearch(@(x)f(x,S,c),[1,1,1,1])
You can use this code as basis to implement your problem.
  댓글 수: 11
Muhammad Usama
Muhammad Usama 2020년 7월 5일
Thank you Sir.
one more thing, I want to add sum(x) ==1
is it possible?
Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 7월 5일
You have this already. Note that you divide by sum(x). This is a linear operation, so it would be the same as:
(x/(sum(x)))*c'
which would give: sum(x) ==1. In other words, if you normalize x by it's sum you'll get the same result as the not normalized one.

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

추가 답변 (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