Skip to content

Commit 6eb9f53

Browse files
blegatulfworsoe
andauthored
add geomeancone support (#213)
* add geomeancone support * add geomean cone reorder * Fix format --------- Co-authored-by: ulfw <ulf.worsoe@mosek.com>
1 parent 814de70 commit 6eb9f53

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

src/LinkedInts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function allocate_block(s::LinkedInts, N::Int, id::Integer)
125125
ptre = s.free_ptr
126126
# ptre is the last index
127127
ptrb = ptre
128-
for i in 1:N-1
128+
for i in 1:(N-1)
129129
s.back[ptrb] = id
130130
ptrb = s.prev[ptrb]
131131
end

src/attributes.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ function MOI.get(model::Optimizer, ::MOI.ListOfConstraintTypesPresent)
169169
MOI.ExponentialCone,
170170
MOI.DualExponentialCone,
171171
MOI.PositiveSemidefiniteConeTriangle,
172+
MOI.GeometricMeanCone,
172173
MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle},
173174
)
174175
if MOI.get(model, MOI.NumberOfConstraints{F,S}()) > 0
@@ -424,6 +425,34 @@ function MOI.get(
424425
return _dual_scale(m) * dual
425426
end
426427

428+
function reorder(i::Integer, set::MOI.GeometricMeanCone, moi_to_mosek::Bool)
429+
if moi_to_mosek
430+
if i == 1
431+
MOI.dimension(set)
432+
else
433+
i - 1
434+
end
435+
else
436+
if i < MOI.dimension(set)
437+
i + 1
438+
else
439+
1
440+
end
441+
end
442+
end
443+
444+
function reorder(
445+
x::AbstractVector,
446+
::Type{MOI.GeometricMeanCone},
447+
moi_to_mosek::Bool,
448+
)
449+
if moi_to_mosek
450+
[x[2:length(x)]..., x[1]]
451+
else
452+
[x[length(x)], x[1:(length(x)-1)]...]
453+
end
454+
end
455+
427456
# The dual or primal of an SDP variable block is returned in lower triangular
428457
# form but the constraint is in upper triangular form.
429458
function reorder(

src/constraint.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const VectorConeDomain = Union{
2323
MOI.DualPowerCone,
2424
MOI.ExponentialCone,
2525
MOI.DualExponentialCone,
26+
MOI.GeometricMeanCone,
2627
MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle},
2728
}
2829

@@ -179,6 +180,8 @@ function _get_bound(
179180
return MOI.SecondOrderCone(solsize(m, ci))
180181
elseif dt == Mosek.MSK_DOMAIN_RQUADRATIC_CONE
181182
return MOI.RotatedSecondOrderCone(solsize(m, ci))
183+
elseif dt == Mosek.MSK_DOMAIN_PRIMAL_GEO_MEAN_CONE
184+
return MOI.GeometricMeanCone(solsize(m, ci))
182185
elseif dt == Mosek.MSK_DOMAIN_PRIMAL_EXP_CONE
183186
return MOI.ExponentialCone()
184187
elseif dt == Mosek.MSK_DOMAIN_DUAL_EXP_CONE
@@ -384,6 +387,10 @@ function _append_cone_domain(
384387
return Mosek.appendrquadraticconedomain(t, n)
385388
end
386389

390+
function _append_cone_domain(t::Mosek.Task, n::Int, ::MOI.GeometricMeanCone)
391+
return Mosek.appendprimalgeomeanconedomain(t, n)
392+
end
393+
387394
function _append_cone_domain(
388395
t::Mosek.Task,
389396
n::Int,
@@ -918,6 +925,8 @@ _domain(::Type{MOI.PowerCone{Float64}}) = Mosek.MSK_DOMAIN_PRIMAL_POWER_CONE
918925

919926
_domain(::Type{MOI.DualPowerCone{Float64}}) = Mosek.MSK_DOMAIN_DUAL_POWER_CONE
920927

928+
_domain(::Type{MOI.GeometricMeanCone}) = Mosek.MSK_DOMAIN_PRIMAL_GEO_MEAN_CONE
929+
921930
function _domain(::Type{MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}})
922931
return Mosek.MSK_DOMAIN_SVEC_PSD_CONE
923932
end

0 commit comments

Comments
 (0)