Skip to content

Commit 514c8b6

Browse files
authored
[Bridges.constraint] change conversion cost to 0.5 for ScalarAffineFunction
1 parent 9abcbea commit 514c8b6

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/Bridges/Constraint/bridges/AbstractFunctionConversionBridge.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,22 @@ function conversion_cost(
275275
::Type{<:MOI.ScalarAffineFunction},
276276
::Type{MOI.VariableIndex},
277277
)
278-
return 1.0
278+
# We want to favor bridges which convert VariableIndex or VectorOfVariables
279+
# into ScalarAffineFunction or VectorAffineFunction.
280+
#
281+
# This is most useful for conic solvers, which often support
282+
# VectorAffineFunction-in-S, but not VectorOfVariables-in-S.
283+
#
284+
# The value in this function controls the cost of the transformation
285+
# VectorOfVariables-in-S -> VectorAffineFunction-in-S. When we had the
286+
# previous cost of `1.0`, there might be an alternative bridge
287+
# VectorOfVariables-in-S -> VectorAffineFunction-in-S2 which also has a cost
288+
# of `1.0`, and so, depending on the order in which we choose bridges, we
289+
# might end up using a more complicated bridge that adds a different set
290+
# type to the model.
291+
#
292+
# This was a practical concern for Hypatia in MathOptInterface.jl#3062.
293+
return 0.5
279294
end
280295

281296
function conversion_cost(

0 commit comments

Comments
 (0)