Skip to content

Commit

Permalink
add example with powermean cone
Browse files Browse the repository at this point in the history
  • Loading branch information
lkapelevich committed May 24, 2021
1 parent 913d0b7 commit 5470031
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ New examples are welcomed and should be implemented similarly to the existing ex
- [Convexity parameter.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/convexityparameter) Find the strong convexity parameter of a polynomial function over a domain.
- [Covariance estimation.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/covarianceest) Estimate a covariance matrix that satisfies some given prior information and minimizes a given convex spectral function.
- [Density estimation.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/densityest) Find a valid polynomial density function maximizing the log likelihood of a set of observations.
- [Discrete maximum likelihodd.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/discretemaxlikelihood) Maximize likelihood of observations at discrete points, subject to probability vector not being too far from a uniform prior.
- [D-optimal design.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/doptimaldesign) Solve a D-optimal experiment design problem, i.e. maximize the determinant of the information matrix subject to side constraints.
- [Entanglement-assisted capacity.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/entanglementassisted) Compute the entanglement-assisted classical capacity of a quantum channel.
- [Experiment design.](https://github.com/chriscoey/Hypatia.jl/tree/master/examples/experimentdesign) Solve a general experiment design problem that minimizes a given convex spectral function of the information matrix subject to side constraints.
Expand Down
1 change: 1 addition & 0 deletions examples/Examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const JuMP_examples = [
"convexityparameter",
"covarianceest",
"densityest",
"discretemaxlikelihood",
"doptimaldesign",
"entanglementassisted",
"experimentdesign",
Expand Down
30 changes: 30 additions & 0 deletions examples/discretemaxlikelihood/JuMP.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#=
maximize likelihood of d observations at discrete points appearing with random
frequencies, subject to probability vector not being too far from a uniform
prior
=#

struct DiscreteMaxLikelihood{T <: Real} <: ExampleInstanceJuMP{T}
d::Int
end

function build(inst::DiscreteMaxLikelihood{T}) where {T <: Float64}
d = inst.d
@assert d >= 2
freq = rand(1:(2 * d), d)

model = JuMP.Model()
JuMP.@variables(model, begin
p[1:d] >= 0
prodp
end)
JuMP.@constraints(model, begin
vcat(prodp, p) in Hypatia.HypoPowerMeanCone{T}(freq / sum(freq))
vcat(inv(d), inv(d), p) in Hypatia.EpiPerSepSpectralCone{T}(
Cones.NegEntropySSF(), Cones.VectorCSqr{T}, d)
sum(p) == 1
end)
JuMP.@objective(model, Max, prodp)

return model
end
16 changes: 16 additions & 0 deletions examples/discretemaxlikelihood/JuMP_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

insts = Dict()
insts["minimal"] = [
((2,),),
]
insts["fast"] = [
((10,),),
((100,),),
((1000,),),
]
insts["various"] = [
((2500,),),
((5000,),),
((10000,),),
]
return (DiscreteMaxLikelihood, insts)

0 comments on commit 5470031

Please sign in to comment.