addInequality

Class: PortfolioMAD

Add linear inequality constraints for portfolio weights to existing constraints for PortfolioMAD object

Syntax

obj = addInequality(obj,AInequality,bInequality)

Description

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

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

AInequality * Port <= bInequality

addInequality "stacks" additional linear inequality constraints onto any existing linear inequality constraints that already exist in the input PortfolioMAD object. If no constraints already exist, this method is the same as setInequality.

Tips

  • You can also use dot notation to add linear inequality constraints for portfolio weights to existing constraints.

    obj = obj.addInequality(AInequality, bInequality)
  • You can remove linear inequality constraints for portfolio weights from a MAD portfolio object using dot notation.

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

Input Arguments

obj

MAD portfolio object [PortfolioMAD].

AInequality

Matrix to form linear inequality constraints [matrix].

bInequality

Vector to form linear inequality constraints [vector].

    Note:   An error results if AInequality is empty and bInequality is nonempty, or if AInequality is nonempty and bInequality is empty.

Output Arguments

obj

Updated MAD portfolio object [PortfolioMAD].

Attributes

Accesspublic
Staticfalse
Hiddenfalse

To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.

Examples

expand all

Add Linear Inequality Constraint

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

     1     1     1     0     0
     0     0    -1    -1    -1

    0.5000
   -0.5000

Was this topic helpful?