Forum Discussion

FICO's avatar
FICO
Community Manager
6 years ago

Additional usage info for btran and ftran?

Hi!

I'm using xpress for a 33-variable linear programming problem in python. I'm having some issues, though, figuring out how to properly use btran and ftran in my code.

I'm currently using btran to get the optimal simplex tableau for my constraints, but I'm having trouble understanding how to acquire the same for my variables using ftran. I'm not sure if I'm just misunderstanding the documentation (very possible!) but I'm getting essentially the same matrix back from both functions. If I could get an example of how to use both, I think that would help a ton!

Just to show how I'm currently getting the constraint tableau, the code I have for using btran is:

import numpy as np
constraints = problem.getConstraint()
n = len(constraints)
tableau = np.zeros((n, n))
for i in range(n):
    y = [0]*n
    y[i] = 1
    problem.btran(y)
    tableau[i, :] = y

I would appreciate any help/direction! Thank you!

1 Reply

  • FICO's avatar
    FICO
    Community Manager

    Hi Leigh,

    Let's consider an LP in standard form: min cT x, A x = b, x >= 0. After using problem.solve(), A is partitioned into a basic part A_B and a nonbasic part A_N.

    FTRAN is just a transposed version of BTRAN in the following sense. FTRAN(z) solves (finds y) such that A_B y = z. If z = e_i, the i'th unit vector, the solution y corresponds to the i'th column of A_B-1, the inverse of the basis matrix A_B. In contrast, BTRAN(z) solves A_BT y = z, such that for z = e_i, you obtain the i'th row vector of A_B-1.

    Therefore, your code above exits with matrix tableau containing A_B-1. You could also use problem.ftran(y), in which case you would have to transpose the last line: tableau[ i , : ] becomes tableau[ :, i] in that case.

    Note that both methods require an array of length problem.attributes.rows as input. There is no FTRAN operation on the variables (columns) of the problem.

    This being said, it would be good to understand better what you are trying to achieve. The optimal simplex tableau is a table that holds information on the matrix, the right hand side, and the (reduced) cost vector, but not the variables.

    All this information, you can query more easily than by computing the linear algebra by hand: