Total Pageviews

Search This Blog

Wednesday, October 4, 2023

How to Solve Linear Programming Problems (Optimization of 2 Variables)

Suppose you have a food truck business that sells gourmet hotdogs and hamburgers. You sell hotdogs for $2 each and hamburgers for $4 each. You make the buns yourself from flour and hotdogs and burgers from ground beef. 1 pound of flour is enough for 8 hotdog buns or 8 hamburger buns. 1 pound of ground beef is enough for 12 hotdogs or 4 hamburgers (you use cheap filler for the hotdogs). If you have 1 pound of flour and 1 pound of ground beef, how many hotdogs and hamburgers should you make in order to earn the most money?

Take a few minutes to try this on your own. Hint: the two unknowns are the number of hotdogs and the number of hamburgers.

Let x = # of hotdogs and y = # of hamburgers

The revenue equation is given by 2x + 4y. This is the objective function we want to maximize.

We can graph the equations for the flour and ground beef. 

x/8 + y/8 = 1

x/12+ y/4 = 1



We graph the two lines and see the intersection point is (6,2). The other points of interest are (0,4) and (8,0). If we test all three points with the objective function, we'll find the maximum.

2(6) + 2(4) = $20

2(0) + 4(4) = $16

2(8) + 0(4) = $16

In these kinds of problems, the solution is often found at the intersection of the constraint lines. Another way of finding that intersection is called elimination.

x/8 + y/8 = 1 is the same as x + y = 8

 x/12 + y/4 = 1 is the same as x + 3y = 12

I can subtract the second equation from the first to get rid of x.

 x + 3y = 12

-x + y = 8

2y = 4

y = 2

Putting 2 in for y in either equation, I get x = 6.

It's possible to solve problems like this that have more than two variables, but they are usually done with a matrix (and not the red pill, blue pill kind).

On a related note, in order to solve a system of equations like this, the number of independent equations must be the same as the number of unknowns. For example, the system x + y = 5 and 2x + 2y = 10 cannot be solved because the second equation is just twice the first equation.  

No comments: