Math glossary

Linear Programming: Graphical Method, Constraints, and Examples

Solve two-variable linear programs using feasible vertices. Compare finite optima, integer constraints, ties, and infeasible or unbounded cases.

TL;DR

Linear programming maximises or minimises a linear objective subject to linear constraints. For a bounded two-variable feasible polygon, evaluate the objective at its vertices to find an optimum.

Key Points

  • Define the decision variables and what their units represent.
  • Write the quantity to optimise as a linear objective.
  • The feasible region contains points satisfying all constraints together.
  • Check the feasible vertices, including intersections of constraints and axes.
  • A continuous solution can be fractional. Whole-number decisions require an integer model.

What is a linear programming problem?

Choose values for the decision variables, such as the quantities of two products. A constraint limits their allowed combinations. An objective function measures what you want to maximise or minimise, such as output or cost. Both must be linear in the variables. A term like xyxy or x2x^2 would change the type of problem.

For example, suppose xx and yy use two limited resources. The constraints might be 2x+y≤122x+y\le12, x+2y≤12x+2y\le12, x≥0x\ge0, and y≥0y\ge0. The objective might be to maximise Z=3x+5yZ=3x+5y. All allowable solutions must satisfy the four inequalities at once. The inclusive inequality guide explains how to handle boundaries.

One common maximisation form is cTxc^{\mathsf T}x subject to Ax≤bAx\le b and x≥0x\ge0. Here the vector xx collects decisions, cc lists their objective coefficients, and each row of AA gives the amounts used in a constraint. The matching entry of bb is that constraint's limit. Inequalities between vectors are checked one row at a time.

How do you solve a two-variable linear program graphically?

  1. Convert each constraint temporarily to an equation and graph its boundary line.
  2. Use a test point to identify the half-plane that satisfies each inequality. Use a point off the line.
  3. Keep the intersection of the feasible half-planes.
  4. Find the vertices of that region by solving pairs of boundary equations or checking axis intersections. Verify each vertex against all inequalities.
  5. Evaluate the objective at every feasible vertex. Choose the largest or smallest value as requested.
A shaded polygon has vertices at zero zero, six zero, four four, and zero six, where two resource constraints meet
Only points in the shaded region satisfy both resource limits and the nonnegativity constraints.

For a bounded polygon, every feasible point is a weighted combination of vertices, with nonnegative weights adding to 1. A linear objective at that point is the same weighted combination of its values at the vertices. It cannot exceed the largest of those values or fall below the smallest. This explains the corner method used in OpenStax and the UNAM notes.

How do you distinguish infeasibility, unboundedness, and ties?

Situation Meaning What to check
Infeasible No point satisfies every constraint Check for inconsistent limits
Unbounded feasible region Some allowable values extend without limit The objective can still have a finite optimum
Unbounded maximum or minimum The objective can improve without limit Identify a feasible direction that improves it
Multiple optimal solutions Different feasible points have the same best value If two feasible points tie for the optimum, the segment between them ties too

Larger linear programs are usually solved with algorithms such as simplex or interior-point methods. The graphical method is especially suited to two variables. If the quantities must be whole numbers, a linear objective with integrality constraints is an integer linear program. Rounding a fractional solution can make a constraint fail.

Worked Linear Programming Examples

Example 1

Maximise Z=3x+5yZ=3x+5y with 2x+y≤122x+y\le12, x+2y≤12x+2y\le12, and x,y≥0x,y\ge0.

  1. The feasible axis intercepts are (6,0)(6,0) and (0,6)(0,6). Solving both resource boundaries gives (4,4)(4,4). The origin also satisfies the constraints.
  2. Evaluate ZZ at (0,0)(0,0), (6,0)(6,0), (4,4)(4,4), and (0,6)(0,6). The values are 0, 18, 32 and 30.
  3. The maximum is 32 at (4,4)(4,4).

Example 2

Minimise C=4x+3yC=4x+3y with x+y≥6x+y\ge6, x≥2x\ge2, and y≥1y\ge1.

  1. The boundary x+y=6x+y=6 meets x=2x=2 at (2,4)(2,4) and y=1y=1 at (5,1)(5,1).
  2. These give costs 20 and 23 respectively. Moving farther out with either coordinate increases cost when the other is fixed.
  3. For fixed xx, the least costly permissible yy is max(1,6−x)\max(1,6-x). Substitution shows cost rises as xx increases from 2, so the minimum is 20 at (2,4)(2,4).

Example 3

Use the feasible region from Example 1 to maximise Z=2x+yZ=2x+y.

  1. The resource limit 2x+y≤122x+y\le12 bounds ZZ above by 12.
  2. Both (6,0)(6,0) and (4,4)(4,4) are feasible and give 12.
  3. Every point on that segment is feasible and gives the same maximum. There are infinitely many optimal solutions.

Example 4

Find the maximum of x+yx+y if 3x+2y≤73x+2y\le7 and x,y≥0x,y\ge0. Then require both variables to be whole numbers.

  1. In the continuous model, 2(x+y)≤3x+2y≤72(x+y)\le3x+2y\le7. The point (0,3.5)(0,3.5) gives the maximum of 3.5.
  2. If both variables are integers, their sum is an integer, so it cannot exceed 3. The point (1,2)(1,2) is feasible and has sum 3.
  3. The integer maximum is 3. Rounding y=3.5y=3.5 up to 4 while keeping x=0x=0 would violate the capacity limit.

Example 5

Can x≥5x\ge5 and x≤3x\le3 hold together?

  1. Any value satisfying the first constraint is at least 5.
  2. Any value satisfying the second is at most 3.
  3. No xx meets both. The system is infeasible regardless of the objective.

Example 6

Maximise x+yx+y with only x≥0x\ge0 and y≥0y\ge0.

  1. Points (t,0)(t,0) are feasible for all t≥0t\ge0.
  2. At each such point the objective equals tt.
  3. It can increase without bound. There is no finite maximum.

Mistakes That Change a Linear Program

Mistake 1: Using a boundary intersection that violates another constraint

After finding a candidate point, substitute it into all the inequalities. For Example 1, (12,0)(12,0) lies on one boundary but violates 2x+y≤122x+y\le12.

Mistake 2: Maximising a coefficient by itself

The coefficient 5 in 3x+5y3x+5y tells you the contribution of one unit of yy. The resource limits still decide how much yy is feasible. Compare full objective values at the vertices.

Mistake 3: Deleting an equality boundary from an inclusive constraint

For ≤\le and ≥\ge, points on the boundary can be feasible and often contain the optimum. Draw the boundary as included.

Try It Yourself

  1. Maximise 2x+y2x+y with x+y≤4x+y\le4 and x,y≥0x,y\ge0.
  2. For the same region, where is x+yx+y maximised?
  3. Is (3,4)(3,4) feasible for 2x+y≤92x+y\le9 and x,y≥0x,y\ge0?

Answers and Reasoning

  1. At (0,0)(0,0), (4,0)(4,0), and (0,4)(0,4), the objective values are 0, 8, and 4. The maximum is 8 at (4,0)(4,0).
  2. Every point on the segment x+y=4x+y=4 with nonnegative coordinates gives 4.
  3. No. The left side is 2(3)+4=10>92(3)+4=10>9.

Questions About Linear Programming

Does every feasible linear program have a solution?

A feasible program has allowable points. It can lack a finite optimal value if the objective improves without limit. A continuous linear objective on a nonempty bounded, closed feasible region always attains an optimum.

What do the objective lines show?

In two variables, equal objective values lie on parallel lines. Moving these lines toward better values shows where one last touches the feasible region, such as a single vertex or an entire edge.

Conclusion

  • Model the variables, objective, and all constraints.
  • Check the feasible region and its corner points.
  • Consider whether the model requires integers and whether the objective has a finite optimum.

Read More

Research Behind This Article

  1. OpenStax, Contemporary Mathematics — Linear Programming. OpenStax
  2. Omar Antolín Camarena, Thinking of Linear Programs Geometrically. UNAM
  3. Oregon State University Extension, Operations Research: Using the Graphical Method to Solve Linear Programs. Oregon State
  4. National Taiwan University, Optimization — Introduction to Linear Programming. NTU