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

The Improved Model

One way to make our product mix model more flexible is to use some of RASON's built-in functions that operate on all the elements of an array at once, treating it as a vector or matrix.

{
 modelName: "ImprovedLinearModel", 
 modelType: "optimization",
 variables: {
    x: { dimensions: [3], lower: 0, finalValue: [] } 
 },
 data: {
    profits: { dimensions: [3, 1], value: [75, 50, 35], 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: { 
    num_used: { dimensions: [5], formula: "MMULT(parts, x)", upper: 'inventory' }
 },
 objective: {
    total: { formula: "sumproduct(x, profits)", type: "maximize", finalValue: [] }
 }
}

In the variables section, we again define a column array x of size 3 but this time the dimensions property is used to explicitly define the size of the array. As a result, we can pass a single value to the lower property applying a lower bound of 0 to all three elements of the x array. Again, the empty array, finalValue:[] tells the RASON system that you want the results from solving to include the final values of each variable.

In our example above, we calculated our five constraints in the constraints section using explicit formulas such as "x[1] * 1 + x[2] * 1 + x[3] * 0". In this model, we have created three arrays in data to hold the information for our model: profits (to hold the profit margin of each product), inventory (to hold the available inventory) and parts (a matrix holding the part requirements for each product). Note: The RASONTM Language Interpreter currently ONLY supports constants, a name with constant values, or a named array of constants for the lower and upper arguments.

The MMULT function in the num_used constraint multiplies the matrix parts (with 5 rows and 3 columns) by the column array x. The product of this multiplication is a column vector with 5 rows which must be less than the column vector, inventory.

With this version of the model, if the number of parts or products are increased or decreased, you will need to adjust the size of your arrays, but no changes will be needed for the constraints formula which can sometimes be the hardest part of the model to define.

Back to a Basic Optimization Model