Indirection is a computer programming concept that describes a computer's ability to reference a value through a name or container, rather than the value itself. Each time that a value is referenced through such a name or container is known as a level of indirection.
In Optimizer, the line items that you use for objectives and constraints fall into one of three categories. Those that:
- are a variable;
- are dependent upon a variable; or
- are independent of variables.
Any line items that are dependent upon variables that you used in your objective or constraint formulas can only have one level of indirection (although formula components that are independent of variables can have more than one level of indirection). This means that your formulas can refer to line items that are a variable or that contain a variable — but they can't refer to line items that refer to another line item containing a variable. This concept is illustrated in the table and first diagram below.
|Line Item||Data Type||Formula||Line Item Category|
|A||Number-formatted||N/A||Independent of variables|
|B||Number-formatted||N/A||Independent of variables|
|C||Number-formatted||N/A||Independent of variables|
|D||Number-formatted||N/A||Independent of variables|
|E||Number-formatted||N/A||Independent of variables|
|F||Number-formatted||N/A||Independent of variables|
||Formula independent of variables|
|First Indirection 1||Number-formatted||
|First Indirection 2||Number-formatted||
If you attempted to use the constraint formula in the diagram above in an optimization it would not work, returning an error such as the one below when you run the optimization:
The error message states that an objective (or constraint) does not exist because it uses a variable with two levels of indirection, which Optimizer is not able to process.
In the diagram, the error would occur because the line item First Indirection 2 refers to a second line item Second Indirection, which contains a formula that uses a variable.
Optimization problems can be remodeled to account for the single indirection limitation. This is achieved by ensuring that any variables are referenced directly in the first level of indirection. To remodel an optimization problem:
- Identify how any formulas in the first and second level of indirection interact with variables.
- Isolate the variables and any attached operators; then create new line items containing the rest of the contents of these formulas.
- Use the new line items in the first level of indirection, combining them with the variables to create new formulas that directly reference the variables.
See the diagram below for an example of how to work around the indirection limitation using the steps above.
Let's break down the steps you can use to go from the first diagram to the second:
- Identify that the indirection problem originates in Second Indirection, and by extension First Indirection 2
- Examine the formulas used in these line items and consolidate them:
E * F * z
- Isolate the variable and its operator,
- Create a new line item, G, that contains the remainder of the formula,
E * F
- Use the new line item G to create a new formula in First Indirection 2,
G * z, recombining the new line item with the isolated variable and its operator.
By creating the new line item G and using it in a formula with the variable z, we are able to remove the second level of indirection. This means our constraint formula will work and the optimization can run without error.