{ From user Lonnie, Model Abstracted_subset_ex at Sat, Sep 12, 2009 9:10 AM}
Softwareversion 4.2.0
{ System Variables with non-default values: }
Typechecking := 1
Checking := 1
Saveoptions := 2
Savevalues := 0
{!40000|Att_contlinestyle Graph_primary_valdim: 1}
{!40000|Att_catlinestyle Graph_primary_valdim: 9}
Model Abstracted_subset_ex
Title: Abstracted Subset Example
Description: Demonstrates how Subset can be utilized in a manner that array abstracts. Makes use of features that are new to Analytica 4.2.~
~
The standard usage of the Subset(D) function cannot array abstract. D must have exactly 1 dimension. If it has more than one dimension, the result for each slice of D along the extra dimension(s) is a list, with each list potentially being a different length. The result would be a non-rectangular array, but there is no index available at that point for representing this result dimension whose length varies. ~
~
To array-abstract, Subset needs two extra things. It needs to know which dimension (in the multi-D array) you are operating over, and then it needs an index to map the results to. If the result index is shorter than any component subset, the elements in the result are truncated to the resultIndex length. If there are fewer elements satisifying the criteria than elements in resultIndex, the final cells are "padded" with null values.~
~
In this example, Subset has been applied to a 2-Dimensional array, operating over the Location dimension and abstracting over the Situation dimension. The result for each situation has a different number of elements, so the result is, in general, non-rectangular. These results are indexed by the Place index, which keeps the first 25 elements (dropping any if there are more than 25 that satisfy the requirement, padding with nulls if there are fewer than 25).
Author: Lonnie Chrisman
Date: Sat, Sep 12, 2009 8:48 AM
Saveauthor: Lonnie
Savedate: Sat, Sep 12, 2009 9:10 AM
Defaultsize: 48,24
Diagstate: 1,1,7,550,300,17
Windstate: 2,76,394,564,458
Fontstyle: Arial, 15
Fileinfo: 0,Model Abstracted_subset_ex,2,2,0,0,W:\Analytica\ExecDebug\Example Models\Function Examples\Abstracted Subset.ana
Index Situation
Title: Situation
Definition: ['a','b','c','d','e','f']
Nodelocation: 104,80,1
Nodesize: 48,24
Index Location1
Title: Location
Definition: "Location " & (1..50)
Nodelocation: 232,80,1
Nodesize: 48,24
Variable A
Title: A
Definition: Random(over:Situation,Location1)
Nodelocation: 104,152,1
Nodesize: 48,24
Valuestate: 2,515,30,506,822,0,MIDM
Reformval: [Situation,Location1]
Variable Locations_of_small_a
Title: Locations of small A
Definition: Subset( A<0.5, I:Location1, resultIndex:Place )
Nodelocation: 232,152,1
Nodesize: 48,24
Valuestate: 2,87,206,527,555,0,MIDM
Reformval: [Situation,Place]
Index Place
Title: Place
Definition: "Place " & (1..25)
Nodelocation: 360,80,1
Nodesize: 48,24
Variable Positions_of_small_a
Title: Positions of small A
Definition: Subset( A<0.5, I:Location1, resultIndex:Place, position:true )
Nodelocation: 232,208,1
Nodesize: 48,24
Valuestate: 2,136,146,482,533,0,MIDM
Reformval: [Situation,Place]
Variable Small_a_values
Title: Small A values
Definition: if Locations_of_small_a=null then null~
else A[Location1=Locations_of_small_a]
Nodelocation: 352,152,1
Nodesize: 48,24
Valuestate: 2,606,36,545,608,0,MIDM
Reformval: [Situation,Place]
Close Abstracted_subset_ex