'Maximization of portfolio return by implementing the portfolio variance constraint in MATLAB

I have solved the minimization of portfolio variance problem many times, using fmincon or quadprog (of course, quadprog is much faster). The formulation of the problem is as follows:

%Initialize Portfolio Weights.
wo=ones(n,1)/n;

%set the options and the algorithm-solver
options = optimoptions('quadprog','Algorithm','interior-point-convex');
options = optimoptions(options,'TolX',1e-10,'TolF',1e-10,'MaxIter',5000,'display','none');

%cretae the objective function w'Σw
objective=@(wo) wo.'*cov*wo;

%constraints
A=[];
b=[];
Aeq=ones(1,n);
beq=1;
lb=zeros(n,1);
ub=ones(n,1);

%solve the problem
PortWeights=quadprog(cov,wo,A,b,Aeq,beq,lb,ub,[],options);
PortMean=PortWeights.'*meanVec;

Now, i would like to change the formulation of the problem and maximize the portfolio return by adding the constraint for the variance (w'Σw=a constant variance defined by the user).How shall we write this constraint inside the A matrix? Which solver will be used in this situation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source