Anatomy of a linprog call
Standard form: linprog always solves the same shape of problem - minimize \(c^\top x\) - subject to \(A_{ub}\, x \le b_{ub}\), then \(A_{eq}\, x = b_{eq}\), and \(l \le x \le u\)
Inputs (each is a plain list or NumPy array) - \(c\): 1-D cost vector, length = number of variables - \(A_{ub}\), \(b_{ub}\): matrix and vector for the inequality (\(\le\)) constraints - \(A_{eq}\), \(b_{eq}\): matrix and vector for the equality (\(=\)) constraints - bounds: a list of \((\text{low}, \text{high})\) pairs, one per variable (default \((0, \infty)\)) - method: the solver to use, default "highs"
Output: a single OptimizeResult object - .x: the optimal solution vector (the variable values) - .fun: the optimal objective value \(c^\top x\) - .success: True if an optimum was found - .status, .message: why it stopped (0 = solved, 2 = infeasible, 3 = unbounded) - .slack, .con: leftover room in the inequality and equality constraints
Key idea: everything is just vectors and matrices - variable \(j\) is column \(j\) in every matrix, so all arrays must line up - this uniform layout is what makes an LP fast to solve and easy to build programmatically