Optimization Tool
The Optimization tool solves linear programming (LP), mixed integer linear programming (MILP), and quadratic programming (QP) optimization problems using matrix, manual, and file input modes.
This tool uses the R tool. Go to Options > Download Predictive Tools and sign in to the Alteryx Downloads and Licenses portal to install R and the packages used by the R Tool.
What is Optimization?
Optimization has wide applications in many industries, such as supply chain, transportation, financial services, retail, telecommunications, and energy. Application areas include supply chain optimization, assortment optimization, portfolio optimization, workforce scheduling, and sports scheduling.
An optimization problem typically has the following mathematical form, consisting of an objective function (first equation), a set of constraints (second equation), and a specification of the types (continuous, integer, binary) and bounds of the decision variables (third equation). The goal is usually to find the values of the decision variables that maximize or minimize the objective, while satisfying all the underlying constraints, types and bounds.
Connect inputs
No inputs are required for the manual or file input modes. For the matrix input mode, inputs O and A are required, but B and Q are optional.
- O anchor: (Required for matrix input mode) Use this input to provide the names of the decision variables, their coefficients in the objective function, and optionally their bounds and types.
- variable: (Required) a string, decision variable names. Corresponds to x in the equations.
- coefficient: (Required) a number, coefficient of each decision variable in objective function. Corresponds to c.
- lb: (Optional) a number, lower bound of the decision variable. The default value is 0.
- ub: (Optional) a number, upper bound of the decision variable. The default value is Inf (positive infinity).
- type: (Optional) a character, the type of the decision variable, which can be C (continuous), B (binary), or I (integer). The default value is C.
- A anchor: (Required for matrix input mode) Use this input to provide the constraint matrix corresponding to A in the equations. You can organize the matrix in two different ways:
- Dense matrix:
- Constraints in rows: Each row corresponds to a constraint. The first field can optionally be named constraint to indicate the constraint name in each row, while the remaining field names should correspond to the decision variables defined in O. Additionally, you can include the fields dir and rhs to roll the B input into this.
- Variables in rows: Each row corresponds to a variable. The first field should be named variable, while the remaining field names should correspond to the constraint names. Note that this corresponds to the transpose of the A matrix in the above equations.
- Sparse matrix: For larger constraint sets, you can specify the A matrix in its SLAM form. It consists of three required fields i, j, and v, where i and j are row and column indexes, respectively, and v is the non-zero value of the matrix element. Sparse matrix mode always assumes constraints in rows.
- B anchor: (Required if not already provided in A) Use this input to provide the name, direction, and right hand side of the constraints.
- constraint: (Optional) a string, name of the constraint.
- dir: a string, direction of the constraint inequality. It has to be >=, <= or ==.
- rhs: a number, the right hand side of the inequality, corresponding to b.
- Q anchor: Optional. Use this input to provide the quadratic portion of the objective function, for Quadratic Programming problems. It corresponds to Q in the equations. You can specify it as a dense matrix or as a sparse matrix.
- Dense matrix: The field names should correspond to the decision variable names defined in O.
- Sparse matrix: The field names are i, j, and v, where i and j are row and column indexes, respectively, and v is the non-zero value of the associated matrix element.
Beginning with Designer 11.0, you can enable the Display field mapping for Input Anchor O option for more flexibility with field names.
If your constraint equations are: x + 2y + 3z <= 4 and x + y >= 1, the following are all legitimate input for input A:
With constraint field:
constraint | x | y | z | |
---|---|---|---|---|
1 | c1 | 1 | 2 | 3 |
2 | c2 | 1 | 1 | 0 |
Without constraint field:
variable | c1 | c2 | |
---|---|---|---|
1 | x | 1 | 1 |
2 | y | 2 | 1 |
3 | z | 3 | 0 |
Including dir and rhs:
x | y | z | dir | rhs | |
---|---|---|---|---|---|
1 | 1 | 2 | 3 | <= | 4 |
2 | 1 | 1 | 0 | >= | 1 |
The order of variables for input O and input A should be the same.
The following is a legitimate input for input A:
variable | c1 | c2 | |
---|---|---|---|
1 | x | 1 | 1 |
2 | y | 2 | 1 |
3 | z | 3 | 0 |
Beginning with Designer 11.0, you can use other field names for “constraint” or “variable” and the Optimization tool intelligently infers which field contains constraints and which field contains variables. However, the naming convention is still preferred and recommended.
Input Modes
Matrix mode supports either dense or sparse(slam) matrices. Inputs O and A are required for matrix input mode.
Select problem type:
- Linear Program: (Default)(LP) Linear objective and linear constraints with continuous decision variables.
- Mixed Integer Program: (MILP) Linear objective and linear constraints with binary or integer decision variables along with continuous decision variables.
- Quadratic Program: (QP) Quadratic objective and linear constraints with continuous decision variables.
Select solver:
- Glpk: (Default) For Linear Programs and Mixed Integer Linear Programs
- Symphony: For Linear Programs and Mixed Integer Programs. It usually performs better than Glpk for MILP.
- Quadprog: For Quadratic Programs.
Maximize Objective?: Enable this option if you want to maximize the objective function. Otherwise, the tool minimizes the objective function.
Select constraint mode for Input Anchor A: For details, see Inputs.
- Dense matrix, constraints in rows (Default)
- Dense matrix, variables in rows
- Sparse (SLAM) matrix
Display field mapping for Input Anchor O: (Optional) Input O requires the reserved words variable, coefficient, lb, ub, or type for the input table's field names. If you use different field names, or if the field names contain leading or trailing white space, errors occur. By enabling this option, you can map your existing fields to corresponding variable, coefficient, lb, ub, and type fields without the extra step of using a Select Tool to change field names.
This mode offers an interactive interface where you can specify objectives and constraints directly. Sensitivity analysis is available for linear programming problems.
Select problem type
- Linear Program: (LP) Linear objective and linear constraints with continuous decision variables.
- Mixed Integer Program: (MILP) Linear objective and linear constraints with binary or integer decision variables along with continuous decision variables.
- Quadratic Program: (QP) Quadratic objective and linear constraints with continuous decision variables.
Select solver: Glpk (for Linear Program and Mixed Integer Program), Symphony (for Linear Program and Mixed Integer Program), or Quadprog (for Quadratic Program).
Maximize Objective?: Enable this option if this is a maximization problem.
Variable List: Specify a comma-separated list of decision variable names.
Objective: Specify an objective function to be maximized or minimized.
Constraints: Specify the constraints. Ensure that all variables in the constraint are on the left side of the inequality / equality sign. (For example, solver will fail for constraint 2x>=y+4 but will run successfully for constraint 2x-y>=4. While both equations are mathematically equivalent, the second meets the solver’s requirements.)
Bounds & Types: Specify the bounds and types.
This mode supports industry standard model file input.
Select file type: CLPEX_LP, MathProg, or MPS_Free.
Select solver: Glpk (for Linear Program and Mixed Integer Program), Symphony (for Linear Program and Mixed Integer Program), or Quadprog (for Quadratic Program).
Select file: Specify an optimization model file.
View the output
- I anchor: This output provides an interactive dashboard of the solution.
- D anchor: This output consists of three pipe-separated tables: summary, variables, and constraints. They can be used upstream in the workflow to create reports and dashboards.
- S anchor: This is a simple data output that consists of a single table with the optimal value of the objective function and the decision variables. For problems consisting of only binary decision variables (0/1), this table contains only those values that are 1.