Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jun 20, 2024
1 parent d5752d9 commit 2104387
Showing 1 changed file with 0 additions and 79 deletions.
79 changes: 0 additions & 79 deletions src/Utilities/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,85 +154,6 @@ function _pass_attribute(
return
end

"""
_try_constrain_variables_on_creation(
dest::MOI.ModelLike,
src::MOI.ModelLike,
index_map::IndexMap,
::Type{S},
) where {S<:MOI.AbstractVectorSet}
Copy the constraints of type `MOI.VectorOfVariables`-in-`S` from the model `src`
to the model `dest` and fill `index_map` accordingly. The copy is only done when
the variables to be copied are not already keys of `index_map`.
It returns a list of the constraints that were not added.
"""
function _try_constrain_variables_on_creation(
dest::MOI.ModelLike,
src::MOI.ModelLike,
index_map::IndexMap,
::Type{S},
) where {S<:MOI.AbstractVectorSet}
not_added = MOI.ConstraintIndex{MOI.VectorOfVariables,S}[]
for ci_src in
MOI.get(src, MOI.ListOfConstraintIndices{MOI.VectorOfVariables,S}())
f_src = MOI.get(src, MOI.ConstraintFunction(), ci_src)
if !allunique(f_src.variables)
# Can't add it because there are duplicate variables
push!(not_added, ci_src)
elseif any(vi -> haskey(index_map, vi), f_src.variables)
# Can't add it because it contains a variable previously added
push!(not_added, ci_src)
else
set = MOI.get(src, MOI.ConstraintSet(), ci_src)::S
vis_dest, ci_dest = MOI.add_constrained_variables(dest, set)
index_map[ci_src] = ci_dest
for (vi_src, vi_dest) in zip(f_src.variables, vis_dest)
index_map[vi_src] = vi_dest
end
end
end
return not_added
end

"""
_try_constrain_variables_on_creation(
dest::MOI.ModelLike,
src::MOI.ModelLike,
index_map::IndexMap,
::Type{S},
) where {S<:MOI.AbstractScalarSet}
Copy the constraints of type `MOI.VariableIndex`-in-`S` from the model `src` to
the model `dest` and fill `index_map` accordingly. The copy is only done when the
variables to be copied are not already keys of `index_map`.
It returns a list of the constraints that were not added.
"""
function _try_constrain_variables_on_creation(
dest::MOI.ModelLike,
src::MOI.ModelLike,
index_map::IndexMap,
::Type{S},
) where {S<:MOI.AbstractScalarSet}
not_added = MOI.ConstraintIndex{MOI.VariableIndex,S}[]
for ci_src in
MOI.get(src, MOI.ListOfConstraintIndices{MOI.VariableIndex,S}())
f_src = MOI.get(src, MOI.ConstraintFunction(), ci_src)
if haskey(index_map, f_src)
# Can't add it because it contains a variable previously added
push!(not_added, ci_src)
else
set = MOI.get(src, MOI.ConstraintSet(), ci_src)::S
vi_dest, ci_dest = MOI.add_constrained_variable(dest, set)
index_map[ci_src] = ci_dest
index_map[f_src] = vi_dest
end
end
return not_added
end

"""
_copy_constraints(
dest::MOI.ModelLike,
Expand Down

0 comments on commit 2104387

Please sign in to comment.