From d3766e40a7e020435dd42f97d032a029695b8556 Mon Sep 17 00:00:00 2001 From: Gaspard Jankowiak Date: Fri, 20 Dec 2024 12:42:30 +0100 Subject: [PATCH] some comments on initial condition, included possible algorithms --- optim_mixture.jl | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/optim_mixture.jl b/optim_mixture.jl index 2fca757..9440194 100644 --- a/optim_mixture.jl +++ b/optim_mixture.jl @@ -262,7 +262,6 @@ function plot_result_mixture_1(X::Vector{Float64}, N::Int, M::Int, m::Int) GLM.Axis(fig[1, i], aspect=aspect) end - n = Int(sqrt(N)) # Component density @@ -287,7 +286,13 @@ function optim(algo::Symbol=:LD_MMA) N::Int, M::Int = size(Y) m::Int = 2 - X::Vector{Float64} = fill(0.5, (N + M) * m) + # Initial choice of X + # it seems that: + # * ∇E(0) = 0 + # X::Vector{Float64} = zeros((N + M) * m) + # * choosing X = 0.5 and BFGS yields a relatively quick convergence to two identical components + # X::Vector{Float64} = fill(0.5, (N + M) * m) + X::Vector{Float64} = 0.5 .+ 0.1 * rand((N + M) * m) ∇E::Vector{Float64} = zeros((N + M) * m) tmp = zeros(size(Y)) @@ -311,13 +316,31 @@ function optim(algo::Symbol=:LD_MMA) res = NLopt.optimize(opt, X) - return res + @show opt + + return res, opt end end # module -res = OptimMixture.optim(:LD_LBFGS); +# possible algorithms from NLopt +# LD_LBFGS_NOCEDAL +# LD_LBFGS +# LD_VAR1 +# LD_VAR2 +# LD_TNEWTON +# LD_TNEWTON_RESTART +# LD_TNEWTON_PRECOND +# LD_TNEWTON_PRECOND_RESTART +# LD_MMA +# LD_AUGLAG +# LD_AUGLAG_EQ +# LD_SLSQP +# LD_CCSAQ + +res, opt = OptimMixture.optim(:LD_LBFGS); +# res, opt = OptimMixture.optim(:LD_TNEWTON) OptimMixture.plot_result_mixture_1(res[2], 512 * 512, 32, 2) # OptimMixture.benchmark(); # OptimMixture.test_E(512 * 512, 32, 2)