jump-dev / HiGHS.jl

A Julia interface to the HiGHS solver
https://highs.dev
MIT License
97 stars 13 forks source link

quadratic objectives not getting copied? #148

Closed chriscoey closed 1 year ago

chriscoey commented 1 year ago

an MRE:

using MathOptInterface, HiGHS
const MOI = MathOptInterface

s = """
variables: x
minobjective: 1.0 * x * x
"""

h = MOI.instantiate(HiGHS.Optimizer, with_bridge_type = Float64)
MOIU.loadfromstring!(h, s)
println(h)

dest = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_LP)
MOI.copy_to(dest, h)
h2 = sprint(write, dest)
println(h2)

prints:

Minimize ScalarQuadraticFunction{Float64}:
 0.0 + 1.0 x²

Subject to:

minimize
obj: 
subject to
Bounds
x free
End

so the objective gets lost in the copy_to apparently. this does not occur when using other QP solvers instead of HiGHS, e.g. with DAQP it correctly prints:

Minimize ScalarQuadraticFunction{Float64}:
 0.0 + 1.0 x²

Subject to:

minimize
obj: [ 2 x ^ 2 ]/2
subject to
Bounds
x free
End

@odow

odow commented 1 year ago

Urgh. Another trivial bug. Fix incoming. It seems our file I/O leaves a lot to be desired... I guess most people don't use that part of the API.