experiment with barriers
This commit is contained in:
parent
1a500a37ba
commit
b2a7f1ba13
1 changed files with 27 additions and 10 deletions
37
test.jl
37
test.jl
|
@ -36,15 +36,15 @@ mean_5k_full = begin
|
||||||
mean_params = vec(sum(params_pop; dims=1) / N_trials)
|
mean_params = vec(sum(params_pop; dims=1) / N_trials)
|
||||||
end
|
end
|
||||||
|
|
||||||
# best_5k = PLUV.reduce_to_free_parameters(meta, [100000.0000000, 7.5004085, 23.5074449, 9.8664991, 0.0000000, 1.0000000, 0.2900000, 0.2203793,
|
# best_5k = Utils.reduce_to_free_parameters(meta, [100000.0000000, 7.5004085, 23.5074449, 9.8664991, 0.0000000, 1.0000000, 0.2900000, 0.2203793,
|
||||||
# 0.2990402, 0.4122816, 0.3266636, 0.2276763, 0.2481895, 0.6642123, 0.1203572, 0.2629861, 0.9000000, 0.3050000,
|
# 0.2990402, 0.4122816, 0.3266636, 0.2276763, 0.2481895, 0.6642123, 0.1203572, 0.2629861, 0.9000000, 0.3050000,
|
||||||
# 0.2945315, 0.2762371, 0.4777401, 0.8100000, 2.0149998, 37.0000000, 0.0299139, 0.0002171])
|
# 0.2945315, 0.2762371, 0.4777401, 0.8100000, 2.0149998, 37.0000000, 0.0299139, 0.0002171])
|
||||||
#
|
#
|
||||||
# best_5k = PLUV.reduce_to_free_parameters(meta, [100000.0000000, 7.6975592, 23.4041912, 9.7275630, 0.0000000, 1.0000000, 0.2900000, 0.2219937, 0.3000114,
|
# best_5k = Utils.reduce_to_free_parameters(meta, [100000.0000000, 7.6975592, 23.4041912, 9.7275630, 0.0000000, 1.0000000, 0.2900000, 0.2219937, 0.3000114,
|
||||||
# 0.4158804, 0.3278631, 0.2296156, 0.2475607, 0.6664143, 0.1191859, 0.2618609, 0.9000000, 0.3050000, 0.2963982, 0.2770345, 0.4762528,
|
# 0.4158804, 0.3278631, 0.2296156, 0.2475607, 0.6664143, 0.1191859, 0.2618609, 0.9000000, 0.3050000, 0.2963982, 0.2770345, 0.4762528,
|
||||||
# 0.8100000, 1.9706651, 37.0000000, 0.0299179, 0.0002167])
|
# 0.8100000, 1.9706651, 37.0000000, 0.0299179, 0.0002167])
|
||||||
|
|
||||||
best_5k_params = PLUV.reduce_to_free_parameters(meta, best_params)
|
best_5k_params = Utils.reduce_to_free_parameters(meta, best_params)
|
||||||
|
|
||||||
q, I_data, err = Utils.select_columns(qie_data, meta["q_min"], meta["q_max"], meta["binning"], meta["binning"])
|
q, I_data, err = Utils.select_columns(qie_data, meta["q_min"], meta["q_max"], meta["binning"], meta["binning"])
|
||||||
q_all, I_all, err_all = Utils.select_columns(qie_data, meta["q_min"], meta["q_max"], 1, meta["binning"])
|
q_all, I_all, err_all = Utils.select_columns(qie_data, meta["q_min"], meta["q_max"], 1, meta["binning"])
|
||||||
|
@ -57,12 +57,22 @@ w_all = Utils.compute_logscale_weights(q_all)
|
||||||
|
|
||||||
# I_init = PLUV.intensity(params_init, q)
|
# I_init = PLUV.intensity(params_init, q)
|
||||||
|
|
||||||
intensity_reduced, P_reduced, lb_reduced, ub_reduced = PLUV.reduce_to_free_parameters(meta, params_init, lower_bounds, upper_bounds, q)
|
intensity_reduced, P_reduced, lb_reduced, ub_reduced = Utils.reduce_to_free_parameters(meta, PLUV.intensity, params_init, lower_bounds, upper_bounds, q)
|
||||||
|
|
||||||
simple_bounds = collect(zip(lb_reduced, ub_reduced))
|
simple_bounds = collect(zip(lb_reduced, ub_reduced))
|
||||||
|
|
||||||
simple_init = 0.5 * (lb_reduced .+ ub_reduced)
|
simple_init = 0.5 * (lb_reduced .+ ub_reduced)
|
||||||
padding_factor = fill(1e-1, length(simple_init))
|
padding_factors = fill(1e-1, length(simple_init))
|
||||||
|
scaling_factors = fill(0.0, length(simple_init))
|
||||||
|
|
||||||
|
#padding_factors[4] = 1e0
|
||||||
|
#padding_factors[7] = 1e0
|
||||||
|
#padding_factors[17] = 1e0
|
||||||
|
#padding_factors[18] = 1e0
|
||||||
|
|
||||||
|
# scaling_factors[4] = 1e1
|
||||||
|
# scaling_factors[6] = 1e1
|
||||||
|
#scaling_factors[7] = 1e3
|
||||||
|
|
||||||
bounds = MH.boxconstraints(lb=lb_reduced, ub=ub_reduced)
|
bounds = MH.boxconstraints(lb=lb_reduced, ub=ub_reduced)
|
||||||
|
|
||||||
|
@ -74,13 +84,15 @@ function obj_χ2(P)
|
||||||
end
|
end
|
||||||
|
|
||||||
function obj_residuals(P)
|
function obj_residuals(P)
|
||||||
|
print(".")
|
||||||
I_model, neg_H20 = intensity_reduced(P)
|
I_model, neg_H20 = intensity_reduced(P)
|
||||||
residuals = Utils.residuals(I_data, I_model, err)
|
residuals = Utils.residuals(I_data, I_model, err)
|
||||||
factor = (neg_H20 == 0 ? 1.0 : 5.0 * (neg_H20 + 1))
|
factor = (neg_H20 == 0 ? 1.0 : 5.0 * (neg_H20 + 1))
|
||||||
return factor * residuals
|
res = factor * residuals
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
barriered_obj = Utils.add_log_barriers(obj_residuals, simple_bounds; padding_factor=padding_factor, mode=:outer)
|
barriered_obj = Utils.add_log_barriers(obj_residuals, simple_bounds; padding_factors=padding_factors, mode=:inner)
|
||||||
|
|
||||||
information = MH.Information(f_optimum=0.0)
|
information = MH.Information(f_optimum=0.0)
|
||||||
information = MH.Information()
|
information = MH.Information()
|
||||||
|
@ -89,16 +101,18 @@ algorithm = MH.ECA(information=information, options=options)
|
||||||
#algorithm = MH.PSO()
|
#algorithm = MH.PSO()
|
||||||
|
|
||||||
I_best_5k, _ = PLUV.intensity(best_5k_full, q)
|
I_best_5k, _ = PLUV.intensity(best_5k_full, q)
|
||||||
|
I_best_5k_reduced, _ = intensity_reduced(best_5k_params)
|
||||||
|
|
||||||
I_mean_5k, _ = PLUV.intensity(mean_5k_full, q_all)
|
I_mean_5k, _ = PLUV.intensity(mean_5k_full, q_all)
|
||||||
|
|
||||||
# Gauss-Newton
|
# Gauss-Newton
|
||||||
if true
|
if true
|
||||||
initial_guess = PLUV.reduce_to_free_parameters(meta, collect(Float64, values(params_init)))
|
initial_guess = Utils.reduce_to_free_parameters(meta, collect(Float64, values(params_init)))
|
||||||
initial_guess = best_5k_params
|
initial_guess = simple_init
|
||||||
|
# initial_guess = best_5k_params
|
||||||
|
|
||||||
_, result = GN.optimize(barriered_obj, initial_guess; show_trace=true, iscale=1, ZCP=1e-2, ZCPMIN=1e-2)
|
_, result = GN.optimize(barriered_obj, initial_guess; show_trace=true, iscale=1, ZCP=1e-2, ZCPMIN=1e-2)
|
||||||
#_, result = GN.optimize(barriered_obj, initial_guess)
|
# _, result = GN.optimize(barriered_obj, initial_guess)
|
||||||
|
|
||||||
if GN.has_converged(result)
|
if GN.has_converged(result)
|
||||||
@info "Gauss-Newton converged"
|
@info "Gauss-Newton converged"
|
||||||
|
@ -130,6 +144,9 @@ if true
|
||||||
ax = M.Axis(fig[1, 1]; xscale=log10, yscale=log10)
|
ax = M.Axis(fig[1, 1]; xscale=log10, yscale=log10)
|
||||||
#ax = M.Axis(fig[1, 1])
|
#ax = M.Axis(fig[1, 1])
|
||||||
|
|
||||||
|
I_initial, _ = intensity_reduced(initial_guess)
|
||||||
|
|
||||||
|
M.lines!(ax, q, I_initial, label="initial", linestyle=:dash, linewidth=2)
|
||||||
M.lines!(ax, q, I_best, label="MH best (julia)")
|
M.lines!(ax, q, I_best, label="MH best (julia)")
|
||||||
M.scatter!(ax, q, I_data, label="data")
|
M.scatter!(ax, q, I_data, label="data")
|
||||||
M.lines!(ax, q, I_best_5k, label="TSA best (5k)")
|
M.lines!(ax, q, I_best_5k, label="TSA best (5k)")
|
||||||
|
|
Loading…
Reference in a new issue