-
Notifications
You must be signed in to change notification settings - Fork 526
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
Adjusting mps writer to the correct structure regarding integer variables declaration #2946
Adjusting mps writer to the correct structure regarding integer variables declaration #2946
Conversation
Hi @Raphael-D-F-Gomes - Please read the Contributing guide to see how to resolve the linting failure. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2946 +/- ##
==========================================
- Coverage 87.93% 87.93% -0.01%
==========================================
Files 769 769
Lines 89855 89871 +16
==========================================
+ Hits 79018 79030 +12
- Misses 10837 10841 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will ask you to write a small test for this. You can do a small baseline comparison test to ensure that behavior is correct.
I conducted research on MILP problems encoded in MPS files, but I struggled to locate suitable examples for creating tests that effectively validate the written MPS files. To rigorously assess this feature, I believe it's prudent to employ an alternative library for reading MPS files and verifying the linear problems. Would it be appropriate to utilize the "pulp" library for testing this particular feature? |
…o bugfix/adjust-mps-structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a number of changes that I think should be made.
In addition, which solver are you testing against? Or, more specifically, which solver requires the INTORG/INTEND markers? Looking into several solvers' documentation (Cplex, Mosek), they indicate that the markers are not necessary.
pyomo/repn/tests/mps/knapsack_problem_binary_variable_declaration.mps.baseline
Outdated
Show resolved
Hide resolved
… marker script // changing set_integer name to in_integer_section // adding marker to the end of integer section
…o bugfix/adjust-mps-structure
The requested modifications have been duly assessed and subsequently implemented. As outlined in the associated document, there exist two distinct methods for specifying integer variables within the MPS format: one involving markers (INTORG, INTEND) in the COLUMNS section, and the other employing types (BV, LI, SC, UI) in the BOUNDS section. It is noteworthy that the present iteration of Pyomo exclusively supports the latter method for declaring these variables. However, it is worth mentioning that certain solvers, such as lpsolve and the PuLP library, acknowledge the former approach when parsing MPS files. In light of enhancing the robustness of the Pyomo library, it is proposed to introduce the capability to include integer markers within the Pyomo MPS writer. Consequently, a flag has been introduced within the WriterFactory, enabling users to determine whether or not to include integer markers during the writing process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All comments from this review have been addressed
Fixes #1132
This pull request aims to fix the bug described in issue #1132. It involves making simple changes to the MPS writer structure to include the separation of discrete variables following the MPS format (https://lpsolve.sourceforge.net/5.0/mps-format.htm). It wasn't added tests to the bug fix, due to the lack of a mps reader function in the library.
Summary/Motivation:
I use the Pyomo library to write mixed-integer linear problems (MILP) to MPS files in my work. I noticed there was a problem in the model, as some binary variables were resulting in floating-point numbers. After researching the Pyomo MPS writer structure, I realized that the MPS file wasn't being exported correctly. So, I expanded the 'ProblemWriter_mps' class and adjusted it to the correct format. These changes worked for me, and I believe they could be a valuable contribution to the library. I created an example using PuLP to read the MPS file exported by Pyomo.
Consider the MILP problem:
With the corrent version of pyomo, we have the linear problem:
Note that the variable "x1" was suppose to be a integer. Now, that is the linear problem with the changes.
Changes proposed in this PR:
Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: