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

replace random.random with np.random.choice in selRoulette #689

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Mach-2
Copy link

@Mach-2 Mach-2 commented Mar 10, 2023

I noticed that selRoulette was causing a major bottleneck when I tried to scale up to larger populations. This update uses the np.random.choice function in place of random.random, which removes the need to sort the input list of individuals and the nested for loops.

@fmder
Copy link
Member

fmder commented Mar 10, 2023

Could this be done with the new random.choices?

@Mach-2
Copy link
Author

Mach-2 commented Mar 10, 2023

Yes, random.choices looks like it does the same thing. This shaved off a bit of runtime again, too! 👍

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

Successfully merging this pull request may close these issues.

2 participants