Difference between revisions of "LpDefine"

Line 6: Line 6:
 
''requires Analytica Optimizer''
 
''requires Analytica Optimizer''
  
= LpDefine( Vars, Constraints, objCoef, Lhs, Rhs ) =
+
== LpDefine(Vars, Constraints, objCoef, Lhs, Rhs) ==
 
 
Defines a linear-programming optimization problem. 
 
 
 
 
This function has been superceded 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.
 
This function has been superceded 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.
 
A linear programming problem has the following form:
 
 
(TBD: Fill in)
 
  
 
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.
  
= Full set of Parameters =
+
== Full set of Parameters ==
 
+
[[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
+
* «Vars» : Index
* ''Constraints'' : Index
+
* «Constraints» : Index
* ''objCoef'' : Numeric all[Vars]
+
* «objCoef» : Numeric all[Vars]
* ''Lhs'' : numeric all[Vars,Constraints]
+
* «Lhs» : numeric all[Vars,Constraints]
* ''Rhs'' : numeric all[Constraints]
+
* «Rhs» : numeric all[Constraints]
* ''Sense'' : optional Textual[Constraints]
+
* «Sense» : optional Textual[Constraints]
 
One of: '<', '>' or '='
 
One of: '<', '>' or '='
* ''Maximize'' : optional Boolean  
+
* «Maximize» : optional Boolean  
 
True for maximization problems, false (default) for minimization.
 
True for maximization problems, false (default) for minimization.
* ''Lb'' : optional Numeric[Vars]
+
* «Lb» : optional Numeric[Vars]
* ''Ub'' : optional Numeric[Vars]
+
* «Ub» : optional Numeric[Vars]
* ''CType'' : optional Textual[Vars]
+
* «CType» : optional Textual[Vars]
** 'C' : Continuous (real-valued)
+
** <code>'C'</code> : Continuous (real-valued)
** 'I' : Integer-valued
+
** <code>'I'</code> : Integer-valued
** 'B' : Binary (0/1) valued
+
** <code>'B'</code> : Binary (0/1) valued
** 'G' : Group valued
+
** <code>'G'</code> : Group valued
* ''Group'' : optional number all[Vars]  
+
* «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
+
* «Engine» : optional text
 
Used to select a third-party (non-default) solver engine.  Use [[SolverInfo]]("AvailEngines") to get a list of installed engines.
 
Used to select a third-party (non-default) solver engine.  Use [[SolverInfo]]("AvailEngines") to get a list of installed engines.
* ''SettingName'' : optional Text  
+
* «SettingName» : optional Text  
* ''SettingValue'' : optional numeric
+
* «SettingValue» : optional numeric
Parameter and Setting are 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).
+
Parameter and Setting are 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 variables 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 variables 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)
+
* <code>'C'</code> : Continuous (real-valued)
* 'I' : Integer-valued
+
* <code>'I'</code> : Integer-valued
* 'B' : Binary (0/1) valued
+
* <code>'B'</code> : Binary (0/1) valued
* 'G' : Group valued
+
* <code>'G'</code> : Group valued
  
 
If you specify a single value, such as:
 
If you specify a single value, such as:
LpDefine( ..., CType : 'I', ... )
+
:<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 Vars index.
 
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 x1, x2 and x3 are all in the same group, then x1=1, x2=3 and x3=2 would be a possible solution, but x1=2, x2=3, x3=2 would not.
+
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 ''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'').
+
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 <code>Vars</code>).
  
= 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
LpDefine(..., Parameter:"SolutionTol", Setting:100n )
+
:<code>LpDefine(..., Parameter: "SolutionTol", Setting: 100n)</code>
  
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.
+
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.
  
= See Also =
+
== See Also ==
  
 
* [[QpDefine]], [[NlpDefine]]
 
* [[QpDefine]], [[NlpDefine]]
 
* [[LpStatusText]], [[LpSolution]]
 
* [[LpStatusText]], [[LpSolution]]
 
* [[LpRead]], [[LpWrite]]
 
* [[LpRead]], [[LpWrite]]

Revision as of 01:58, 21 January 2016


Superceded by DefineOptimization as of Analytica 4.3.

requires Analytica Optimizer

LpDefine(Vars, Constraints, objCoef, Lhs, Rhs)

This function has been superceded 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 are 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 variables 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.

See Also

Comments


You are not allowed to post comments.