Closed LebedevRI closed 1 month ago
MWE:
julia> using JuMP
julia> model = Model() ;
julia> @variable(model, x);
julia> @constraint(model, c[i=1:2], x <= i);
julia> delete(model, c[1])
julia> c
2-element Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.LessThan{Float64}}, ScalarShape}}:
Error showing value of type Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.LessThan{Float64}}, ScalarShape}}:
ERROR: The index MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.LessThan{Float64}}(1) is invalid. Note that an index becomes invalid after it has been deleted.
Stacktrace:
[1] throw_if_not_valid
@LebedevRI I will commend you. You somehow keep finding the rough edges of JuMP!
@odow thank you!
@LebedevRI I will commend you. You somehow keep finding the rough edges of JuMP!
Thank you, i guess? It's a bit of a curse :[ I would very much prefer to never encounter bugs anywhere instead, but the exact opposite happens in practice...
At least, i would hope this quirk should be documented, although since the model is still printable, it seems like a bug, especially since it is recommended/ to print separate constraints for debugging.