-
Couldn't load subscription status.
- Fork 96
Description
Interval constraints in file readers seem to be handled differently when reading back a model (c.f. #2121, #2351). This happens for LP and MPS files. It "works" with MOF, and is weird with NL. I'm not sure right now if making these consistent is even possible with the file formats (it's 05:18am at my place so this might be wrong in many ways...).
MWE:
using JuMP
m = Model()
@variable(m, 0 <= x <= 1)
has_lower_bound(x) # true
write_to_file(m, "test.lp")
m = read_from_file("test.lp")
x = all_variables(m)[1]
has_lower_bound(x) # falseThis may, e.g., lead to
has_lower_bound(x) || set_lower_bound(x, 0)
# ERROR: MathOptInterface.LowerBoundAlreadySet{MathOptInterface.Interval{Float64},
# MathOptInterface.GreaterThan{Float64}}: Cannot add `VariableIndex`-in-`MathOptInterface.GreaterThan{Float64}`
# constraint for variable MOI.VariableIndex(1) as a `VariableIndex`-in-`MathOptInterface.Interval{Float64}`
# constraint was already set for this variable and both constraints set a lower bound.Additional information:
A model looking like:
Subject to
x ≥ 0
x ≤ 1leads to:
LP:0 <= x <= 1in the bounds sectionMPS:LO 0andUP 1in the bounds section- a correct
NLfile (as far as I can decipher...)
One that is constructed using an explicit interval:
Subject to
x ∈ [0, 1]leads to: exactly the same files for LP, MPS, and NL as with the non-interval model
I can't really say if the last point with the interval
NLfile is a bug or intended... I kinda think that AMPL supports lower- and upper-bounds on non-linear constraints - there is a type for that (?) and the NL writer seems to handle these here. But... this format always confuses me, so this is just guess work. But if that were correct, then theNLfile is kinda inconsistent too.