There are three forms of constraints in the model:

1.we must be fully invested,
2.we can't invest too much in any one asset, and
3.expected return should meet, or exceed, our threshold level of 12%.

The following expression enforces the 100% investment requirement:

! Must be fully invested;

[FULL] @SUM( ASSET: X) = 1;

In words , the sum of all the weights of all the assets in the portfolio must equal 1. Without this constraint, LINGO will tend to under invest in order to get a lower variance. You can confirm this by dropping the constraint and running the model.

To keep the solution from investing too much in any one asset, we use the @BND function:

! Upper bounds on each;

@FOR( ASSET: @BND( 0, X, UB));

As you recall, the @BND function is the most efficient method for placing simple bounds on variables.

We constrain the portfolio's expected return to be greater than or equal to our target with the expression:

! Desired value or return after 1 period;

[RET] @SUM( ASSET: RATE * X) >= GROWTH;

The left-hand side of this expression is the expected rate of return and is the sum of the fractions invested in each asset weighted by each asset's return.