OptScalarToDecision

Revision as of 22:39, 2 March 2011 by Lchrisman (talk | contribs) (Created page with "Category:Optimization Functions ''(New to Analytica 4.3)'' = Function OptScalarToDecision(opt,decision,scalarValues'',decisionVector'') = When you define a ''Structure...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


(New to Analytica 4.3)

Function OptScalarToDecision(opt,decision,scalarValues,decisionVector)

When you define a Structured Optimization problem using DefineOptimization(), any given decision in the problem may have intrinsic indexes, making it an array-valued decision. Internally, each decision in the structured model must be flattened into a vector, and the vector for each decision must be concatentated to obtain the scalar representation of the problem, which can the be passed to a solver engine. Analytica take care of this mapping from structured decisions to internal vector and back again for you. However, should a reason arise where you need to map from the scalar decisions vector back to an individual structured decision, OptScalarToDecision performs that mapping. It extracts the portion of the «scalarValues» corresponding to the indicated «decision», then unflattens that subvector to obtain a result with the intrinsic indexes of «decision».

To use, «opt» must be the result of a call to DefineOptimization, «constraint» must identify a constraint in the optimization, «scalarValues» is an array indexed by the index «decisionVector», which must have exactly the same number of elements as there are scalar decision variables in the problem. The «decisionVector» index parameter is optional when «scalarValues» is 1-D.

Examples

The function call OptSolution(opt), with a single parameter, returns the solution values for all scalar decision variables. The solution for one particular decision, Price, can be obtained as:

var opt_v:=OptSolution(opt) do OptScalarToDecision(opt,Price,opt_v,opt_v.DecisionVector)

This result is identical to what you get from a call to OptDecision(opt,Price) with the second parameter specified.

Uses

Most users will never need to use this function. It is really intended for some highly specialized purposes in which you have implemented some particularly customized functionality based on the scalar representation of an optimization problem.

One example where it has been used has been as followed. A large LP model was formulated in Analytica using Structured Optimization. The scalar representation of the problem was exported using OptWrite, and an external optimization package (Gusek) was used to compute the solution (rather than one of the built-in Engines). The external solves wrote the solution to a file, which was then loaded in and parsed, yielding a vector of the scalar decision values. These were then mapped back into the dimensionality of the original decision variables and used within the model.

See Also

Comments


You are not allowed to post comments.