Maximization of a function with two constraints

1 回表示 (過去 30 日間)
Andreas S
Andreas S 2020 年 10 月 7 日
コメント済み: Ameer Hamza 2020 年 10 月 8 日
Hi everyone, i'm new in matlab and i have a problem of coding it. I have to find the Wt that solves the following problem.
max Wt'*μt/sqrt(Wt'Σwt)
s.t. w'ti=1
0<=Wt<=0.25
i=1...N
i=ones(10,1)
That is, Wt is such that it maximizes the portfolio's Sharpe ratio with the constraint that all
weights have to be between 0 and 0.25. (Hint: you should use numerical optimization.)
Thank you in advance for your time!
  1 件のコメント
John D'Errico
John D'Errico 2020 年 10 月 7 日
Note: this being a clear homework assignment, you should have tried it yourself.

サインインしてコメントする。

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 7 日
編集済み: Ameer Hamza 2020 年 10 月 7 日
You can use fmincon() from optimization toolbox
mu = rand(10, 1); % example value
sigma = rand(10);
objFun = @(Wt) Wt'*mu/sqrt(Wt'*sigma*Wt);
x0 = zeros(10, 1); % initial guess
lb = zeros(1, 10);
ub = 0.25*ones(1, 10);
Aeq = ones(1, 10); Beq = 1; % wt'*i=1;
sol = fmincon(objFun, x0, [], [], ones(1, 10), 1, lb, ub);
  2 件のコメント
Andreas S
Andreas S 2020 年 10 月 7 日
Ameer Hamza thank you very much. It worked for me!
Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
I am glad to be of help!!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver 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