Path: Math/Analysis
% Uses the simplex method to minimize the cost when solving the problem au = b and the cost is cu. Constraints should be stacked in the following order: hard, soft equality, soft inequality. Type Simplex for a demo. -------------------------------------------------------------------------- Form: [u, f, rc] = Simplex( c, a, b, maxValue, maxIter, slack, relax, nhardcon, nsofteq ) -------------------------------------------------------------------------- ------ Inputs ------ c (1,n) Cost vector a (m,n) Constraint matrix b (m,1) Right-hand-side maxValue (1,1) Maximum constraint on u maxIter (1,1) Maximum number of iterations slack (1,1) Optional. Set to 1 for a*u <= b Set to 0 for a*u = b (default) relax (1,1) Optional. Set to 1 to relax infeasible constraint Set to 0 for hard constraints (dflt) nhardcon (1,1) Number of hard constraints (used if relax = 1) nsofteq (1,1) Number of soft equality constraints (if relax=1) ------- Outputs ------- u (n,1) Solution f (1,1) Feasible solution = 1, No feasible solution = 0 rc (:,l) Vector denoting which constraints were relaxed --------------------------------------------------------------------------
Common: General/DispWithTitle Math: Analysis/Simplex2 Math: Linear/InvP Math: Linear/Mag
Back to the Math Module page