Running Example ModelsTo 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.) 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. 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.
To solve more complex models, you'll need to use the asynchronous endpoints. POSTing a RASON ModelTo 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.
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.) 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. 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". 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 ModelChange 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. You'll receive a result similar to the following.
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". Solving a Rason ModelClick the previous version under Models (the version that is not the champion) to open the previously posted model. 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.
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. 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 ModelClick 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 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:
Obtaining the Results of a Rason ModelClick 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. 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.
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.
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 ResultTo delete a model version or result from the Editor page, simply right click the version or result in the Models pane and select Delete. To delete all versions and results of a model, right click the model name, then select Delete All.
|