Ask Your Question
2

values of variables from points in the polyhedron defined by a linear program

asked 2021-01-31 19:51:48 +0100

Max Alekseyev gravatar image

updated 2021-03-01 00:32:58 +0100

SageMath provides a function for constructing the polyhedron defined by a linear program. Given a point in such a polyhedron, how can I tell which coordinate of the point corresponds to which variable of the linear program?

ADDED: The documentation suggests that "the polyhedron is built from the variables stored by the LP solver" and that "they usually match the ones created explicitly when defining the LP", except possibly for Gurobi solver. So, the question seems to reduce to finding the order number of each variable in LP (or an accurate bookkeeping of their creations). Things are even more fuzzy for Gurobi, which one of the best solvers out there.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-10-10 18:36:33 +0100

Max Alekseyev gravatar image

updated 2024-10-10 18:54:49 +0100

It seems that the order number (backend index) of a MIP variable can be obtained from its string representation as follows:

def get_backend_index(mip_var):
    return int(str(mip_var)[2:])

I've added a request for an "official" way to get this index at https://github.com/sagemath/sage/issu...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-01-31 19:51:48 +0100

Seen: 322 times

Last updated: Oct 10