Dualization.jl icon indicating copy to clipboard operation
Dualization.jl copied to clipboard

Request to add support for PSD constraints in square form in future release

Open bcdandurand opened this issue 5 years ago • 6 comments

In applying Dualization in our project, I found that support is provided for PSD constraints in triangular form but not in square form. May I request that support for PSD in square form also be provided in a future release? If this is feasible?

I can use Dualization for our purposes still, but I need to modify my local version of other third party Julia packages to post PSD constraints in triangular form rather than square form, and so my rationale for this request is for the sake of minimizing the potential need to modify third party code in the future. Thank you.

bcdandurand avatar Jan 09 '20 15:01 bcdandurand

You can use a bridge layer on top of Dualization (e.g. with MOI.Bridges.full_bridge_optimizer) so that the square PSD constraint is automatically transformed to a triangle PSD one. Supporting square PSD cones natively in Dualization would require defining its dual set (see https://github.com/JuliaOpt/MathOptInterface.jl/blob/2a8603407fdabce4f322cd90fe646f3a0efdc6a6/src/Bridges/Constraint/square.jl#L1-L35 for a description of it)

blegat avatar Jan 09 '20 20:01 blegat

The use of the MOI bridge interface seems to be sensible. I'm attempting the use of the bridge interface, but I need time to learn how to apply this with Dualization if there aren't examples already. I need to return to other tasks now, but at some point, I may post what I'm attempting to do.

bcdandurand avatar Jan 10 '20 17:01 bcdandurand

I am tagging the issue as documentation, Try to write a small script with a PSD square and dualize it using bridges

guilhermebodin avatar Feb 04 '20 13:02 guilhermebodin

Using bridges outside a DualizationOptimizer may not work as expected because of https://github.com/JuliaOpt/Dualization.jl/issues/77. IIRC, we use a bridge layer inside the DualizationOptimizer because when the optimizer did not support free variables, it meant the DualizationOptimizer did not support Zeros constraints but we were missing a Zeros bridge. Now that it was added in https://github.com/JuliaOpt/MathOptInterface.jl/pull/1005, we should not add a bridge layer inside DualizationOptimizer anymore. The user should add a bridge layer on top of the DualizationOptimizer. This was made easier with MOI.instantiate(::MOI.AbstractOptimizer, with_bridge_type=Float64) added in https://github.com/JuliaOpt/MathOptInterface.jl/pull/1008

blegat avatar Feb 04 '20 13:02 blegat

I found something like the following function to provide a dualizable model, where the input jump_model has a square PSD constraint.

function DualizeModel(jump_model)
    dualizable_model = MOI.Utilities.Model{Float64}()
    bridged_model = MOI.Bridges.Constraint.Square{Float64}(dualizable_model)
    MOI.copy_to(bridged_model,backend(jump_model))
    dualized_problem = dualize(dualizable_model)
    dualized_model = JuMP.Model()
    MOI.copy_to(dualized_model,dualized_problem.dual_model)
    return dualized_model
end

bcdandurand avatar Feb 04 '20 16:02 bcdandurand

That's indeed a valid workaround. MOI.Bridges.Constraint.Square{Float64} is a Bridges.Constraint.SingleBridgeOptimizer. This bridge optimizer bridges any constraint that can be bridged independently on whether the inner model supports it.

blegat avatar Feb 05 '20 09:02 blegat