Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore optimization algorithms #14

Open
murrellb opened this issue Jan 24, 2024 · 1 comment
Open

Explore optimization algorithms #14

murrellb opened this issue Jan 24, 2024 · 1 comment

Comments

@murrellb
Copy link
Member

... for rates, and for discrete distributions (ie. with a sum to 1 constraint). Start here: https://github.com/libprima/PRIMA.jl

@nossleinad
Copy link
Collaborator

Switching from NLopt to PRIMA could look like this for a typical BOBYQA use case

NLopt

opt = Opt(:LN_BOBYQA, num_params)

min_objective!(opt, (x,y) -> (objective  unflatten)(x))
lower_bounds!(opt, [-5.0 for i in 1:num_params])
upper_bounds!(opt, [5.0 for i in 1:num_params])
xtol_rel!(opt, 1e-12)
score,mini,did_it_work = NLopt.optimize(opt, flat_initial_params)

final_params = unflatten(mini)
optimized_model = build_model_vec(final_params)
LL = log_likelihood!(tree,optimized_model)

println(did_it_work)
println("Opt LL:",LL)

PRIMA

lower_bounds = [-5.0 for i in 1:num_params]
upper_bounds = [5.0 for i in 1:num_params]
tr_radius = 1e-12 #trust-region radius

mini, info = bobyqa(objective  unflatten, flat_initial_params, xl=lower_bounds, xu=upper_bounds, rhoend=tr_radius)

final_params = unflatten(mini)
optimized_model = build_model_vec(final_params)
LL = log_likelihood!(tree,optimized_model)

println("SUCCESS: $(issuccess(info))")
println("Opt LL:",LL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants