Skip to content

Inconsistent "interval" constraints when reading models from file #2547

@sstroemer

Description

@sstroemer

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)              # false

This 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 ≤ 1

leads to:

  • LP: 0 <= x <= 1 in the bounds section
  • MPS: LO 0 and UP 1 in the bounds section
  • a correct NL file (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 NL file 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 the NL file is kinda inconsistent too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions