-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Let there be names in LP files #2811
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
base: master
Are you sure you want to change the base?
Conversation
Benchmarks that have improved:
Benchmarks that have stayed the same:
|
I think it's a great idea, but I am not too familiar with LP files so cannot comment on how useful this feature is. Also I am not sure users would want the variable names as columns every time (so maybe it should be a flag?).
that's ok, you can maybe merge the master branch onto this one once #2810 gets merged. |
This generally looks fine. There is a lot of demand for better naming in LP files so thanks for working on this. Starting by adding the functionality for one solver interface as you've done is a good approach. |
64720f7
to
4f459fa
Compare
I went ahead and rebased the PR to clean up the diff. Can you explain the workflow for .lp files? I'm trying to better design the APIs. |
afaik, cvxpy does not have a way to export .lp/.mps files natively and it uses the underlying solver for exporting the model. So the workflow depends on the underlying solver (gurobi, cplex, highs, etc.) but with highs, setting write_model_file option does the trick and the solver creates a model file with the variable names it received. If the following snippet sparked your comment, these lines were just a temporary hack, and I'll remove it now.
|
👍 Would @SteveDiamond any idea about this question:
I suspect it should be alright (at least for |
The solvers that support variable names (at least Cplex, Gurobi, Highs) create them internally even if the user doesn't set them as far as I know, like so: By passing the variable names from cvxpy space to the solver space ( Variable names (for that matter, constraint names) are not only useful for model exports but they help with warnings originating from the solver when they are set correctly:
|
@PTNobel was your commen about designing a general interface for model/solutions exports/writers? |
The |
4f459fa
to
4e96c7b
Compare
Sorry for the radio silence folks. I refactored and cleaned up the code. While at it:
if options.write_model_file:
# TODO: This part can be removed once the following HiGS PR is released:
# https://github.com/ERGO-Code/HiGHS/pull/2274
solver.writeModel(options.write_model_file)
And with that this PR is open for reviews 👀 |
Description
This is an unsolicited proposal. I am curious what you think and whether there is a cleaner and more automatic way to do this.
Long story short, this sets the variable/column names so that the exported LP file contains the original names set by the user.
This PR is actually on top of #2810 but I can't point at that branch as the source of that PR is not in cvxpy/cvxpy repo. Basically the first two commits are from #2810 and only the last commit is for this PR.
TODO:
Issue link (if applicable): N/A
Type of change
Contribution checklist