Skip to content

Commit efbdbe7

Browse files
authored
[Utilities] simplify PenaltyRelaxation methods to remove ambiguities (#3017)
1 parent 560ef62 commit efbdbe7

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

‎src/Utilities/penalty_relaxation.jl‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,25 +365,14 @@ mutable struct PenaltyRelaxation{T}
365365
warn::Bool
366366

367367
function PenaltyRelaxation(
368-
p::Dict{MOI.ConstraintIndex,T};
368+
p::Dict{<:MOI.ConstraintIndex,T} = Dict{MOI.ConstraintIndex,Float64}();
369369
default::Union{Nothing,T} = one(T),
370370
warn::Bool = true,
371371
) where {T}
372-
return new{T}(default, p, warn)
372+
return new{T}(default, convert(Dict{MOI.ConstraintIndex,T}, p), warn)
373373
end
374374
end
375375

376-
function PenaltyRelaxation(; kwargs...)
377-
return PenaltyRelaxation(Dict{MOI.ConstraintIndex,Float64}(); kwargs...)
378-
end
379-
380-
function PenaltyRelaxation(
381-
d::Dict{<:MOI.ConstraintIndex,T};
382-
kwargs...,
383-
) where {T}
384-
return PenaltyRelaxation(convert(Dict{MOI.ConstraintIndex,T}, d); kwargs...)
385-
end
386-
387376
function MOI.modify(model::MOI.ModelLike, relax::PenaltyRelaxation{T}) where {T}
388377
map = Dict{MOI.ConstraintIndex,MOI.ScalarAffineFunction{T}}()
389378
penalty_expr = zero(MOI.ScalarAffineFunction{T})

0 commit comments

Comments
 (0)