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

Running Example Models

To open any example model discussed in this guide, click the down arrow in the RASON Examples drop down menu. (Note that Rason models may also be dragged onto the Editor window.)

Example Model List

If you select ProductMix.json beneath Linear Optimizations from the list of example models. The ProductMix.json example model is loaded into the blank RASON Model Editor. To format a model and make it easier to read, click Format Model. To turn off "word wrap", click Turn word wrap off.

Product Mix Example in RASON Editor

To quickly solve the model, click the down arrow next to Quick Run (top left) and select either Optimize or Solve to run the Quick Solve endpoint POST rason.net/api/optimize or (/solve), respectively. Recall that this endpoint can be used to run an optimization that will complete in less than 30 seconds and retrieve the result without creating a resource ID. Since the model is linear, and we did not specify a specific engine, the LP/Quadratic engine was used to solve the model. For more information on how to select an engine, see "Engine Settings" within the RASON Model Components chapter in the RASON Reference Guide.

The result "Solver found a solution. All constraints and optimality conditions are satisfied" is displayed in the Output editor for codeText. This result means that no other solution exists that is better than the solution found. (For more information on this and all possible Solver Result messages, please see the RASON Reference Guide.) For more information on this example model, see the earlier chapter, Defining Your Model. To clear this result from the editor click the Clear Output (or the X) button in the bottom right.


{
   "status": {
      "code": 0,
      "id": "2590+2020-01-17-22-05-08-311425",
      "codeText": "Solver found a solution. All constraints and optimality conditions are satisfied."
   },
   "variables": {
      "d9:f9": {
         "finalvalue": [
            [200, 200, 0]
         ]
       }
   },
   "objective": {
      "d18": {
         "finalvalue": 25000 
       }
   }
}

To solve more complex models, you'll need to use the asynchronous endpoints.

POSTing a RASON Model

To post a model of any type and obtain a resource ID, click the cloud icon to call "POST rason.net/api/model". In return you will receive a similar result.


  Executing ajax call...: POST https://rason.net/api/model
  {
  "ModelId": "2590+productMixExample+2020-02-05-19-34-18-651834",
  "ModelName": "productMixExample",
  "ModelDescr": "Your company manufactures TVs, stereos and speakers, using a common parts inventory of power supplies, 
  speaker cones, etc. Parts are in limited supply and you must determine the most profitable mix of products to build.  
  See our Tutorial Online for step-by-step instructions on formulating this linear programming model.",
  "ModelFiles": [],
  "RuntimeToken": "",
  "ModelType": Origin,
  "ModelKind": "Rason",
  "IsChampion": false,
  "ParentModelId": null,
  "QueryString": "",
  "ModelContainer": null
  }

Calling this endpoint creates the Resource ID, 2590+productMixExample+2020-02-05-19-34-18-651834, where productMixExample matches the modelName component in the RASON model (screenshot above).

The model name and version will appear on the left of the Editor page beneath Models. (Click Refresh if needed.)

Models Pane Refresh button

Note: unamed models will appears under "Unnamed" in the Models pane.

As mentioned earlier, every model (named or unnamed) that is posted to the RASON Server will have a resource ID. Every model that is updated on the RASON Server (PUT rason.net/api/model/{nameorid}) will have a new ID for the new version; the old ID will identify the old version.

Models Pane

What is a Model Champion?

An API call using a RASON model name always refers to the "champion" version of that model. If no "Champion" has been designated, then the most recent version of the model is used. The "champion" is designated in the Models pane on the Editor page with a ✮. The user can designate a specific version (resource ID) as the current "champion" by clicking the desired version under Models to open, then clicking the Mark Champion icon on the right of the Model Editor thereby marking that resource ID as the current "champion" (i.e. the ID to use when future direct API calls specify the model name; then the user can create newer versions as "challengers".

Models Pane with Champion

This button toggles between "Unmark Champion" and "Mark Champion" depending on if the version selected has been marked as a champion or not.

To mark a different version as the champion, simply select the desired version and click Mark Champion.

Editing a previously POSTed Model

Change the first element in the d17:f17 data component from 75 to 100, then use the REST API endpoint PUT rason.net/api/model/{nameorid} to update the model version.

Editing in RASON Editor

You'll receive a result similar to the following.


  Executing asynchronous solve: POST https://rason.net/api/model/2590+productMixExample+2020-02-05-19-34-18-651834/solve
  {
  "ModelId": "2590+productMixExample+2020-02-05-19-38-44-141617",
  "ModelName": "productMixExample",
  "ModelDescr": "Your company manufactures TVs, stereos and speakers, using a common parts inventory of power supplies,
  speaker cones, etc.  Parts are in limited supply and you must determine the most profitable mix of products to build.
  See our Tutorial Online for step-by-step instructions on formulating this linear programming model.",
  "ModelFiles": [],
  "RuntimeToken": "",
  "ModelType": Version,
  "ModelKind": "Rason,
  "IsChampion": false,
  "ParentModelId": "2590+productMixExample+2020-02-05-19-34-18-651834",
  "QueryString": "",
  "ModelContainer": null
  }

Every model that is updated on the RASON server via PUT will have a new ID for the new version; the old ID will identify the old version. You'll notice a new version now appears in the list. An API call using the model name "ProductMixExample" will refer to this newly created version, 2020-02-05019-38-44-141617. Each time a new version is created, that version becomes the "most recent" and will be used in any API call to a named model unless a specific model is designated as the "champion", using the "Mark Champion" button, or the complete Model ID is used, i.e. "ModelId": "2590+productMixExample+2020-02-05-19-38-44-141617".

Model pane

Solving a Rason Model

Click the previous version under Models (the version that is not the champion) to open the previously posted model.

Model pane

Click the down arrow next to the Play button and select Solve from the menu. This endpoint solves the model (of any modeltype) and automatically creates an OData endpoint. See the next chapter for more information on this new endpoint. Alternatively, the model type (optimize) could have been selected.

The following appears in the Result pane.

Solve button
  
    Executing asynchronous solve: POST https://rason.net/api/model/2590+productMixExample+2020-02-05-19-38-44-651834/solve
    {
    "ModelId": "2590+productMixExample+2020-02-05-19-45-47-712467",
    "ModelName": "productMixExample",
    "ModelDescr": "Your company manufactures TVs, stereos and speakers, using a common parts inventory 
    of power supplies, speaker cones, etc. Parts are in limited supply and you must determine the most 
    profitable mix of products to build.  See our Tutorial Online for step-by-step instructions on 
    formulating this linear programming model.",
    "ModelFiles": null,
    "RuntimeToken": "",
    "ModelType": Instance,
    "ModelKind": "Rason",
    "IsChampion": false,
    "ParentModelId": "2590+productMixExample+2020-02-05-19-34-18-651834",
    "QueryString": "",
    "ModelContainer": null
    }
  

When a model is solved via POST rason.net/api/model/{nameorid}/solvetype (where solvetype= Solve, Optimize, Simulate, Datamine, Decision or Diagnose and ID = the ID of the desired version of the model) the call returns a Location header with a new resource ID that identifies this unique model instance (model bound to data), as shown above. This new ID will be used in subsequent calls to GET rason.net/api/model/id/status and GET rason.net/api/model/id/result.

The Models pane has been updated with the new model instance appearing beneath Results. The timestamp embedded in this ID records the date/time when the model was run, and when any regularly-updated data sources (OneDrive, CDS, CDataCloudHub) were accessed by the model instance.

Models pane

Now we will use this new model instance to check the status of the solve and obtain our results using GET rason.net/api/model/{nameorid}/status and GET rason.net/api/model/{nameorid}/result.

Checking the Status of a Rason Model

Click the checkmark icon to call GET rason.net/api/model/{nameorid}/status to check the status of the previously submitted model. This endpoint returns:

       
         {"status": "Complete" }
       
     

Status: Complete means that the optimization has been completed. If the optimization was still in progress we would have received an incomplete status with an intermediate result, for example:


{
 "status": "Incomplete",
 "Milliseconds" : -2147483648,
 "Iterations" : 0,
 "Subproblems" : 287,
 "LocalSolutions" : 8,
 "Objective" : 3849
}

Obtaining the Results of a Rason Model

Click the entry under Results to enable the two result endpoints, GET rason.net/api/model/{nameorid}/result and GET rason.net/api/model/{nameorid}/result/data.

Models pane

Click GET rason.net/api/model/{nameorid}/result to display the results in the Model Editor. Notice that the RASON response produced by the RASON Server includes the resource ID of the model instance that was run. (This is true for "quick solves" as well as "long solves".) This model resource ID is stored in the User Metrics table on the My Account page.

   
     {
       "status": {
       "id": "2590+productMixExample+2020-02-05-19-45-47-712467",
       "code": 0,
       "codeText": "Solver found a solution.  All constraints and
        optimality conditions are satisfied.",
        "solveTime": 80
       },
       "results": {
         "d18": ["finalValue"],
         "d9:f9": ["finalValue"]
       },
       "d9:f9": {
         "objectType": "dataFrame",
         "name": "d9:f9",
         "order": "col",
         "colNames": ["finalvalue"],
         "colTypes": ["double"],
         "indexCols": null,
         "data": [
           [200, 200, 0]
         ]
       },
       "d18": {
       "objectType": "dataFrame",
       "name": "d18",
       "order": "col",
       "colNames": ["finalvalue"],
       "colTypes": ["double"],
       "indexCols": null,
       "data": [
         [25000]
       ]
      }
    }
   

Note that the endpoint POST rason.net/api/model/{nameorid}/solve returns the results as "objectType": " dataframe" and automatically creates an OData endpoint for easy retrieval, querying, etc.

If using the endpoint POST rason.net/api/model/{nameorid}/optimize, the results would be as follows. For more information on each endpoint, see the next section below.


{
  "status": {
    "code": 0,
    "id": "2590+productMixExample+2020-02-05-19-45-47-712467",
    "codeText": "Solver found a solution.  All constraints and
     optimality conditions are satisfied."
  },
  "variables": {
    "d9:f9": {
      "finalValue": [
        [200, 200, 0]
      ]
    }
  },
  "objective": {
    "d18": {
      "finalValue": 25000
    }
  }
}

If your Rason model contains an exported data source, you would use the endpoint GET rason.net/api/model/{nameorid}/result/{data} to download the exported file. See the Using the REST API chapter for more details on this endpoint and all endpoints offered in RASON 2020.

Deleting a Model Version or Result

To delete a model version or result from the Editor page, simply right click the version or result in the Models pane and select Delete.

Models pane

To delete all versions and results of a model, right click the model name, then select Delete All.

Models pane
Back to Rason WEB IDE