Main Content

setEquality

Set up linear equality constraints for portfolio weights

Description

obj= setEquality(obj,AEquality,bEquality) sets up linear equality constraints for portfolio weights 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 linear equality constraint matrix AEquality and vector bEquality, every weight in a portfolio Port must satisfy the following:

 AEquality * Port = bEquality

example

Examples

collapse all

Suppose you have a portfolio of five assets, and you want to ensure that the first three assets are 50% of your portfolio. Given a Portfolio object p, set the linear equality constraints with the following.

A = [ 1 1 1 0 0 ];
b = 0.5;
p = Portfolio;
p = setEquality(p, A, b);

disp(p.NumAssets);
     5
disp(p.AEquality);
     1     1     1     0     0
disp(p.bEquality);
    0.5000

To add additional Linear Equality constraints, use addEquality.

Suppose you have a portfolio of five assets and you want to ensure that the first three assets are 50% of your portfolio. Given a PortfolioCVaR object p, set the linear equality constraints and obtain the values for AEquality and bEquality:

A = [ 1 1 1 0 0 ];
b = 0.5;
p = PortfolioCVaR;
p = setEquality(p, A, b);
disp(p.NumAssets);
     5
disp(p.AEquality);
     1     1     1     0     0
disp(p.bEquality);
    0.5000

To add additional Linear Equality constraints, use addEquality.

Suppose you have a portfolio of five assets and you want to ensure that the first three assets are 50% of your portfolio. Given a PortfolioMAD object p, set the linear equality constraints and obtain the values for AEquality and bEquality:

A = [ 1 1 1 0 0 ];
b = 0.5;
p = PortfolioMAD;
p = setEquality(p, A, b);
[AEquality, bEquality] = getEquality(p)
AEquality = 1×5

     1     1     1     0     0

bEquality = 
0.5000

To add additional Linear Equality constraints, use addEquality.

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

Matrix to form linear equality constraints, returned as a matrix for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

An error results if AEquality is empty and bEquality is nonempty.

Data Types: double

Vector to form linear equality constraints, returned as a vector for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

An error results if AEquality is nonempty and bEquality is empty.

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 set up linear equality constraints for portfolio weights.

    obj = obj.setEquality(AEquality, bEquality);

  • Linear equality constraints can be removed from a portfolio object by entering [] for each property you want to remove.

Version History

Introduced in R2011a