Skip to content

Commit

Permalink
added changes in optimize_pso
Browse files Browse the repository at this point in the history
  • Loading branch information
PRAVEEN-mnl committed Nov 9, 2023
1 parent 2dda923 commit f5e5bd7
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pycbc/live/snr_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,24 @@ def compute_minus_network_snr_pso(v, *argv, **kwargs):


def optimize_di(bounds, cli_args, extra_args, initial_point):
# Convert from dict to array with parameters in a given order
bounds = numpy.array([
bounds['mchirp'],
bounds['eta'],
bounds['spin1z'],
bounds['spin2z']
])

# Initialize the population with random values within specified bounds
population = numpy.random.uniform(bounds[:, 0], bounds[:, 1],
size=(int(cli_args.snr_opt_di_popsize), len(bounds)))

population = numpy.random.uniform(
bounds[:, 0],
bounds[:, 1],
size=(int(cli_args.snr_opt_di_popsize), len(bounds))
)
if cli_args.snr_opt_include_candidate:
# add the initial point to the population
population = numpy.concatenate((population[:-1],
initial_point))
logging.info('population: %s', population)
logging.debug('Initial population: %s', population)

results = differential_evolution(
compute_minus_network_snr,
Expand Down Expand Up @@ -249,14 +251,17 @@ def optimize_pso(bounds, cli_args, extra_args, initial_point):
])

# Initialize the population with random values within specified bounds
population = numpy.random.uniform(min_bounds, max_bounds,
size=(int(cli_args.snr_opt_di_popsize), len(bounds)))
population = numpy.random.uniform(
min_bounds,
max_bounds,
size=(int(cli_args.snr_opt_pso_particles), len(bounds))
)

if cli_args.snr_opt_include_candidate:
# add the initial point to the population
population = numpy.concatenate((population[:-1],
initial_point))
logging.info('population: %s', population)
logging.debug('Initial population: %s', population)

optimizer = ps.single.GlobalBestPSO(
n_particles=int(cli_args.snr_opt_pso_particles),
Expand Down

0 comments on commit f5e5bd7

Please sign in to comment.