From fbfbe5eaff7b61354ad3b57921b57c4d969cc936 Mon Sep 17 00:00:00 2001 From: ThibeauWouters Date: Mon, 27 Nov 2023 11:28:17 -0800 Subject: [PATCH 1/3] added popsize kwarg to EvolutionaryOptimizer --- src/jimgw/likelihood.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jimgw/likelihood.py b/src/jimgw/likelihood.py index 579eca5b..3c7f93c0 100644 --- a/src/jimgw/likelihood.py +++ b/src/jimgw/likelihood.py @@ -378,7 +378,7 @@ def maximize_likelihood( y = jax.jit(jax.vmap(y)) print("Starting the optimizer") - optimizer = EvolutionaryOptimizer(len(bounds), verbose=True) + optimizer = EvolutionaryOptimizer(len(bounds), popsize=set_nwalkers, 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) From 5e42892027e2a99c4c25516275c0739120d3cb2f Mon Sep 17 00:00:00 2001 From: ThibeauWouters Date: Mon, 27 Nov 2023 11:30:47 -0800 Subject: [PATCH 2/3] added comment --- src/jimgw/likelihood.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jimgw/likelihood.py b/src/jimgw/likelihood.py index 3c7f93c0..507cbb40 100644 --- a/src/jimgw/likelihood.py +++ b/src/jimgw/likelihood.py @@ -370,7 +370,7 @@ def maximize_likelihood( n_loops: int = 2000, ): bounds = jnp.array(bounds).T - set_nwalkers = set_nwalkers + set_nwalkers = set_nwalkers # TODO remove this? y = lambda x: -self.evaluate_original( prior.add_name(x, transform_name=True, transform_value=True), None From 7cc4843b817cea19810aa7d1c81d5e77eb3f49e1 Mon Sep 17 00:00:00 2001 From: ThibeauWouters Date: Mon, 27 Nov 2023 11:33:28 -0800 Subject: [PATCH 3/3] renamed walkers to popsize --- src/jimgw/likelihood.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jimgw/likelihood.py b/src/jimgw/likelihood.py index 507cbb40..3320c7a2 100644 --- a/src/jimgw/likelihood.py +++ b/src/jimgw/likelihood.py @@ -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__( @@ -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 @@ -366,11 +366,11 @@ 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 # TODO remove this? + popsize = popsize # TODO remove this? y = lambda x: -self.evaluate_original( prior.add_name(x, transform_name=True, transform_value=True), None @@ -378,7 +378,7 @@ def maximize_likelihood( y = jax.jit(jax.vmap(y)) print("Starting the optimizer") - optimizer = EvolutionaryOptimizer(len(bounds), popsize=set_nwalkers, 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)