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

Export variable and constraint names in LP files #391

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

olivierjuan
Copy link

@olivierjuan olivierjuan commented Dec 6, 2024

A small modification to export LP files with variable and constraint names.
Gurobi is able to read the generated LP files.

This modification does not apply to polar export.
I'm ready to improve the code if needed

This is related to issue #157

@olivierjuan olivierjuan changed the title Export variable and constraints names in LP files Export variable and constraint names in LP files Dec 6, 2024
@olivierjuan
Copy link
Author

I'll fix the tests first

@olivierjuan
Copy link
Author

I added a new io_api type called "lp-debug" to write lp file with variable and constraint names. I don't know if you will like that approach. I can replace it by an extra argument to the function to_file instead if you prefer.

Copy link
Collaborator

@FabianHofmann FabianHofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty cool @olivierjuan! Thank you for your contribution! I would suggest to have an extra argument for this and raise an error if a non-supported io-api is passed. Could you check whether this has any impact on the regular lp file writing?

@olivierjuan
Copy link
Author

Ok. I'm on it

@olivierjuan
Copy link
Author

olivierjuan commented Dec 13, 2024

@FabianHofmann , I extended it to lp-polars too, and added tests to check with and without variable names.
A variable name is now passed with the following pattern '{name}#{index}' to maintain the logic of extracting the index of the variable from the name. (same for the constraint). This makes the export compatible with solving.
It seems to me that it is now feasible to extend it to direct io_api. Do you want me to try it ?
BTW, that will add it also to MPS file.

olivierjuan and others added 3 commits December 13, 2024 16:10
…ompatible with variables names. MindOpt untested since my license is not functioning
@olivierjuan
Copy link
Author

Well I did it in the end.
So the variable and constraint names can be transfered to the solver either for lp, lp-polars, mps or direct api.

Only CBC and GLPK are incompatible (if trying to solve with_names=True and with one of these solvers, a warning will be printed and the option will be deactivated).
I couldn't test it with mindopt due to issues with my mindopt license. But all other solvers work fine

@FabianHofmann
Copy link
Collaborator

Wow, well done @olivierjuan ! I promise to have a look soon and then we can merge it 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants