# Difference between revisions of "OptInfo"

(→OptInfo(opt, item, decision, constraint, asRef)) |
("Status" item - EW 19003) |
||

(7 intermediate revisions by 2 users not shown) | |||

Line 1: | Line 1: | ||

− | + | [[Category:Optimization_Functions]] | |

− | + | ||

− | + | ||

− | Provides access to an | + | == OptInfo(opt, item'', decision, constraint, asRef'') == |

+ | Provides access to an «item» in the definition of an optimization problem definition («opt») created by [[DefineOptimization]]. | ||

Possible values for the «item» are: | Possible values for the «item» are: | ||

− | {| | + | :{| class="wikitable" |

|- | |- | ||

− | ! | + | ! «Item» |

! Used for | ! Used for | ||

! Indexed by | ! Indexed by | ||

Line 15: | Line 14: | ||

! Description | ! Description | ||

|- | |- | ||

− | | " | + | ! <code>"All"</code> |

− | | LP, QP | + | | LP, QP, QCP, NLP |

+ | | local .item | ||

+ | | ''various'' | ||

+ | | Returns a comprehensive view inside the optimization, listing most items shown here. This is the same info you get when you double click on the «LP», «NLP», etc., cell in a result window. | ||

+ | |- | ||

+ | ! <code>"DecisionVector"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | | Vars | ||

+ | | Text | ||

+ | | This lists all scalar decision variable, where each structured decision has been "flattened" to a single vector. This same index is used to index may of the possible [[OptInfo]] results that refer to scalar decisions, e.g., "ObjCoef", "Q", "Lhs", "LhsQ", etc. | ||

+ | |- | ||

+ | ! <code>"ConstraintVector"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | | Constraints | ||

+ | | Text | ||

+ | | This lists all the scalar constraints, where each structured constraint has been flattened to a single vector. This same index is used to index many of the possible [[OptInfo]] results that refer to scalar constraints, e.g., "Lhs", "LhsQ", "Rhs", "Sense", "constraintLb", "constraintUb", etc. | ||

+ | |- | ||

+ | ! <code>"Decisions"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | (Structured only) | ||

+ | | local .Decision | ||

+ | | Text | ||

+ | | This lists the names of each structured decision in the optimization. This index is also used by other items of [[OptInfo]] when the result applies to the set of structured decision variables. This only applies to problems created using [[DefineOptimization]]. | ||

+ | |- | ||

+ | ! <code>"Constraints"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | (Structured only) | ||

+ | | local .Constraint | ||

+ | | Text | ||

+ | | This lists the names of each structured constraint in the optimization. This index is also used by other items of [[OptInfo]] when the result applies to the set of structured constraints. This only applies to problems created using [[DefineOptimization]]. | ||

+ | |- | ||

+ | ! <code>"ObjCoef"</code> | ||

+ | | LP, QP, QCP | ||

| Vars | | Vars | ||

| numeric | | numeric | ||

+ | | The scalar objective linear coefficients. | ||

|- | |- | ||

− | + | ! <code>"Q"</code> | |

− | | QP | + | | QP, QCP |

| Vars, Vars2 | | Vars, Vars2 | ||

| numeric | | numeric | ||

+ | | The scalar quadratic coefficients for the objective. Dense matrix. | ||

|- | |- | ||

− | + | ! <code>"Lhs"</code> | |

− | | LP, QP | + | | LP, QP, QCP |

| Vars, Constraints | | Vars, Constraints | ||

| numeric | | numeric | ||

+ | | The linear coefficients for all scalar constraints. Dense matrix. You may optionally specify «constraint» to obtain the coefficients for just one constraint, in the intrinsic dimensionality of that constraint but with respect to all scalar decision variables. Or you may specify «decision» to get the coefficients for just one decision, but relative to all scalar constraints. Or you may specify both «decision» and «constraint» to get the coefficients for only one decision and only one constraint, in the dimensionality of each. | ||

|- | |- | ||

− | + | ! <code>"LhsQ"</code> | |

− | | | + | | QCP |

| Vars, Vars2, Constraints | | Vars, Vars2, Constraints | ||

| numeric | | numeric | ||

+ | | The quadratic coefficients for all scalar scalar constraints. Dense matrices, may be too large to fit in memory for some large structured QCPs. You may optionally specify «decision» and/or «constraint» to obtain the quadratic coefficients for just that structured decision and constraint. | ||

|- | |- | ||

− | + | ! <code>"Rhs"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Constraints | | Constraints | ||

| numeric | | numeric | ||

+ | | The right-hand side coefficients for all scalar constraints. You may optionally specify «constraint» to get the coefficients for a single structured constraint, in which case the result will be indexed by the constraint's intrinsic indexes. For a linear or quadratic constraint, the RHS will be the constant term. There is no guarantee of the sign, since it depends on how [[DefineOptimization]] re-arranges the constraint when it processes the coefficients. For a non-linear constraint, rhs will usually be 0. For a range constraint, e.g., <code>a <= f(x) <= b</code>, the far right constant (b) is returned. It is better to use "constraintLb" and "constraintUb" for range constraints. | ||

|- | |- | ||

− | + | ! <code>"ConstraintUb"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Constraints | | Constraints | ||

| numeric | | numeric | ||

− | | Upper bound for each constraint | + | | Upper bound for each scalar constraint. You may optionally specify «constraint» to obtain the values for a single structured constraint in the intrinsic dimensionality of the constraint. |

|- | |- | ||

− | + | ! <code>"ConstraintLb"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Constraints | | Constraints | ||

| numeric | | numeric | ||

− | | Lower bound for each constraint | + | | Lower bound for each scalar constraint. You may optionally specify «constraint» to obtain the values for a single structured constraint in the intrinsic dimensionality of the constraint. |

|- | |- | ||

− | + | ! <code>"Sense"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Constraints | | Constraints | ||

| '>=','<=', '=', 'R' | | '>=','<=', '=', 'R' | ||

− | | | + | | Inequality for each constraint. 'R' for range (lb & ub). You may optionally specify «constraint» to obtain the sense for a single structured constraint. |

|- | |- | ||

− | + | ! <code>"Lb"</code> | |

− | | LP,QP,NLP | + | | LP,QP,QCP,NLP |

| Vars | | Vars | ||

| numeric | | numeric | ||

− | | | + | | Lower bound for each scalar variable. You may optionally specify «decision» to obtain the value for a single structured decision variable, in terms of the decision's intrinsic indexes. |

|- | |- | ||

− | + | ! <code>"Ub"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Vars | | Vars | ||

| numeric | | numeric | ||

− | | | + | | Upper bound for each scalar variable. You may optionally specify «decision» to obtain the value for a single structured decision variable, in terms of the decision's intrinsic indexes. |

|- | |- | ||

− | + | !<code>"IntegerType"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Vars | | Vars | ||

− | | ' | + | | 'Continuous', 'Integer', 'Boolean', 'Grouped Integer', or 'Semi-Continuous'. |

+ | | The type of all scalar decision variables. Optionally you may specify «decision» to get the integer type(s) for the indicated structured decision, in terms of the decision's intrinsic indexes. | ||

|- | |- | ||

− | + | ! <code>"Group"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| Vars | | Vars | ||

| numeric | | numeric | ||

+ | | Applicable only to a grouped integer variable, returns the group number for each scalar decision variable. You may optionally specify «decision» to obtain the groups for a single structured decision, which will be indexed by the decision's intrinsic indexes. | ||

|- | |- | ||

− | + | ! <code>"Maximize"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| atomic | | atomic | ||

− | | True, False | + | | True, False, Null |

+ | | Indicates whether the optimization maximizes or minimizes an objective, or whether there is no objective at all (a find any feasible problem). | ||

|- | |- | ||

− | + | ! <code>"Engine"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| atomic | | atomic | ||

| text | | text | ||

+ | | The name of the engine that will be, or was, used to solve the optimization. | ||

|- | |- | ||

− | + | ! <code>"Setting"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

− | | local . | + | | local .SettingName |

| numeric | | numeric | ||

+ | | A list of all solver engine control setting values. | ||

|- | |- | ||

− | + | ! <code>"Type"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

| atomic | | atomic | ||

− | | "LP","QP", "QCP" | + | | "LP","QP", "QCP", "CQCP", "NCQCP", "NLP", "NSP" |

+ | | The problem type. | ||

|- | |- | ||

− | + | ! <code>"Intrinsic Indexes"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

− | | | + | (Structured only) |

− | | | + | | local .index, Local .item |

+ | | [[Null]], [[Handle]], [[Set Functions|set]] of [[Handle]]s | ||

+ | | This lists in the index .index a set of handles for all the indexes treated as intrinsic indexes anywhere in the optimization. The array shows which structured decisions (<code>result[.item = 'Decision']</code>) and which structured constraints (<code>result[.item = 'Constraint']</code>) contains the index as an intrinsic index. | ||

+ | |||

+ | You may optionally specify either «decision» or «constraint» to get the intrinsic indexes for a single node. In this case the result is scalar (Null, [[Handle]], or [[Set Functions|set]] of [[Handle]]s. | ||

|- | |- | ||

− | + | ! <code>"Extrinsic Indexes"</code> | |

− | | LP,QP,NLP | + | | LP, QP, QCP, NLP |

− | | | + | (Structured only) |

− | | the | + | | local .index, Local .item |

+ | | [[Null]], [[Handle]], [[Set Functions|set]] of [[Handle]]s | ||

+ | Boolean (0 or 1) for objective. | ||

+ | | This lists in the index .index a set of handles for all the indexes treated as extrinsic indexes anywhere in the optimization. The array shows which structured decisions (<code>result[.item = 'Decision']</code>) and which structured constraints (<code>result[.item = 'Constraint']</code>) contains the index as an intrinsic index, and also whether the index is shows up as extrinsic in the objective. | ||

+ | |||

+ | You may optionally specify either «decision» or «constraint» to get the extrinsic indexes for a single node. In this case the result is scalar (Null, [[Handle]], or [[Set Functions|set]] of [[Handle]]s. | ||

+ | |||

+ | This option is very useful when you wondering why [[DefineOptimization]] has array-abstracted over an index, producing multiple optimization problems. The result points to you exactly which component(s) of your problem the extra indexes are arising from. | ||

+ | |- | ||

+ | ! <code>"Decision Intrinsic Indexes"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | (Structured only) | ||

+ | | local .Decision | ||

+ | | [[Null]] or [[Set Functions|set]] of [[Handle]]s | ||

+ | | Lists all structured decision nodes, and for each, a set containing the the indexes that are intrinsic to decision variable. You may optionally select a single decision node by specifying «decision». | ||

+ | |- | ||

+ | ! <code>"Decision Extrinsic Indexes"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | (Structured only) | ||

+ | | local .Decision | ||

+ | | [[Null]] or [[Set Functions|set]] of [[Handle]]s | ||

+ | | Lists all structured decision nodes, and for each, a set containing the the indexes treated as extrinsic for the decision. You may optionally select a single decision node by specifying «decision». | ||

+ | |- | ||

+ | ! <code>"Objective Dims"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | (Structured only) | ||

+ | | scalar | ||

+ | | [[Null]], [[Handle]], or [[Set Functions|set]] of [[Handle]]s | ||

+ | | A list of the indexes that show up in the objective (i.e., are extrinsic to the objective). These result in an array-abstraction over the indexes by [[DefineOptimization]], resulting in an array of optimizations. | ||

+ | |- | ||

+ | !<code>"Status"</code> | ||

+ | | LP, QP, QCP, NLP | ||

+ | | atomic | ||

+ | | Text | ||

+ | | The current solve status. This may be <code>"Not yet solved"</code>, or it may be the same text returned by [[OptStatusText]](). Unlike [[OptStatusText]](), it does not initiate a solve. | ||

|} | |} | ||

− | + | If you include as a «decision» the identifier of a decision variable passed into the «decisions» parameter of [[DefineOptimization]], it gives results just for that decision. The result is dimensioned by the decision variable's indexes rather than by the <code>.Vars</code> index. The «decision» parameter is relevant to any of the «item»s in the above table that show <code>.Vars</code> in the dimensionality column. | |

− | «constraint» is the identifier of a constraint node passed into the «constraints» parameter of [[DefineOptimization]]. When this is provided, only the portion of the requested item relevant to that constraint is returned, and the result is dimensioned by the constraint's [[OptDimensions]] rather than by the | + | «constraint» is the identifier of a constraint node passed into the «constraints» parameter of [[DefineOptimization]]. When this is provided, only the portion of the requested item relevant to that constraint is returned, and the result is dimensioned by the constraint's [[OptDimensions]] rather than by the <code>.Constraints</code> index. The «constraint» parameter is relevant to any of the «item»s in the above table that show <code>.Constraints</code> in the dimensionality column. |

− | = | + | ==History== |

+ | This function was introduced in [[Analytica 4.3]] and supersedes the earlier [[SolverInfo]] function. | ||

+ | == See Also == | ||

*[[OptEngineInfo]] | *[[OptEngineInfo]] | ||

*[[DefineOptimization]] | *[[DefineOptimization]] | ||

*[[OptRead]] | *[[OptRead]] | ||

− | |||

− |

## Latest revision as of 19:29, 4 March 2019

## OptInfo(opt, item*, decision, constraint, asRef*)

Provides access to an «item» in the definition of an optimization problem definition («opt») created by DefineOptimization.

Possible values for the «item» are:

«Item» Used for Indexed by Type Description `"All"`

LP, QP, QCP, NLP local .item *various*Returns a comprehensive view inside the optimization, listing most items shown here. This is the same info you get when you double click on the «LP», «NLP», etc., cell in a result window. `"DecisionVector"`

LP, QP, QCP, NLP Vars Text This lists all scalar decision variable, where each structured decision has been "flattened" to a single vector. This same index is used to index may of the possible **OptInfo**results that refer to scalar decisions, e.g., "ObjCoef", "Q", "Lhs", "LhsQ", etc.`"ConstraintVector"`

LP, QP, QCP, NLP Constraints Text This lists all the scalar constraints, where each structured constraint has been flattened to a single vector. This same index is used to index many of the possible **OptInfo**results that refer to scalar constraints, e.g., "Lhs", "LhsQ", "Rhs", "Sense", "constraintLb", "constraintUb", etc.`"Decisions"`

LP, QP, QCP, NLP (Structured only)

local .Decision Text This lists the names of each structured decision in the optimization. This index is also used by other items of **OptInfo**when the result applies to the set of structured decision variables. This only applies to problems created using DefineOptimization.`"Constraints"`

LP, QP, QCP, NLP (Structured only)

local .Constraint Text This lists the names of each structured constraint in the optimization. This index is also used by other items of **OptInfo**when the result applies to the set of structured constraints. This only applies to problems created using DefineOptimization.`"ObjCoef"`

LP, QP, QCP Vars numeric The scalar objective linear coefficients. `"Q"`

QP, QCP Vars, Vars2 numeric The scalar quadratic coefficients for the objective. Dense matrix. `"Lhs"`

LP, QP, QCP Vars, Constraints numeric The linear coefficients for all scalar constraints. Dense matrix. You may optionally specify «constraint» to obtain the coefficients for just one constraint, in the intrinsic dimensionality of that constraint but with respect to all scalar decision variables. Or you may specify «decision» to get the coefficients for just one decision, but relative to all scalar constraints. Or you may specify both «decision» and «constraint» to get the coefficients for only one decision and only one constraint, in the dimensionality of each. `"LhsQ"`

QCP Vars, Vars2, Constraints numeric The quadratic coefficients for all scalar scalar constraints. Dense matrices, may be too large to fit in memory for some large structured QCPs. You may optionally specify «decision» and/or «constraint» to obtain the quadratic coefficients for just that structured decision and constraint. `"Rhs"`

LP, QP, QCP, NLP Constraints numeric The right-hand side coefficients for all scalar constraints. You may optionally specify «constraint» to get the coefficients for a single structured constraint, in which case the result will be indexed by the constraint's intrinsic indexes. For a linear or quadratic constraint, the RHS will be the constant term. There is no guarantee of the sign, since it depends on how DefineOptimization re-arranges the constraint when it processes the coefficients. For a non-linear constraint, rhs will usually be 0. For a range constraint, e.g., `a <= f(x) <= b`

, the far right constant (b) is returned. It is better to use "constraintLb" and "constraintUb" for range constraints.`"ConstraintUb"`

LP, QP, QCP, NLP Constraints numeric Upper bound for each scalar constraint. You may optionally specify «constraint» to obtain the values for a single structured constraint in the intrinsic dimensionality of the constraint. `"ConstraintLb"`

LP, QP, QCP, NLP Constraints numeric Lower bound for each scalar constraint. You may optionally specify «constraint» to obtain the values for a single structured constraint in the intrinsic dimensionality of the constraint. `"Sense"`

LP, QP, QCP, NLP Constraints '>=','<=', '=', 'R' Inequality for each constraint. 'R' for range (lb & ub). You may optionally specify «constraint» to obtain the sense for a single structured constraint. `"Lb"`

LP,QP,QCP,NLP Vars numeric Lower bound for each scalar variable. You may optionally specify «decision» to obtain the value for a single structured decision variable, in terms of the decision's intrinsic indexes. `"Ub"`

LP, QP, QCP, NLP Vars numeric Upper bound for each scalar variable. You may optionally specify «decision» to obtain the value for a single structured decision variable, in terms of the decision's intrinsic indexes. `"IntegerType"`

LP, QP, QCP, NLP Vars 'Continuous', 'Integer', 'Boolean', 'Grouped Integer', or 'Semi-Continuous'. The type of all scalar decision variables. Optionally you may specify «decision» to get the integer type(s) for the indicated structured decision, in terms of the decision's intrinsic indexes. `"Group"`

LP, QP, QCP, NLP Vars numeric Applicable only to a grouped integer variable, returns the group number for each scalar decision variable. You may optionally specify «decision» to obtain the groups for a single structured decision, which will be indexed by the decision's intrinsic indexes. `"Maximize"`

LP, QP, QCP, NLP atomic True, False, Null Indicates whether the optimization maximizes or minimizes an objective, or whether there is no objective at all (a find any feasible problem). `"Engine"`

LP, QP, QCP, NLP atomic text The name of the engine that will be, or was, used to solve the optimization. `"Setting"`

LP, QP, QCP, NLP local .SettingName numeric A list of all solver engine control setting values. `"Type"`

LP, QP, QCP, NLP atomic "LP","QP", "QCP", "CQCP", "NCQCP", "NLP", "NSP" The problem type. `"Intrinsic Indexes"`

LP, QP, QCP, NLP (Structured only)

local .index, Local .item Null, Handle, set of Handles This lists in the index .index a set of handles for all the indexes treated as intrinsic indexes anywhere in the optimization. The array shows which structured decisions ( `result[.item = 'Decision']`

) and which structured constraints (`result[.item = 'Constraint']`

) contains the index as an intrinsic index.You may optionally specify either «decision» or «constraint» to get the intrinsic indexes for a single node. In this case the result is scalar (Null, Handle, or set of Handles.

`"Extrinsic Indexes"`

LP, QP, QCP, NLP (Structured only)

local .index, Local .item Null, Handle, set of Handles Boolean (0 or 1) for objective.

This lists in the index .index a set of handles for all the indexes treated as extrinsic indexes anywhere in the optimization. The array shows which structured decisions ( `result[.item = 'Decision']`

) and which structured constraints (`result[.item = 'Constraint']`

) contains the index as an intrinsic index, and also whether the index is shows up as extrinsic in the objective.You may optionally specify either «decision» or «constraint» to get the extrinsic indexes for a single node. In this case the result is scalar (Null, Handle, or set of Handles.

This option is very useful when you wondering why DefineOptimization has array-abstracted over an index, producing multiple optimization problems. The result points to you exactly which component(s) of your problem the extra indexes are arising from.

`"Decision Intrinsic Indexes"`

LP, QP, QCP, NLP (Structured only)

local .Decision Null or set of Handles Lists all structured decision nodes, and for each, a set containing the the indexes that are intrinsic to decision variable. You may optionally select a single decision node by specifying «decision». `"Decision Extrinsic Indexes"`

LP, QP, QCP, NLP (Structured only)

local .Decision Null or set of Handles Lists all structured decision nodes, and for each, a set containing the the indexes treated as extrinsic for the decision. You may optionally select a single decision node by specifying «decision». `"Objective Dims"`

LP, QP, QCP, NLP (Structured only)

scalar Null, Handle, or set of Handles A list of the indexes that show up in the objective (i.e., are extrinsic to the objective). These result in an array-abstraction over the indexes by DefineOptimization, resulting in an array of optimizations. `"Status"`

LP, QP, QCP, NLP atomic Text The current solve status. This may be `"Not yet solved"`

, or it may be the same text returned by OptStatusText(). Unlike OptStatusText(), it does not initiate a solve.

If you include as a «decision» the identifier of a decision variable passed into the «decisions» parameter of DefineOptimization, it gives results just for that decision. The result is dimensioned by the decision variable's indexes rather than by the `.Vars`

index. The «decision» parameter is relevant to any of the «item»s in the above table that show `.Vars`

in the dimensionality column.

«constraint» is the identifier of a constraint node passed into the «constraints» parameter of DefineOptimization. When this is provided, only the portion of the requested item relevant to that constraint is returned, and the result is dimensioned by the constraint's OptDimensions rather than by the `.Constraints`

index. The «constraint» parameter is relevant to any of the «item»s in the above table that show `.Constraints`

in the dimensionality column.

## History

This function was introduced in Analytica 4.3 and supersedes the earlier SolverInfo function.

Enable comment auto-refresher