Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/Bridges/Constraint/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ end

_index(ci::MOI.ConstraintIndex) = ci.value

_index(ci::MOI.ConstraintIndex{MOI.VectorOfVariables}) = -ci.value

function Base.haskey(map::Map, ci::MOI.ConstraintIndex{F,S}) where {F,S}
return 1 <= _index(ci) <= length(map.bridges) &&
map.bridges[_index(ci)] !== nothing &&
Expand Down Expand Up @@ -118,10 +116,6 @@ end

_index(index, F, S) = MOI.ConstraintIndex{F,S}(index)

function _index(index, F::Type{MOI.VectorOfVariables}, S)
return MOI.ConstraintIndex{F,S}(-index)
end

function _iterate(map::Map, state = 1)
while state ≤ length(map.bridges) && map.bridges[state] === nothing
state += 1
Expand Down Expand Up @@ -235,7 +229,7 @@ Return the list of all keys that correspond to
function vector_of_variables_constraints(map::Map)
return MOI.Utilities.lazy_map(
MOI.ConstraintIndex{MOI.VectorOfVariables},
i -> MOI.ConstraintIndex{map.constraint_types[i]...}(-i),
i -> MOI.ConstraintIndex{map.constraint_types[i]...}(i),
Base.Iterators.Filter(
i ->
map.bridges[i] !== nothing &&
Expand Down Expand Up @@ -284,7 +278,7 @@ function _ensure_available(
::Type{S},
is_available::Function,
) where {S}
while !is_available(MOI.ConstraintIndex{F,S}(-length(map.bridges) - 1))
while !is_available(MOI.ConstraintIndex{F,S}(length(map.bridges) + 1))
push!(map.bridges, nothing)
push!(map.constraint_types, (F, S))
end
Expand Down
Loading
Loading