Main Content

addEquality

Add linear equality constraints for portfolio weights to existing constraints

Description

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

AEquality * Port = bEquality

This function "stacks" additional linear equality constraints onto any existing linear equality constraints that exist in the input portfolio object. If no constraints exist, this method is the same as setEquality.

example

Examples

collapse all

Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

p = Portfolio;
A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;
p = addEquality(p, A, b);

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

Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

p = PortfolioCVaR;
A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;
p = addEquality(p, A, b);

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

Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

p = PortfolioMAD;
A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;
p = addEquality(p, A, b);

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

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

Linear equality constraints, specified as a matrix.

Note

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

Data Types: double

Linear equality constraints, specified as a vector.

Note

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

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

    obj = obj.addEquality(AEquality, bEquality)

  • You can also remove linear equality constraints from a portfolio object using dot notation.

    obj = obj.setEquality([ ], [ ])

Version History

Introduced in R2011a