Solving the ModelModels 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.) 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. 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. 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.
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 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 Model has been placed in the queue to be optimized. Click the {"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
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 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. 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. 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.
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 |