Linear Programming: Simplex Method and Potential Problems

This is part of the course “Optimization for Programmers”.

Image for post
Image for post
GitHub Repository with Source Code

In the previous part we implemented and tested the simplex method on a simple example, and it has executed without any problems. But in some linear programs, we can face troubles.

Unboundedness

In the first part, we have seen an example of the unbounded linear program. What will happen if we apply the simplex algorithm for it?

It will go forever since the can_be_imroved function will always return True. To make our algorithm more robust, we will detect unboundedness and throw the error. To do this, we need to go to the get_pivot_position function and check if all elements in restrictions are infinity.

Now if we run the simplex method for this linear program, we will receive this result.

Degeneracy

Degeneracy happens when the equations in a tableau do not permit any increment of the selected nonbasic variable, and it may actually be impossible to increase the objective function z in a single pivot step.

To see if there was a moment of degeneracy in our program we will render a chart showing how objective function value changed on each step. Let’s test it on an example from the previous part.

On this example, we can see that the program had two iterations and on each one objective function value increased. Now let’s run the simplex method for another program.

On this example, we can see that on first iteration objective function value made no gains. In general, there might be longer runs of degenerate pivot steps. It may even happen that some tableau is repeated in a sequence of degenerate pivot steps. It may even happen that some tableau is repeated in a sequence of degenerate pivot steps, and so the algorithm might pass through an infinite sequence of tableau without any progress. This phenomenon is called cycling.

Pivot Rules

A pivot rule is a rule for selecting the entering variable if there are several possibilities, which is usually the case(in our algorithm get_pivot_position determine this element).

The number of pivot steps needed for solving a linear program depends substantially on the pivot rule. The problem is, of course, that we do not know in advance which choices will be good in the long run. Let’s list some of the common pivot rules:

  • Largest coefficient. Choose an improving variable with the largest coefficient in the row of the objective function z.
  • Largest increase. Choose an improving variable that leads to the largest absolute improvement in z.
  • Steepest edge. This rule is a champion among pivot rules in practice. Choose and improving variable whose entering into the basis moves the current basic feasible solution in a direction closest to the direction of the vector c. Written by a formula, the ratio should be maximized.
Image for post
Image for post
  • Bland’s rule. Choose the improving variable with the smallest index, and if there are several possibilities for the leaving variable, also take the one with the smallest index.
  • Random edge. Select the entering variable uniformly at random among all improving variables. Randomized rules are also very important theoretically since they lead to the current best provable bounds for the number of pivot steps of the simplex method.

Cycling

It may happen that for some linear programs the simplex method cycles and theoretically, this is the only possibility of how it may fail. Such a situation is encountered very rarely in practice, if at all, and thus may implementations simply ignore the possibility of cycling. There are several ways that probably avoid cycling. One of them is the already mentioned Bland’s rule, but it is one of the slowest pivot rules and it is almost never used in practice.

Next part ->

Reach the next level of focus and productivity with increaser.org.

Image for post
Image for post
Increaser

Written by

Software engineer, creator of increaser.org. More at geekrodion.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store