Javascript required
Skip to content Skip to sidebar Skip to footer

How to Find Optimal Solution Linear Programming

Linear programming can be used to solve a problem when the goal of the problem is to maximize some value and there is a linear system of inequalities that defines the constraints on the problem.

A constraint is an inequality that defines how the values of the variables in a problem are limited. In order for linear programming techniques to work, all constraints should be linear inequalities.

Returning to the example in the introduction:

Note that there is a cost associated with producing each part. Each doodad costs $2 to make and each whirligig costs $4 to make. The factory only has $220 available to spend on these costs, so the production is limited by cost. Let x x be the number of doodads produced, and let y y be the number of whirligigs produced. Then this constraint can be written as an inequality:

2 x + 4 y 220. 2x+4y \le 220.

There is also the limitation on how much time the factory has to produce these parts. Each doodad requires 3 hours to make and each whirligig requires 2 hours to make. The factory only has 150 hours available this week, so production is also limited by time. This constraint can be written as an inequality:

3 x + 2 y 150. 3x+2y \le 150.

In addition to these constraints, there is also a couple of "common sense" constraints. It's not possible to produce less than 0 of any part, so these constraints are also written:

x 0 y 0. \begin{aligned} x &\ge 0 \\ y &\ge 0. \end{aligned}

These are called non-negative constraints. Altogether, the constraints form a system of inequalities:

