Skip to content

Commit 934fdd1

Browse files
authored
[Utilities] add shift_constant for Parameter set (#2105)
1 parent d39cc85 commit 934fdd1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Utilities/sets.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ function shift_constant(set::MOI.Interval, offset)
6161
end
6262
supports_shift_constant(::Type{<:MOI.Interval}) = true
6363

64+
function shift_constant(set::MOI.Parameter, offset)
65+
return MOI.Parameter(MOI.constant(set) + offset)
66+
end
67+
supports_shift_constant(::Type{<:MOI.Parameter}) = true
68+
6469
"""
6570
ScalarLinearSet{T}
6671

test/Utilities/sets.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function test_shifts()
6161
@test MOIU.shift_constant(MOI.Interval(-2, 3), 1) == MOI.Interval(-1, 4)
6262
@test MOIU.supports_shift_constant(MOI.ZeroOne) == false
6363
@test_throws MethodError MOIU.shift_constant(MOI.ZeroOne(), 1.0)
64+
@test MOIU.supports_shift_constant(MOI.Parameter{Int})
65+
@test MOIU.shift_constant(MOI.Parameter(3), 1) == MOI.Parameter(4)
6466
return
6567
end
6668

0 commit comments

Comments
 (0)