Difference between revisions of "LpDefine"
Line 2: | Line 2: | ||
[[Category:Doc Status C]] <!-- For Lumina use, do not change --> | [[Category:Doc Status C]] <!-- For Lumina use, do not change --> | ||
− | '' | + | ''Superseded by [[DefineOptimization]] as of [[Analytica 4.3]].'' |
''requires Analytica Optimizer'' | ''requires Analytica Optimizer'' | ||
== LpDefine(Vars, Constraints, objCoef, Lhs, Rhs) == | == LpDefine(Vars, Constraints, objCoef, Lhs, Rhs) == | ||
− | This function has been | + | This function has been superseded in [[Analytica 4.3]] by [[DefineOptimization]]. In rare cases where you are given the coefficients for an LP in matrix form, [[LpDefine]] might be slightly more convenient, but in general [[DefineOptimization]] is easier and cleaner to use and can do everything [[LpDefine]] does. |
Returns an LP object, which can then be used from various other optimization functions to access the solution status ([[LpStatusText]]), the solution ([[LpSolution]]), etc. | Returns an LP object, which can then be used from various other optimization functions to access the solution status ([[LpStatusText]]), the solution ([[LpSolution]]), etc. | ||
Line 14: | Line 14: | ||
[[LpDefine]] supports many optional parameters. The full set of parameters are as follows: | [[LpDefine]] supports many optional parameters. The full set of parameters are as follows: | ||
− | + | ;«Vars» : Index | |
− | + | ;«Constraints» : Index | |
− | + | ;«objCoef» : Numeric all[Vars] | |
− | + | ;«Lhs» : numeric all[Vars,Constraints] | |
− | + | ;«Rhs» : numeric all[Constraints] | |
− | + | ;«Sense» : optional Textual[Constraints] | |
− | One of: '<', '>' or '=' | + | :One of: '<', '>' or '=' |
− | + | ;«Maximize» : optional Boolean | |
− | True for maximization problems, | + | :<code>True</code> for maximization problems, <code>False</code> (default) for minimization. |
− | + | ;«Lb» : optional Numeric[Vars] | |
− | + | ; «Ub» : optional Numeric[Vars] | |
− | + | ; «CType» : optional Textual[Vars] | |
− | + | :<code>'C'</code> : Continuous (real-valued) | |
− | + | : <code>'I'</code> : Integer-valued | |
− | + | : <code>'B'</code> : Binary (0/1) valued | |
− | + | :<code>'G'</code> : Group valued | |
− | + | ;«Group» : optional number all[Vars] | |
− | The group number for a group-integer-valued variable. | + | :The group number for a group-integer-valued variable. |
− | + | ;«Engine» : optional text | |
− | Used to select a third-party (non-default) solver engine. Use | + | :Used to select a third-party (non-default) solver engine. Use <code>SolverInfo("AvailEngines")</code> to get a list of installed engines. |
− | + | ;«SettingName» : optional Text | |
− | + | ;«SettingValue» : optional numeric | |
− | + | ;«Parameter» and «Setting»: used together to change a search-control parameter from its default value. To set multiple parameters, ensure that «Parameter» and «Setting» contain a common index. For a list of parameters supported by a given engine, use | |
+ | :<code>SolverInfo("DefaultSettings", engine: engineName)</code>. | ||
== Mixed-Integer Linear Programs == | == Mixed-Integer Linear Programs == | ||
− | + | Each variable in a linear program may be continuous or integer-valued. Integer-valued variables may be general integer, binary (0/1), or group-valued. The «CType» parameter specifies the type of each variable, and may take on the following values: | |
− | Each | + | :<code>'C'</code> : Continuous (real-valued) |
− | + | :<code>'I'</code> : Integer-valued | |
− | + | :<code>'B'</code> : Binary (0/1) valued | |
− | + | :<code>'G'</code> : Group valued | |
− | |||
− | |||
If you specify a single value, such as: | If you specify a single value, such as: | ||
:<code>LpDefine( ..., CType : 'I', ... )</code> | :<code>LpDefine( ..., CType : 'I', ... )</code> | ||
− | then all variables will be of that type. For a mixed-integer problem, where some variables are continuous and others are integer-valued, the parameter value should be indexed by the | + | then all variables will be of that type. For a mixed-integer problem, where some variables are continuous and others are integer-valued, the parameter value should be indexed by the «Vars» index. |
=== Group Variables === | === Group Variables === | ||
+ | An integer-valued variable may belong to a group. A group of ''N'' variables take on the values 1..N, such that each variable in the group must have a different value. For example, if <code>x1, x2</code> and <code>x3</code> are all in the same group, then ,code>x1 = 1, x2 = 3</code> and <code>x3 = 2</code> would be a possible solution, but <code>x1 = 2, x2 = 3</code>, <code>x3 = 2</code> would not. | ||
− | + | A group-valued variable is specified by setting <code>CType: 'G'</code> for the variable and specifying the group number for the variable in the «Group» parameter. If a variable does not belong to a group, «Group» should be zero. (If not all variables belong to the same group, then the «Group» parameter must be indexed by «Vars»). | |
− | |||
− | A group-valued variable is specified by setting <code>CType: 'G'</code> for the variable and specifying the group number for the variable in the | ||
== Specifying Search Control Parameters == | == Specifying Search Control Parameters == | ||
− | |||
In complex problems, you may need to adjust search control parameters. This is done using the parameters «Parameter» and «Setting», where «parameter» contains the parameter name and «setting» contains the value. For example, to change the solution tolerance from its default value to 100n, use | In complex problems, you may need to adjust search control parameters. This is done using the parameters «Parameter» and «Setting», where «parameter» contains the parameter name and «setting» contains the value. For example, to change the solution tolerance from its default value to 100n, use | ||
:<code>LpDefine(..., Parameter: "SolutionTol", Setting: 100n)</code> | :<code>LpDefine(..., Parameter: "SolutionTol", Setting: 100n)</code> | ||
Line 66: | Line 63: | ||
== See Also == | == See Also == | ||
− | + | * [[QpDefine]] | |
− | * [[QpDefine]] | + | * [[NlpDefine]] |
− | * [[LpStatusText]] | + | * [[LpStatusText]] |
− | * [[LpRead]] | + | * [[LpSolution]] |
+ | * [[LpRead]] | ||
+ | * [[LpWrite]] | ||
+ | * [[DefineOptimization]] |
Latest revision as of 21:41, 3 February 2016
Superseded by DefineOptimization as of Analytica 4.3.
requires Analytica Optimizer
LpDefine(Vars, Constraints, objCoef, Lhs, Rhs)
This function has been superseded in Analytica 4.3 by DefineOptimization. In rare cases where you are given the coefficients for an LP in matrix form, LpDefine might be slightly more convenient, but in general DefineOptimization is easier and cleaner to use and can do everything LpDefine does.
Returns an LP object, which can then be used from various other optimization functions to access the solution status (LpStatusText), the solution (LpSolution), etc.
Full set of Parameters
LpDefine supports many optional parameters. The full set of parameters are as follows:
- «Vars»
- Index
- «Constraints»
- Index
- «objCoef»
- Numeric all[Vars]
- «Lhs»
- numeric all[Vars,Constraints]
- «Rhs»
- numeric all[Constraints]
- «Sense»
- optional Textual[Constraints]
- One of: '<', '>' or '='
- «Maximize»
- optional Boolean
True
for maximization problems,False
(default) for minimization.- «Lb»
- optional Numeric[Vars]
- «Ub»
- optional Numeric[Vars]
- «CType»
- optional Textual[Vars]
'C'
: Continuous (real-valued)'I'
: Integer-valued'B'
: Binary (0/1) valued'G'
: Group valued- «Group»
- optional number all[Vars]
- The group number for a group-integer-valued variable.
- «Engine»
- optional text
- Used to select a third-party (non-default) solver engine. Use
SolverInfo("AvailEngines")
to get a list of installed engines. - «SettingName»
- optional Text
- «SettingValue»
- optional numeric
- «Parameter» and «Setting»
- used together to change a search-control parameter from its default value. To set multiple parameters, ensure that «Parameter» and «Setting» contain a common index. For a list of parameters supported by a given engine, use
SolverInfo("DefaultSettings", engine: engineName)
.
Mixed-Integer Linear Programs
Each variable in a linear program may be continuous or integer-valued. Integer-valued variables may be general integer, binary (0/1), or group-valued. The «CType» parameter specifies the type of each variable, and may take on the following values:
'C'
: Continuous (real-valued)'I'
: Integer-valued'B'
: Binary (0/1) valued'G'
: Group valued
If you specify a single value, such as:
LpDefine( ..., CType : 'I', ... )
then all variables will be of that type. For a mixed-integer problem, where some variables are continuous and others are integer-valued, the parameter value should be indexed by the «Vars» index.
Group Variables
An integer-valued variable may belong to a group. A group of N variables take on the values 1..N, such that each variable in the group must have a different value. For example, if x1, x2
and x3
are all in the same group, then ,code>x1 = 1, x2 = 3 and x3 = 2
would be a possible solution, but x1 = 2, x2 = 3
, x3 = 2
would not.
A group-valued variable is specified by setting CType: 'G'
for the variable and specifying the group number for the variable in the «Group» parameter. If a variable does not belong to a group, «Group» should be zero. (If not all variables belong to the same group, then the «Group» parameter must be indexed by «Vars»).
Specifying Search Control Parameters
In complex problems, you may need to adjust search control parameters. This is done using the parameters «Parameter» and «Setting», where «parameter» contains the parameter name and «setting» contains the value. For example, to change the solution tolerance from its default value to 100n, use
LpDefine(..., Parameter: "SolutionTol", Setting: 100n)
To specify more than one parameter setting, the values for «Parameter» and «Setting» should have a common index. Alternatively, «Setting» can be specified without «Parameter», as long as «Setting» is a 1-D array, where the index values contain the parameter name.
Enable comment auto-refresher