Introduction to RASON
About RASON Models and the RASON Server
Rason Subscriptions
Rason Web IDE
Creating and Running a Decision Flow
Defining Your Optimization Model
Defining Your Simulation Model
Performing Sensitivity Analysis
Defining Your Stochastic Optimization Model
Defining Your Data Science Model
Defining Custom Types
Defining Custom Functions
Defining Your Decision Table
Defining Contexts
Using the REST API
REST API Quick Call Endpoints
REST API Endpoints
Decision Flow REST API Endpoints
OData Endpoints
OData Service for Decision Flows
Creating Your Own Application
Using Arrays, For, Loops and Tables
Organization Accounts

Arrays and tables in indexed array formulas

Currently the RASON modeling language supports arrays with up to 2 dimensions. If you require an array with more than 2 dimensions, then you must create a table. There are many advantages to using tables:

  • Tables may hold more than 2 dimensions
  • A table result may be used in an indexed array formula
  • A table can be sparse while an array is dense.
  • The evaluation of a table is less expensive (time consuming) than the evaluation of an array with more than 2 dimensions.

Below is an example of how to assign an indexed array formula to a table.

"for(p in 'POT', c in 'CRUCE', g in 'GRADE')" : {
   "Amount[p, c, g]": { formula: "SumTap[p, c, g] - AMT[p, c, g]", equal: 0 }
}

The example code below illustrates how to assign an indexed array formula to an array. In this example, 'time' is the index set { 1, 2, 3, ..., 10 }.

"for(t in 'time')": {
        "dist[t]": { dimensions: ['time'], formula: "sqrt(Vx[t]^2 + Vy[t]^2" }
}

Due to the presence of the dimensions property in the object above, the result, dist[t], will be an array. This is only possible if the array has no more than 2 dimensions. Even if the index set is non-numeric, dist[t] will still result in an array as long as the dimensions property exists in the object definition.

Recall that we must refer to an array element by indices, while we refer to a table element using the names of index set components. For example, to refer to the 2nd element in the dist[] array, we would use dist[2]. To avoid confusion, it is permissible to use indexed array formulas with arrays that do not involve any index sets. The above example can be re-written as:

"for(t in 1..time)": {
        "dist[t]": { dimensions: ['time'], formula: "sqrt(Vx[t]^2 + Vy[t]^2)" }
}

where time is either the constant 10 or an index set/index column with size 10.

Back to Applying a Common For to Multiple Formulas