Skip to content
DeepForgeby svx
All problems
HardOptimizationop-194

Simplex Pivot

Problem

Perform a Gauss-Jordan pivot on a simplex tableau.

Divide the pivot row by the pivot element tableau[row][col], then eliminate the pivot column from every other row by subtracting a multiple of the normalized pivot row. Return the new tableau as a list of rows.

Hint

The pivot column becomes a unit vector with a 1 in the pivot row.

Test cases

case 1
in: [[[1,1,1,4],[2,1,0,5],[-3,-2,0,0]],0,0]
expected: [[1,1,1,4],[0,-1,-2,-3],[0,1,3,12]]
case 2
in: [[[2,1,5],[1,3,6],[-1,-2,0]],1,0]
expected: [[0,-5,-7],[1,3,6],[0,1,6]]
case 3
in: [[[2,1,4],[1,1,3],[-1,-1,0]],0,1]
expected: [[2,1,4],[-1,0,-1],[1,0,4]]
Starter codePython
def simplex_pivot(tableau, row, col):
    # Your code here
    pass

3 test cases · run your code against them in the editor