Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

addInequality

Add linear inequality constraints for portfolio weights to existing constraints

Use the addInequality function with a Portfolio, PortfolioCVaR, or PortfolioMAD object to add linear inequality constraints for portfolio weights to existing constraints.

For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

Syntax

obj = addInequality(obj,AInequality,bInequality)

Description

example

obj = addInequality(obj,AInequality,bInequality) adds linear inequality constraints for portfolio weights to existing constraints.

Given a linear inequality constraint matrix AInequality and vector bInequality, every weight in a portfolio Port must satisfy the following:

AInequality * Port = bInequality

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

Examples

collapse all

Set a linear inequality constraint to ensure that the first three assets constitute at most 50% of a portfolio. Then add another linear inequality constraint to ensure that the last three assets constitute at least 50% of a portfolio.

p = Portfolio;
A = [ 1 1 1 0 0 ];    % first inequality constraint
b = 0.5;
p = setInequality(p, A, b);

A = [ 0 0 -1 -1 -1 ];    % second inequality constraint
b = -0.5;
p = addInequality(p, A, b);

disp(p.NumAssets);
     5
disp(p.AInequality);
     1     1     1     0     0
     0     0    -1    -1    -1
disp(p.bInequality);
    0.5000
   -0.5000

Set a linear inequality constraint to ensure that the first three assets constitute at most 50% of a portfolio. Then add another linear inequality constraint to ensure that the last three assets constitute at least 50% of a portfolio.

p = PortfolioCVaR;
A = [ 1 1 1 0 0 ];    % first inequality constraint
b = 0.5;
p = setInequality(p, A, b);

A = [ 0 0 -1 -1 -1 ];    % second inequality constraint
b = -0.5;
p = addInequality(p, A, b);

disp(p.NumAssets);
     5
disp(p.AInequality);
     1     1     1     0     0
     0     0    -1    -1    -1
disp(p.bInequality);
    0.5000
   -0.5000

Set a linear inequality constraint to ensure that the first three assets constitute at most 50% of a portfolio. Then add another linear inequality constraint to ensure that the last three assets constitute at least 50% of a portfolio.

p = PortfolioMAD;
A = [ 1 1 1 0 0 ];    % first inequality constraint
b = 0.5;
p = setInequality(p, A, b);

A = [ 0 0 -1 -1 -1 ];    % second inequality constraint
b = -0.5;
p = addInequality(p, A, b);

disp(p.NumAssets);
     5
disp(p.AInequality);
     1     1     1     0     0
     0     0    -1    -1    -1
disp(p.bInequality);
    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

Linear inequality constraints, specified as a matrix.

Note

An error results if AInequality is empty and bInequality is nonempty.

Data Types: double

Linear inequality constraints, specified as a vector.

Note

An error results if bInequality is empty and AInequality 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 inequality constraints for portfolio weights.

    obj = obj.addInequality(AInequality, bInequality)

  • You can also remove linear inequality constraints from any of the portfolio objects using dot notation.

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

Introduced in R2011a

Was this topic helpful?