Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Bridges/Objective/bridges/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ function supports_objective_function(
return isfinite(MOI.Bridges.Constraint.conversion_cost(F, G))
end

function MOI.Bridges.bridging_cost(
::Type{FunctionConversionBridge{T,F,G}},
) where {T,F,G}
return MOI.Bridges.Constraint.conversion_cost(F, G)
end

function MOI.Bridges.added_constrained_variable_types(
::Type{<:FunctionConversionBridge},
)
Expand Down
29 changes: 29 additions & 0 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,35 @@ function test_ToScalarQuadraticBridge_variable_bounds()
return
end

MOI.Utilities.@model(
ModelQuadObj,
(),
(),
(MOI.Nonnegatives, MOI.Zeros),
(),
(),
(),
(MOI.VectorOfVariables,),
(MOI.VectorAffineFunction,),
)

function MOI.supports(
::ModelQuadObj{T},
::MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}},
) where {T}
return false
end

function test_objective_conversion_cost(T = Float64)
model = ModelQuadObj{T}()
bridged = MOI.Bridges.full_bridge_optimizer(model, T)
x = MOI.add_variable(bridged)
MOI.set(bridged, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.set(bridged, MOI.ObjectiveFunction{typeof(x)}(), one(T) * x)
@test MOI.get(model, MOI.ObjectiveFunctionType()) == MOI.VariableIndex
return
end

end # module

TestBridgesLazyBridgeOptimizer.runtests()