Responses: Solution Status and Results
When you call GET rason.net/api/model/id/status to check the solution status, the JSON response format is fixed, and easy to examine.
For example, if the solution process has completed, you'll get { "status": "Complete" }, so you can check for this with code such as
if(response.status == "Complete"). When you call GET rason.net/api/model/id/result to retrieve results, the response
includes a fixed portion describing the solution status, and a variable portion that depends on what you ask for in the RASON model.
For example, if you run the example optimization model AirlineHub.json (available in the dropdown list on the
Editor page if using the Web IDE or at C:\Program Files\Frontline Systems\Solver SDK Platform\Examples\RASON if
using the Desktop IDE), you'll see the following response:
var modelRequest = {
"variables" :
{
"x" : { "value": 1.0, "finalValue": [] },
...
"objective" :
{
"z" : { "type": "minimize", "finalValue": [] }
}
};
The fixed part of the response includes the "status" property, which tells you the outcome of the optimization. You can test this with JavaScript code
such as if (response.status.code == 0). The variable part of the response includes final values for the three decision variables x, y and
z and the objective being minimized (which is the third variable, z). Recall from the topic Defining Your Model, we got this part of the response
because we asked for it in the RASON model -- we included the property finalValue: [] in the definition of the objective and
each decision variable.
To retrieve the final value of the objective in your JavaScript code, you would simply reference response.objective.z.finalValue. If the
model had asked for the dual value of x by including the property dualValue: [], your JavaScript code could obtain this
value with a reference to response.variables.x.dualValue.
|