Skip to content

Commit

Permalink
Remove unneeded _affine_coefficient (#3660)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jan 29, 2024
1 parent 8b72fff commit d7fd827
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
4 changes: 0 additions & 4 deletions src/aff_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ end

GenericAffExpr{C,V}() where {C,V} = zero(GenericAffExpr{C,V})

function _affine_coefficient(f::GenericAffExpr{C,V}, variable::V) where {C,V}
return get(f.terms, variable, zero(C))
end

"""
map_coefficients_inplace!(f::Function, a::GenericAffExpr)
Expand Down
11 changes: 3 additions & 8 deletions src/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -852,15 +852,10 @@ julia> normalized_coefficient(con, x)
```
"""
function normalized_coefficient(
con_ref::ConstraintRef{<:AbstractModel,MOI.ConstraintIndex{F,S}},
con_ref::ConstraintRef{<:AbstractModel,<:MOI.ConstraintIndex{F}},
variable,
) where {
S,
T,
F<:Union{MOI.ScalarAffineFunction{T},MOI.ScalarQuadraticFunction{T}},
}
con = constraint_object(con_ref)
return _affine_coefficient(con.func, variable)
) where {F<:Union{MOI.ScalarAffineFunction,MOI.ScalarQuadraticFunction}}
return coefficient(constraint_object(con_ref).func, variable)
end

"""
Expand Down
4 changes: 0 additions & 4 deletions src/quad_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ function _map_quad(
return GenericQuadExpr(aff, terms)
end

function _affine_coefficient(f::GenericQuadExpr{C,V}, variable::V) where {C,V}
return _affine_coefficient(f.aff, variable)
end

"""
constant(aff::GenericQuadExpr{C, V})::C
Expand Down

0 comments on commit d7fd827

Please sign in to comment.