Skip to content

Commit 87a3c9f

Browse files
committed
Update
1 parent a29fe7c commit 87a3c9f

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/Utilities/penalty_relaxation.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ end
142142
PenaltyRelaxation(
143143
penalties = Dict{MOI.ConstraintIndex,Float64}();
144144
default::Union{Nothing,T} = 1.0,
145-
no_warning_skip_constraint::Bool = false,
145+
warn::Bool = true,
146146
)
147147
148148
A problem modifier that, when passed to [`MOI.modify`](@ref), destructively
@@ -189,8 +189,7 @@ cannot be modified in-place.
189189
To modify variable bounds, rewrite them as linear constraints.
190190
191191
If a constraint type can not be modified, a warning is logged and the
192-
constraint is skipped. This can be disabled by setting
193-
`no_warning_skip_constraint = true`.
192+
constraint is skipped. This can be disabled by setting `warn = false`.
194193
195194
## Example
196195
@@ -247,14 +246,14 @@ true
247246
mutable struct PenaltyRelaxation{T}
248247
default::Union{Nothing,T}
249248
penalties::Dict{MOI.ConstraintIndex,T}
250-
no_warning_skip_constraint::Bool
249+
warn::Bool
251250

252251
function PenaltyRelaxation(
253252
p::Dict{MOI.ConstraintIndex,T};
254253
default::Union{Nothing,T} = one(T),
255-
no_warning_skip_constraint::Bool = false,
254+
warn::Bool = true,
256255
) where {T}
257-
return new{T}(default, p, no_warning_skip_constraint)
256+
return new{T}(default, p, warn)
258257
end
259258
end
260259

@@ -293,7 +292,7 @@ function _modify_penalty_relaxation(
293292
map[ci] = MOI.modify(model, ci, ScalarPenaltyRelaxation(penalty))
294293
catch err
295294
if err isa MethodError && err.f == MOI.modify
296-
if !relax.no_warning_skip_constraint
295+
if relax.warn
297296
@warn(
298297
"Skipping PenaltyRelaxation for ConstraintIndex{$F,$S}"
299298
)

test/Utilities/penalty_relaxation.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ function test_relax_no_warn()
8585
model = MOI.Utilities.Model{Float64}()
8686
MOI.Utilities.loadfromstring!(model, src_str)
8787
@test_logs(
88-
MOI.modify(
89-
model,
90-
MOI.Utilities.PenaltyRelaxation(no_warning_skip_constraint = true),
91-
),
88+
MOI.modify(model, MOI.Utilities.PenaltyRelaxation(; warn = false)),
9289
)
9390
dest = MOI.Utilities.Model{Float64}()
9491
MOI.Utilities.loadfromstring!(dest, relaxed_str)

0 commit comments

Comments
 (0)