{ 2 x + 4 y 220 3 x + 2 y 150 x 0 y 0. \begin{cases}\begin{aligned} 2x+4y &\le 220 \\ 3x+2y &\le 150 \\ x &\ge 0 \\ y &\ge 0. \end{aligned}\end{cases}

Graphing these inequalities in the coordinate plane creates a polygon shape.

Graph the system of constraints

{ 2 x + 4 y 220 3 x + 2 y 150 x 0 y 0. \begin{cases}\begin{aligned} 2x+4y &\le 220 \\ 3x+2y &\le 150 \\ x &\ge 0 \\ y &\ge 0. \end{aligned}\end{cases}

The shaded region above is the feasible region of this problem.

The region that is bound by the system of constraints is called the feasible region. It represents the possible values of the variables that satisfy all of the constraints. In order for linear programming techniques to work, it should be a convex polytope (in 2 dimensions, a convex polygon; in 3 dimensions, a convex polyhedron; and so on).

Finding the feasible region is only sufficient to give the possible solutions of a problem. The goal of linear programming is to find the best solution to a problem. This is done by maximizing or minimizing the objective function.

The objective function is a function that defines some quantity that should be minimized or maximized. The arguments of the objective function are the same variables that are used in the constraints. In order for linear programming techniques to work, the objective function should be linear.

Each doodad costs $2 to make and sells for $6. This gives a profit of $4 per doodad. Each whirligig costs $4 to make and sells for $7. This gives a profit of $3 per whirligig. The profit function can be defined as

p ( x , y ) = 4 x + 3 y . p(x,y)=4x+3y.

This is the objective function of this problem, and the goal is to maximize it.

It seems like the strategy now would be to test ordered pairs in the feasible region until a maximum profit is found. However, a more efficient method is available.

Let P P be the maximum profit in the feasible region:

P = 4 x + 3 y . P=4x+3y.

Solve for y:

y = 4 3 x + P 3 . y=-\frac{4}{3}x+\frac{P}{3}.

This maximum profit gives an equation of a line, and whatever point in the feasible region passes through this line is the optimal solution. The y y -intercept of this line is P 3 . \frac{P}{3}. Since P P is maximized, this y y -intercept should be maximized as well.

Graph several lines with the same slope of 4 3 . -\frac{4}{3}.

The line that maximizes the y y -intercept is the one that passes through the vertex at ( 20 , 45 ) , (20,45), the intersection of the first two constraints. All other higher lines do not pass through the feasible region. All other lower lines pass through more than one point in the feasible region, and do not maximize the y y -intercept of the line.

Therefore, the factory should produce 20 doodads and 45 whirligigs. This will give a profit of $ 215. \$215. _\square

In the previous example, it was shown that the optimal solution was on a vertex of the feasible region. This is true for all linear programming problems.

Given a convex polygonal feasible region and a linear objective function, the solution that maximizes or minimizes the objective function will be located on one of the vertices of the feasible region.

Let the objective function be f ( x , y ) = a x + b y . f(x,y)=ax+by. Let the maximum value of this function be P , P, and let the minimum value of this function be Q . Q. There exist lines which intersect each of the optimal solutions, ( x , y ) (x,y) :

a x + b y = P ( 1 ) a x + b y = Q ( 2 ) y = a b x + P b ( 1 ) y = a b x + Q b . ( 2 ) \begin{aligned} ax+by &= P &&\qquad (1) \\ ax+by &= Q &&\qquad (2) \\\\ \Rightarrow y &= -\frac{a}{b}x + \frac{P}{b} &&\qquad (1) \\ y &= -\frac{a}{b}x + \frac{Q}{b}. &&\qquad (2) \end{aligned}

Since P P is the maximum value of the objective function, ( 1 ) (1) has the maximum y y -intercept of a line with slope a b -\frac{a}{b} that passes through the feasible region. Likewise, ( 2 ) (2) has the minimum y y -intercept of a line with slope a b -\frac{a}{b} that passes through the feasible region.

Suppose that ( 1 ) (1) or ( 2 ) (2) passes through a point that is not one of the vertices of the feasible region.

  • Case 1. The intersection point is on a side of the feasible region that is parallel to lines ( 1 ) (1) and ( 2 ) . (2).
    If this is the case, then line ( 1 ) (1) or ( 2 ) (2) also contains a vertex of the feasible region, so this cannot be so.

  • Case 2. The intersection point is somewhere else within the feasible region.
    The line will intersect more than one point in the feasible region. Then there will exist another point within the feasible region, either higher or lower, that a line with a parallel slope intersects. This cannot be true if line ( 1 ) (1) or ( 2 ) (2) has the maximum or minimum y y -intercept of a line that passes through the feasible region.

Hence, ( 1 ) (1) and ( 2 ) (2) must intersect a vertex of the feasible region. Each optimal solution is located at a vertex of the feasible region. _\square

This theorem gives a simple method for finding the optimal solution to a linear programming problem in two variables.

Process for finding the optimal solution of a linear programming problem in two variables

  • Confirm that the feasible region is a convex polygon and the objective function is linear.

  • Find the ordered pair of each vertex of the feasible region.

  • Substitute each ordered pair into the objective function to find the solution that maximizes or minimizes the objective function.

A farmer feeds his cows a feed mix to supplement their foraging. The farmer uses two types of feed for the mix. Corn feed contains 100 g protein per kg and 750 g starch per kg. Wheat feed contains 150 g protein per kg and 700 g starch per kg. Each cow should be fed at most 7 kg of feed per day. The farmer would like each cow to receive at least 650 g protein and 4000 g starch per day. If corn feed costs $0.40/kg and wheat costs $0.45/kg, then what is the optimal feed mix that minimizes cost? Round your answers to the nearest gram.


Let c c be the kilograms of corn feed per cow per day, and let w w be the kilograms of wheat feed per cow per day. The system of constraints can be written:

{ 0.1 c + 0.15 w 0.65 0.75 c + 0.7 w 4 c + w 7 c 0 w 0. \begin{cases} \begin{aligned} 0.1c+0.15w &\ge 0.65 \\ 0.75c+0.7w &\ge 4 \\ c+w &\le 7 \\ c &\ge 0 \\ w &\ge 0. \end{aligned} \end{cases}

The objective function is

Minimize: f ( c , w ) = 0.40 c + 0.45 w . \text{Minimize:} \ f(c,w)=0.40c+0.45w.

Graphing the system of constraints gives an idea of where the vertices of the feasible region are, and which lines intersect to form them:

Solve for each vertex of the feasible region by solving each pair of intersecting lines as a system of equations. For example, to solve for the vertex within the 1 st 1^\text{st} quadrant, solve the system of equations

{ 0.1 c + 0.15 w = 0.65 0.75 c + 0.7 w = 4. \begin{cases} \begin{aligned} 0.1c+0.15w &= 0.65 \\ 0.75c +0.7w &= 4. \end{aligned} \end{cases}

Solving this system gives c 3.411 c \approx 3.411 and w 2.059. w \approx 2.059. These values can be substituted into the objective function to obtain the cost of this mix:

f ( 3.411 , 2.059 ) = $ 2.29. f(3.411,2.059) = \$2.29.

Note that it is not necessary to solve for every vertex. Since the problem requires a minimum and the objective function line has a negative slope, the optimal solution must be on the underside of the feasible region. Solve for these vertices:

{ 0.75 c + 0.7 w = 4 c = 0 c = 0 , w 5.714 f ( 0 , 5.714 ) = $ 2.57 \begin{cases} \begin{aligned} 0.75c +0.7w &= 4 \\ c &= 0 \end{aligned} \end{cases} \implies c=0, w \approx 5.714 \implies f(0,5.714)=\$2.57

{ 0.1 c + 0.15 w = 0.65 w = 0 c = 6.5 , w = 0 f ( 6.5 , 0 ) = $ 2.60. \begin{cases} \begin{aligned} 0.1c+0.15w &= 0.65 \\ w &= 0 \end{aligned} \end{cases} \implies c=6.5, w=0 \implies f(6.5,0)=\$2.60.

The feed mix that minimizes cost contains 3411 g corn and 2059 g wheat. It costs $2.29 per cow. _\square

A manufacturer has 750 meters of cotton and 1000 meters of polyester. Production of a sweatshirt requires 1 meter of cotton and 2 meters of polyester, while production of a shirt requires 1.5 meters of cotton and 1 meter of polyester. The sale prices of a sweatshirt and a shirt are 30 € and 24 €, respectively. What are the number of sweatshirts ( S ) (S) and the number of shirts ( C ) (C) that maximize total sales?

Submit S + C . S + C.

Jordan has $100 to buy some comic books. He really likes the Star Wars books which cost $12 each, but he could also buy the Marvels books which cost $5 each. If he has to buy at least 12 books, what is the maximum number of the Star Wars books that he can buy?

An amateur bodybuilder is looking for supplement protein bars to build his muscle fast, and there are 2 available products: protein bar A and protein bar B.

Each protein bar A contains 15 g of protein and 30 g of carbohydrates and has total 200 calories. On the other hand, each protein bar B contains 30 g of protein and 20 g of carbohydrates and has total 240 calories.

According to his nutritional plan, this bodybuilder needs at least 20,000 calories from these supplements over the month, which must comprise of at least 1,800 g of protein and at least 2,200 g of carbohydrates.

If each protein bar A costs $3 and each protein bar B costs $4, what is the least possible amount of money (in $) he can spend to meet all his one-month requirements?

This kind of method would also work for linear optimization problems in more than two variables. However, these kinds of problems are more challenging to visualize with a coordinate graph, and there can be many more vertices to check for the optimal solution. The simplex algorithm was developed as an efficient method to solve these kinds of problems.

The simplex algorithm is a method to obtain the optimal solution of a linear system of constraints, given a linear objective function. It works by beginning at a basic vertex of the feasible region, and then iteratively moving to adjacent vertices, improving upon the solution each time until the optimal solution is found.

The simplex algorithm has many steps and rules, so it is helpful to understand the logic behind these steps and rules with a simple example before proceeding with the formal algorithm.

Given the system of constraints

{ 2 x + 3 y 90 3 x + 2 y 120 x 0 y 0 , \begin{cases} \begin{aligned} 2x+3y &\le 90 \\ 3x+2y &\le 120 \\ x & \ge 0 \\ y & \ge 0, \end{aligned} \end{cases}

maximize the objective function

f ( x , y ) = 7 x + 5 y . f(x,y)=7x+5y.


The simplex algorithm begins by converting the constraints and objective functions into a system of equations. This is done by introducing new variables called slack variables. Slack variables represent the positive difference, or slack, between the left hand side of an inequality and the right hand side of that inequality.

The inequality

2 x + 3 y 90 2x+3y \le 90

becomes

2 x + 3 y + s 1 = 90. 2x+3y+s_1=90.

Likewise, the inequality

3 x + 2 y 120 3x+2y \le 120

becomes

3 x + 2 y + s 2 = 120. 3x+2y+s_2 = 120.

In addition to the slack variables, a variable z z is introduced to represent the value of the objective function. This gives the equation

z 7 x 5 y = 0. z-7x-5y=0.

These equations give the system of equations

{ z 7 x 5 y = 0 ( 0 ) 2 x + 3 y + s 1 = 90 ( 1 ) 3 x + 2 y + s 2 = 120. ( 2 ) \begin{cases} \begin{array}{cccccccccccc} z & - & 7x & - & 5y & & & & & = & 0 && (0) \\ & & 2x & + & 3y & + & s_1 & & & = & 90 && (1) \\ & & 3x & + & 2y & & & + & s_2 & = & 120. && (2) \end{array} \end{cases}

In augmented matrix form, this is

[ 1 7 5 0 0 0 0 2 3 1 0 90 0 3 2 0 1 120 ] . ( 0 ) ( 1 ) ( 2 ) \left[\begin{array}{ccccc|c} 1 & -7 & -5 & 0 & 0 & 0 \\ 0 & 2 & 3 & 1 & 0 & 90 \\ 0 & 3 & 2 & 0 & 1 & 120 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \end{array}

It is implied that all variables in this system (including s 1 , s_1, s 2 , s_2, and z z ) are greater than or equal to 0. The variables s 1 s_1 and s 2 s_2 have zero coefficients in row ( 0 ) (0) and are called basic variables. The variables x x and y y have non-zero coefficients in row ( 0 ) (0) and are called non-basic variables. At any point in this process, the basic solution is given by setting the non-basic variables to 0. Currently, the basic solution is

x = 0 , y = 0 , s 1 = 90 , s 2 = 120 , z = 0. x=0, \quad y=0, \quad s_1=90, \quad s_2=120, \quad z=0.

Consider what effect increasing the values of the non-basic variables would have on the value of z . z. Increasing either x x or y y would cause z z to also increase, because x x and y y have negative coefficients in row ( 0 ) . (0). Thus, this is not the optimal solution.

The iterations of the simplex algorithm involve exchanging basic variables and non-basic variables by using matrix row operations. At each step of the process, a non-basic variable in row ( 0 ) (0) is eliminated, leading another basic variable to take its place as a non-basic variable. This is called a pivot.

Suppose x x were to be eliminated in row ( 0 ) . (0). This can be done with either row ( 1 ) (1) or row ( 2 ) . (2).

Case 1. Eliminating x x in row ( 0 ) (0) with row ( 1 ) (1) ,

[ 1 0 21 2 7 2 0 315 0 2 3 1 0 90 0 3 2 0 1 120 ] . ( 0 ) 1 2 ( 1 ) ( 2 ) \left[\begin{array}{ccccc|c} 1 & 0 & \frac{21}{2} & \frac{7}{2} & 0 & 315 \\ 0 & 2 & 3 & 1 & 0 & 90 \\ 0 & 3 & 2 & 0 & 1 & 120 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1) \\ (2) \end{array}

During this pivot, the variable x x entered as a basic variable, and the variable s 1 s_1 left to become a non-basic variable. Now eliminate x x in row ( 2 ) (2) :

[ 1 0 21 2 7 2 0 315 0 2 3 1 0 90 0 0 5 2 3 2 1 15 ] . ( 0 ) 1 2 ( 1 ) ( 2 ) 1 2 \left[\begin{array}{ccccc|c} 1 & 0 & \frac{21}{2} & \frac{7}{2} & 0 & 315 \\ 0 & 2 & 3 & 1 & 0 & 90 \\ 0 & 0 & -\frac{5}{2} & -\frac{3}{2} & 1 & -15 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1) \\ (2)\vphantom{\frac{1}{2}} \end{array}

This gives the basic solution

x = 45 , y = 0 , s 1 = 0 , s 2 = 15 , z = 315. x=45, \quad y=0, \quad s_1=0, \quad s_2=-15, \quad z=315.

This solution is impossible, because it leads to one of the variables being negative.

Case 2. Eliminating x x in row ( 0 ) (0) with row ( 2 ) (2) ,

[ 1 0 1 3 0 7 3 280 0 2 3 1 0 90 0 3 2 0 1 120 ] . ( 0 ) 1 2 ( 1 ) ( 2 ) \left[\begin{array}{ccccc|c} 1 & 0 & -\frac{1}{3} & 0 & \frac{7}{3} & 280 \\ 0 & 2 & 3 & 1 & 0 & 90 \\ 0 & 3 & 2 & 0 & 1 & 120 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1) \\ (2) \end{array}

During this pivot, the variable x x entered as a basic variable, and the variable s 2 s_2 left to become a non-basic variable. Now eliminate x x in row ( 1 ) (1) :

[ 1 0 1 3 0 7 3 280 0 0 5 3 1 2 3 10 0 3 2 0 1 120 ] . ( 0 ) 1 2 ( 1 ) 1 2 ( 2 ) \left[\begin{array}{ccccc|c} 1 & 0 & -\frac{1}{3} & 0 & \frac{7}{3} & 280 \\ 0 & 0 & \frac{5}{3} & 1 & -\frac{2}{3} & 10 \\ 0 & 3 & 2 & 0 & 1 & 120 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1)\vphantom{\frac{1}{2}} \\ (2) \end{array}

This gives the basic solution

x = 40 , y = 0 , s 1 = 10 , s 2 = 0 , z = 280. x=40, \quad y=0, \quad s_1=10, \quad s_2=0, \quad z=280.

This solution is possible, but it is not optimal, because there is a negative coefficient in row ( 0 ) . (0). This implies that z z can be increased further by increasing y . y. Another pivot will be needed to find the optimal solution.

It is a fair amount of work to perform a pivot, only to find that it gives an infeasible solution. Fortunately, one can anticipate which pivot will result in a feasible solution by observing the ratio of the element in the right part of the augmented matrix to the coefficient of the entering variable. Consider y y as the entering variable, and calculate these ratios:

[ 1 0 1 3 0 7 3 280 0 0 5 3 1 2 3 10 0 3 2 0 1 120 ] . ( 0 ) 1 2 ( 1 ) 1 2 ( 2 ) \left[\begin{array}{ccccc|c} 1 & 0 & -\frac{1}{3} & 0 & \frac{7}{3} & 280 \\ 0 & 0 & {\color{#D61F06}\frac{5}{3}} & 1 & -\frac{2}{3} & {\color{#D61F06}10} \\ 0 & 3 & {\color{#3D99F6}2} & 0 & 1 & {\color{#3D99F6}120} \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1)\vphantom{\frac{1}{2}} \\ (2) \end{array}

For entering variable y , y, this ratio is 10 ÷ 5 3 = 6 10\div \frac{5}{3}=6 for row ( 1 ) (1) and 120 2 = 60 \frac{120}{2}=60 for row ( 2 ) . (2). Selecting the row that minimizes this ratio will ensure that the pivot results in a feasible solution. Thus, row ( 1 ) (1) should be selected as the pivot row.

Eliminating y y in row ( 0 ) (0) with row ( 1 ) (1) ,

[ 1 0 0 1 5 11 5 282 0 0 5 3 1 2 3 10 0 3 2 0 1 120 ] . ( 0 ) 1 2 ( 1 ) 1 2 ( 2 ) \left[\begin{array}{ccccc|c} 1 & 0 & 0 & \frac{1}{5} & \frac{11}{5} & 282 \\ 0 & 0 & \frac{5}{3} & 1 & -\frac{2}{3} & 10 \\ 0 & 3 & 2 & 0 & 1 & 120 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1)\vphantom{\frac{1}{2}} \\ (2) \end{array}

Then eliminating y y in row ( 2 ) (2) ,

[ 1 0 0 1 5 11 5 282 0 0 5 3 1 2 3 10 0 3 0 6 5 9 5 108 ] . ( 0 ) 1 2 ( 1 ) 1 2 ( 2 ) 1 2 \left[\begin{array}{ccccc|c} 1 & 0 & 0 & \frac{1}{5} & \frac{11}{5} & 282 \\ 0 & 0 & \frac{5}{3} & 1 & -\frac{2}{3} & 10 \\ 0 & 3 & 0 & -\frac{6}{5} & \frac{9}{5} & 108 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1)\vphantom{\frac{1}{2}} \\ (2)\vphantom{\frac{1}{2}} \end{array}

This gives the basic solution

x = 36 , y = 6 , s 1 = 0 , s 2 = 0 , z = 282. x=36, \quad y=6, \quad s_1=0, \quad s_2=0, \quad z=282.

This solution must be optimal, because any increase in the non-basic variables s 1 s_1 and s 2 s_2 will cause a decrease in z . z. Thus, the maximum value of the objective function is

f ( 36 , 6 ) = 282. f(36,6)=282.\ _\square

Simplex Algorithm for Maximization

  • This version of the simplex algorithm is valid for a maximization problem with all constraints (except for the non-negative constraints) giving maximum values (using the \le symbol). In matrix form, the requirements are Maximize: c T x Subject to: Ax b , x i 0 , \begin{array}{ll} \text{Maximize:} & \textbf{c}^\text{T} \cdot \textbf{x} \\ \text{Subject to:} & \textbf{A}\textbf{x} \le \textbf{b}, \ \ x_i \ge 0, \end{array} where c \textbf{c} is a vector containing the coefficients of the objective function, x \textbf{x} is a vector containing the variables of the problem, A \textbf{A} is a matrix containing the constraint coefficients, and b \textbf{b} is a vector containing the maximum values of those constraints.

  • Convert the constraints and objective function into a system of equations by introducing slack variables and the z z variable.

  • Put the system of equations into augmented matrix form. The objective function equation should go in row ( 0 ) . (0).

  • Select one of the non-basic variables to be the entering variable.

  • Select the pivot row by computing the ratio Element on right side of augmented matrix Coefficient of entering variable \frac{\text{Element on right side of augmented matrix}}{\text{Coefficient of entering variable}} for each row. The correct pivot row minimizes this ratio. However, this ratio must be positive.

  • If all coefficients of non-basic variables in row ( 0 ) (0) are positive, then you have the optimal solution. Otherwise, select a non-basic variable that has a negative coefficient in row ( 0 ) (0) to be the next entering variable, then pivot again to find another feasible solution. Continue pivoting until the optimal solution is found.

A toy factory manufactures three kinds of toys: cars, motorcycles, and boats. One toy car makes $20 profit, one toy motorcycle makes $15 profit, and one toy boat makes $25 profit. There are three departments of labour: casting, which has 8 workers; assembly, which has 12 workers; quality control, which has 10 workers.

Every day, the labour is allocated as follows: a toy car requires 2 casting, 2 assembly, 2 quality control; a toy motorcycles requires 1 casting, 2 assembly, 1 quality control; a toy boat requires 2 casting, 3 assembly, 3 quality control.

What is the maximum profit per day (in dollars) the toy company can achieve?

The simplex algorithm for minimization problems works by converting the problem to a maximization problem. This concept that every maximization problem has a corresponding minimization problem is formalized with the von Neumann duality principle.

Given the system of constraints

{ 4 x + 3 y + 5 z 65 x + 3 y + 2 z 38 2 x + 3 y + 4 z 52 x , y , z 0 , \begin{cases}\begin{aligned} 4x+3y+5z &\ge 65 \\ x+3y+2z &\ge 38 \\ 2x+3y+4z &\ge 52 \\ x,y,z &\ge 0, \end{aligned}\end{cases}

minimize the function

f ( x , y , z ) = 12 x + 3 y + 10 z . f(x,y,z)=12x+3y+10z.


This problem could be put into the form shown in the maximization examples above, but an issue would occur with finding the first basic solution: setting the x , x, y , y, and z , z, variables to 0 0 would give an infeasible solution with the slack variables taking on negative values. The simplex algorithm needs to start with a feasible solution, so this would not work. The Big-M method gives a workaround to this problem, but there is a much simpler method for this problem.

A "dual" of this problem can be written by transposing the coefficients. Place the coefficients of the constraints into an augmented matrix. Place the coefficients of the objective function into the bottom row, with a 0 in the right part:

[ 4 3 5 65 1 3 2 38 2 3 4 52 12 3 10 0 ] . \left[\begin{array}{ccc|c} \color{#20A900}4 & \color{#D61F06}3 & \color{#3D99F6}5 & \color{#EC7300}65 \\ \color{#20A900}1 & \color{#D61F06}3 & \color{#3D99F6}2 & \color{#EC7300}38 \\ \color{#20A900}2 & \color{#D61F06}3 & \color{#3D99F6}4 & \color{#EC7300}52 \\ \hline \color{#20A900}12 & \color{#D61F06}3 & \color{#3D99F6}10 & \color{#EC7300}0 \end{array}\right].

Transpose the elements of the matrix:

[ 4 1 2 12 3 3 3 3 5 2 4 10 65 38 52 0 ] . \left[\begin{array}{ccc|c} \color{#20A900}4 & \color{#20A900}1 & \color{#20A900}2 & \color{#20A900}12 \\ \color{#D61F06}3 & \color{#D61F06}3 & \color{#D61F06}3 & \color{#D61F06}3 \\ \color{#3D99F6}5 & \color{#3D99F6}2 & \color{#3D99F6}4 & \color{#3D99F6}10 \\ \hline \color{#EC7300}65 & \color{#EC7300}38 & \color{#EC7300}52 & \color{#EC7300}0 \end{array}\right].

Note: It's tempting to divide out the 3 in the second row of this matrix, but this will break the symmetry that is required to return to the original problem.

This gives a new system of constraints and an objective function to be maximized: Given the system of constraints

{ 4 u + v + 2 w 12 3 u + 3 v + 3 w 3 2 u + 3 v + 4 w 52 u , v , w 0 , \begin{cases}\begin{aligned} 4u+v+2w &\le 12 \\ 3u+3v+3w &\le 3 \\ 2u+3v+4w &\le 52 \\ u,v,w &\ge 0, \end{aligned}\end{cases}

maximize the function

g ( u , v , w ) = 65 u + 38 v + 52 w . g(u,v,w)=65u+38v+52w.

Now the simplex algorithm can be applied to find the optimal solution

[ 1 65 38 52 0 0 0 0 0 4 1 2 1 0 0 12 0 3 3 3 0 1 0 3 0 2 3 4 0 0 1 52 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) \left[\begin{array}{ccccccc|c} 1 & -65 & -38 & -52 & 0 & 0 & 0 & 0 \\ 0 & 4 & 1 & 2 & 1 & 0 & 0 & 12 \\ 0 & 3 & 3 & 3 & 0 & 1 & 0 & 3 \\ 0 & 2 & 3 & 4 & 0 & 0 & 1 & 52 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

Enter u u with row ( 2 ) (2) :

[ 1 0 27 13 0 65 3 0 65 0 0 3 2 1 4 0 8 0 1 1 1 0 1 3 0 1 0 0 1 2 0 2 1 50 ] . ( 0 ) 1 2 ( 1 ) ( 2 ) 1 2 ( 3 ) \left[\begin{array}{ccccccc|c} 1 & 0 & 27 & 13 & 0 & \frac{65}{3} & 0 & 65 \\ 0 & 0 & -3 & -2 & 1 & -4 & 0 & 8 \\ 0 & 1 & 1 & 1 & 0 & \frac{1}{3} & 0 & 1 \\ 0 & 0 & 1 & 2 & 0 & -2 & 1 & 50 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1) \\ (2)\vphantom{\frac{1}{2}} \\ (3) \end{array}

All coefficients in row ( 0 ) (0) are positive, so this is the optimal solution. The maximum value in the top right of the matrix, 65 , 65, is the same as the minimum value for the original problem. However, the variables u , u, v , v, and w w are not the same as the variables in the original problem. Fortunately, the values of the variables that minimize the original problem correspond to the coefficients of the slack variables in row ( 0 ) . (0).

[ 1 0 27 13 0 65 3 0 65 0 0 3 2 1 4 0 8 0 1 1 1 0 1 3 0 1 0 0 1 2 0 2 1 50 ] . ( 0 ) 1 2 ( 1 ) ( 2 ) 1 2 ( 3 ) \left[\begin{array}{ccccccc|c} 1 & 0 & 27 & 13 & \color{#D61F06}0 & \color{#D61F06}\frac{65}{3} & \color{#D61F06}0 & 65 \\ 0 & 0 & -3 & -2 & 1 & -4 & 0 & 8 \\ 0 & 1 & 1 & 1 & 0 & \frac{1}{3} & 0 & 1 \\ 0 & 0 & 1 & 2 & 0 & -2 & 1 & 50 \end{array}\right]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{2}} \\ (1) \\ (2)\vphantom{\frac{1}{2}} \\ (3) \end{array}

Thus, the values of the original problem that minimize the objective function are

x = 0 , y = 65 3 , z = 0. x=0, \quad y=\frac{65}{3}, \quad z=0.\ _\square

Simplex Algorithm for Minimization

  • This version of the simplex algorithm is valid for a minimization problem with all constraints giving minimum values (using the \ge symbol). In matrix form, the requirements are:

Minimize: c T x Subject to: Ax b x i 0 \begin{array}{ll} \text{Minimize:} & \textbf{c}^\text{T} \cdot \textbf{x} \\ \text{Subject to:} & \textbf{A}\textbf{x} \ge \textbf{b}\, \quad x_i \ge 0 \end{array}

where c \textbf{c} is a vector containing the coefficients of the objective function, x \textbf{x} is a vector containing the variables of the problem, A \textbf{A} is a matrix containing the constraint coefficients, and b \textbf{b} is a vector containing the minimum values of those constraints.

  • Place the coefficients of the constraints and objective function into an augmented matrix. The coefficients of the objective function should go into the bottom row.

  • Transpose this matrix.

  • This new matrix represents the dual maximization problem. Write the new system of constraints and objective function. This problem has different variables than the original problem.

  • Use the simplex algorithm for maximization to obtain the maximum value. This maximum value is the same as the minimum value for the original problem. The coefficients of the slack variables in row ( 0 ) (0) correspond to the values of the variables in the original problem.

An amateur bodybuilder is looking for supplement protein bars to build his muscle fast, and there are 2 available products: protein bar A and protein bar B.

Each protein bar A contains 15 g of protein and 30 g of carbohydrates and has total 200 calories. On the other hand, each protein bar B contains 30 g of protein and 20 g of carbohydrates and has total 240 calories.

According to his nutritional plan, this bodybuilder needs at least 20,000 calories from these supplements over the month, which must comprise of at least 1,800 g of protein and at least 2,200 g of carbohydrates.

If each protein bar A costs $3 and each protein bar B costs $4, what is the least possible amount of money (in $) he can spend to meet all his one-month requirements?

The simplex algorithm can sometimes lead to some surprising results. It is possible that a linear programming problem has infinite solutions or no solutions. These special cases are explored here.

As was stated earlier, a linear programming problem that has minimum constraints does not work with the simplex algorithm. The reason for this is that the initial basic solution is infeasible.

Given the system of constraints

{ 2 x + 3 y 10 3 x + y 8 x 0 y 0 , \begin{cases}\begin{aligned} 2x+3y &\ge 10 \\ 3x+y &\ge 8 \\ x &\ge 0 \\ y &\ge 0, \end{aligned}\end{cases}

minimize the function

f ( x , y ) = 5 x + 10 y . f(x,y)=5x+10y.

Show that this cannot be done using the normal simplex algorithm.


This problem could be solved with a dual or by simply testing the vertices of the feasible region, but consider solving it with the simplex algorithm. Because the constraints are minimum constraints, the slack variables need to have negative coefficients. In addition, the objective function is a minimization. This can be accounted for by treating the problem as a maximization of z . -z. Applying the simplex algorithm, this gives the initial matrix

[ 1 5 10 0 0 0 0 2 3 1 0 10 0 3 1 0 1 8 ] . ( 0 ) ( 1 ) ( 2 ) \left[ \begin{array}{ccccc|c} -1 & 5 & 10 & 0 & 0 & 0 \\ 0 & 2 & 3 & -1 & 0 & 10 \\ 0 & 3 & 1 & 0 & -1 & 8 \\ \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \end{array}

This initial matrix implies an infeasible solution of s 1 = 10 , s 2 = 8. s_1=-10,\ s_2=-8. The simplex algorithm will not produce a meaningful result if the initial basic solution is infeasible. _\square

It is sometimes possible to solve the problem with its dual, but this is not the case if a problem mixes minimum constraints with maximum constraints.

Given the system of constraints

{ x + 5 y 25 6 x + 5 y 60 x + y 2 x 0 y 0 , \begin{cases}\begin{aligned} -x+5y &\le 25 \\ 6x+5y &\le 60 \\ x+y &\ge 2 \\ x &\ge 0 \\ y &\ge 0, \end{aligned}\end{cases}

minimize the function

f ( x , y ) = x 10 y . f(x,y)=x-10y.

Show that this cannot be done using the normal simplex algorithm or the dual method.


Putting this problem into a simplex matrix would give an initial basic solution that is infeasible:

[ 1 1 10 0 0 0 0 0 1 5 1 0 0 25 0 6 5 0 1 0 60 0 1 1 0 0 1 2 ] ( 0 ) ( 1 ) ( 2 ) ( 3 ) \left [ \begin{array}{cccccc|c} -1 & 1 & -10 & 0 & 0 & 0 & 0 \\ 0 & -1 & 5 & 1 & 0 & 0 & 25 \\ 0 & 6 & 5 & 0 & 1 & 0 & 60 \\ 0 & 1 & 1 & 0 & 0 & -1 & 2 \\ \end{array} \right ] \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

s 1 = 25 , s 2 = 60 , s 3 = 2. \begin{array}{ccc} s_1 = 25, & s_2 = 60, & s_3 = -2. \end{array}

Putting the problem's dual into a simplex matrix would also yield an infeasible initial basic solution:

[ 1 25 60 2 0 0 0 0 1 6 1 1 0 1 0 5 5 1 0 1 10 ] ( 0 ) ( 1 ) ( 2 ) \left [ \begin{array}{cccccc|c} 1 & -25 & -60 & 2 & 0 & 0 & 0\\ 0 & 1 & -6 & 1 & 1 & 0 & 1 \\ 0 & -5 & -5 & 1 & 0 & 1 & -10 \end{array} \right ] \qquad \begin{array}{c} (0) \\ (1) \\ (2) \end{array}

s 1 = 1 , s 2 = 10. \begin{array}{cc} s_1 = 1, & s_2 = -10.\ _\square \end{array}

The Big-M method can be used when an initial basic solution is infeasible. The idea behind this method is to introduce artificial variables to the problem in order to move the solution into the feasible region. Unlike slack variables, these artificial variables must have a value of zero in the final solution.

Given the system of constraints

{ x + 5 y 25 6 x + 5 y 60 x + y 2 x 0 y 0 , \begin{cases}\begin{aligned} -x+5y &\le 25 \\ 6x+5y &\le 60 \\ x+y &\ge 2 \\ x &\ge 0 \\ y &\ge 0, \end{aligned}\end{cases}

minimize the function

f ( x , y ) = x 10 y . f(x,y)=x-10y.


From the previous example, it is known that the third constraint produces an infeasible s 3 = 2. s_3=-2. To compensate for this, an artificial variable, a 1 , a_1, is introduced to this constraint and the objective function. In the objective function, this variable has a coefficient of M . M. M M represents an arbitrarily large constant amount. The new constraints and objective function are

{ z + x 10 y + M a 1 = 0 x + 5 y + s 1 = 25 6 x + 5 y + s 2 = 60 x + y s 3 + a 1 = 2. ( 0 ) ( 1 ) ( 2 ) ( 3 ) \begin{cases}\begin{array}{ccccccccccccccc} -z & + & x & - & 10y & & & & & & & + & Ma_1 & = & 0 \\ & - & x & + & 5y & + & s_1 & & & & & & & = & 25 \\ & & 6x & + & 5y & & & + & s_2 & & & & & = & 60 \\ & & x & + & y & & & & & - & s_3 & + & a_1 & = & 2. \end{array}\end{cases} \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

In matrix form,

[ 1 1 10 0 0 0 M 0 0 1 5 1 0 0 0 25 0 6 5 0 1 0 0 60 0 1 1 0 0 1 1 2 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) \left [ \begin{array}{ccccccc|c} -1 & 1 & -10 & 0 & 0 & 0 & M & 0 \\ 0 & -1 & 5 & 1 & 0 & 0 & 0 & 25 \\ 0 & 6 & 5 & 0 & 1 & 0 & 0 & 60 \\ 0 & 1 & 1 & 0 & 0 & -1 & 1 & 2 \end{array} \right ]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

The first goal with the Big-M method is to move the problem into the feasible region. Recall that the current basic solution has s 3 = 2. s_3=-2. This variable will be the leaving variable, with the artificial variable, a 1 , a_1, being the entering variable:

[ 1 1 M 10 M 0 0 M 0 2 M 0 1 5 1 0 0 0 25 0 6 5 0 1 0 0 60 0 1 1 0 0 1 1 2 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) \left [ \begin{array}{ccccccc|c} -1 & 1-M & -10-M & 0 & 0 & M & 0 & -2M \\ 0 & -1 & 5 & 1 & 0 & 0 & 0 & 25 \\ 0 & 6 & 5 & 0 & 1 & 0 & 0 & 60 \\ 0 & 1 & 1 & 0 & 0 & -1 & 1 & 2 \\ \end{array} \right ]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

The current solution is now in the feasible region, with all basic variables positive:

s 1 = 25 , s 2 = 60 , a 1 = 2. s_1 = 25, \quad s_2 = 60, \quad a_1 = 2.

This solution is clearly not correct, because it contains a non-zero artificial variable in the solution. Furthermore, there are negative coefficients in row ( 0 ) (0) . The Big-M method now proceeds just as the simplex algorithm. The new goal is to enter variables with negative coefficients in row ( 0 ) (0) . Since y y has the most negative coefficient in the row ( 0 ) (0) , that variable will be entered first. The row that minimizes the ratio of the right hand side and the coefficient is ( 3 ) (3) , so y y will be entered through this row:

[ 1 11 0 0 0 10 10 + M 20 0 6 0 1 0 5 5 15 0 1 0 0 1 5 5 50 0 1 1 0 0 1 1 2 ] ( 0 ) ( 1 ) ( 2 ) ( 3 ) \left [ \begin{array}{ccccccc|c} -1 & 11 & 0 & 0 & 0 & -10 & 10+M & 20 \\ 0 & -6 & 0 & 1 & 0 & 5 & -5 & 15 \\ 0 & 1 & 0 & 0 & 1 & 5 & -5 & 50 \\ 0 & 1 & 1 & 0 & 0 & -1 & 1 & 2 \\ \end{array} \right ] \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

y = 2 , s 1 = 15 , s 2 = 50. y=2, \quad s_1=15, \quad s_2=50.

This solution no longer contains the artificial variable, but it is not yet optimal due to the negative coefficient in row ( 0 ) . (0). s 3 s_3 must be the next variable to enter. The minimum positive ratio for this variable is in row ( 1 ) (1) :

[ 1 1 0 2 0 0 M 50 0 6 0 1 0 5 5 15 0 7 0 1 1 0 0 35 0 1 5 1 0 0 0 25 ] ( 0 ) ( 1 ) ( 2 ) ( 3 ) \left [ \begin{array}{ccccccc|c} -1 & -1 & 0 & 2 & 0 & 0 & M & 50 \\ 0 & -6 & 0 & 1 & 0 & 5 & -5 & 15 \\ 0 & 7 & 0 & -1 & 1 & 0 & 0 & 35 \\ 0 & -1 & 5 & 1 & 0 & 0 & 0 & 25 \\ \end{array} \right ] \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \end{array}

y = 5 , s 2 = 35 , s 3 = 3. y = 5, \quad s_2 = 35, \quad s_3 = 3.

Now x x must be the entering variable, and the only row with a positive ratio is ( 2 ) (2) :

[ 1 0 0 15 7 1 7 0 M 55 0 0 0 1 7 6 7 5 5 45 0 7 0 1 1 0 0 35 0 0 5 6 7 1 7 0 0 30 ] . ( 0 ) 1 7 ( 1 ) 1 7 ( 2 ) ( 3 ) 1 7 \left [ \begin{array}{ccccccc|c} -1 & 0 & 0 & \frac{15}{7} & \frac{1}{7} & 0 & M & 55 \\ 0 & 0 & 0 & \frac{1}{7} & \frac{6}{7} & 5 & -5 & 45 \\ 0 & 7 & 0 & -1 & 1 & 0 & 0 & 35 \\ 0 & 0 & 5 & \frac{6}{7} & \frac{1}{7} & 0 & 0 & 30 \\ \end{array} \right ]. \qquad \begin{array}{c} (0)\vphantom{\frac{1}{7}} \\ (1)\vphantom{\frac{1}{7}} \\ (2) \\ (3)\vphantom{\frac{1}{7}} \end{array}

Now it is clear that this gives the optimal solution:

x = 5 , y = 6 , s 3 = 9 f ( 5 , 6 ) = 55. x=5, y=6, s_3=9\implies f(5,6)=-55.\ _\square

Big M Simplex Method

  • This method is viable for any linear programming problem that does not match the forms of the previous section. It is also required for problems which contain equality constraints.

  • Assign slack variables and the z z variable as with the basic simplex algorithm, and create a simplex matrix. For each slack variable that has a negative value in the initial basic solution, add a distinct artificial variable to that constraint. Also add a distinct artificial variable to each equality constraint. Artificial variables begin with a coefficient of 1 1 in each constraint row. In the objective function row, every artificial variable begins with the same coefficient, M . M. This represents an arbitrarily large positive constant amount.

  • If the problem is a minimization, then the coefficients of the objective function row are negated, and the goal is to maximize z . -z.

  • Move the solution into the feasible region by performing pivots with a negative slack variable as the leaving variable and an artificial variable as the entering variable.

  • Once the basic solution is in the feasible region, proceed with the simplex algorithm as before.

  • While performing the simplex algorithm, ensure that the elements in the right side of the matrix are positive. If an element in the right side is not positive, multiply that row by 1 -1 to make it positive. If an element in the right side of the matrix is 0 , 0, then ensure that the coefficient of the basic variable in that row is positive.

  • Choose the entering variable by observing the coefficient in row ( 0 ) (0) that is the most negative. Choose pivot rows by selecting the row that minimizes the ratio Element on right side of augmented matrix Coefficient of entering variable . \frac{\text{Element on right side of augmented matrix}}{\text{Coefficient of entering variable}}. The ratio must be non-negative, and the coefficient of the entering variable in the pivot row must be positive.

  • An optimal solution cannot contain any artificial variables. If row ( 0 ) (0) of the matrix contains no negative coefficients, and the solution contains an artificial variable, then the problem has no solution.

Vanessa is scheduling her employees for the upcoming week. When on the assembly line, Darren assembles 5 units per hour, and when on the packaging line, he packages 10 units per hour. Lori only works on the assembly line, and she assembles 4 units per hour. Darren's pay is $12 per hour and Lori's pay is $9 per hour

Vanessa needs to have at least 200 units assembled and packaged by the end of the week. She can assign each worker a maximum of 40 hours. How should Vanessa schedule her employees to minimize payroll?


This problem can be solved with simpler methods, but is solved here with the Big M method as a demonstration of how to deal with different types of constraints with the Big M method.

Let m d m_d and m l m_l be the number of hours that Darren and Lori work on the assembly line, respectively. Let p d p_d be the number of hours that Darren and Lori work on the packaging line, respectively. Each worker can work a maximum of 40 hours. This gives the constraints

m d + p d 40 m l 40. \begin{aligned} m_d+p_d &\le 40 \\ m_l &\le 40. \end{aligned}

Vanessa would not want to waste hours on packaging if there are no assembled units to package. Therefore, the number of units assembled should equal the number of units packaged. This can be expressed with the equation

5 m d + 4 m l = 10 p d . 5m_d+4m_l=10p_d.

The number of units assembled and packaged should be at least 200. This can be expressed with the constraint

10 p d 200 p d 20. \begin{aligned} 10p_d &\ge 200 \\ p_d &\ge 20. \end{aligned}

This gives the following system of constraints:

{ m d + p d 40 m l 40 p d 20 5 m d + 4 m l 10 p d = 0 m d , m l , p d 0. \begin{cases} \begin{array}{ccccccc} m_d & & & + & p_d & \le & 40 \\ & & m_l & & & \le & 40 \\ & & & & p_d & \ge & 20 \\ 5m_d & + & 4m_l & - & 10p_d & = & 0 \\ m_d, & & m_l, & & p_d & \ge & 0. \end{array} \end{cases}

The objective function is

f ( m d , m l , p d ) = 12 m d + 9 m l + 12 p d . f(m_d,m_l,p_d)=12m_d+9m_l+12p_d.

Converting the system of constraints and objective function to a simplex matrix,

[ 1 12 9 12 0 0 0 0 0 1 0 1 1 0 0 40 0 0 1 0 0 1 0 40 0 0 0 1 0 0 1 20 0 5 4 10 0 0 0 0 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccc|c} -1 & 12 & 9 & 12 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 1 & 1 & 0 & 0 & 40 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 40 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 20 \\ 0 & 5 & 4 & -10 & 0 & 0 & 0 & 0 \\ \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

The basic solution is currently infeasible:

m d = 0 , m l = 0 , p d = 0 , s 1 = 40 , s 2 = 40 , s 3 = 20. m_d=0, \quad m_l=0, \quad p_d=0, \quad s_1 = 40, \quad s_2=40, \quad s_3=-20.

Since s 3 s_3 has an infeasible value, the row that contains it requires an artificial variable. The equality constraint row also requires an artificial variable. These artificial variables are given the coefficient M M in row ( 0 ) : (0):

[ 1 12 9 12 0 0 0 M M 0 0 1 0 1 1 0 0 0 0 40 0 0 1 0 0 1 0 0 0 40 0 0 0 1 0 0 1 1 0 20 0 5 4 10 0 0 0 0 1 0 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 12 & 9 & 12 & 0 & 0 & 0 & M & M & 0 \\ 0 & 1 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 40 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 40 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 1 & 0 & 20 \\ 0 & 5 & 4 & -10 & 0 & 0 & 0 & 0 & 1 & 0 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

To move the solution into the feasible region, s 3 s_3 will be the leaving variable and a 1 a_1 will be the entering variable. The pivot will be performed with row ( 3 ) : (3):

[ 1 12 9 12 M 0 0 M 0 M 20 M 0 1 0 1 1 0 0 0 0 40 0 0 1 0 0 1 0 0 0 40 0 0 0 1 0 0 1 1 0 20 0 5 4 10 0 0 0 0 1 0 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 12 & 9 & 12-M & 0 & 0 & M & 0 & M & -20M \\ 0 & 1 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 40 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 40 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 1 & 0 & 20 \\ 0 & 5 & 4 & -10 & 0 & 0 & 0 & 0 & 1 & 0 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

The other artificial variable must be moved into the basic solution as well:

[ 1 12 5 M 9 4 M 12 + 9 M 0 0 M 0 0 20 M 0 1 0 1 1 0 0 0 0 40 0 0 1 0 0 1 0 0 0 40 0 0 0 1 0 0 1 1 0 20 0 5 4 10 0 0 0 0 1 0 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 12-5M & 9-4M & 12+9M & 0 & 0 & M & 0 & 0 & -20M \\ 0 & 1 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 40 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 40 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 1 & 0 & 20 \\ 0 & 5 & 4 & -10 & 0 & 0 & 0 & 0 & 1 & 0 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

Now the algorithm proceeds as the usual simplex algorithm. The goal is to eliminate the negative coefficients in row ( 0 ) . (0). Since M M is an arbitrarily large positive constant value, 12 5 M 12-5M is the most negative coefficient in row ( 0 ) . (0). Therefore, m d m_d will be the entering variable. The selection of the pivot row is slightly more challenging than the usual simplex algorithm.

Observe that every value in the right-hand side of the constraint rows is positive except for the value in row ( 4 ) . (4). In this row, the right-hand side is 0 , 0, and the basic variable contained in this row, a 2 , a_2, has a positive coefficient. It is important to maintain these two things:

  • values in the right-hand sides of the constraint rows are positive, or
  • if the value in the right hand side is 0 , 0, then the coefficient of the basic variable in that row is positive.

Maintaining this will ensure the correct selection of the pivot row. The pivot row is selected by choosing the row that minimizes the ratio of Element on right side of augmented matrix Coefficient of entering variable , \frac{\text{Element on right side of augmented matrix}}{\text{Coefficient of entering variable}}, provided that the coefficient of the entering variable is positive.

Thus, the minimum ratio for the entering variable is 0 5 \frac{0}{5} from row ( 4 ) . (4). This will be the pivot row:

[ 1 0 3 5 36 M 0 0 M 0 M 12 5 20 M 0 0 4 15 5 0 0 0 1 200 0 0 1 0 0 1 0 0 0 40 0 0 0 1 0 0 1 1 0 20 0 5 4 10 0 0 0 0 1 0 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 0 & -\frac{3}{5} & 36-M & 0 & 0 & M & 0 & M-\frac{12}{5} & -20M \\ 0 & 0 & -4 & 15 & 5 & 0 & 0 & 0 & -1 & 200 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 40 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 1 & 0 & 20 \\ 0 & 5 & 4 & -10 & 0 & 0 & 0 & 0 & 1 & 0 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

Now 36 M 36-M is the most negative coefficient in row ( 0 ) . (0). Thus, p d p_d will be the entering variable. Row ( 4 ) (4) will not be chosen as the pivot row again, as it has a negative coefficient for this variable. The row that minimizes the ratio is 200 15 \frac{200}{15} from row ( 1 ) : (1):

[ 1 0 9 4 15 M 0 1 3 M 12 0 M 0 14 15 M 20 3 M 480 0 0 4 15 5 0 0 0 1 200 0 0 1 0 0 1 0 0 0 40 0 0 4 0 5 0 15 15 1 100 0 15 4 0 10 0 0 0 1 400 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 0 & 9-\frac{4}{15}M & 0 & \frac{1}{3}M-12 & 0 & M & 0 & \frac{14}{15}M & -\frac{20}{3}M-480 \\ 0 & 0 & -4 & 15 & 5 & 0 & 0 & 0 & -1 & 200 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 40 \\ 0 & 0 & 4 & 0 & -5 & 0 & -15 & 15 & 1 & 100 \\ 0 & 15 & 4 & 0 & 10 & 0 & 0 & 0 & 1 & 400 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

Now 9 4 15 M 9-\frac{4}{15}M is the most negative coefficient in row ( 0 ) . (0). m l m_l will be the entering variable and the minimizing ratio is 100 4 \frac{100}{4} in row ( 3 ) : (3):

[ 1 0 0 0 3 4 0 135 4 M 135 4 M 9 4 705 0 0 0 1 0 0 1 1 0 20 0 0 0 0 5 4 15 15 1 60 0 0 4 0 5 0 15 15 1 100 0 1 0 0 1 0 1 1 0 20 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 0 & 0 & 0 & -\frac{3}{4} & 0 & \frac{135}{4} & M-\frac{135}{4} & M-\frac{9}{4} & -705 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 1 & 0 & 20 \\ 0 & 0 & 0 & 0 & 5 & 4 & 15 & -15 & -1 & 60 \\ 0 & 0 & 4 & 0 & -5 & 0 & -15 & 15 & 1 & 100 \\ 0 & 1 & 0 & 0 & 1 & 0 & 1 & -1 & 0 & 20 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

Now 3 4 -\frac{3}{4} is the most negative coefficient in row ( 0 ) . (0). s 1 s_1 will be the entering variable and the minimizing ratio is 60 5 \frac{60}{5} in row ( 2 ) : (2):

[ 1 0 0 0 0 3 5 36 M 36 M 12 5 696 0 0 0 1 0 0 1 1 0 20 0 0 0 0 5 4 15 15 1 60 0 0 1 0 0 1 0 0 0 40 0 5 0 0 0 4 10 10 1 40 ] . ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) \left[\begin{array}{ccccccccc|c} -1 & 0 & 0 & 0 & 0 & \frac{3}{5} & 36 & M-36 & M-\frac{12}{5} & -696 \\ 0 & 0 & 0 & 1 & 0 & 0 & -1 & 1 & 0 & 20 \\ 0 & 0 & 0 & 0 & 5 & 4 & 15 & -15 & -1 & 60 \\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 40 \\ 0 & 5 & 0 & 0 & 0 & -4 & -10 & 10 & 1 & 40 \end{array}\right]. \qquad \begin{array}{c} (0) \\ (1) \\ (2) \\ (3) \\ (4) \end{array}

With all coefficients in row ( 0 ) (0) positive and no artificial variables in the solution, the solution is optimal. The solution is

m d = 8 , m l = 40 , p d = 20 , z = 696. m_d=8, \quad m_l=40, \quad p_d=20, \quad z=696.

Vanessa should put Darren on the assembly line for 8 hours and on the packaging line for 20 hours. She should put Lori on the assembly line for 40 hours. This will put payroll at $696 for the week. _\square

How to Find Optimal Solution Linear Programming

Source: https://brilliant.org/wiki/linear-programming/