Accelerating the pace of engineering and science

# Documentation

### Contents

Class: PortfolioCVaR

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

## 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`

## 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 CVaR portfolio object using dot notation.

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

## Input Arguments

 obj CVaR portfolio object [PortfolioCVaR]. 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 CVaR portfolio object [PortfolioCVaR].

## Attributes

 Access public Static false Hidden false

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

## Examples

expand 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 = 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;

disp(p.NumAssets);
disp(p.AInequality);
disp(p.bInequality);
```
```     5

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

0.5000
-0.5000

```