GetSolution method: OptInterface class
Syntax
GetSolution(ModelID, varArrayID, skipZero [, KeyFieldNames, KeyFieldValues [, &Solution]])
Description
The GetSolution method retrieves the model solution values generated by the Solve method.
Parameters
| Parameter | Description |
|---|---|
|
ModelID |
Specify as a string the name of the optimization model for which you want the solution. This is the name used for the model definition in Application Designer. |
|
varArrayID |
Specify as a string the name of the variable array being optimized. Your application documentation should provide this name. |
|
skipZero |
Indicate whether solutions with a value of zero should be fetched. This parameter takes a Boolean value:
|
|
KeyFieldNames and KeyFieldValues |
Specify a set of key field names as an array of string and a set of key field values as an equal length array of ANY, with one key field value corresponding to each key field name. You use these arrays to restrict the set of returned solutions. Solutions are returned only for model variables with the specified key field values. Note: If you provide either of these arrays, you must provide both. You can include each parameter from the variable array at most only once. |
|
&Solution |
Specify a rowset to contain the solutions. |
Returns
This method returns a constant value. Valid values are:
| Value | Description |
|---|---|
|
%OptInter_Success |
Returned if method succeeds. |
|
%OptInter_Fail |
Returned if the solver fails to solve the problem. |
Example
Local array of string &strArray;
Local array of any &valArray;
Local integer &index;
Local Rowset &rowSet;
Local integer &result;
Local string &modelId = "QE_PSA_MODEL";
Local string &varArrayName = "X";
Local boolean &bSkipZero = True;
Local OptInterface &oi = CreateOptInterface();
&strArray = CreateArrayRept("", 0);
&valArray = CreateArrayAny();
&rowSet = CreateRowset(Record.QEOPT_VAL_X_WRK);
&strArray [1] = "EMPLID";
&valArray [1] = 1;
&strArray [2] = "ORDER_ID";
&valArray [2] = 23;
/* fetch only the part of the solution where EMPLID = 1 and ORDER_ID = 23 */
&result = &oi.GetSolution(&modelId, &varArrayName,
&bSkipZero, &strArray, &valArray, &rowSet);