The core model for our investing example follows:

! Core Model -------------------------------------------+;

 

SETS:

  TIME;

  ASSETS: MU, SIGMA;

  AXT( ASSETS, TIME): INVEST, RETURN;

  AXA( ASSETS, ASSETS) | &2 #GT# &1: RHO;

ENDSETS

 

DATA:

  INITIAL = 55;

  GOAL = 80;

  PENALTY = 4;

  TIME = T0..T3;

  ASSETS,   MU,  SIGMA =

   BONDS   1.12   .01

   STOCKS  1.16   .10;

  RHO = .5;

ENDDATA

 

MIN = PENALTY * UNDER - OVER;

 

@FOR( TIME( T) | T #GT# 1:

 @SUM( ASSETS( A): RETURN( A, T) * INVEST( A, T - 1)) =

  @SUM( ASSETS( A): INVEST( A, T))

);

 

FINAL = @SUM( ASSETS( A): INVEST( A, @SIZE( TIME)));

FINAL = GOAL + OVER - UNDER;

 

@SUM( ASSETS( A): INVEST( A, @INDEX( TIME, T0))) = INITIAL;

 

@FOR( ASSETS( A):

  RETURN( A, @INDEX( TIME, T0)) = 0;

);

Core Model for College Investing Example

In the sets section, we have two primitive sets: TIME and ASSETS.  The TIME set will be used to represent our time periods and will have four members: T0 will represent the initial decision period, while T1, T2 and T3 will represent the three time periods.  The set ASSETS will contain two members: BONDS and STOCKS.

We also define two derived sets in the sets section: AXT and AXA.  The AXT set is a dense, 2-dimensional set consisting of all (ASSETS,TIME) pairs. We define the two attributes INVEST and RETURN on AXT.  The INVESTa,t attribute is our decision variable of how much to invest in asset a in period t, while RETURNa,t is a random variable representing the return of asset a in period t.

Next, in the data section we input the following pieces of data:

INITIAL - the initial wealth,
GOAL -  the final goal for wealth,
PENALTY -  the penalty factor to apply to goal shortfalls,
TIME -  the four members of the TIME set,
ASSETS,MU,SIGMA - the normal distribution data for returns on bonds and stocks, and
RHO -  the correlation coefficient between bond and stock returns.

Getting into the model section, the first expression:

MIN = PENALTY * UNDER - OVER;

is the objective function, which can be viewed as a penalty function that we will be minimizing.  For each dollar under our goal (UNDER) we get penalized 4 units, while for each dollar over our goal (OVER) we reduce the penalty by 1 unit.  This will force the solver to more heavily weight solutions that meet our goal, perhaps at the expense of maximizing total wealth.

In the next expression:

@FOR( TIME( T) | T #GT# 1:

 @SUM( ASSETS( A): RETURN( A, T) * INVEST( A, T - 1)) =

  @SUM( ASSETS( A): INVEST( A, T))

);

we are setting total investments in period t equal to total investments plus returns in period t-1.  Note that by formulating the investment flows in this manner, we are free to reallocate investments each period.

The following two expressions are used to calculate the amount that we are either over (OVER) or under (UNDER) goal:

FINAL = @SUM( ASSETS( A): INVEST( A, @SIZE( TIME)));

FINAL = GOAL + OVER - UNDER;

Next, we add a constraint to limit the initial investments to our initial wealth level:

@SUM( ASSETS( A): INVEST( A, @INDEX( TIME, T0))) = INITIAL;

Without this expression, the model would allow infinite investment, leading to an unbounded solution.

Finally, there are no investment returns in the initial decision period, so we zero out them out:

@FOR( ASSETS( A):

  RETURN( A, @INDEX( TIME, T0)) = 0;

);