-
Notifications
You must be signed in to change notification settings - Fork 5
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
Is it possible to read an MPS model? #25
Comments
It is not possible to get the problem from a file (MPS or LP). I totally get your usecase and why it would be helpful. If I want to add something to read a MPS file, I see 2 options:
Neither of these 2 options seem easy, and I don't think I will have time to do it. You would be very welcome to propose something though :) I'll try and check how feasible it would be to have solution 2 done, but I can't promise anything. |
I got some time tonight and implemented a MPS reader: I really like the idea of initializing a problem from any file, it would allow someone who generated such a file to benefit from the conflict finder. It is not fully tested and is probably inefficient at loading a file, but it seems to work well on the file I tested. You can try the branch feature/fromfile #26 : model = Cbc::Utils::Mps.new("path_to_file.mps").to_model
p = model.to_problem
p.solve #should be infeasible
p.proven_infeasible? # => true
p.find_conflict Tell me if that works for you! |
@gverger thanks a lot for the quick response and even quicker dev, I will try this afternoon. |
@gverger hello again, I am not sure what went wrong but on my Mac, cbs-wrapper cannot find the cbc library. I guess something is changed since this comment and Edit: I am actually not sure if the reason was |
Hello, thanks for the feedback. It seems that for mac (Apple Silicon) the homebrew directory has changed compared to mac Intel: see here |
I managed to get my setup working (sorry! my previous message didn't make that clear). I just read my infeasible model; however, I am getting the following error even though the objective function is defined and OBJ exists in the model
|
I think it should be like
EDIT: but it seems cbc ignores
|
It turns out If I remove OBJSENSE Regarding OBJSENSE incompatibility, I guess a solution would be reading the MPS file and if it has OBJSENSE and it is maximization*, setting the direction via *: At least Cplex, Gurobi and CBC are on the same page about the default objective function direction being minimization I believe. |
Yes, it seems I'll think about how I want it to be dealt with here. Thanks for reporting the issue, I don't work on this gem a lot since I don't use it anymore, but I am very happy to keep it alive :) I'll finalize the mps reader at some point and close this issue. |
Ah. The file is dumped by Gurobi solver 🤷
Wikipedia says that the objective function direction is not in the original
MPS format and different solvers implement it differently.
I guess supporting newline and whitespace possibilities would increase the
compatibility with different MPS flavours unless it is too much of a
hassle.
In any case, I will be turning that whitespace into a newline and then try
again tomorrow.
On Tue, 20 Sep 2022, 18:52 gverger, ***@***.***> wrote:
I think it should be like
OBJSENSE
MAX
ROWS
...
—
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZ226JBKKARU3DVOBOKHPTV7HTVPANCNFSM6AAAAAAQQCUENY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Halil Sen
linkedin.com/in/halilsen
|
It looks like CBC has a function for this purpose
Cbc_readMps
, a similar function in ruby-cbc would make it possible to callproblem.find_conflict
with an MPS file.The text was updated successfully, but these errors were encountered: