Scalar Declarations of Outcome Table Distributions

In the previous section, we discussed how to declare outcome tables using matrix-based declarations.  In general, the matrix form of declaration is the simplest and easiest to use.  However, there may be models that are not set based that would be unable to use matrix declarations.  Also, there may be instances when you only wish to declare  portions of an attribute to be random.  In these cases, you will need to use scalar-based outcome table declarations.  The scalar-based functions used to declare outcome tables are: @SPTABLESHAPE, @SPTABLEOUTC., @SPTABLEINST and @SPTABLERNDV.

@SPTABLESHAPE( 'TABLE_NAME', NUMBER_OF_OUTCOMES, NUMBER_OF_RANDOM_VARS)

This function initializes an outcome table and requires three arguments: a unique name for the distribution table (entered as text), the number of possible outcomes, and the number of random variables in the distribution. Some examples follow:

Example 1:        @SPTABLESHAPE( 'WEATHER', 3, 1);

Declares an outcome table called WEATHER with 3 outcomes and 1 independent variable.

Example 2:        @SPTABLESHAPE( 'RETURN', @SIZE( OUTCOMES), @SIZE( ASSETS));

Declares an outcome table called RETURN with the number of outcomes equal to the size of set OUTCOMES and the number of jointly distributed variables equal to the size of set ASSETS.

@SPTABLEOUTC( 'TABLE_NAME', OUTC_PROB, OUTC_VAL1[ ,..., OUTC_VALN])

Once an outcome table has been declared with @SPTABLESHAPE, the next step is to load the table with its set of outcome values and their probabilities.  This is accomplished through calls to @SPTABLEOUTC . @SPTABLEOUTC accepts a multiple number of arguments; however, there must always be at least two arguments, with argument 1 always being the distribution name and the remaining arguments being numeric values.  The first numeric value passed will be taken as the probability of outcome 1.  Assuming the distribution has N variables, the next N arguments will be taken as the values for variables 1 through N for outcome 1.  This process repeats for each outcome until a total of M * (N + 1) numeric values have been passed, where M is the number of outcomes.  These numeric values may be passed in as many calls as is convenient, but, again, the first argument of each call must be the name of the relevant distribution.  The following examples should help to illustrate:

Example 1:        @SPTABLEOUTC( 'WEATHER', .3, 56, .6, 77, .1, 92);

In this example, we have a 3-outcome, single-variable, outcome table named 'WEATHER'.  We make a single call to @SPTABLEOUTC to load all three outcomes.  Outcome 1 has a probability of .3 and a value of 56, outcome 2 has a .6 probability and a value of 77, while outcome 3 has a .1 probability and a value of 92.

Example 2:        @FOR( OUTCOMES( O):

 @SPTABLEOUTC( 'D1', 1 / @SIZE( OUTCOMES));

 @FOR( ASSETS( A): @SPTABLEOUTC( 'D1', O_RETURN( O, A)));

);

Here we are making two calls to @SPTABLEOUTC for each member of the OUTCOMES set. The first call passes the probability of the outcome, while the second call passes the outcomes for each member of the ASSETS set.  This example was taken from the SPCOLLEGEDISC.LG4 example, which you may wish to review for additional clarification.

@SPTABLEINST( 'PARENT_TABLE_NAME', 'TABLE_INSTANCE_NAME')

In order to actually use an outcome table distribution in a model we must also declare an instance of the relevant distribution.  This allows us to use a particular distribution a multiple number of times in a model, saving us from having to reenter the distribution's parameters each time. @SPTABLEINST is the function for declaring distribution instances. This function takes two arguments: the parent outcome table's name as established in the call to @SPTABLESHAPE, and a unique name to apply to the new instance of the distribution.  A particular outcome table may be used many times in a single model, however, each particular instance requires a unique name.  Some examples follow:

Example 1:        @SPTABLEINST( 'WEATHER', 'WEATHER_1');

Declares an instance of the parent distribution 'WEATHER', giving it a name 'WEATHER_1'.

Example 2:        @FOR( TIME( T):

  @SPTABLEINST( 'D1', 'D1_' + TIME( T)));

Declares multiple instances of the parent distribution 'D1', assigning each one the name 'D1_'+TIME( T).  In this case, TIME( T) is a primitive set member whose name gets appended to the 'D1_' string to form the instance name.  As an example, if set TIME has values T1..T12, then the instance name for the first distribution would be 'D1_T1'.

@SPTABLERNDV( 'DIST_INSTANCE_NAME',  RANDOM_VAR_1[, ... , RANDOM_VAR_N])

The final step in setting up an outcome table distribution is binding the random variables to the distribution.  This step associates specific random variables with the outcome table instance that was defined as described above.  The @SPTABLERNDV function is used for this purpose. This function takes two, or more, arguments.  The first argument is the distribution instance name, entered as text.  The second argument is the name of the random variable to bind to the distribution instance.  If the distribution has multiple variables, then you may include the additional variable names as arguments, or you may call @SPTABLERNDV multiple times, until all relevant random variable names have been assigned to the distribution instance.  Some examples follow:

Example 1:        @SPTABLERNDV( 'WEATHER_1', RV_WEATHER_1);

Binds random variable RV_WEATHER_1 to the 'WEATHER_1' distribution instance.

Example 2:        @FOR( TIME( T): @FOR( ASSETS( A):

  @SPTABLERNDV( 'D1_' + TIME( T), RETURN( T, A))));

Assuming the TIME set consists of members T1..T12, this example assigns one random for each member of the ASSETS set to distribution instance 'D1_Ti', for i =1,...,12.  Assuming the ASSETS set has two members, then two random variables are assigned to each the 12 distribution instances.

Sample SP models installed with LINGO that utilize the above techniques include: SPGAS1 and SPCOLLEGEDISC.