Referencing other Array Elements

It is very common when working with arrays to need to reference elements of an array that are different from the current element. This happens automatically with builtins such as SUM which will include all array elements, and can be done explicitly by using an equation to determine dimensions. For example

final_production = production[final_stage]

Would bring the last element of the array production into the variable final_production. Similarly, you could define

semi_final_production = production[semi_final_stage]

or equivalently

semi_final_production = production[final_stage-1]

The ability to use this computation in array elements opens the doors to a variety of variable formulations.

Reference other elements of the same array

You can reference another element of the same array using the SELF function. As a simple example consider a variable counting that is dimensioned by Dim where Dim is a number array with 10 elements. Then the equation

IF Dim = 1 THEN 1 ELSE SELF[Dim-1] + 1

Would take on the values 1,2,3...10. This is not a particularly practical example, since you could just use Dim itself in the equation to have the same effect, but it demonstrates the principle. As a more complete example suppose you wanted to know the light penetration into the ocean at different depths and you had an array stratifying the water as

Surface, Down1, Down2, Down5, Down10, Down20

where Down1 was 1 meter down, Down2 2 meters and so on. Then you might have an equation for light received arrayed by strata as

IF strata = Surface THEN sunlight_received ELSE SELF[strata-1]* transimissibility[strata]

Where transmissibility is the amount of light transmitted from the previous strata to the current and might take values such as 1,0.9,0.9,0.5,0.1,0.1. In this case if sunlight was 1, then you would see light received as 1,0.9,0.81,0.405, 0.0405, 0.00405.

Circular References

Normally, if you try to create a loop between converters will represent an error as you would need to know the value of a converter in order to compute the value of the same converter. However, if there are arrays involved, you may need to know the value of the first element to compute the second element and so on. While this would look like a circularity in the diagram, it is not a true circularity. Thus, if you try to make such a connection in a model that is arrayed you will see the dialog:

If you select yes, the connection will be made giving you a diagram such as:

If you use as the equation for a

b[Dim]-1

and as the equation for b

IF Dim = 10 THEN 10 ELSE a[Dim+1]

Then b will have the values 1,2,3...10 and a 0,1,...9. If, on the other hand, you were to use as the equation for b

IF Dim = 10 THEN 10 ELSE a[Dim+1]

You would receive an error message that a[1] and b[1] are involved in a circularity. The same would be true of a[2] and b[2] but only the first detection is reported.

Again, this is not a very practical use of this functionality, but it demonstrates how dependencies can be take down to the element level when working with arrays.

Initialization

The above example are for converters, but the same reasoning applies when computing the initial values for stocks. in this case there is no diagrammatic connection being made, so you don't have to acknowledge the potential circularity. Instead, the software will look directly at the equations to determine if there is any problem and report back on that problem. If you have arrays with a large number of elements these circular paths can become quite long, but hopefully it will be clear from context why it is happening.

Concept Link IconSee Also