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

Why does the samples (population) for the first iteration not uniform? #57

Open
smao-astro opened this issue Jun 8, 2023 · 0 comments

Comments

@smao-astro
Copy link

Dear @RobertTLange ,

Thank you for creating and sharing this valuable repository. I am new to evolutionary algorithms and have a question regarding the initial population distribution.

Following the tutorial at https:/RobertTLange/evosax/blob/af5c32271583672a42adef08f19cd535a9fa0d93/README.md?plain=1#LL10C1-L10C1 or https://colab.research.google.com/github/RobertTLange/evosax/blob/main/examples/01_classic_benchmark.ipynb, I notice that the population at the first iteration, before evaluating the objective functions, is non-uniform.

For your reference, please see the test code and its outputs below:

import jax
import jax.numpy as jnp
import numpy as np
from evosax import PSO

key=jax.random.PRNGKey(0)
strategy=PSO(128, 1)

es_params=strategy.default_params
state=strategy.initialize(key, es_params)
print(np.mean(state.archive))
print(state.mean)
global_best = state.best_archive[jnp.argmin(state.best_archive_fitness)]
print(f"Biased global_best in `single_member_velocity`:", global_best)
_, key = jax.random.split(key, 2)
x, state = strategy.ask(key, state, es_params)
print("Biased samples:")
print(np.mean(state.velocity))
print(np.mean(x))

Outputs

-0.0031656926
[-0.00316569]
Biased global_best in `single_member_velocity`: [-0.08077727]
Biased samples:
-0.08185574
-0.085021436

The questions are,

  1. Why does the x from the code above bias towards the lower boundary?
  2. To achieve a uniformly distributed population in the first iteration, should I use state.archive? Is this the recommended approach?

Thanks,
Shunyuan

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

1 participant