Difference between revisions of "DefineOptimization"
Line 43: | Line 43: | ||
[[image:Variable node classes.png]] | [[image:Variable node classes.png]] | ||
+ | |||
+ | For example, the expression to be maximized (or minimized) is placed in the [[Definition Attribute|definition]] of an objective node, and any equality or inequality constraints are placed directly in definitions of constraint nodes. | ||
+ | |||
+ | The use of variable nodes in a model allowed you to structure your optimization model in the form of an influence diagram, break up the computation into many steps, splitting among many variable nodes. It also allows you to use your model outside of an optimization context, for example, when exploring the solution space manually or via [[Parametric Analysis|parametric analysis]]. And it allows further specification of each component within the model nodes themselves. So, for example, if a certain decision variable is integer-valued with special bounds, those can be indicated directly in the decision variable. If certain decisions or constraints incorporate (assimilate) indexes as part of the optimization problem, these can be indicated directly in the decision or constraint node. Thus, most of the problem specification exists within the Analytica model structure, rather than in the parameters to [[DefineOptimization]]. Once a model is defined (including decision, constraint and objective nodes), the specific optimization to be solved is defined using [[DefineOptimization]]. |
Revision as of 21:42, 7 September 2010
New to Analytica 4.3
DefineOptimization( decisions, maximize/minimize, constraints, type, ... )
Defines an optimization problem, in which Analytica Optimizer should find a set of values for the indicated decisions variables that satisfies all the indicated constraints and, if an objective is also specified, maximizes or minimizes the objective. The function is used for defining Linear Programs (LPs), Quadratic Programs (QPs), Quadratically Constrained Programs (QCPs), and Non-Linear Programs (NLPs).
DefineOptimization has a long list of optional parameters, but typically the core parameters («decisions», «minimize» or «maximize», and «constraints») suffice to define the optimization problem definition, with attributes within your model filling in the necessary details about each decision and constraint. You should generally use a named-parameter syntax when calling DefineOptimization, by spelling out the name of each parameter followed by a colon, and then followed by argument(s) for that parameter.
A problem definition always specifies one or more decision variables (i.e., there must be at least one thing to solve for or optimize). These are typically decision nodes in your model (the green rectangle nodes), although local variables may also be used as decision variables. Each decision variable may be scalar or array-valued. For example, when solving for an optimal portfolio allocation, the allocation decision would typically be dimensioned by an investment index.
Many problems include an objective, which is an expression passed to either the «minimize» or «maximize» parameter, such that the expression depends directly or indirectly on the decision variables. To simply solve a system of equations and inequalities to find a feasible solution, the objective is omitted. When specified, the objective is a standard Analytica expression, typically one that computes a scalar result when the decision variables are set to a candidate solution.
Many problems also specify constraints that must be satisfied by any solution. A problem with no constraints is referred to as an unconstrained optimization problem and must have an objective function. You may specify any number of constraints, each being an equality or inequality expression. Each constraint may be array-valued, which in effect specifies a collection of constraints that must be satisfied.
The «type» parameter is optional, but may be explicitly specified as 'LP', 'QP', 'QCP', 'CQCP', 'NCQCP', 'NLP', or 'NSP'. (Linear, Quadratic, Quadratically constrained, Convex Quadratically Constrained, Non-convex Quadratically Constrained, Non-Linear, or Non-Smooth). When this is omitted, Analytica will automatically analyze the model to determine the problem type, and will select the solver engine that is appropriate for that type of problem. When you explicitly specify «type», an error will be reported if the problem is found to be outside of that problem class. To utilize a linear or quadratic solver, your model must contain only linear (or quadratic) relationships.
Note that all types of problems, linear, quadratic, non-linear alike, are formulated in the same way, using the structure of an Analytica model, and all formulated using DefineOptimization. The DefineOptimization function supercedes the older LpDefine, QpDefine and NlpDefine functions that were used in Analytica 4.0 through Analytica 4.2, although these older functions are still available to be used in the cases where they are more convenient.
Examples
Suppose your model has two decision node variables, X and Y. The following specifies a linear program:
DefineOptimization( Decisions: X,Y, Maximize: 3*X + 2*Y, Constraints: 5*X + 2*Y <= 900, 8*X + 10*Y <= 2800 )
Local variables may also be used for the decision variables:
Var X := 0; Var Y := 0; DefineOptimization( Decisions:X,Y, Maximize: X + 4*Y, Constraints: 4*X >= Y-2 2*X <= Y+1 )
Variable/Node Classes
In most cases, constraints and objectives are encoded within Analytica variables as part of a larger model. When so doing, the variable (or node) class becomes relevant, where the following distinguished variable classes are used for the respective components of the optimization problem:
For example, the expression to be maximized (or minimized) is placed in the definition of an objective node, and any equality or inequality constraints are placed directly in definitions of constraint nodes.
The use of variable nodes in a model allowed you to structure your optimization model in the form of an influence diagram, break up the computation into many steps, splitting among many variable nodes. It also allows you to use your model outside of an optimization context, for example, when exploring the solution space manually or via parametric analysis. And it allows further specification of each component within the model nodes themselves. So, for example, if a certain decision variable is integer-valued with special bounds, those can be indicated directly in the decision variable. If certain decisions or constraints incorporate (assimilate) indexes as part of the optimization problem, these can be indicated directly in the decision or constraint node. Thus, most of the problem specification exists within the Analytica model structure, rather than in the parameters to DefineOptimization. Once a model is defined (including decision, constraint and objective nodes), the specific optimization to be solved is defined using DefineOptimization.
Enable comment auto-refresher