Skip to content

Commit 44b63a6

Browse files
committed
Rename cost to bridging_cost
1 parent 961ef6b commit 44b63a6

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

docs/src/submodules/Bridges/reference.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ get(::Bridges.AbstractBridge, ::NumberOfConstraints)
2020
get(::Bridges.AbstractBridge, ::ListOfConstraintIndices)
2121
Bridges.needs_final_touch
2222
Bridges.final_touch
23-
Bridges.cost
23+
Bridges.bridging_cost
2424
```
2525

2626
## Constraint bridge API
@@ -74,7 +74,6 @@ Bridges.unbridged_variable_function
7474
Bridges.bridged_function
7575
Bridges.supports_constraint_bridges
7676
Bridges.recursive_model
77-
Bridges.bridging_cost
7877
```
7978

8079
## LazyBridgeOptimizer API

src/Bridges/Constraint/bridges/functionize.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ end
202202
conversion_cost(
203203
F::Type{<:MOI.AbstractFunction},
204204
G::Type{<:MOI.AbstractFunction},
205-
)::Int
205+
)::Union{Int,Nothing}
206206
207207
Return an `Int` returning the cost of converting any function of type `G`
208208
to a function of type `F` with `convert`.
@@ -273,7 +273,7 @@ function concrete_bridge_type(
273273
return FunctionConversionBridge{T,F,G,S}
274274
end
275275

276-
function MOI.Bridges.cost(
276+
function MOI.Bridges.bridging_cost(
277277
::Type{<:FunctionConversionBridge{T,F,G}},
278278
) where {T,F,G}
279279
return conversion_cost(F, G)

src/Bridges/bridge.jl

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,13 @@ If you implement this method, you must also implement
285285
function final_touch end
286286

287287
"""
288-
cost(BT::Type{<:AbstractBridge})::Int
288+
bridging_cost(BT::Type{<:AbstractBridge})::Int
289289
290-
Return the *cost* a bridge of type `BT`.
290+
Return the cost of adding a bridge of type `BT`.
291291
292-
This cost is used to compute the [`bridging_cost`](@ref).
293-
294-
There is a default implementation for any [`AbstractBridge`](@ref) returning
295-
`1` so this should only be implemented for bridges returning a distance
296-
different from `1`.
292+
The default implementation for any [`AbstractBridge`](@ref) returns `1`, so this
293+
method should only be implemented for bridges returning a cost different from
294+
`1`.
297295
298296
## Example
299297
@@ -302,22 +300,23 @@ constraints from a given function type to a function type to a wider one,
302300
we want it to have lower priority.
303301
304302
For example, we want to prioritize bridging a
305-
[`MOI.ScalarAffineFunction`](@ref)-in-[`MOI.LessThan`](@ref) constraint into
306-
a [`MOI.VectorAffineFunction`](@ref)-in-[`MOI.Nonnegatives`](@ref) constraint
307-
over bridging it to a [`MOI.ScalarQuadraticFunction`](@ref)-in-[`MOI.LessThan`](@ref) constraint.
303+
[`MOI.ScalarAffineFunction`](@ref)-in-[`MOI.LessThan`](@ref) constraint into a
304+
[`MOI.VectorAffineFunction`](@ref)-in-[`MOI.Nonnegatives`](@ref) constraint
305+
over bridging it to a [`MOI.ScalarQuadraticFunction`](@ref)-in-[`MOI.LessThan`](@ref)
306+
constraint.
308307
309308
For this reason, the [`Bridges.Constraint.FunctionConversionBridge`](@ref) is
310309
given a cost of `10`:
311310
312311
```jldoctest; setup=(import MathOptInterface as MOI)
313-
julia> T = Float64;
314-
315-
julia> F = MOI.ScalarQuadraticFunction{T};
312+
julia> F = MOI.ScalarQuadraticFunction{Float64};
316313
317-
julia> G = MOI.ScalarAffineFunction{T};
314+
julia> G = MOI.ScalarAffineFunction{Float64};
318315
319-
julia> MOI.Bridges.cost(MOI.Bridges.Constraint.FunctionConversionBridge{T,F,G})
316+
julia> MOI.Bridges.bridging_cost(
317+
MOI.Bridges.Constraint.FunctionConversionBridge{Float64,F,G},
318+
)
320319
10
321320
```
322321
"""
323-
cost(::Type{<:AbstractBridge}) = 1
322+
bridging_cost(::Type{<:AbstractBridge}) = 1

src/Bridges/lazy_bridge_optimizer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function _edge(b::LazyBridgeOptimizer, index::Int, BT::Type{<:AbstractBridge})
156156
index,
157157
_variable_nodes(b, BT),
158158
_constraint_nodes(b, BT),
159-
cost(BT),
159+
bridging_cost(BT),
160160
)
161161
end
162162

@@ -171,7 +171,7 @@ function _edge(
171171
_variable_nodes(b, BT),
172172
_constraint_nodes(b, BT),
173173
node(b, set_objective_function_type(BT)),
174-
cost(BT),
174+
bridging_cost(BT),
175175
)
176176
end
177177

0 commit comments

Comments
 (0)