Parallel array formulas
"constraints" : {
"distance": {
"dimensions": [6],
"formula": "sqrt((x - dx)^2 + (y - dy)^2) - z",
"upper": 0
}
},
Code snippet taken from the example, ParallelArray.json. Click RASON Examples -- Example Models using Arrays Loops and Tables -- Using an Array to open.
This type of array formula is interpreted (evaluated) once but the operations inside the formula are applied element-by-element in parallel across all array operands. Each operation is performed
simultaneously for every corresponding element of the array. In the above example, x, y, z are scalars, while dx and dy are
1-D arrays containing 6 elements each. The operations (x - dx) and (y-dy) are therefore executed for all 6 elements of dx and dy, respectively.
The result of the formula evaluation is assigned to the array variable, distance, which is a 1-D vertical array with 6 elements. Because the formula is defined in the constraints section, one
constraint is generated for each element of the array.
In general, the result of a parallel array evaluation may be a one-dimensional (horizontal or vertical) array or a two-dimensional array. When a formula uses just one row or one column from a table (AKA a
table slice), that data is always handled as a vertical array during parallel operations. The biggest disadvantage of this array formula type is that it prevents reverse-mode evaluation,
which is significantly faster than the native forward evaluation.
|