## Linear Constraints

### Description

There are conceptually two types of linear constraint.

There are linear constraints on categorical variables — for example, constraints on sectors or industries or countries. If the constraint is on countries, then the linear constraint will specify a minimum and maximum value for each country (separately).

There are also linear constraints on numeric variables. The leading example of this is to specify a range for the beta of the portfolio given that we have a beta value for each of the assets.  Duration in a bond portfolio is another example of a numeric linear constraint.

The constraints on variance partitions are — in the larger picture — not actually linear constraints at all.  But they are linear given that the risk fractions for the individual assets have been computed.

### Implementation

A representation of the variables to be constrained is given as the `lin.constraints` argument.  The bounds for the constraints are given in `lin.bounds`. There are several related arguments that control the specifics of the constraints.

Each constraint can be bounding:

• weight
• fraction of portfolio variance
• monetary value
• value of portfolio variance

Each constraint can be (with some limitations):

• on the portfolio
• on the trade

Each constraint can be (with some limitations):

• on the net
• on the gross

Each constraint can be:

• on the long-side only
• on the short-side only
• on all assets