How write these equation in Matlab for optimization
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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 



채택된 답변
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
Q and SA are vectors
why we are not using corr?
as corr(Vector A, Vector B) would be a single value
You can use corr, it will give the same answer, I just forgot about it. You would just need to change the line to
f = @(x,S,c)-corr(S', ((x*c')/sum(x))' );
Muhammad Usama
2020년 7월 5일
편집: Muhammad Usama
2020년 7월 5일
Actully in f
there was
sum(x*c')/sum(x)
%instead of
(x*c')/sum(x)
however when I write sum with numerator it not woks
Also, c would be rectangular matrix, so
sum(x.*c(:,i))/sum(x)
I replaced sum with a matrix operation. If you want to have the sum it would be:
sum(x.*c,2)'/sum(x)
Which is the same
how can we restrict 'x' value to be non-negtive in this ?
sum(abs(x).*c,2)'/sum(abs(x))
But it is giving -ve values of x as well
I want to constraint x >= 0
Suppose the optimizer finds a value of -2 for a x entry. When it goes to the function the -2 becomes +2 because of the absolute. Which means that if you do
[x,fval] = fminsearch(@(x)f(x,S,c),[1,1,1,1])
x = abs(x);
You will still get the same cost function, i.e., the abs(x) is exact the same minimum.
Thank you Sir.
one more thing, I want to add sum(x) ==1
is it possible?
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개)
카테고리
도움말 센터 및 File Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기
참고 항목
2020년 7월 5일
2020년 7월 5일
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
