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

Async fitness and functions caller functions #7

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

Conversation

albanm
Copy link

@albanm albanm commented Aug 31, 2015

This is actually some quite large modification. I am not sure you will be interested, but I think it is worth proposing.

First, I noticed that when running without web workers the page freezes, this is because everything is synchronous and genetic-js never releases the process. Making the fitness async with optional callback passing makes it possible to use at least a setTimeout. The page still lags of course, but it doesn't freeze.

Second, I needed to do some work with the DOM in my fitness function, but I still wanted to use web workers otherwise. So I used messages to simulate running functions in the worker that are actually in the caller context. It works well for me.

@Glavin001
Copy link

For those looking for async support, I've forked this repo and rewrote it in TypeScript and added support for async fitness method (including unit tests): https://github.com/Glavin001/genetic-js
Hope this helps you, 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