Bug in write_to_file for max-type problems in bilinear terms?

The max objective problem in JuMP when written to an mps file is converted to a min type objective by flipping the signs. However, it didn’t do it for the bilinear terms in the objective.

Am I missing something?

Following is the MWE

model = Model()

# Define variables x1 and x2
@variable(model, x1 >= 0)
@variable(model, x2 >= 0)

# Define the bilinear objective function
@objective(model, Max, 3*x1 + 2*x2 + x1 * x2)

# Add the constraints
@constraint(model, x1^2 + x2^2 <= 10)
@constraint(model, x1 + x2 >= 1)

# Write the model to an mps file
write_to_file(model, "my_model.mps")

# Read the saved model
new_model = read_from_file("my_model.mps")

print(model)

# Max x1*x2 + 3 x1 + 2 x2
# Subject to
# x1 + x2 >= 1.0
# x1² + x2² <= 10.0
# x1 >= 0.0
# x2 >= 0.0

print(new_model)

# Min x1*x2 - 3 x1 - 2 x2
# Subject to
# c1 : x1 + x2 >= 1.0
# c1_1 : x1² + x2² <= 10.0
# x1 >= 0.0
# x2 >= 0.0

Hi @anogaja, welcome to the forum :smile:

That’s a nasty bug that you have found. Sorry!

I’ll get it fixed ASAP: [FileFormats.MPS] quadratic maximization objectives · Issue #2538 · jump-dev/MathOptInterface.jl · GitHub

p.s., Thanks for the MWE. It was very helpful

2 Likes

This bug was my fault, and the oversight was pretty embarrassing: [FileFormats.MPS] fix MAX_SENSE with quadratic objective by odow · Pull Request #2539 · jump-dev/MathOptInterface.jl · GitHub

I’ll get a new release tagged in the next day or so.