A fully scalable model with 'loop()'
[Example Model: Space2.json; Space.txt must also be opened]
datasources: {
sun_data: { type: "csv", connection: "Space.txt",
indexCols: ['time'], valueCols: ['sun1x', 'sun1y', 'sun2x', 'sun2y']
}
},
formulas: {
"loop(t in 2..time)" : {
"direction[t]": { dimensions: ['time'], value: 1.570796327, formula: "direction[t-1] + change[t]" },
"Vx[t]": { dimensions: ['time'], value: 0, formula: "Vx[t-1] + COS(direction[t])*blast[t] + x1grav[t-1] x2grav[t-1]" },
...
}
}
In this example, the dimensioning and initialization of arrays is performed inside the loop. The difference between this
example and the previous
example is that here an index set is determined through a data source binding. (All arrays with constants are put in an
external source of type CSV and imported into the model through binding. For more information, see the Data
section within the RASON Reference Guide.)
Notice that loop() is used in the formulas section and does not define any constraints. If, when
evaluating a given constraint, the RASON Interpreter finds that a given part of a constraint formula depends on another
formula, the whole loop must execute in sequence in order to determine the needed precedent.
|