Skip to content

Commit

Permalink
[Bridges] fix adjoint functions in SetDotInverseScalingBridge (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Sep 7, 2023
1 parent fdf2559 commit 90cd379
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/bridges/set_dot_scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ function MOI.Bridges.adjoint_map_function(
::Type{<:SetDotInverseScalingBridge{T,S}},
func,
) where {T,S}
return _inverse_scale(T, S, func)
return _scale(T, S, func)
end

function MOI.Bridges.inverse_adjoint_map_function(
::Type{<:SetDotInverseScalingBridge{T,S}},
func,
) where {T,S}
return _scale(T, S, func)
return _inverse_scale(T, S, func)
end

# Since the set type is not defined, the default `MOI.supports_constraint`
Expand Down
36 changes: 36 additions & 0 deletions test/Bridges/Constraint/set_dot_scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,42 @@ function test_inverse_scaling_quadratic()
return
end

function test_set_dot_scaling_constraint_dual_start()
inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
model = MOI.Bridges.Constraint.SetDotScaling{Float64}(inner)
x = MOI.add_variables(model, 3)
c = MOI.add_constraint(
model,
MOI.VectorOfVariables(x),
MOI.PositiveSemidefiniteConeTriangle(2),
)
MOI.set(model, MOI.ConstraintDualStart(), c, [1.0, 1.0, 1.0])
@test MOI.get(model, MOI.ConstraintDualStart(), c) [1.0, 1.0, 1.0]
F = MOI.VectorAffineFunction{Float64}
S = MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}
d = MOI.get(inner, MOI.ListOfConstraintIndices{F,S}())[1]
@test MOI.get(inner, MOI.ConstraintDualStart(), d) [1.0, 2, 1.0]
return
end

function test_set_dot_inverse_scaling_constraint_dual_start()
inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
model = MOI.Bridges.Constraint.SetDotInverseScaling{Float64}(inner)
x = MOI.add_variables(model, 3)
c = MOI.add_constraint(
model,
MOI.VectorOfVariables(x),
MOI.ScaledPositiveSemidefiniteConeTriangle(2),
)
MOI.set(model, MOI.ConstraintDualStart(), c, [1.0, 1.0, 1.0])
@test MOI.get(model, MOI.ConstraintDualStart(), c) [1.0, 1.0, 1.0]
F = MOI.VectorAffineFunction{Float64}
S = MOI.PositiveSemidefiniteConeTriangle
d = MOI.get(inner, MOI.ListOfConstraintIndices{F,S}())[1]
@test MOI.get(inner, MOI.ConstraintDualStart(), d) [1.0, 1 / 2, 1.0]
return
end

end # module

TestConstraintSetDotScaling.runtests()

0 comments on commit 90cd379

Please sign in to comment.