Generated reference › Scalar Bounded Minimization — Control Systems/Optimization
kind: generated#block#control-systems-optimization

Scalar Bounded Minimization — Control Systems/Optimization

Control_Systems/Optimization/Scalar_Bounded_Minimization · 1 input / 3 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Scalar Bounded Minimization

Control Systems / Optimization

Finds the x that minimizes p(x) over an interval, for a polynomial whose coefficients arrive on a port – MATLAB's fminbnd(@(z) polyval(c, z), x1, x2), solved again on every sample:

p(x) = c₀·xL−1 + c₁·xL−2 + … + cL−1, minimized over x1 ≤ x ≤ x2.

The iteration is Brent's: a golden-section step, replaced by a parabolic interpolation step whenever a parabola through the three best points is trustworthy. It is fminbnd's own, so the answer is the same double MATLAB reports.

Ports

  • c – the polynomial's coefficients in descending powers, a column [L,1] with L from 1 to 64 – the shape Polynomial Fit emits and Evaluate Fit reads, so a curve fitted every sample can be minimized every sample. A row is refused, because the block reads the column entry by entry.
  • x – the minimizer, a scalar [1,1], always inside [x1, x2].
  • f(x) – the value of the polynomial there, a scalar [1,1]: the minimum itself.
  • exitflag – a scalar [1,1]: 1 when the interval of uncertainty shrank inside the tolerance, 0 when a limit below stopped the search first. fminbnd's own two flags for this case.

Parameters

  • Options – empty (default), or the path of a Solver Options block (Home/Solver Options), MATLAB’s options argument: for the run, every option it sets replaces this block’s parameter of the same name; one it leaves at default, or one this block does not have, changes nothing.
  • Lower Bound – x1, fminbnd's second argument.
  • Upper Bound – x2. It must not be below x1: that is the one case fminbnd answers with exit flag −2 and NO point at all, and a block has to put a number on every port, so an inverted pair is refused as a configuration error before the run instead. x1 = x2 is allowed and answers that point.
  • X Tolerance – optimset's TolX, positive. The default is fminbnd's own 1e-4, which is coarse on purpose: the search stops when the bracket is that wide, so x is accurate to about it and no further.
  • Maximum Iterations – optimset's MaxIter, default 500, 1 to 10000.
  • Maximum Function Evaluations – optimset's MaxFunEvals, default 500. The search evaluates once before the loop and once per pass, so whichever of the two limits binds first stops it and the exit flag is 0; with both at 500 that is 499 passes.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text, printed from one description of the iteration, so every target does the same arithmetic in the same order as the simulation. The interval, the tolerance and the two limits are baked in at export time; the coefficients are a signal, so nothing about the polynomial is.

The loop is emitted with a fixed trip count – the resolved limit, 499 at the defaults – and a flag that stops the arithmetic once the answer is found, because none of the ten has an unbounded loop a hardware target could also carry. A large limit therefore costs in every target whether or not the samples need it; the search itself rarely needs more than 30 passes.

The three HDL targets carry the iteration in real arithmetic and quantize only at the ports: simulation-only, not offered as synthesizable. A minimizer is found by comparing values that differ in their last digits near the bottom of the curve, which Q16.16's 1.5×10−5 cannot resolve.

Simulink bridge

None (Support::None). The Optimization Toolbox ships no Simulink library at all – measured, not assumed – so there is no block to map onto and no library path a diagram could name. fminbnd is a MATLAB function. The bridge reports this block rather than dropping it silently, and it therefore has no parity testbench; code export verification covers it across all ten languages.

Notes

  • The search is LOCAL, and that is not a caveat about this block but about fminbnd. On a curve with two dips inside the interval it returns the one its sequence of points lands in, which need not be the deeper. Narrow the interval around the dip you mean, or evaluate several intervals with several blocks and pick with a MinMax.
  • x is accurate to about X Tolerance, f(x) to far better than that – near a minimum the curve is flat, so an x that is 1e-4 out gives an f that is ~1e-8 out. Read f(x) when what you need is the value, not the place.
  • Algebraic and stateless: the whole search happens inside one sample and nothing is carried to the next.
  • Cost is bounded and not constant: between 1 and the resolved limit polynomial evaluations per sample, each L − 1 multiply-adds.
  • Verified against R2026a bit for bit – x, f(x), the exit flag and the iteration count over 1500 random polynomials and intervals, and the stopped point over 8941 runs cut short by the two limits. The source banner carries the measurement.
  • No state space. The relation is nonlinear in the coefficients, so the block carries none and model reduction correctly reports it as unmergeable.

Code facts#

FactValue
registered typeControl_Systems/Optimization/Scalar_Bounded_Minimization
familyControl_Systems/Optimization
solver environment classICoreBlock_0_Control_Systems_1_Optimization_2_Scalar_Bounded_Minimization
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Optimization/Scalar_Bounded_Minimization/ICoreBlock_0_Control_Systems_1_Optimization_2_Scalar_Bounded_Minimization.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Optimization/Scalar_Bounded_Minimization/ICoreBlock_0_Control_Systems_1_Optimization_2_Scalar_Bounded_Minimization.h
default size on canvas170 × 90 px
ports at insert1 in, 3 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublec
2outICoreDoublex
3outICoreDoublef(x)
4outICoreDoubleexitflag

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Lower Bound-1—
Upper Bound1—
X Tolerance1e-4—
Maximum Iterations500—
Maximum Function Evaluations500—
Options——

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): the Optimization Toolbox ships no Simulink library at all, so there is no block to map onto and no library path a diagram could name; fminbnd is a MATLAB function. The block is reported rather than dropped when a model crosses

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Scalar Bounded Minimization -- fminbnd over a polynomial whose coefficients arrive on a wire p(x) = c0*x^(L-1) + c1*x^(L-2) + ... + c(L-1) c is the input signal, descending [x, fval, exitflag] = fminbnd(@(z) polyval(c, z), x1, x2)

The interval, the tolerance and the two limits are configuration; the function is the signal. The iteration -- golden section with parabolic interpolation -- is fminbnd.m's, transcribed in ICoreScalarSolverSupport and used by the live run and all ten exports alike.

Measured against R2026a: over 1500 random polynomials (degree 1 to 8) and random intervals the reference reproduces fminbnd's x, fval, exit flag and iteration count BIT FOR BIT; over 8941 further solves stopped early by MaxIter or MaxFunEvals (every prefix of every one of 400 runs) it reproduces the stopped point and the exit flag bit for bit; and over 400 solves at tolerances from 1e-1 to 1e-9, likewise.

The three HDL targets carry the iteration in real: SIMULATION-ONLY, quantized at the ports.

Sample results#

Scalar Bounded Minimization — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleScalar Bounded Minimization — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-202012345t (s)in ICoreDouble-Out-0out ICoreDouble-Out-0out ICoreDouble-Out-1out ICoreDouble-Out-2
tin ICoreDouble-Out-0out ICoreDouble-Out-0out ICoreDouble-Out-1out ICoreDouble-Out-2
0-21-21
0.40.510.51
0.8-21-21
1.20.510.51
1.6-21-21
20.510.51
2.4-21-21
2.80.510.51
3.2-21-21
3.60.510.51
4-21-21
4.40.510.51
4.8-21-21
5.20.510.51

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)1 … 1
rampRamp: slope 1 from t = 01 … 1
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias1 … 1
stepStep: 0 -> 1 at t = 1 s1 … 1

Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample

Category static · sample time 0.1 · 60 steps · commit 6b0471a23bd6163d7d7f33f764df08a614c2b6b8 · produced by docsSample --out <folder> --blocks Scalar_Root_Find Scalar_Bounded_Minimization Order_Waveform Order_Track RPM_Frequency_Map RPM_Order_Map --steps 60 · data docs/generated/samples/Control_Systems__Optimization__Scalar_Bounded_Minimization.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).