This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Working with Linear Inequality Constraints Using Portfolio Object

Linear inequality constraints are optional linear constraints that impose systems of inequalities on portfolio weights (see Linear Inequality Constraints). Linear inequality constraints have properties AInequality for the inequality constraint matrix, and bInequality for the inequality constraint vector.

Setting Linear Inequality Constraints Using the Portfolio Function

The properties for linear inequality constraints are set using the Portfolio object. Suppose that you have a portfolio of five assets and you want to ensure that the first three assets are no more than 50% of your portfolio. To set up these constraints:

A = [ 1 1 1 0 0 ];
b = 0.5;
p = Portfolio('AInequality', A, 'bInequality', b);
disp(p.NumAssets);
disp(p.AInequality);
disp(p.bInequality);
5

1     1     1     0     0

0.5000

Setting Linear Inequality Constraints Using the setInequality and addInequality Functions

You can also set the properties for linear inequality constraints using setInequality. Suppose that you have a portfolio of five assets and you want to ensure that the first three assets constitute no more than 50% of your portfolio. Given a Portfolio object p, use setInequality to set the linear inequality constraints:

A = [ 1 1 1 0 0 ];
b = 0.5;
p = Portfolio;
p = setInequality(p, A, b);
disp(p.NumAssets);
disp(p.AInequality);
disp(p.bInequality);
5

1     1     1     0     0

0.5000

Suppose that you want to add another linear inequality constraint to ensure that the last three assets constitute at least 50% of your portfolio. You can set up an augmented system of linear inequalities or use the addInequality function to build up linear inequality constraints. For this example, create another system of inequalities:

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

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

0.5000
-0.5000

The Portfolio object, setInequality, and addInequality implement scalar expansion on the bInequality property based on the dimension of the matrix in the AInequality property.

See Also

| | | | | | | | | | |

Related Examples

More About

External Websites