The graphical method only works for 2 (or 3) decision variables. An algebraic method is needed beyond that, and it starts by rewriting the linear program in a fixed form.
Given an LP in n variables and m constraints, with x∈Rn, c∈Rn, A∈Rm×n, b∈Rm, standard form requires:
Maximization
Replace mincTx by max(−cTx).
Equality constraints
Convert every inequality with a slack, surplus, or artificial variable, and scale each row so b≥0.
Non-negative variables x≥0.
maximizes.t.z=cTxAx=bx≥0,b≥0
where n counts the original variables plus the added ones.
Variable
Assume A has full row rank m with n≥m. Pick m linearly independent columns forming an invertible basis matrix B∈Rm×m; the remaining columns form N. Partition x=(xB,xN) accordingly.
Basic Variable
A component of xB. Setting xN=0 gives xB=B−1b. The solution is a basic feasible solution when B−1b≥0.
Non-Basic Variable
A component of xN, fixed at 0 while xB is solved for.
Slack Variable
For a constraint aiTx≤bi, add si≥0 to get aiTx+si=bi. Absorbs unused capacity.
Surplus Variable
For a constraint aiTx≥bi, subtract si≥0 to get aiTx−si=bi. Absorbs excess over the minimum.
Artificial Variable
A variable ai≥0 added to row i with coefficient +1 purely to supply a starting basic variable, with no meaning in the original problem.
When It Is Required
After the RHS of every constraint is made non-negative (multiply the row by −1 if needed), each constraint must contribute one variable that appears with coefficient +1 in that row and 0 in all others (a unit column). That variable becomes basic in the starting solution.
≤ constraint
The slack variable is already such a unit column. No artificial variable.
≥ constraint
The surplus variable has coefficient −1, not a unit column. Add an artificial variable.
= constraint
No slack or surplus at all. Add an artificial variable.
So the number of artificial variables equals the number of ≥ constraints plus the number of = constraints (after fixing signs).
Handling Them
A valid final solution must have every artificial variable equal to 0 (non-basic, or basic at value 0). If one stays positive, the original problem is infeasible. 2 methods drive them out: