Linear Programming (Part 1)

By Mike Taptich

Linear Programming (LP) is one of many mathematical used in optimization (e.g., maximization or minimization). Formally, LP is the process of selecting optimal policies for a linear function subject to linear constraints. The most common applications of LPs usually come in the following form:

You find yourself in a situation where you must allocate a limited set of resources among competing activities in the most efficient manner, given a number of restrictions.

While many engineering programs will dedicate entire courses to solving LPs, I plan to only present you with a few graphical examples that review two fundamentals of linear programing and optimization.

  1. Bounding

  2. Extreme Points


A constraint is a condition placed on a decision variable or combination of decision variables that must be satisfied. Constaints are what define the of all possible solutions to an LP in some known real coordinate space, Rn.

In standard form, LP constraints may allow the linear combination of decision variables up to a point (i.e., less than or equal to) or hold these combinations to be equal to some value.

A one-dimensional example, R1:

A two-dimensional example, R2:

For each case, the feasible region is represented in red. Again, a solution to an LP is possible if a policy is chosen within this region.


Now, suppose that you are the sole controller over your family's household thermostat. Without knowing it, you may have been intuitively solving a constrained LP! Operating as the controller, you may decide on some dial setting (x) that will maintain the house at a respective temperature. The following are examples of constraints you may face under different LP objectives.

Maximize x:

Your sister insists that you make the house as hot as possible, but she isn't in the mood to argue with your brother.

Minimize x:

Your brother insists that you make the house as cold as possible, but your dad prefers that the air conditioning unit remains offline.

Maximize |x - x0|:

All conditions considered, you decide to choose the dial setting that is greatest from your current temperature setting.

In this last example, the feasible region or solution set was all the possible temperatures within your sister and father's preferential constraints. Given your final objective, you decide on the optimal policy of 78 degrees F. This choice is referred to as a . However, not all LPs result in this condition. The solution of an LP can also be either infeasible or unbounded.

Maximize x (infeasible):

An infeasible solution implies that the feasible region is over-constrained and no solution is possible. In our previous examples, you would arrive at an infeasbile solution if your brother's maximum temperature preference required you to use the broken AC unit (i.e., colder than applying strictly heat).

Maximize x (unbounded):

An unbounded solution implies the solution space continues forever in at least one direction. In our previous examples, you would arrive at a unbounded solution if your thermostat could always increase the temperature in your house (i.e., approaches infinity possible solutions).

Did you notice that your optimal choice for the temperature dial always seemed to lie somewhere along a bound? Well, that is because unique solutions of LPs will never fall within the of the feasible region!

#Extreme Points

To ellborate more on my last point, I have provided you with three additional examples: Problem 1, Problem 2, Problem 3. Now, drag the blue ball to the coordinate in the x-y space that optimizes each LP. Feel free to build your own problems, too.

Objective Value:   Z = {{xobj+"x +"+yobj+"y = "}} {{(xobj*Z.x + yobj*Z.y | number : 5)}}

   x +  y  
Subject to:
  • {{constraint.text}}
 x +  y  
[ undo ]   [ clear ]

(Hint: If you over-constrain your circle, click the feasile region and it will reappear.)

In each problem, you will find that the optimal policy, X* = (x*, y*), falls along the boundary of the feasible region. This makes sense if you think about your decision-making process in terms of your objective: why settle for less than you deserve!

Thus, X* is called an extreme point. These extreme points exists if and only if you cannot represent the point as a convex combination of points that fall within the feasible region. You may be asking yourself, " of... huh?" This was my early reaction to the math-heavy jargon relating to extreme points and more generally optimization. If this is the case, I found that this definition is best explained visually.

In two dimensions (x,y), a convex combination of two points is simply a line drawn between them. Since extreme points by nature fall along the boundary of the feasible region, you can never draw a line through the point using any points with the set!

Extreme points and bounding are the fundamental building blocks used in algorithms that efficiently . In the next Visually Explained post on linear programming, I hope to dive deeper into solving LPs!

Mike Taptich is a PhD student in the Energy, Civil Infrastructure, and Climate program at UC Berkeley. He is also a co-founder of the Visualizing Urban Data Idealab.