Failure in initial objective function evaluation. FMINCON cannot continue HELP

25 ビュー (過去 30 日間)
Leonardo Coccia
Leonardo Coccia 2021 年 7 月 6 日
コメント済み: Steve Grikschat 2021 年 7 月 6 日
Hi, I have to solve the problem in the image but my fmincon doesn't work. Someone could help me? My code attached. Thanks in advance!
n_asset = size(Assets,2);
Aeq = ones(1,n_asset);
beq = 1;
x0 = mean(Returns);
lb = zeros(1,n_asset);
ub = ones(1,n_asset);
fun = @(x) -(x')*(sqrt(variance))/sqrt((x')*Covariance*(x))
w = -fmincon(fun,x0,[],[],Aeq,beq,lb,ub)
  2 件のコメント
Sergey Kasyanov
Sergey Kasyanov 2021 年 7 月 6 日
What are sizes of variance and covariance?
Steve Grikschat
Steve Grikschat 2021 年 7 月 6 日
fmincon calls the objective with x0 before starting and that's where this error occurs.
Try evaluating fun with x0 before calling fmincon. That will give you the specific error.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeEconometrics Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by