diff --git a/docs/src/examples.md b/docs/src/examples.md index d29d16baf..5cb84cd78 100644 --- a/docs/src/examples.md +++ b/docs/src/examples.md @@ -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. diff --git a/examples/Examples.jl b/examples/Examples.jl index c92ca34ea..55ded1a15 100644 --- a/examples/Examples.jl +++ b/examples/Examples.jl @@ -38,6 +38,7 @@ const JuMP_examples = [ "convexityparameter", "covarianceest", "densityest", + "discretemaxlikelihood", "doptimaldesign", "entanglementassisted", "experimentdesign", diff --git a/examples/discretemaxlikelihood/JuMP.jl b/examples/discretemaxlikelihood/JuMP.jl new file mode 100644 index 000000000..84593c2b0 --- /dev/null +++ b/examples/discretemaxlikelihood/JuMP.jl @@ -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 diff --git a/examples/discretemaxlikelihood/JuMP_test.jl b/examples/discretemaxlikelihood/JuMP_test.jl new file mode 100644 index 000000000..05826e913 --- /dev/null +++ b/examples/discretemaxlikelihood/JuMP_test.jl @@ -0,0 +1,16 @@ + +insts = Dict() +insts["minimal"] = [ + ((2,),), + ] +insts["fast"] = [ + ((10,),), + ((100,),), + ((1000,),), + ] +insts["various"] = [ + ((2500,),), + ((5000,),), + ((10000,),), + ] +return (DiscreteMaxLikelihood, insts)