Main Content

Working with Linear Inequality Constraints Using PortfolioMAD Object

Linear inequality constraints are optional linear constraints that impose systems of inequalities on portfolio weights (seeLinear Inequality Constraints). Linear inequality constraints have propertiesAInequality不等式约束矩阵,bInequalityfor the inequality constraint vector.

Setting Linear Inequality Constraints Using thePortfolioMADFunction

The properties for linear inequality constraints are set using thePortfolioMADobject. 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 = PortfolioMAD('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 thesetInequalityandaddInequalityFunctions

You can also set the properties for linear inequality constraints usingsetInequality. 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 aPortfolioMADobjectp, usesetInequalityto set the linear inequality constraints:

A = [ 1 1 1 0 0 ]; b = 0.5; p = PortfolioMAD; 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 theaddInequalityfunction to build up linear inequality constraints. For this example, create another system of inequalities:

p = PortfolioMAD; A = [ 1 1 1 0 0 ];% first inequality constraintb = 0.5; p = setInequality(p, A, b); A = [ 0 0 -1 -1 -1 ];% second inequality constraintb = -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

ThePortfolioMADobject,setInequality, andaddInequalityimplement scalar expansion on thebInequalityproperty based on the dimension of the matrix in theAInequalityproperty.

See Also

|||||||||

Related Examples

More About