Blog 1

Random Talk on Random Thoughts

Generate Simplex Tableaux With Octave

| Comments |

Background

It’s easy that one makes careless mistakes in a pivot operation. As a result, in test/exams in which calculators are allowed, I used a simple program to save time.

Answering linear programming question on Mathematics Stack Exchange, I used GNU Octave to do the tedious work.

Initial tableau

First write the LPP in standard form. I assume that $b$ and $c$ are column vectors.

  • c is the objective function.
  • A is the coefficient matrix of the constraints. (a.k.a technology matrix)
  • b is the RHS of the constraints.
  • T0 is the initial tableau.

My habit is to

  1. place $b$ on the RHS;
  2. place the objective function row at the bottom;
  3. omit the coefficient for $z$ since it’ll never be changed.
Generate the initial tableaulink
1
2
3
4
5
6
7
format rat;
c = [-1 2 -3 0 0 0]'; b = [11 0 8]';
A = [
1 -.5 1 1 0 0;
0 2 -1 0 1 0;
0 0 0 2 0 1];
T0 = [A b; -c' 0]

Current simplex tableau

The command basis = [3 2 6] is used to choose the decision variables $x_3,x_2$ and $x_6$ as the basis. Note that the order of the entries in the array basis is very important. By setting this array, I don’t need to repeat typing the same set of numbers for $B$ and $c_B$.

Generate the tableau from the current basislink
1
2
basis = [3 2 6]; B = A(:,basis); cB = c(basis);
T = [B\A B\b; cB'*(B\A)-c' cB'*(B\b)]

Inadequacies

Since I’m no longer in an LP course, I’m too lazy to write the code for finding the suitable elements for a pivot operation. We don’t need to re-develop something that has been well-developed.

Comments