Skip to content

FileFormats/LP: read_from_file returns incorrect quadratic terms  #2181

Description

@inversed-ru

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)²

Activity

  1. added
    Submodule: FileFormats
    on May 30, 2023
  2. self-assigned this
    on May 30, 2023
  3. odow commented on May 30, 2023

    @odow
    Member

    Ooops. Fix is here: #2182

  4. inversed-ru commented on May 31, 2023

    @inversed-ru
    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
    
  5. reopened this on May 31, 2023
  6. odow commented on May 31, 2023

    @odow
    Member

    I hate LP files

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

Metadata

Metadata

Assignees

Labels

Submodule: FileFormatsType: Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions