Arrays

Variable or object arrays are defined by square brackets with a range of integers and separated by a colon as variable[index 1:index 2]. Arrays may be used to define multiple equations or connections on one line. Any line with an array is processed sequentially from the lowest to the highest index. The model parser creates and processes the arrays as if they were written sequential in non-array form as shown in the example.

Higher dimensional arrays

Arrays with more than one dimension are allowed. The array indices are separated by commas as in var[i,j,k...].

Array Index Consistency

When processing the arrays, the parser checks for array size consistency. An error with an appropriate message is returned if the vector indeces are of different dimension.

Example

 ! Summation with arrays
 Model array
   Constants
      n = 5
   End Constants

   Parameters
     p[1:n] = 1
   End Parameters

   Variables
     sum
   End Variables

   Intermediates
     z[1] = p[1]
     z[2:n] = z[1:n-1] + p[2:n]
   End Intermediates

   Equations
     sum = z[n]
   End Equations
 End Model
 ! Summation without arrays
 Model array
   Parameters
     p[1] = 1
     p[2] = 1
     p[3] = 1
     p[4] = 1
     p[5] = 1
   End Parameters

   Variables
     sum
   End Variables

   Intermediates
     z[1] = p[1]
     z[2] = z[1] + p[2]
     z[3] = z[2] + p[3]
     z[4] = z[3] + p[4]
     z[5] = z[4] + p[5]
   End Intermediates

   Equations
     sum = z[5]
   End Equations
 End Model