Linear programming problems are solved by defining what you want to optimize, writing it as a mathematical model, and then using a method (graphical, algorithmic, or software-based) to find the best solution. The core idea is straightforward: you have a goal, you have limits, and you need to find the combination of choices that gives you the best outcome within those limits. Whether you’re working through a textbook exercise or tackling a real business problem, the process follows the same logical steps.
What a Linear Programming Problem Looks Like
Every linear programming problem has three components. First, there are decision variables: the unknowns you’re trying to determine. These represent “how much” of something, like how many units to produce, how many hours to schedule, or how much to invest in each asset.
Second, there’s an objective function: a formula that calculates the thing you’re trying to maximize or minimize. It might be total profit, total cost, total distance, or total time. The key requirement is that this formula is linear, meaning each decision variable is multiplied by a constant and added together. No exponents, no variables multiplied by each other.
Third, there are constraints: inequalities or equations that describe your limits. You can’t spend more money than your budget allows. You can’t use more machine hours than are available. You must produce at least enough to fill existing orders. Each constraint is also a linear expression. Finally, most problems include non-negativity constraints, which simply state that your decision variables can’t be negative (you can’t produce negative five chairs).
Step 1: Formulate the Problem
Formulation is where most of the thinking happens. Before any math, you need to translate a real situation into a clean mathematical model. Here’s how to work through it.
Identify the decision variables. Ask yourself: what am I deciding? If the problem says a company makes tables and chairs, your variables might be T (number of tables) and C (number of chairs). Label them clearly.
Write the objective function. Determine whether you’re maximizing or minimizing, and build a formula from your variables. If each table earns $40 profit and each chair earns $30, your objective function is: Maximize Z = 40T + 30C. Don’t use an equals sign with the objective itself; it’s an expression to optimize, not an equation to solve.
Write the constraints. Look for phrases like “at least,” “no more than,” “cannot exceed,” or “must meet demand for.” Each one becomes an inequality. If a table requires 2 hours of labor and a chair requires 1 hour, and you have 12 hours available, that constraint is 2T + 1C ≤ 12. Go through every resource limit, minimum requirement, and ratio restriction in the problem.
Add non-negativity constraints. Write T ≥ 0 and C ≥ 0. This step is easy to forget, but it matters for solving the problem correctly.
Step 2: Solve With the Graphical Method
When your problem has two decision variables, you can solve it by graphing. This method is limited to two dimensions, so it won’t work for larger problems, but it builds strong intuition for how linear programming works.
Start by plotting each constraint as a line on a coordinate plane, with one decision variable on each axis. For an inequality like 2T + C ≤ 12, draw the line 2T + C = 12, then shade the side that satisfies the inequality. Do this for every constraint, including the non-negativity constraints (which simply restrict you to the first quadrant). The region where all the shaded areas overlap is the feasible region: the set of all possible solutions that satisfy every constraint simultaneously.
The optimal solution always occurs at a corner point of this feasible region. This is a fundamental property of linear programming. So you identify every corner point, plug each one into the objective function, and the corner that gives the highest value (for maximization) or lowest value (for minimization) is your answer.
For example, if the corner points of your feasible region are (0, 0), (6, 0), (4, 4), and (0, 10), you’d calculate Z at each: Z(0,0) = 0, Z(6,0) = 240, Z(4,4) = 280, Z(0,10) = 300. The optimal solution is (0, 10) with Z = 300.
Step 3: Solve Larger Problems With the Simplex Method
Real problems often have dozens or hundreds of variables, making graphing impossible. The simplex method, developed in the 1940s, is the classic algorithm for these situations. It’s efficient because it doesn’t check every possible corner point. Instead, it starts at one corner of the feasible region and moves systematically to adjacent corners, improving the objective function at each step, until no further improvement is possible.
To set up the simplex method, you first convert each inequality constraint into an equation by adding a slack variable. A slack variable represents unused capacity. If your constraint is T + C ≤ 12, you add a variable s₁ to get T + C + s₁ = 12. The variable s₁ equals however much of that 12-unit capacity you’re not using.
Next, you arrange everything into a table called a simplex tableau. Each constraint gets its own row, and the objective function goes in the bottom row (rewritten so all terms are on one side). The columns represent each decision variable, each slack variable, and the right-hand side values.
From there, the algorithm follows a repeating cycle. You look at the bottom row to find the most negative entry, which identifies the “pivot column,” the variable that will improve the objective the most. Then you calculate ratios to determine the “pivot row,” which tells you which constraint is the tightest. You perform row operations (similar to those in basic linear algebra) to pivot on that element, updating the tableau. You repeat this process until no negative entries remain in the bottom row. At that point, the optimal solution can be read directly from the tableau: the value in the bottom-right corner is the optimal objective value.
The simplex method sounds complex on paper, but it’s mechanical. Once you’ve set up the tableau correctly, each iteration follows the same rules. Most students find that working through two or three full examples by hand is enough to internalize the process.
Using Excel Solver
For practical use, you rarely need to solve by hand. Microsoft Excel includes a Solver add-in that handles linear programming directly. If it’s not visible under your menu, you can enable it through the Add-Ins settings.
To set up a model in Excel, create a spreadsheet where each column represents a decision variable. Put the objective function coefficients in one row and the constraint coefficients in rows below. Use a separate column for the right-hand side values of each constraint. In an adjacent cell, use the SUMPRODUCT function to calculate the objective function value: it multiplies each decision variable’s current value by its coefficient and sums the results. Create similar SUMPRODUCT formulas for each constraint row.
Then open Solver, set your objective cell (the SUMPRODUCT formula for the objective), choose Max or Min, point it to the cells holding your decision variable values, and add each constraint. Select “Simplex LP” as the solving method, and click Solve. Excel fills in the optimal values for each decision variable and displays the objective function result. For beginners, starting with problems that have fewer than five variables and five constraints is a good way to verify your setup against hand calculations.
Using Python
Python’s SciPy library provides a function called linprog that solves linear programs in a few lines of code. It minimizes by default, so if you need to maximize, you multiply your objective coefficients by -1.
The function takes your objective coefficients as a list, your inequality constraint coefficients as a matrix, and the right-hand side of those constraints as another list. You can also pass equality constraints and variable bounds. By default, all variables are assumed to be non-negative (bounded at zero from below with no upper limit), which matches most standard formulations. The default solving algorithm is HiGHS, a modern high-performance solver.
A simple example: to minimize 5x₁ + 4x₂ subject to x₁ + x₂ ≥ 8 and 2x₁ + x₂ ≥ 10, you’d flip the inequalities (since linprog expects ≤ form) by multiplying by -1, then call the function with those arrays. The result object contains the optimal variable values and the minimum objective value.
Understanding the Dual and Shadow Prices
Every linear programming problem (called the “primal”) has a companion problem called the “dual.” If the primal maximizes profit subject to resource constraints, the dual minimizes the total value of those resources. The two problems always share the same optimal objective value.
The practical payoff is shadow prices. Each constraint in your model has a shadow price, which tells you how much your objective function would improve if you had one more unit of that resource. If your labor constraint has a shadow price of $15, that means one additional hour of labor would increase your profit by $15. This is the maximum price at which buying extra labor would be worthwhile, and the minimum price at which selling some of your labor capacity would make sense. Shadow prices are reported automatically by most solvers, including Excel Solver’s sensitivity report, and they’re often more valuable to decision-makers than the optimal solution itself.
Where Linear Programming Gets Used
Linear programming shows up anywhere resources are limited and decisions can be expressed as quantities. Supply chain teams use it to decide how much product to ship from each warehouse to each store, minimizing transportation costs while meeting demand at every location. Financial analysts use it to build investment portfolios that maximize expected returns within risk limits. Airlines use it to assign crews to flights while respecting labor regulations and minimizing staffing costs.
Even small businesses benefit. A recent study of a jewelry manufacturer in Peru used linear programming to determine the optimal product mix across different types of rings, chains, pendants, bracelets, and earrings. The model factored in raw material availability, production capacity, and market demand, then identified which products to focus on to minimize operating costs. The approach applies the same way to any company choosing how to allocate limited resources across multiple products or activities.