Skip to content

Add LP Base.read! and tests #1713

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

Merged
merged 12 commits into from
Jan 24, 2022
Merged

Add LP Base.read! and tests #1713

merged 12 commits into from
Jan 24, 2022

Conversation

guilhermebodin
Copy link
Contributor

@guilhermebodin guilhermebodin commented Jan 6, 2022

This implementation is some copy from https://github.com/odow/LPWriter.jl/blob/master/src/reader.jl

There are still a few missing important features.

  • Obj constant
  • SOS variables

I will probably implement them next week.

I have some questions regarding the files we use as test sets. Do you have any suggestions?

Closes #1675

@odow
Copy link
Member

odow commented Jan 6, 2022

Just use my tests here? It includes some annoying files like https://github.com/odow/LPWriter.jl/blob/master/test/model1_tricky.lp

Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

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

@odow
Copy link
Member

odow commented Jan 8, 2022

@guilhermebodin what's the status of this? Do you want me to merge this as-is? Or are you going to benchmark the performance first?

@guilhermebodin
Copy link
Contributor Author

Hi @odow, since we already have a working version, I think it is worth benchmarking this solution and compare with a new one without the TempLPModel. After revisiting the code, I believe there are no significant design changes, so it should not be an extensive rewrite of the current PR.

@odow
Copy link
Member

odow commented Jan 9, 2022

Okay. So I'll hold off merging this then? Or do you want to work on that in a different PR?

@guilhermebodin
Copy link
Contributor Author

I was not clear in the previous message, let's hold this PR for a couple days.

@guilhermebodin
Copy link
Contributor Author

I have changed a few definitions using the file generated with this code

model = Model()
@variable(model, x[1:1_000] >= 0)
@constraint(model, con[i=1:200], sum(x) >= i)
@objective(model, Min, sum(x))

io = open("test_big.lp", "w")
write(
    io,
    model;
    format= MOI.FileFormats.FORMAT_LP
)

The modifications that made the biggest effect were in the function _tokenize and _get_variable_from_name .

Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

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

Looking better.

There's lots of untested error scenarios. We should add a bunch of malformed LP files to test the error conditions.

@guilhermebodin guilhermebodin requested a review from odow January 14, 2022 19:54
Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

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

This is an improvement on what we currently have so it's good by me. There are still a few opportunities to improve things (e.g., CacheLPModel has abstract fields, I don't know about the cost of try-catch, we could use more tests to improve coverage), but we can do them in separate, smaller PRs.

@guilhermebodin
Copy link
Contributor Author

Just realized there exists a function Base.tryparse https://docs.julialang.org/en/v1/base/numbers/#Base.tryparse. I can rewrite the PR using this function.
Let's hold this PR until Monday and I will try to fix these issues today.

@odow odow merged commit 9ef6efe into jump-dev:master Jan 24, 2022
@odow
Copy link
Member

odow commented Jan 24, 2022

Let's do improvements in a separate PR. This one is already quite big, and the functionality is stand-alone so there's no problem with merging it.

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

Successfully merging this pull request may close these issues.

Implement read! for LP file format
3 participants