Parallel array formulas
...
"constraints" : {
"distance": {
"dimensions": [6],
"formula": "sqrt((x - dx)^2 + (y - dy)^2) - z", upper: 0 }
"upper": 0
}
},
...
Code snippet taken from the exaxmple, ParallelArray.json. Click RASON Examples -- Example Models using Arrays Loops and Tables -- Using Arrays to open.
This type of array formula is interpreted (evaluated) only once. Every operation is executed in parallel for all components of its array operands. In the above example, x, y,
z are scalars, while dx and dy are 1-D arrays containing 6 elements each. The operation (x - dx) is executed for all 6 elements of
dx resulting in a 1-D array of 6 elements.
The multi-dimensional result of the formula evaluation is assigned to an array variable with the appropriate dimensions. In the above example, the result is held by the 1-D vertical array
constraint1, which has 6 elements. If the formula definition is in the constraints section, one constraint will be generated for each component of the result.
The result of the evaluation is a 1-D horizontal/vertical array, or 2-D array. If a table slice is presented in the formula, it is always considered a vertical array in parallel operations. Currently, the
RASON modeling language supports only 2-D arrays. The biggest disadvantage of this array formula type is the prevention of the reverse mode of evaluation which is much faster than the native
forward evaluation.
|