Mixed Integer Linear Program — Control Systems/Optimization
Control_Systems/Optimization/Mixed_Integer_Linear_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.
Mixed-Integer Linear Program
Control Systems / Optimization
Solves minx f'·x subject to A·x ≤ b,
Aeq·x = beq and lb ≤ x ≤ ub, with the variables listed in Integer
Variables restricted to whole numbers, on every step – MATLAB's
intlinprog. Integer variables are how on/off decisions, counts and discrete choices
enter an optimization: unit commitment, scheduling, a hybrid controller's mode. The constraint
matrices and bounds are settings; the linear term f and the inequality right-hand side
b arrive on ports. The method is branch and bound: each node solves the linear
relaxation with an interior point, branches on the most fractional integer variable, and prunes a
node that cannot beat the best whole-number point found.
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], its integer entries exact whole numbers.
- fval – the objective at x, f'·x, [1,1].
- exitflag – [1,1], with
intlinprog's values: 1 optimal within the gap tolerances, 2 stopped early (node limit) with a whole-number point, 0 stopped early without one, −2 no feasible point exists, −3 the linear relaxation is unbounded. 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 atdefault, or one this block does not have, changes nothing. - Integer Variables – the indices of the integer variables, 1-based as in
intlinprog'sintcon: [1 3] makes x1 and x3 whole numbers. At least one; each needs finite lower and upper bounds, at most 1e6 apart. - 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 are allowed on continuous variables only.
- Maximum Nodes – the cap on branch-and-bound nodes per step, 1 to 2000; default 1000. Every node is one linear solve, so this bounds the step's cost.
- Integer Tolerance – how far from a whole number a value may be and still count
as one. Default 1e-5,
intlinprog's. - Absolute Gap Tolerance, Relative Gap Tolerance – a node is pruned unless
it can beat the best point by more than max(absolute, relative·|best|). Defaults 0
and 1e-4,
intlinprog's; set both to 0 for the exact optimum. - Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
At most 12 variables, 12 of them integer, and 60 rows from A, the finite continuous bounds and two rows per integer variable together.
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 search runs in every generated body; its node loop is Maximum Nodes 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). intlinprog 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.
- ⚠ x jumps: a whole-number answer changes discontinuously as f and b move, so a target that sees slightly different inputs – the HDL targets' Q16.16 ports – can land on a different optimum when two tie.
- ⚠ This is not intlinprog's algorithm, whose code is sealed: where several points share the optimal value, the two can return different x with the same fval.
- ⚠ An exit flag other than 1 or 2 leaves x defined but not a solution: it is the last relaxation's point, where MATLAB returns an empty x.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Optimization/Mixed_Integer_Linear_Program |
| family | Control_Systems/Optimization |
| solver environment class | ICoreBlock_0_Control_Systems_1_Optimization_2_Mixed_Integer_Linear_Program |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Optimization/Mixed_Integer_Linear_Program/ICoreBlock_0_Control_Systems_1_Optimization_2_Mixed_Integer_Linear_Program.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Optimization/Mixed_Integer_Linear_Program/ICoreBlock_0_Control_Systems_1_Optimization_2_Mixed_Integer_Linear_Program.h |
| default size on canvas | 170 × 100 px |
| ports at insert | 2 in, 3 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | f |
| 2 | in | ICoreDouble | b |
| 3 | out | ICoreDouble | x |
| 4 | out | ICoreDouble | fval |
| 5 | out | ICoreDouble | exitflag |
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 variable | Default | Simulink parameter |
|---|---|---|
Integer Variables | [1 2] | — |
Inequality Matrix A | [2 1 -1; 1 3 -1] | — |
Equality Matrix Aeq | [] | — |
Equality Vector beq | [] | — |
Lower Bounds lb | [0; 0; 0] | — |
Upper Bounds ub | [4; 4; 5] | — |
Maximum Nodes | 1000 | — |
Integer Tolerance | 1e-5 | — |
Absolute Gap Tolerance | 0 | — |
Relative Gap Tolerance | 1e-4 | — |
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.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): intlinprog 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:
B0no 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).
Mixed-Integer Linear Program -- MATLAB's intlinprog, on every step minimize f'x subject to A x <= b, Aeq x = beq, lb <= x <= ub, x_j integer (j in intcon)
intlinprog is HiGHS behind a sealed .p, so the solver is an independent depth-first branch and bound (ICoreMilpSupport) whose node LPs are Second-Order Cone Program's interior point, written once as statements: the live run interprets exactly the program the ten exports print.
Measured against R2026a's intlinprog with RelativeGapTolerance and AbsoluteGapTolerance 0 on 210 random problems (2 to 8 variables, 1 to all of them integer, equalities, one-sided and free continuous variables; 150 general -- 20 of them infeasible by construction, and 15 whose relaxation is unbounded -- and 60 knapsack-like ones that branch up to 199 nodes):
every exit flag equal, 210 / 210 (175 optimal, 20 infeasible, 15 unbounded) f'x within 3.5e-8 relative where both are optimal, 79 of 175 to the last digit; the residue is the interior point's tolerance in the CONTINUOUS variables (the integer entries are snapped to exact integers)
and the emitted Python is bit-identical to the live run on all 210.
Support::None: intlinprog 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.