Reading JuMP model "lower bound already set"

Writing the model like this works

model = JuMP.Model(Clarabel.Optimizer)
*set variables and contraints*
write_to_file(model, "my_model.lp")

The model is also solved correctly by Clarabel. However, problems occur when I try to read it.

model = read_from_file("my_model.lp")
set_optimizer(model, Clarabel.Optimizer)
optimize!(model)

I get the error:

LoadError: MathOptInterface.LowerBoundAlreadySet{MathOptInterface.Interval{Float64}, MathOptInterface.GreaterThan{Float64}}: Cannot add `VariableIndex`-in-`MathOptInterface.GreaterThan{Float64}` constraint for variable MathOptInterface.VariableIndex(1) as a `VariableIndex`-in-`MathOptInterface.Interval{Float64}` constraint was already set for this variable and both constraints set a lower bound.

These 3 lines are all I’m doing in the read portion. Also, it throws the same error if I get rid of the second line.

1 Like

Can you provide a reproducible example? What is the contents of my_model.lp?

This is an embarrassing bug! Let me take a look.

julia> using JuMP

julia> model = Model();

julia> @variable(model, 0 <= x <= 1)
x

julia> write_to_file(model, "model.lp")

julia> read_from_file("model.lp")
ERROR: MathOptInterface.LowerBoundAlreadySet{MathOptInterface.Interval{Float64}, MathOptInterface.GreaterThan{Float64}}: Cannot add `VariableIndex`-in-`MathOptInterface.GreaterThan{Float64}` constraint for variable MathOptInterface.VariableIndex(1) as a `VariableIndex`-in-`MathOptInterface.Interval{Float64}` constraint was already set for this variable and both constraints set a lower bound.
Stacktrace:

Fixed in [FileFormats.LP] fix reading models with default bounds by odow · Pull Request #2121 · jump-dev/MathOptInterface.jl · GitHub.

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

Thanks, I tried using the package manager to add the branch you linked here

add MathOptInterface#od/fix-lp-read

This worked with no issues, but then I got the same error when running my code. Not sure if I am not doing it correctly or if it just hasn’t been updated.

Edit: I think the problem is that it hasn’t been updated properly in my package directory

Not sure if I am not doing it correctly or if it just hasn’t been updated.

After updating a package, you need to restart Julia for the change to take effect.

If it’s still a problem after that, can you provide a reproducible example?

Note that I merged the branch, so now you need ] add MathOptInterface#master.

Thanks, that worked!

1 Like

We’ll tag the fix in the next day or so. Just waiting for a couple of other things: Prep for v1.13.2 by odow · Pull Request #2122 · jump-dev/MathOptInterface.jl · GitHub.

Sorry for the bug! It turns out we could read and write LP files, but we couldn’t read some of our own LP files…

1 Like