Feedback loops

In ModelBuilder, the output of a process can be used as an input to a previous process. This is known as feedback, since an output is fed back to a previous process as input.

Make a feedback loop

You can make a feedback loop by connecting an output variable of one process to the input variable of the same process. To make this connection, click and hold the left mouse button on the output variable, move the cursor to the input variable, then release the left mouse button when the cursor is on top of the input variable. The model knows that when the output is connected to the input it is a feedback loop and automatically creates a dotted blue feedback connector line. Every time the tool iterates, the output variable will be used as input for the next iteration.

Since the model produces one output dataset for each iteration, it is important to have a unique output name for each iteration so the previous iteration output is not overwritten. Assigning a unique name for each iteration output can be accomplished by appending the output path with the inline variable substitution, as shown in the example below.

Example

The example model below shows the Buffer tool and a feedback loop to iteratively create multiple rings of buffers.

Using feedback loop
The Buffer tool in a feedback loop
  1. To run the feedback loop a certain number of times, use the For iterator. Enter an appropriate From Value, To Value, and By Value. For example, to iterate the model four times, set a starting From Value of 1, an ending To Value of 4, and an interval By Value of 1.
  2. Make the output of the For tool a precondition to the next tool. This ensures that the iteration number is available before the next tool executes.
  3. To avoid overwriting the output of each iteration, append the output name with the %Value% inline variable. When the model runs, %Value% will be replaced by the number coming from the output Value of the For iterator.
  4. Connect the output of Buffer to the Input variable as feedback so the previous buffered output is used as input in the next iteration.
  5. Connect the output of Buffer to the Collect Values tool.
  6. If you wish to run a model with a feedback loop from the Geoprocessing pane, the final output of the model should be connected to the Collect Values tool. Make the output of Collect Values a model parameter so the feedback outputs are added to the map.
  7. Run the model.