Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide access to the backend index for a MIPVariable #38799

Open
1 task done
maxale opened this issue Oct 10, 2024 · 0 comments
Open
1 task done

Provide access to the backend index for a MIPVariable #38799

maxale opened this issue Oct 10, 2024 · 0 comments

Comments

@maxale
Copy link
Contributor

maxale commented Oct 10, 2024

Problem Description

Documentation says:

The underlying MILP backends always work with matrices where each column corresponds to a linear variable. The variable corresponding to the i-th column (counting from 0) is displayed as x_i.
MixedIntegerLinearProgram maintains a dynamic mapping from the arbitrary keys indexing the components of MIPVariable objects to the backend variables (indexed by nonnegative integers).

However, Sage does not provide a way to get the corresponding index of the backend variable. These indices are important when it comes to conversion of a MILP instance into a polyhedron since they indicate which MIP variables correspond to which coordinates in the resulting polyhedron.

When the requested method is added, it should be mentioned in the documentation for the .polyhedron() method.

Proposed Solution

It seems possible to obtain the backend index from the string representation (as x_i) of a MIP variable as follows:

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

but internally there should be a more direct way to get this number.

Alternatives Considered

N/A

Additional Information

No response

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant