Generated reference › Second Order Cone Program — Control Systems/Optimization
kind: generated#block#control-systems-optimization

Second Order Cone Program — Control Systems/Optimization

min f'x

Control_Systems/Optimization/Second_Order_Cone_Program · 2 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.

Second-Order Cone Program

Control Systems / Optimization

Solves minx f'·x subject to K second-order cone constraints ‖Ak·x − bk‖ ≤ dk'·x − γk, together with A·x ≤ b, Aeq·x = beq and lb ≤ x ≤ ub, on every step – MATLAB's coneprog. Cone constraints are what robust linear programs, norm and distance limits, friction cones and many model-predictive-control constraints come to. The cones and the other constraint matrices are settings; the linear term f and the inequality right-hand side b arrive on ports. The method is a primal-dual interior point on the homogeneous self-dual embedding, with Nesterov-Todd scaling and Mehrotra's predictor-corrector, so an infeasible or unbounded problem is recognized and flagged rather than iterated on forever.

Ports

  • f – the linear term, an [n,1] column with one entry per variable.
  • b – the right-hand side of A·x ≤ b, a [p,1] column with one entry per row of A. When A is empty this port is unused and must be connected to any [1,1] signal.
  • x – the minimizer, [n,1].
  • fval – the objective at x, f'·x, [1,1].
  • exitflag – [1,1], with coneprog's values: 1 optimal, 0 the iteration limit was reached, −2 no feasible point exists, −3 the problem is unbounded, −7 the step became too small to continue, −10 the problem is numerically unstable. Read it before using x.

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.
  • Inequality Matrix A – [p,n], or [] for none. Its right-hand side is the b port.
  • Equality Matrix Aeq, Equality Vector beq – [q,n] and [q,1], or [] for none. The rows of Aeq must be linearly independent.
  • Lower Bounds lb, Upper Bounds ub – [n,1] each or []; -Inf/Inf entries leave a variable unbounded on that side.
  • Cone Row Counts – one entry per cone, the number of rows of its Ak: [2 3] is two cones, of 2 and 3 rows. [] for no cone (a linear program).
  • Cone Matrices – the Ak stacked on top of each other, [Σ rows, n].
  • Cone Vectors – the bk stacked the same way, one column.
  • Cone Directions d – one row dk' per cone, [K,n].
  • Cone Offsets gamma – one γk per cone, [K,1].
  • Optimality Tolerance – the duality gap to stop at, absolute or relative to |f'·x|. Default 1e-6, coneprog's own.
  • Constraint Tolerance – the scaled primal and dual residuals to stop at, and the certificate threshold for infeasibility. Default 1e-6.
  • Maximum Iterations – default 200, coneprog's; each iteration factors one small matrix.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

At most 12 variables, 8 cones, 11 equalities, and 60 rows from A, the finite bounds and the cones together (a cone of r rows counts r + 1).

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The block's simulation runs the very program that is printed, so every target does the same arithmetic in the same order. The whole solve runs in every generated body; its loop is Maximum Iterations long and exits early through a flag.

The three HDL targets carry the arithmetic in real and quantize only at the ports: simulation-only, not offered as synthesizable.

Simulink bridge

None (Support::None). coneprog is an Optimization Toolbox function and that toolbox ships no Simulink library at all, so there is no path a diagram could name. The bridge reports this block rather than dropping it silently, and it has no parity testbench; code export verification covers all ten languages.

Notes

  • Algebraic: the answer depends on this step's f and b alone, and nothing is carried between steps. It is not linear in f and b, so it carries no state space.
  • ⚠ This is not coneprog's own algorithm, whose code is sealed: it is an independent interior point that finds the same optimum. At the default tolerances the two agree on every exit flag of the 160 problems measured and on f'·x to about the tolerance; x can differ more where the optimum lies on a cone's curved boundary and the objective is flat along it. Tighten both tolerances for a closer x.
  • ⚠ An exit flag other than 1 leaves x defined but not optimal: it is the last iterate (scaled back by the embedding's τ), where MATLAB returns an empty x.
  • Each finite bound becomes one more constraint row; lb = ub fixes a variable exactly as an equality would.

Code facts#

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

Ports#

#DirectionSignal typeDescription label
1inICoreDoublef
2inICoreDoubleb
3outICoreDoublex
4outICoreDoublefval
5outICoreDoubleexitflag

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
Inequality Matrix A[1 1 1]—
Equality Matrix Aeq[]—
Equality Vector beq[]—
Lower Bounds lb[]—
Upper Bounds ub[]—
Cone Row Counts3—
Cone Matrices[1 0 0; 0 1 0; 0 0 1]—
Cone Vectors[0; 0; 0]—
Cone Directions d[0 0 0]—
Cone Offsets gamma-1—
Optimality Tolerance1e-6—
Constraint Tolerance1e-6—
Maximum Iterations200—
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): coneprog is an Optimization Toolbox function and that toolbox ships no Simulink library, so there is no path a diagram could name; the block is reported rather than dropped when a model crosses

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

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 no sample under docs/generated/samples/ — nothing to cross-check (P8.1)

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).

Second-Order Cone Program -- MATLAB's coneprog, on every step minimize f'x subject to ||A_k x - b_k|| <= d_k'x - gamma_k, A x <= b, Aeq x = beq, lb <= x <= ub

coneprog's engine is sealed (optim.coneprog.interiorPointMethod.p), so the solver is an independent homogeneous self-dual interior point with Nesterov-Todd scaling (ICoreConeProgramSupport), written once as statements: the live run interprets exactly the program the ten exports print.

Measured against R2026a's coneprog on 160 random problems (1 to 6 variables, 0 to 3 cones of 1 to 4 rows, 0 to 3 inequality rows, 0 to 2 equalities, bounds with infinite entries; 120 built feasible, 20 infeasible, 20 unbounded):

at coneprog's DEFAULT tolerances (1e-6) every exit flag equal, 160 / 160 (113 optimal, 20 infeasible, 27 unbounded); f'x within 1.6e-5 at 1e-8 both 152 / 160 flags equal -- the other 8 are coneprog stopping with -7 where this solver converges; f'x within 2.1e-7, x median 3.4e-9 at 1e-10 both x median 6e-11 where both converge (coneprog returns -7 on 60 of the 160 there)

x itself moves more than f'x near a flat optimum on a cone's curved boundary (an objective error e allows an x error near sqrt(e)), which is the whole of the default-tolerance spread. The emitted Python is bit-identical to the live run on all 160.

Support::None: coneprog is an Optimization Toolbox function and that toolbox ships no Simulink library, so there is no path a diagram could name.

Sample results#

No sample run is committed for this block. Samples come from the headless harness (DOCS_PLAN.md P8.1) into docs/generated/samples/; until one exists this block's behaviour is witnessed by the parity and export-verification suites, not by a plot here.