|
REST Endpoint: POST: https://rason.net/api/solve
A REST API endpoint that accepts analytic models (optimization, simulation, data science or decision table) in JSON, returns the results of solving
these models in JSON and automatically creates an OData endpoint for the results. (A workflow is a combination of 1 or more stages involving the solving
or diagnosing of an optimization, simulation, decision table, or data science models.) This call should only be used with models that run very quickly,
i.e. within a few seconds. There is a time limit of 30 seconds on all synchronous calls.
Note: This endpoint supports conventional optimization, only. If solving stochastic or simulation optimization models, use POST https://rason.net/api/solve.
- URL: https://rason.net/api/solve
- Method: POST
-
URL Params
Required: None
Optional: This endpoint offers five optional parameters controlling the content of the final results and if and where intermediate results are stored: stage, data-storage, keep-intermediate-results, simplify-final-results and response-format.
-
Stage=>stage-name<
Use this parameter to retrieve information related to a specific stage of a decision flow. If this parameter is passed, the endpoint solves only the part of the decision flow required to solve the specified terminal stage, <stage-name>. The information produced by this optional parameter may be helpful during the creation or debugging phase. If a stage is not specified, a full Directed Acyclic Graph (DAG) solve is performed. To view all stages in a workflow, click or use the REST endpoint GET: https://rason.net/api/model/{nameorid}/stages/all.
Example: POST: https://rason.net/api/solve?stage=imputation
-
Simplify-final-results = True/False
When True, this parameter tells the engine to store and report the results of, only, terminal stages as simplest possible JSON object: a scaler for 1x1 dataframe, 1d - array for Nx1 dataframe and 2d – array for NxM dataframe, No headers or index columns are stored. This option does not affect the results of intermediate stages, these are always dataframes. These simple results are reported in JSON Response may be queried with a REST call. Currently OData does not recognize these objects. The default setting is False.
Example: POST: https://rason.net/api/solve?simplify-final-results = true
-
Response-format = STANDALONE/WORKFLOW
Use this parameter to switch between the default dataframe-based workflow reporting format (for both single and multi-stage workflows) and the default reporting format (for single-stage workflows only). When response-format= workflow and simplify-final-results = false, the formula outputs are reported as dataframes. The default setting is WORKFLOW.
Note: If a formula refers to a decision table, the dataframe will be complete with column headers--as defined in the "outputs" section of the decision table definition, and property types – that will be available in both the JSON response and later in REST/OData queries. If a generic formula, RASON will use default column names and the best possible type for each result column.
Example: POST: https://rason.net/api/solve?response-format = standalone
Example: POST: https://rason.net/api/solve?response-format = workflow
-
Keep-intermediate-results = True/False
This parameter determines whether the RASON server stores the results of the intermediate stages in the workflow, returns them with JSON response and makes them available for REST or OData querying later. Currently, this parameter not only affects the "pipeline solve" (i.e. when a single terminal stage is specified) but also the entire workflow solve, which might have multiple terminal stages. The default setting is False.
Example: POST: https://rason.net/api/solve?keep-intermediate-results=true
-
Data-storage = DATABASE/JSON
This parameter controls whether the SQLite DATABASE or JSON file storage is used to store the results of intermediate stages. Database mode does not affect terminal stages. When database mode is selected, the in-memory SQLite database is used to store the results of intermediate stages and will spill on disk in out-of-memory conditions. The default setting is Database.
DATABASE mode can be orders of magnitude faster than JSON mode. In JSON mode, costs are incurred when reading/writing to/from disk. However, in DATABASE mode all in-memory database read/write operations are much more efficient. Intermediate results can still be stored and examined in DATABASE mode. These results may be queried with REST API or OData but they will not appear in the JSON response as serialized data frames.
If data-storage = database and
- keep-intermediate-results =False, the database stays in memory and will be discarded after terminal stages are processed.
- keep-intermediate-results = True, an in-memory database is saved to disk to enable later querying.
Example: POST: https://rason.net/api/solve?data-storage = json
When submitted together, the two parameters, data-storage and keep-intermediate-results, create four cases.
Example: POST: https://rason.net/api/solve?data-storage = json&keep-intermediate-results=true
-
data-storage = JSON and keep-intermediate-results = True
SQLite database is not used to store results. Rather, JSON files are used for solving, storing, responses and querying. The results of intermediate and terminal stages are reported in JSON response as well as being available for REST/OData querying.
-
data-storage = JSON and keep-intermediate-results = False
Same as when data-storage = JSON and keep-intermediate-results = True, except intermediate results are discarded after the workflow solve. These results are not reported in JSON response and are not available for querying.
- data-storage = DATABASE and keep-intermediate-results = True
SQLite database is used for solving and storing the results of intermediate stages. Results are not returned within JSON response and are available for REST/OData querying only from the stored database. The results of terminal stages are initially stored in JSON files, reported within JSON response and available for REST/OData querying from stored JSON files.
- data-storage = DATABASE and keep-intermediate-results = False
Same as if data-storage = DATABASE and keep-intermediate-results = True except the database with intermediate results is discarded after the workflow is solved. These results are not reported in JSON response and are not available for later querying.
-
Headers:
Required: Authorization - Example: Authorization: bearer {your RASON token}
Optional: None
-
Data Params: A RASON workflow model.
{
"workflow": "imputationWorkflow",
"imputation": {
"datasets": {
"trainData": {
"value": [
[
"black",
null,
6,
2,
1,
"nan",
1
],
[
"",
3,
9,
5.1,
null,
"",
2
],
[
"red",
7,
8,
null,
9.2,
"small",
3
],
[
"red",
10000,
null,
4.4,
4.4,
"large",
-1
],
[
"blue",
2,
3,
5.6,
3.4,
"unknown",
5
]
],
"colNames": [
"A",
"B",
"C",
"D",
"E",
"F",
"G"
]
}
},
"estimator": {
"myImputer": {
"type": "transformation",
"algorithm": "imputation",
"parameters": {
"imputationStrategy": [
[
"A",
"MODE"
],
[
"B",
"MEAN"
],
[
"C",
"MEDIAN"
],
[
"D",
"DELETE_RECORD"
],
[
"E",
"DELETE_RECORD"
],
[
"F",
"VALUE"
],
[
"G",
"MEAN"
]
],
"placeholder": [
[
"B",
10000
],
[
"F",
"unknown"
],
[
"G",
-1
]
]
}
}
},
"actions": {
"imputingModel": {
"data": "trainData",
"estimator": "myImputer",
"action": "fit",
"evaluations": [
"fittedModelJson"
]
}
}
},
"transforming": {
"comment": "imputing missing values based on json model from the parent stage",
"datasources": {
"myModelSrc": {
"type": "stage",
"connection": "imputation",
"selection": "imputingModel.fittedModelJson",
"direction":"import"
}
},
"datasets": {
"newData": {
"value": [
[
"blue",
null,
null,
4,
1,
"unknown",
-1
]
],
"colNames": [
"A",
"B",
"C",
"D",
"E",
"F",
"G"
]
},
"imputingModel": {
"binding": "myModelSrc"
}
},
"actions": {
"fixedNewData": {
"data": "newData",
"fittedModel": "imputingModel",
"parameters": {
"imputation": [
[
"F",
"medium"
]
]
},
"action": "transform",
"evaluations": [
"transformation"
]
}
}
}
}
-
Success Response
Code: 200 (OK)
-
Example Response: Results from a previously solved optimization model.
{
"status": {
"id": "2590+2019-11-18-22-06-58-637468",
"code": 0,
"codeText": "Success"
},
"results": {
"transforming.fixedNewData.transformation": []
},
"transforming": {
"status": {
"code": 0,
"codeText": "Success"
},
"fixedNewData": {
"transformation": {
"objectType": "dataFrame",
"name": "newdata",
"order": "col",
"rowNames": [
"Record 1"
],
"colNames": [
"Treated_A",
"Treated_B",
"Treated_C",
"D",
"E",
"Treated_F",
"Treated_G"
],
"colTypes": [
"wstring",
"double",
"double",
"double",
"double",
"wstring",
"double"
],
"indexCols": null,
"data": [
[
"blue"
],
[
4
],
[
7
],
[
4
],
[
1
],
[
"medium"
],
[
2.75
]
]
}
}
}
}
|