CPLEX (or other open source LP solver) with access to simplex tableau (matrix) each iteration?

81 Views Asked by At

Are there any open source Linear Programming solvers with access to simplex matrix each iteration? Is there some way to create it using some common solvers?

Consider the following example with CPLEX (note, that I also tried such an accessing from the API but failed for a lot of similar packages, e.g. SCIP, SageMath, GLPK, etc, all of these variants are acceptable).

import cplex
# Create a CPLEX model
model = cplex.Cplex()
# Set the objective function and constraints
model.variables.add(names=["x1", "x2", "x3"])
model.objective.set_sense(model.objective.sense.minimize)
model.objective.set_linear([("x1", 1.0), ("x2", 2.0), ("x3", 3.0)])
# Solve the LP problem
model.solve()
# Can one define some function to get the simplex tableau each iteration, i.e., for example:
def tableau_callback(context):
    if context.stage == cplex.callbacks.Context.stage.solution:
        # Some method to access the tableau information
        tableau = context.get_simplex_tableau()
        # Print the tableau
        print("Simplex Tableau:")
        for i, row in enumerate(tableau):
            print("Row {}: {}".format(i, row))
# such that one can force method to print (or even better to save) simplex tableaus
model.register_callback(tableau_callback,cplex.callbacks.Context.id.lp)

So, what is the correct way or is it possible to define such a function? After a detailed check of the packages documentation failed with finding access/calling of simplex tables.

0

There are 0 best solutions below