RobertTLange / evosax

Evolution Strategies in JAX 🦎
Apache License 2.0
475 stars 44 forks source link

Prevent Zero Elite Population #29

Closed nhansendev closed 1 year ago

nhansendev commented 1 year ago

Small suggestion: When using small populations or small elite_ratio values it's easy for the elite_population value to become zero during strategy init: Ex: self.elite_popsize = int(self.popsize / 2 * self.elite_ratio) => int(0.3) => 0 Which can lead to zero-division errors, among other things.

Wrapping the calculation with max(1, *calculation*) could make sense to ensure non-zero elite populations, though I'm not sure if one is a valid value for all strategies.

RobertTLange commented 1 year ago

Hi @Obliman, sounds like a good idea. Yes, I believe 1 should be valid (and if not should simply require a reshape). Do you want to go ahead and open a PR? The strategies which feature elite_ratio are the following:

RobertTLange commented 1 year ago

Addressed in #30