Skip to content

Commit 90cd379

Browse files
authored
[Bridges] fix adjoint functions in SetDotInverseScalingBridge (#2264)
1 parent fdf2559 commit 90cd379

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/Bridges/Constraint/bridges/set_dot_scaling.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ function MOI.Bridges.adjoint_map_function(
179179
::Type{<:SetDotInverseScalingBridge{T,S}},
180180
func,
181181
) where {T,S}
182-
return _inverse_scale(T, S, func)
182+
return _scale(T, S, func)
183183
end
184184

185185
function MOI.Bridges.inverse_adjoint_map_function(
186186
::Type{<:SetDotInverseScalingBridge{T,S}},
187187
func,
188188
) where {T,S}
189-
return _scale(T, S, func)
189+
return _inverse_scale(T, S, func)
190190
end
191191

192192
# Since the set type is not defined, the default `MOI.supports_constraint`

test/Bridges/Constraint/set_dot_scaling.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,42 @@ function test_inverse_scaling_quadratic()
111111
return
112112
end
113113

114+
function test_set_dot_scaling_constraint_dual_start()
115+
inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
116+
model = MOI.Bridges.Constraint.SetDotScaling{Float64}(inner)
117+
x = MOI.add_variables(model, 3)
118+
c = MOI.add_constraint(
119+
model,
120+
MOI.VectorOfVariables(x),
121+
MOI.PositiveSemidefiniteConeTriangle(2),
122+
)
123+
MOI.set(model, MOI.ConstraintDualStart(), c, [1.0, 1.0, 1.0])
124+
@test MOI.get(model, MOI.ConstraintDualStart(), c) [1.0, 1.0, 1.0]
125+
F = MOI.VectorAffineFunction{Float64}
126+
S = MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}
127+
d = MOI.get(inner, MOI.ListOfConstraintIndices{F,S}())[1]
128+
@test MOI.get(inner, MOI.ConstraintDualStart(), d) [1.0, 2, 1.0]
129+
return
130+
end
131+
132+
function test_set_dot_inverse_scaling_constraint_dual_start()
133+
inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
134+
model = MOI.Bridges.Constraint.SetDotInverseScaling{Float64}(inner)
135+
x = MOI.add_variables(model, 3)
136+
c = MOI.add_constraint(
137+
model,
138+
MOI.VectorOfVariables(x),
139+
MOI.ScaledPositiveSemidefiniteConeTriangle(2),
140+
)
141+
MOI.set(model, MOI.ConstraintDualStart(), c, [1.0, 1.0, 1.0])
142+
@test MOI.get(model, MOI.ConstraintDualStart(), c) [1.0, 1.0, 1.0]
143+
F = MOI.VectorAffineFunction{Float64}
144+
S = MOI.PositiveSemidefiniteConeTriangle
145+
d = MOI.get(inner, MOI.ListOfConstraintIndices{F,S}())[1]
146+
@test MOI.get(inner, MOI.ConstraintDualStart(), d) [1.0, 1 / 2, 1.0]
147+
return
148+
end
149+
114150
end # module
115151

116152
TestConstraintSetDotScaling.runtests()

0 commit comments

Comments
 (0)