Splice a table when computed indexes change

A computed index is an index that depends on other variables (that is, not an explicit list of numbers or labels). Computed indexes use functions that return indexes, such as Sequence, Concat, or Subset, for example:

Index Year := Start_year .. Horizon_year
Index K := Concat(i, j)
Index S := Subset(Year < 2002)

Splicing is what happens to an editable table (table, determtable, or prob table) when it uses a computed index that changes because of a change to one of its inputs. The change can cause slices to be added, deleted, or reordered. By default, if the changed index has an item with the same value (number or text) as the previous version, all editable tables retain the old data for the slice identified by that item, even if items are removed, reordered, or added. For example:

Variable Start_year := 2005
Index Year := Start_year .. (Start_year + 2)
Variable Revenues := Table(Year)(100, 200, 300)
Revenues →
2005 2006 2007
100 200 300

Suppose, you change:

Start_year := 2006

Then by default, Revenues will change to:

2005 2006 2007
200 300 0

Thus, it loses the cell for 2005. Cells for 2006 and 2007 retain their original values, and it adds a new cell with default 0 for the new year, 2008. This is called associational correspondence, because it retains the association between index label and value, even if the positions change.

Alternatively, if you change one or more index values to new text labels or numbers, it retains the same values of for the nth slice, even though the index value changes. This is called positional correspondence, because it retains correspondence where the nth position contains the same value.

The default splicing behavior is mixed correspondence, preserving associational correspondence where labels are the same, and preserving positional correspondence where possible otherwise. It is possible to change this splicing behavior for each editable table to pure associational correspondence — retaining values only where index values are the same — or pure positional correspondence — going only by position in the index, irrespective of index values.

See Also


You are not allowed to post comments.