Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 36 ยท Blocks and Models

Simulink Execution Order and Algebraic Loops Explained

Understand how Simulink sorts blocks, what direct feedthrough means, why algebraic loops cause errors, and how Unit Delay, Memory or an Integrator break a loop.

You draw blocks wherever you like on the canvas, yet Simulink runs them in a precise order. It decides that order from the connections, not from where blocks sit. Understanding this order explains a classic error that every Simulink user meets: the algebraic loop. This lesson shows what Simulink does when it sorts a model and how to fix a loop properly.

Simulink is not available on this site, so the diagram descriptions are about the real product, and the Python stand-ins implement the same sorting and loop detection ideas.

Sorted order

Before a simulation starts, Simulink compiles the model: it propagates data types, dimensions and sample times, and it computes a sorted order in which each block executes. The rule is simple: a block can run only after every block feeding its inputs has produced its outputs.

  • Sources run first.
  • Position on the canvas is irrelevant (the layout is for people).
  • You can see the order after an update: Debug > Information Overlays > Execution Order. A small number on each block shows its position. (The exact menu names vary slightly between releases.)

Direct feedthrough

Some blocks' outputs depend on their current input in the same step. This is called direct feedthrough. A Gain is one: y = K*u. Others produce an output from their stored state only. An Integrator outputs its state, and the input only changes the state for the next step. A Unit Delay outputs the value stored in the previous step. These blocks have no direct feedthrough.

Block Direct feedthrough?
Gain, Sum, Product, Saturation, Abs Yes
Integrator No (output is the state)
Unit Delay, Memory No
Transfer Fcn with more poles than zeros No
Transfer Fcn with as many zeros as poles (e.g. (s+1)/(s+2)) Yes
Discrete-Time Integrator Depends on the method

Direct feedthrough

Yes Output uses current input
No Output uses stored state
Loops Need at least one No block

A loop of only Yes blocks is an algebraic loop.

1 / 2

Algebraic loops

If a signal path leads from a block's output back to its own input through direct feedthrough blocks only, the output depends on itself in the same step. For example y = u - y. Simulink cannot sort such blocks, because each needs the other first. It reports an algebraic loop, highlights the blocks and tries to solve it with an iterative algebraic loop solver at every step. This is slow and may fail to converge.

A loop that contains an Integrator or a delay is not algebraic. The integrator's state breaks the cycle: its output is known at the start of the step.

TEXT
Algebraic loop:   Sum -> Gain -> back to Sum        (all direct feedthrough)
Fine:             Sum -> Gain -> Integrator -> back to Sum

Typical causes:

  1. A proportional controller feeds a plant that is itself a pure gain.
  2. A feedback path that goes directly from a Transfer Fcn with equal numerator and denominator order back to its input.
  3. Subsystems where the dependency is hidden inside.

Fixing a loop

  • Solve the equation by hand. For y = u - y, rearrange to y = u/2 and remove the loop.
  • Insert a Unit Delay or Memory in the feedback path. This changes the mathematics: the feedback is delayed by one step, so use it only when that is physically true (a sampled controller measures the previous output).
  • Use an Integrator or a lag when the physical model has dynamics.
  • Use an Algebraic Constraint block when you truly want to define an implicit equation f(z) = 0.
  • Check for loops through virtual and atomic subsystems. Marking a subsystem atomic can hide a false loop; the Minimize algebraic loop occurrences option in subsystem parameters helps with false loops.

Model Settings has Diagnostics > Solver > Algebraic loop: none, warning (the default) or error. Set it to error in team models so a loop is never silently solved.

Explore the order and a loop

Python Stand-in: sorting blocks and detecting algebraic loops (Python)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that the Integrator is allowed to run early (it needs no current input), so the cycle breaks.

What breaking the loop changes

A Unit Delay solves the loop but delays the feedback. The Python below solves y = u - y three ways: exactly, by iteration (the idea behind the loop solver) and with a delay.

Python Stand-in: iteration and delay (Python)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The delayed version does not converge to 0.5: it flips between 1 and 0. Breaking a loop with a delay changes the answer, so do it deliberately.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What decides the order in which Simulink executes blocks?

    Simulink sorts blocks from data dependencies.
  2. 2. Which block does NOT have direct feedthrough?

    An Integrator outputs its state, so its output does not depend on the current input.
  3. 3. When is a feedback loop an algebraic loop?

    A cycle made only of direct feedthrough blocks defines a signal in terms of itself in the same step.
  4. 4. What is a risk of fixing a loop with a Unit Delay?

    The feedback value is now one step old, which can change results or stability.

Summary

  • Simulink sorts blocks by dependencies, not by layout.
  • Direct feedthrough blocks need current inputs; Integrator, Unit Delay and Memory do not.
  • A cycle made only of direct feedthrough blocks is an algebraic loop: slow or failing, and best removed.
  • Fix loops by solving the algebra, adding real dynamics or a deliberate delay; set the diagnostic to error in shared models.

Next: Model Files and Modeling Style