Main Content

addGroups

Add group constraints for portfolio weights to existing group constraints

Description

example

obj = addGroups(obj,GroupMatrix,LowerGroup) adds group constraints for portfolio weights to existing group constraints for Portfolio, PortfolioCVaR, or PortfolioMAD objects. For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

Given GroupMatrix and either LowerGroup or UpperGroup, a portfolio Port must satisfy the following:

LowerGroup <= GroupMatrix * Port <= UpperGroup

example

obj = addGroups(obj,GroupMatrix,LowerGroup,UpperGroup) adds group constraints for portfolio weights to existing group constraints with an additional option for UpperGroup.

Given GroupMatrix and either LowerGroup or UpperGroup, a portfolio Port must satisfy the following:

LowerGroup <= GroupMatrix * Port <= UpperGroup

Examples

collapse all

Set a group constraint to ensure that the first three assets constitute at most 30% of a portfolio. Then add another group constraint to ensure that the odd-numbered assets constitute at least 20% of a portfolio.

p = Portfolio;
G = [ true true true false false ];    % group matrix for first group constraint
p = setGroups(p, G, [], 0.3);
G = [ true false true false true ];    % group matrix for second group constraint
p = addGroups(p, G, 0.2);
disp(p.NumAssets);
     5
disp(p.GroupMatrix);
     1     1     1     0     0
     1     0     1     0     1
disp(p.LowerGroup);
      -Inf
    0.2000
disp(p.UpperGroup);
    0.3000
       Inf

Set a group constraint to ensure that the first three assets constitute at most 30% of a portfolio. Then add another group constraint to ensure that the odd-numbered assets constitute at least 20% of a portfolio.

p = PortfolioCVaR;
G = [ true true true false false ];    % group matrix for first group constraint
p = setGroups(p, G, [], 0.3);
G = [ true false true false true ];    % group matrix for second group constraint
p = addGroups(p, G, 0.2);
disp(p.NumAssets);
     5
disp(p.GroupMatrix);
     1     1     1     0     0
     1     0     1     0     1
disp(p.LowerGroup);
      -Inf
    0.2000
disp(p.UpperGroup);
    0.3000
       Inf

Set a group constraint to ensure that the first three assets constitute at most 30% of a portfolio. Then add another group constraint to ensure that the odd-numbered assets constitute at least 20% of a portfolio.

p = PortfolioMAD;
G = [ true true true false false ];    % group matrix for first group constraint
p = setGroups(p, G, [], 0.3);
G = [ true false true false true ];    % group matrix for second group constraint
p = addGroups(p, G, 0.2);
disp(p.NumAssets);
     5
disp(p.GroupMatrix);
     1     1     1     0     0
     1     0     1     0     1
disp(p.LowerGroup);
      -Inf
    0.2000
disp(p.UpperGroup);
    0.3000
       Inf

Input Arguments

collapse all

Object for portfolio, specified using Portfolio, PortfolioCVaR, or PortfolioMAD object. For more information on creating a portfolio object, see

Data Types: object

Group constraint matrix, specified as a matrix.

Note

The group matrix GroupMatrix often indicates membership in groups, which means that its elements are usually either 0 or 1. Because of this interpretation,GroupMatrix can be a logical or numerical matrix.

Data Types: double

Lower bound for group constraints, specified as a vector.

Note

If input is scalar, LowerGroup undergoes scalar expansion to be conformable with GroupMatrix.

Data Types: double

Upper bound for group constraints, specified as a vector.

Note

If input is scalar, UpperGroup undergoes scalar expansion to be conformable with GroupMatrix.

Data Types: double

Output Arguments

collapse all

Updated portfolio object, returned as a Portfolio, PortfolioCVaR, or PortfolioMAD object. For more information on creating a portfolio object, see

Tips

  • You can also use dot notation to add group constraints for portfolio weights.

    obj = obj.addGroups(GroupMatrix, LowerGroup, UpperGroup)

  • To remove group constraints from any of the portfolio objects using dot notation, enter empty arrays for the corresponding arrays.

Version History

Introduced in R2011a