@@ -659,14 +659,22 @@ function MOI.get(
659659end
660660
661661"""
662- π(v::Vector{Float64}, model::MOI.ModelLike, cones::ProductOfSets)
662+ π(
663+ v::Vector{T},
664+ model::MOI.ModelLike,
665+ cones::MOI.Utilities.RuntimeProductOfSets,
666+ ) where {T}
663667
664668Given a `model`, its `cones`, find the projection of the vectors `v`
665669of length equal to the number of rows in the conic form onto the cartesian
666670product of the cones corresponding to these rows.
667671For more info, refer to https://github.com/matbesancon/MathOptSetDistances.jl
668672"""
669- function π (v:: Vector{T} , model:: MOI.ModelLike , cones:: ProductOfSets ) where {T}
673+ function π (
674+ v:: Vector{T} ,
675+ model:: MOI.ModelLike ,
676+ cones:: MOI.Utilities.RuntimeProductOfSets ,
677+ ) where {T}
670678 return map_rows (model, cones, Flattened {T} ()) do ci, r
671679 return MOSD. projection_on_set (
672680 MOSD. DefaultDistance (),
@@ -677,14 +685,22 @@ function π(v::Vector{T}, model::MOI.ModelLike, cones::ProductOfSets) where {T}
677685end
678686
679687"""
680- Dπ(v::Vector{Float64}, model, cones::ProductOfSets)
688+ Dπ(
689+ v::Vector{T},
690+ model::MOI.ModelLike,
691+ cones::MOI.Utilities.RuntimeProductOfSets,
692+ ) where {T}
681693
682694Given a `model`, its `cones`, find the gradient of the projection of
683695the vectors `v` of length equal to the number of rows in the conic form onto the
684696cartesian product of the cones corresponding to these rows.
685697For more info, refer to https://github.com/matbesancon/MathOptSetDistances.jl
686698"""
687- function Dπ (v:: Vector{T} , model:: MOI.ModelLike , cones:: ProductOfSets ) where {T}
699+ function Dπ (
700+ v:: Vector{T} ,
701+ model:: MOI.ModelLike ,
702+ cones:: MOI.Utilities.RuntimeProductOfSets ,
703+ ) where {T}
688704 return BlockDiagonals. BlockDiagonal (
689705 map_rows (model, cones, Nested {Matrix{T}} ()) do ci, r
690706 return MOSD. projection_gradient_on_set (
@@ -716,7 +732,7 @@ function _map_rows!(
716732 f:: Function ,
717733 x:: Vector ,
718734 model,
719- cones:: ProductOfSets ,
735+ cones:: MOI.Utilities.RuntimeProductOfSets ,
720736 :: Type{F} ,
721737 :: Type{S} ,
722738 map_mode,
732748
733749# Allocate a vector for storing the output of `map_rows`.
734750function _allocate_rows (cones, :: Nested{T} ) where {T}
735- n = mapreduce (length, + , cones. rows; init = 0 )
751+ n = 0
752+ for (F, S) in MOI. get (cones, MOI. ListOfConstraintTypesPresent ())
753+ n += MOI. get (cones, MOI. NumberOfConstraints {F,S} ())
754+ end
736755 return Vector {T} (undef, n)
737756end
738757
@@ -741,7 +760,12 @@ function _allocate_rows(cones, ::Flattened{T}) where {T}
741760end
742761
743762"""
744- map_rows(f::Function, model, cones::ProductOfSets, map_mode::Union{Nested{T}, Flattened{T}})
763+ map_rows(
764+ f::Function,
765+ model,
766+ cones::MOI.Utilities.RuntimeProductOfSets,
767+ map_mode::Union{Nested{T},Flattened{T}},
768+ )
745769
746770Given a `model`, its `cones` and `map_mode` of type `Nested` (resp.
747771`Flattened`), return a `Vector{T}` of length equal to the number of cones (resp.
@@ -753,7 +777,7 @@ form.
753777function map_rows (
754778 f:: Function ,
755779 model,
756- cones:: ProductOfSets ,
780+ cones:: MOI.Utilities.RuntimeProductOfSets ,
757781 map_mode:: Union{Nested,Flattened} ,
758782)
759783 x = _allocate_rows (cones, map_mode)
0 commit comments