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

FileFormats/LP: read_from_file returns incorrect quadratic terms #2181

Closed
inversed-ru opened this issue May 30, 2023 · 3 comments · Fixed by #2182 or #2184
Closed

FileFormats/LP: read_from_file returns incorrect quadratic terms #2181

inversed-ru opened this issue May 30, 2023 · 3 comments · Fixed by #2182 or #2184
Assignees
Labels
Submodule: FileFormats About the FileFormats submodule Type: Bug

Comments

@inversed-ru
Copy link

I've been experimenting with JuMP using QPLIB instances and discovered that the known optima evaluate to incorrect objective values. It turns out that the off-diagonal quadratic terms are inflated by a factor of 2 when reading a model from an .lp file.

Test file:

Minimize
 obj: 1.0 b2 + 1.0 b3 + [ 1.0 b2 * b3 + 1.0 b2^2 ]/2

Binary
 b2 b3

End

Reading from JuMP:

julia> model = read_from_file("test.lp")
       JuMP.objective_function(model)
b2*b3 + 0.5 b2² + b2 + b3

Reading from MOI:

julia> filename = "test.lp"
       src = MOI.FileFormats.Model(; format = MOI.FileFormats.FORMAT_AUTOMATIC, filename = filename)
       MOI.read_from_file(src, filename)
       src.objective.scalar_quadratic
0.0 + 1.0 MOI.VariableIndex(1) + 1.0 MOI.VariableIndex(2) + 1.0 MOI.VariableIndex(1)*MOI.VariableIndex(2) + 0.5 MOI.VariableIndex(1)²
@odow
Copy link
Member

odow commented May 30, 2023

Ooops. Fix is here: #2182

@inversed-ru
Copy link
Author

I'm still getting incorrect QPLIB results. Newlines somehow affect the term coefficients.
Loaded correctly:

Minimize
 obj: [ 1.0 x2^2 + 1.0 x2 * x3 + 1.0 x2 * x4 ]/2
End

julia> JuMP.objective_function(model)
0.5 x2² + 0.5 x2*x3 + 0.5 x2*x4

Loaded incorrectly:

Minimize
 obj: [ 1.0 x2^2 + 1.0 x2 * x3 
 + 1.0 x2 * x4 ]/2
End

julia> JuMP.objective_function(model)
0.5 x2² + x2*x3 + 0.5 x2*x4

@odow odow reopened this May 31, 2023
@odow
Copy link
Member

odow commented May 31, 2023

I hate LP files

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