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

Solving the Model

Models written in the Rason modeling language can be solved in two different ways: 1. By the RASON REST Server when called from a mobile App written in JavaSript or from the RASON.com Web IDE or 2. From the RASON Desktop IDE which calls the Solver SDK Platform directly using problem.load (just like Excel files, LP files, MPS files, etc.). No matter how you solve the model, the result, will always be valid JSON. In this example, we will solve our Improved Model in both ways using the RASON.com Web IDE and the RASON Desktop IDE. Let's start with the RASON.com Web IDE.

Navigate to the RASON membership site www.RASON.com and click Login. (If you have not yet registered on www.RASON.com, click Register and complete the form. For more information on RASON subscriptions, see the earlier RASON Subscriptions chapter.)

www.RASON.com

Once logged in, click "Try It" at the top of the page to navigate to the RASON Web IDE. Open the Improved Model from above by clicking the down arrow next to "Select One" (underneath "RASON Examples") and selecting UGProductMixImp.json. The Improved Model appears in the blank IDE.

RASON WEB IDE

We can quickly solve this model by clicking the POST rason.net/api/solvetype button and selecting optimize from the list. This is equivalent to the QuickSolve endpoint, POST rason.net/api/optimize.

RASON WEB ID

The QuickSolve endpoint should only be used with models that solve very quickly, i.e within a few seconds. Why? There are two reasons. 1. There is a time limit of 30 seconds on all QuickSolve calls. This means that if your model takes longer than 30 seconds to solve, the RASON Server will return the result: "status" : { "code" : 10, "codeText" : "Stop chosen when the maximum time limit was reached." }. 2. Your application code will not be able to continue until the Result is returned. This means that your app will be unresponsive until this endpoint returns a result. In addition, this endpoint does not create a "model resource" which means that this model cannot be saved, edited, retrieved or solved at a later time.

If you wanted to solve the model from your own app, you could use the following code segment which performs the same actions as clicking the Quick Solve button, POST rason.net/api/optimize. Note: The following code segment is missing the OAuth token so if you copy and paste this code into your App, you will get a "Not Authorized" result. Please see the chapter, Using the REST API, for information on how to obtain your OAUTH token.


var request = { "variables" : { ...
"total" : { "formula": "sumproduct(x, profits)", "type": "maximize", "finalValue": [] } } };
$.post("https://rason.net/api/optimize", JSON.stringify(request)).done(function(response){alert(response.objective.z.finalValue);
});

What if you are solving a mixed-integer or global optimization model that might take 30 minutes - or overnight - to run? With a call to the REST API endpoint POST to rason.net/api/model you can create a "model resource," then start an optimization via the REST API endpoint GET rason.net/api/model/id/optimize, check on its progress at any time with the REST API endpoint GET rason.net/api/model/id/status and obtain results when finished with the REST API endpoint GET rason.net/api/model/id/result.

Click POST rason.net/api/model to call the REST API endpoint POST rason.net/api/model to post the model to the RASON Server. In return you will receive a similiar result as shown below.

Model submitted to location: <https://rason.net/api/model/2590+2019-05-15-20-33-31-034142>

Calling this endpoint creates the Model Resource, 2590+2019-05-15-20-33-31-034142. We can now easily retrieve this model by clicking the down arrow next to "Please select a model ID" and selecting this value from the menu.

Click GET rason.net/api/model/id/optimize and select Optimize from the list to call the REST API endpoint GET rason.net/api/model/id/optimize to optimize (or solve) the model . Since we did not specify a specific engine, the LP/Quadratic engine will be selected automatically.

Model has been placed in the queue to be optimized.

Click the GET rason.net/aip/model/id/status to call the REST API endpoint GET Rason.net/api/model/id/status to obtain the status of the solve.

{"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 intermediate results, for example: {"status": "Incomplete", "Milliseconds" : -2147483648, "Iterations" : 0, "Subproblems" : 287, "LocalSolutions" : 8, "Objective" : 3849 }

Click GET rason.net/api/model/id/result to call the REST API endpoint GET rason.net/api/model/id/result to obtain the result of the optimization.


{
"status" : { "code" : 0, "codeText" : "Solver found a solution. All constraints and optimality conditions are satisfied." },
   "parametricInputs" : {
      "profit" : { "finalValue" : [75, 50, 35] }},
      "variables" : {
      "x" : { "finalValue" : [200, 200, 0] }},"objective" :{"total" : { "finalValue" : 25000 }
   }
}

The result "Solver found a solution. All constraints and optimality conditions are satisfied" 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.) To maximize profit, we should make 200 TV sets, 200 stereos and 0 speakers. The final objective value of 25,000 is the maximum profit that we can attain.

We can solve this same model using the desktop IDE which calls the Solver SDK directly (saved on your hard drive or server) to solve a model. Rather than writing code in a programming language such as C++ or C#, we can simply click the Solve button to solve our optimization model.

In a typical installation, this IDE is installed into C:\Program Files\Frontline Systems\Solver SDK Platform\Bin and double click to open RasonIDE.exe.

Continue on to the next section, Using a Simple For() with Index Sets and a Table Assignment.

Click the File Open icon on the toolbar

RASON Desktop IDE menu

and browse to C:\Program Files\Frontline Systems\Solver SDK Examples\RASON to open the example, UGProductMixImp.json. The model opens in the IDE Environment.

RASON Desktop IDE menu

Click Solve on the Ribbon to solve the model. The solution is printed on the right side of the desktop IDE.

Click Solve on the Ribbon to solve the model. The solution is printed on the right side of the desktop IDE.

RASON Desktop IDE menu

If you were defining this same model in a programming language such as C++ or Java, you could use the following code to solve the model.


Problem prob  = new Problem();
prob.Load("UGProductMix2.json");
prob.Solver.Optimize();
MessageBox.Show(prob.FcnObjective.FinalValue[0].ToSTring()):

The first line of code instantiates a new Problem, prob. The second line of code loads the RASON model saved in the file, UGProductMix2.json. The third line of code calls Optimize to solve the model and the last line of code displays a message box with the final value of the objective function. For more information on how to use the REST API to call your model from within an app, please see the following chapter "Using the REST API".

Back to The Improved Model