some comments on initial condition, included possible algorithms

This commit is contained in:
Gaspard Jankowiak 2024-12-20 12:42:30 +01:00
parent 11f955d265
commit d3766e40a7

View file

@ -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) GLM.Axis(fig[1, i], aspect=aspect)
end end
n = Int(sqrt(N)) n = Int(sqrt(N))
# Component density # Component density
@ -287,7 +286,13 @@ function optim(algo::Symbol=:LD_MMA)
N::Int, M::Int = size(Y) N::Int, M::Int = size(Y)
m::Int = 2 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) ∇E::Vector{Float64} = zeros((N + M) * m)
tmp = zeros(size(Y)) tmp = zeros(size(Y))
@ -311,13 +316,31 @@ function optim(algo::Symbol=:LD_MMA)
res = NLopt.optimize(opt, X) res = NLopt.optimize(opt, X)
return res @show opt
return res, opt
end end
end # module 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.plot_result_mixture_1(res[2], 512 * 512, 32, 2)
# OptimMixture.benchmark(); # OptimMixture.benchmark();
# OptimMixture.test_E(512 * 512, 32, 2) # OptimMixture.test_E(512 * 512, 32, 2)