Qu

linprog

Builtin index · Signal processing

result = linprog(c, A, b, [Aeq=], [beq=], [lb=], [ub=], [max_iter=])

Input: c, A, b, Aeq, beq, lb, ub, max_iter · Output: result

What it is

Linear programming: minimises c'x subject to A x <= b, Aeq x = beq and lb <= x <= ub. c: a length-N vector; A: a matrix with N columns (one row per inequality; a plain vector of length N is one row) and b the matching vector, both given or both omitted (pass [] to skip them when you only use Aeq); Aeq/beq: the equalities, same shape rules; lb/ub: a length-N vector or one number for all variables. Bounds default to lb = -Inf, ub = +Inf (MATLAB's convention, so a variable is free unless bounded): the textbook standard form x >= 0 needs lb=0. Aeq, beq, lb and ub can be keywords or, in MATLAB's order, positional arguments 4 to 7. Method: two-phase simplex on a dense tableau (free variables split, finite bounds substituted, inequalities given slacks); Dantzig's pivot rule, switching to Bland's smallest-index rule whenever the objective has stalled, so degenerate vertices cannot cycle (Beale's classic cycling example solves). Made for small and medium problems (hundreds of variables), not for large sparse LPs.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = linprog(c, A, b, [Aeq=], [beq=], [lb=], [ub=], [max_iter=])
c vectorc: a length-N vector.
A matrixA: a matrix with N columns (one row per inequality.
b —Linear programming: minimises c'x subject to A x <= b, Aeq x = beq and lb <= x <= ub.
Aeq optionalAeq/beq: the equalities, same shape rules.
beq optionalLinear programming: minimises c'x subject to A x <= b, Aeq x = beq and lb <= x <= ub.
lb vector or number, optionallb/ub: a length-N vector or one number for all variables.
ub optionalLinear programming: minimises c'x subject to A x <= b, Aeq x = beq and lb <= x <= ub.
max_iter optionalstatus is "optimal", "infeasible" (x is all NaN, fval NaN), "unbounded" (x all NaN, fval = -Inf) or "iteration_limit" (max_iter pivots, default 20000 + 100*(N + rows), were not enough.
Model —kind "linprog"
x —the minimiser
fval —c'x
iterations numberthe number of pivots
Returns a Model (kind "linprog") with x (the minimiser), fval (c'x), status and iterations (the number of pivots). status is "optimal", "infeasible" (x is all NaN, fval NaN), "unbounded" (x all NaN, fval = -Inf) or "iteration_limit" (max_iter pivots, default 20000 + 100*(N + rows), were not enough; x is all NaN). Infeasible and unbounded problems are results, not errors. Errors (all name the offending argument): a column count that does not match c, A without b or Aeq without beq, mismatched row counts, NaN or Inf in c, A, b, Aeq or beq, a NaN bound, and an option given both positionally and as a keyword.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.