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

Popsize argument in EvolutionaryOptimizer in likelihood.py #44

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/jimgw/likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(
trigger_time: float = 0,
duration: float = 4,
post_trigger_duration: float = 2,
n_walkers: int = 100,
popsize: int = 100,
n_loops: int = 2000,
) -> None:
super().__init__(
Expand All @@ -157,7 +157,7 @@ def __init__(
self.freq_grid_low = freq_grid[:-1]

self.ref_params = self.maximize_likelihood(
bounds=bounds, prior=prior, set_nwalkers=n_walkers, n_loops=n_loops
bounds=bounds, prior=prior, popsize=popsize, n_loops=n_loops
)

self.ref_params["gmst"] = self.gmst
Expand Down Expand Up @@ -366,19 +366,19 @@ def maximize_likelihood(
self,
bounds: tuple[Array, Array],
prior: Prior,
set_nwalkers: int = 100,
popsize: int = 100,
n_loops: int = 2000,
):
bounds = jnp.array(bounds).T
set_nwalkers = set_nwalkers
popsize = popsize # TODO remove this?

y = lambda x: -self.evaluate_original(
prior.add_name(x, transform_name=True, transform_value=True), None
)
y = jax.jit(jax.vmap(y))

print("Starting the optimizer")
optimizer = EvolutionaryOptimizer(len(bounds), verbose=True)
optimizer = EvolutionaryOptimizer(len(bounds), popsize=popsize, verbose=True)
state = optimizer.optimize(y, bounds, n_loops=n_loops)
best_fit = optimizer.get_result()[0]
return prior.add_name(best_fit, transform_name=True, transform_value=True)
Loading