ICore Blocks / Features / Edit → Reduce

Block reduction.
Optimize the loop
before it deploys.

Exported code advances every block on its own. A feedback loop drawn as separate blocks is closed a sample late, and each block's hold assumes an input the loop is still changing. Select the loop and choose Reduce: ICore Blocks does the state-space algebra and swaps the selection for one exact State Space block, which deploys as a single discretized loop on fewer signal buffers. When the algebra has no answer, it says so and changes nothing.

Discretized as one loop Fewer signal buffers Series Parallel Feedback loop Unity feedback One undo step each
Right-click → Reduce
A cascaded speed loop, reduced in five steps from the canvas right-click menu. The loop has a PI controller, an actuator, an inner unity-feedback loop around the plant, and a sensor on the outer return path. The steps are the PI's two parallel branches, a series pair, the inner unity feedback loop, another series pair, and finally the outer feedback loop through the sensor. What's left is a single State Space block between the step input and the scope.
01 · Why reduce before you deploy

Discretized block by block, or as one loop.

A reduction doesn't change what the loop is. It changes how the deployed core advances it. The State Space block it builds is exact, so what you gain is everything the interconnection used to cost on the target.

Less discretization error in the closed loop

  • Between blocksThe deployed core visits each block once per sample, in order. A loop is opened at a block with no direct feedthrough, and the blocks after it read the value it wrote last sample. Each continuous block is also discretized on its own, and its zero-order hold assumes its input stays constant for the whole sample, which a signal inside a moving loop doesn't.
  • As one blockAfter the reduction the loop lives inside one realization, and the whole closed-loop A is discretized at once. There is no loop delay and no hold between the blocks that made it up. Under the default Zero-order Hold, the reduced loop is exact at every sample for a held input.
  • How largeOn the Solvers page, a one-state loop advanced block by block, which is the scheme exported code reproduces, ends 2.0e-2 off at one second. Advanced as one state vector, it's 3.3e-7 off. A reduced loop never crosses a block boundary, so it doesn't carry that error.

Fewer buffers on the target

  • SignalsThe exported core keeps one persistent buffer for every block output. Each link inside the selection goes with the reduction, along with the storage the Sum and Gain blocks needed. That's less RAM on the target.
  • Transfer FcnA Transfer Function block keeps a history of past inputs and outputs, about two values per pole. Inside a reduced block the same dynamics cost one state each.
  • The tradeThe reduced block keeps every state of the blocks it replaced, and its A, B, C, D are stored dense. Constants and multiply-adds per sample grow roughly with the square of the total state count. A small scalar loop comes out ahead on RAM. On a large one, weigh the RAM saved against flash and cycles.
02 · Five selections, one block

The same loop, step by step.

This is the loop from the clip, redrawn. Each step highlights the selection first, then replaces it with the block that Reduce builds. Nothing outside the selection moves.

Home | cascaded speed loop Edit → Reduce
AS DRAWN REDUCE → PARALLEL · the PI's two branches REDUCE → SERIES · controller + actuator REDUCE → FEEDBACK LOOP · the inner unity loop REDUCE → SERIES · everything on the forward path REDUCE → FEEDBACK LOOP · one State Space block Reference Output Σ Sensor Kp Integral Σ Actuator Σ Plant State SpacePI State SpacePI · actuator State Spaceinner loop State SpacePI · actuator · inner loop State Spacethe closed loop
1Parallel2Series 3Unity feedback4Series 5Feedback
Reductions5
Undo steps5 · one each
vs the hand-derived loop5e-16

The same five reductions were run in the app straight after loading the model, with no simulation run first. The final block's transfer function matches the closed loop derived by hand to within 5e-16.

03 · Four shapes, one menu

Select the shape. Reduce does the algebra.

Edit → Reduce, or the same submenu on the canvas' right-click menu, has three entries: Series, Parallel and Feedback Loop. Between them they cover four shapes. Each one replaces the selection with a State Space block whose realization is the exact combination of the blocks it replaced.

Series

One after the other

select 2 blocks

Two blocks connected output to input become one realization.

A = [A1 0 ; B2·C1 A2] B = [B1 ; B2·D1] C = [D2·C1 C2] D = D2·D1
Parallel

Same input, summed

2 blocks + the Sum

Two blocks fed from one signal, with their outputs combined by a Sum or Subtract block. Each branch's sign is read from the input port it lands on.

A = [A1 0 ; 0 A2] B = [B1 ; B2] C = [±C1 ±C2] D = ±D1 ± D2
Feedback Loop

Forward and return

Sum + plant + feedback

A forward block and a feedback block around a summing junction. The two feedthrough terms are resolved in closed form.

e = k·(r + D2·C1·x1 + C2·x2) k = 1 / (1 − D1·D2)
Unity feedback

No block on the return

Sum + plant

