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
Supported FEEL Functions
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

A simple 'for()'

[Example Model: ProductMix5 -- To open, click RASON Examples - Example Models using Arrays Loops and Tables -- Using Loop]

variables: {
     x: {
            lower: [0, 0, 0],
            finalValue: []
        }
    }, 
data: {
    	profits: {
            dimensions: [3],
            value: [75, 50, 35],
            binding: "get",
            finalValue: []
    },

parts: {
            dimensions: [5, 3],
            value: [
                [1, 1, 0],
                [1, 0, 0],
                [2, 2, 1],
                [1, 1, 0],
                [2, 1, 1]
            ]
      },

      inventory: {
            value: [450, 250, 800, 450, 600]
      }
    },

constraints: {
	"for(p in 1..5)": {
"cons[p]": { formula: "sumproduct(parts[p,], transpose(x))", upper: 'inventory' }
	}
    }

In the example above, five constraints are created in the vertical array cons[]. The constraints are defined as an array (rather than a table) because 'inventory', holding the upper bounds of the constraints, is a vertical array. Each constraint has a unique index p. To evaluate a given constraint, the model fixes p to a single value (for example, p = 1) and evaluates the formula for that index. Each constraint is evaluated independently for a fixed value of p, not as a vectorized array-formula evaluation. Note that 'x' is transposed from a vertical array to a horizontal array so it can be multiplied with the with the row of the parts array corresponding to index p (parts[p,]).

Back to Examples with Indexed Array Formulas