Skip to content

Commit

Permalink
Merge pull request #44 from ThibeauWouters/main
Browse files Browse the repository at this point in the history
Popsize argument in EvolutionaryOptimizer in likelihood.py
  • Loading branch information
kazewong authored Nov 27, 2023
2 parents 88c88c0 + 7cc4843 commit 2562fb4
Showing 1 changed file with 5 additions and 5 deletions.
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)

0 comments on commit 2562fb4

Please sign in to comment.