Skip to content

Indices of SingleVariable constraints #570

@mlubin

Description

@mlubin

I propose that the constraint index of a single variable constraint should always match the index of the corresponding variable. That is,

x = add_variable(model)
ci = add_constraint(model, SingleVariable(x), ZeroOne())
# Then ci.value must equal x.value.

With this change, the question "Does x have a lower bound?" becomes is_valid(ConstraintIndex{SingleVariable, GreaterThan{Float64}}(x.value)), removing the need for JuMP to keep dictionaries (https://github.com/JuliaOpt/JuMP.jl/issues/1607#issuecomment-438219901).

It would also encourage implementations to store SingleVariable constraints in parallel arrays with the variables, which is the sane thing to do and will probably recover most of the performance from 0.18 (https://github.com/JuliaOpt/JuMP.jl/issues/1607).

This would disallow multiple SingleVariable constraints of the same type for a given variable, but that's an error on most solvers anyway.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions