%% Add Group Ratio Constraints to a PortfolioMAD Object
% Set a group ratio constraint to ensure that the weight in financial assets does not exceed 50% of the weight in nonfinancial assets. Then add another group ratio constraint to ensure that the weight in financial assets constitute at least 20% of the weight in nonfinancial assets of the portfolio.

p = PortfolioMAD;
GA = [ true true true false false false ];    % financial companies
GB = [ false false false true true true ];    % nonfinancial companies
p = setGroupRatio(p, GA, GB, [], 0.5);

GA = [ true false true false true false ];    % odd-numbered companies
GB = [ false false false true true true ];    % nonfinancial companies
p = addGroupRatio(p, GA, GB, 0.2);

disp(p.NumAssets);
disp(p.GroupA);
disp(p.GroupB);
disp(p.LowerRatio);
disp(p.UpperRatio);

% Copyright 2015 The MathWorks, Inc.