MATLAB Answers

Optimization Problem: Max Sharpe Ratio

14 ビュー (過去 30 日間)
Jiadi Cao
Jiadi Cao 2019 年 2 月 25 日
回答済み: Alan Weiss 2019 年 2 月 26 日
How do I resolve this issue:
Here's my code:
prob2 = optimproblem('ObjectiveSense','max');
weights2 = optimvar('weights2',10)
%SR = (weights2*ER-rfmean)/(weights2'*cov1*weights2)^(1/2);
prob2.Objective = (weights2*ER-rfmean)/sqrt(weights2'*cov1*weights2);
prob2.Constraints.cons1 = sum(weights2)== 1;
showproblem(prob2)
sol2 = solve(prob2);
Matlab Returns:
Undefined function 'sqrt' for input arguments of type 'optim.problemdef.OptimizationExpression'.
Error in project_2_part1 (line 99)
prob2.Objective = (weights2*ER-rfmean)/sqrt(weights2'*cov1*weights2);

  0 件のコメント

サインイン to comment.

回答 (1 件)

Alan Weiss
Alan Weiss 2019 年 2 月 26 日
Currently, as the documentation clearly states, the problem-based approach does not apply to general nonlinear problems. You must formulate your problem using the solver-based approach.
Alan Weiss
MATLAB mathematical toolbox documentation

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by