%% Set Bound Constraints to Define Mixed BoundTypes for a Portfolio Object
% Suppose you have the mean and covariance of the asset returns for a three asset portfolio:

AssetMean = [ 0.0101110; 0.0043532; 0.0137058 ];
AssetCovar = [ 0.00324625 0.00022983 0.00420395;
               0.00022983 0.00049937 0.00019247;
               0.00420395 0.00019247 0.00764097 ];  

% The following uses setBounds with both 'Simple' and 'Conditional' BoundType constraints for all i = 1,...NumAssets.

p = Portfolio('AssetMean', AssetMean, 'AssetCovar', AssetCovar);
p = setBounds(p, 0.1, 0.5, 'BoundType',["simple"; "conditional"; "conditional"])
disp(p.LowerBound);
disp(p.UpperBound);
disp(p.BoundType);

% You can use supply lower and upper bounds as vectors, which defines different values for each asset. The following have -0.8 <= x1 <= 0.2; x2 = 0 or 0.1 <= x2 <= 0.5; x3 = 0 or 0.1 <= x3 <=0.5. Note that as 'Simple' BoundType, the assets can be held as short or long positions. However, when using 'Conditional' BoundType, the assets can only be long positions.

p = setBounds(p, [-0.8, 0.1, 0.1], [-0.2,0.5,0.5], 'BoundType',["simple"; "conditional"; "conditional"]);
disp(p.LowerBound);
disp(p.UpperBound);
disp(p.BoundType);

% Copyright 2018 The MathWorks, Inc.