The loop closes straight from the output. The signs of both inputs are read from the junction, so a positive-feedback loop reduces as correctly as a negative one.

e = k·(s_r·r + s_f·C1·x1) k = 1 / (1 − s_f·D1)

A reduced model is one set of state equations instead of an interconnection you have to trace, and it deploys as one discretized loop. Blocks in the library are written with this in mind. A block that can't honestly present a linear form doesn't claim one, because a made-up linear form is worse than none when a reduction is going to consume it.

04 · The hard part

An algebraic loop is solved exactly, or refused.

If both blocks in a feedback loop have direct feedthrough, the loop is algebraic: at each instant the output depends on itself. The reduction solves it in closed form, which is possible exactly when this term can be inverted:

1 − DG·DH ≠ 0

If it is numerically zero (smaller than 1e-9 in magnitude), the loop has no unique solution. The reduction fails and leaves your diagram alone. It will never build a realization that runs and gives wrong answers, which is the failure this feature exists to avoid.

! Feedback Reduction
Refused · diagram unchangedThe closed loop cannot be reduced: the feedthrough terms in the loop create an unresolvable algebraic loop.
What you see when 1 − DG·DH is singular. The diagram isn't touched, and the refusal doesn't use up an undo step, so your next Undo still reverts your last real edit.
✓ Feedback Reduction
Merged · one undo stepMerged the feedback loop into a single State Space block.
Every block that the loop's output fed is reconnected to the new block, not just the first one.
05 · Safe on a real model

It edits your diagram, so it behaves like an edit.

  • One undo stepEach reduction is one step. Undo restores exactly the diagram you had, Redo returns the reduced one, and a save stores the reduced diagram, never a half-finished mix of old and new blocks.
  • Current valuesEach block is re-read from its configuration at the moment you reduce. The result reflects what the block's dialog says now, not what a past run left behind, even if the model hasn't been simulated since you edited it.
  • SignsA Subtract block's two inputs aren't symmetric. The sign each branch, reference or feedback signal enters with is read from the port it lands on.
  • WiringThe links into and out of the selection are moved onto the new block and keep the routes you drew. An output that fanned out to several blocks still reaches all of them. Nothing else on the level moves.
  • Never mid-runReduce refuses while a simulation is running, because the running solver owns the blocks, and while code export is writing the model out. A block whose configuration doesn't load is refused too, instead of being merged from stale values.
Honest edges

What it will not reduce, and why.

Every refusal comes with a notification naming the reason. The diagram is left as it was.

  • SISO onlyEach block must have exactly one input and one output, with a scalar state space. Vector and multi-port blocks aren't merged.
  • Continuous, linearA block has to publish a valid continuous state space. A block with a nonzero nonlinear feedthrough term is refused rather than linearized behind your back.
  • The shape must be exactFor example, in a parallel pair the shared source must drive only the two selected blocks, and each block's output must drive only the Sum. A signal that also leaves the selection would be lost, so the reduction is refused.
  • Two-input junctionsThe Sum or Subtract block in a parallel pair or a loop must have exactly two inputs. A three-way sum is refused, not split up for you.
  • Starts at restThe new State Space block's initial state is zero. Initial conditions set on the blocks it replaced aren't carried over, so a model that relies on them needs them set again on the reduced block.
  • Exact, not minimalThe reduced block has as many states as the blocks it replaced, plus one zero state for each Gain it absorbs. Reduce merges. It doesn't cancel poles against zeros or drop states.
  • Fixed gainsA gain merged into the matrices is no longer a separate parameter of the exported core, so it can't be retuned after export. Leave a gain you want to tune outside the selection.
  • Deployed loopsThe accuracy gain applies when the closed loop itself is what gets deployed, such as a plant model for hardware in the loop, or an observer. A controller that will close its loop through a physical plant can't be merged with that plant.
  • In-app runsUnder the default Joint coupling, the simulation already advances every continuous state together, so a reduction changes its trajectory only by rounding, at most 2.8e-16 in the regression suite. The gain is in the exported code, and under the Discrete solver or Per-block coupling. Under Tustin or Euler the reduced loop is still an approximation, just one without the error between blocks.
  • Singular loopsIf |1 − DG·DH| is below 1e-9, the loop has no unique solution. It is refused, not approximated.

Where to find it

  • Menu barEdit → Reduce → Series · Parallel · Feedback Loop
  • CanvasRight-click the selection → Reduce
  • C++ SDKICoreAPIs::reduceSeriesSelection · reduceParallelSelection · reduceFeedbackSelection - API reference
  • The resultThe State Space block, which you can open, inspect and export like any other block.

See also: Global solvers, per-rate subsystems  ·  Code export

Get started

See it run on your own model.

Download the application from the customer portal, or read the documentation first - the manual, a page for every block, and the full command reference are public.