Hello, I was wondering if you can help me implement a Sharpe ratio optimization problem in CPLEX for matlab.
I read your post for YALMIP portfolio optimization but I can't seem to reproduce the same results when I try to change my Sharpe ratio optimization problem into the convex version you utilized.
This is my code:
-------------------------------------------------------------------------------------------------------------------
function [weights_new] = max_sharpe_ratio(asset_init, exp_ret, Q, risk_free)
% Computes the maximum Sharpe Ratio using CPLEX solver
% Set variable upper and lower bounds
n = length(asset_init);
k = 1;
lb = k*ones(n,1);
ub = lb;
% Set linear aspect of objective function
c = zeros(n,1);
% Set linear constraints
A1 = exp_ret - risk_free;
A2 = ones(1,n);
lhs = 1;
rhs = lhs;
% Compute optimal portfolio weights
cplex1.Cplex('Sharpe');
cplex1.Model.sense = 'minimize';
cplex1.addcols(c, [], lb, ub);
cplex1.addrows(k, A2, k);
cplex1.addrows(lhs, A1', rhs);
cplex1.Model.Q = 2*Q;
cplex1.solve();
% New optimal weights
weights_new = cplex1.Solution.x / sum(cplex1.Solution.x);
-------------------------------------------------------------------------------------------------------------------
My function tries to solve the optimization problem for:
min (y^T)*Q*y
s.t. sum((exp_ret - risk_free)*y) = 1
sum(y) = k
k*lower bound <= y <= k*upper bound
k >= 0
whereby my optimal weights = y/k
My CPLEX solver always gives me an error string of "Infeasible" and so I cannot compute properly