
Show HN: A Genetic Algorithm library written in JavaScript - nyxyn
https://github.com/lodenrogue/genetic-algorithm-js
======
kanobo
Remember that great old flash thingy where you mutate a boxcar until it drives
well, just found out there's a html version:
[https://rednuht.org/genetic_cars_2/](https://rednuht.org/genetic_cars_2/)

~~~
matsemann
I made something similar for teaching shapes to walk [0]. It's actually a
workshop to teach people at my job about how GAs work by having them implement
the different parts themselves.

[0]:
[https://matsemann.github.io/walkingea/](https://matsemann.github.io/walkingea/)

------
bmh100
I like the cleanliness of the library. I learned about and used GAs in
college. It is important for this library to have the ability to hold out the
fittest candidate so far. This avoids the situation where a good solution is
lost because the population evolves away from it. Optionally, the best
candidate can be retained for breeding. Deleting unfit solutions should be a
parameter. Breeding partner selection should also be weighted by fitness.

~~~
djaque
The idea of choosing partners based on fitness is implemented in most GAs.
It's called selection and a basic form looks like choosing two individuals for
each parent and only breeding the fittest in each pair (tournament selection).

Many frameworks also include a "hall of fame" to avoid evolving away from a
good point like you mentioned.

~~~
bmh100
What do you recommend as good GA frameworks?

~~~
djaque
DEAP is the well known framework in python.

------
atum47
interesting.

I did proposed a GA framework in my final thesis, but I end up never actually
sharing the code, because it the end you have to create most of the code
anyways. How to create your population, how to evaluate each individual, how
to cross them...

My final thesis is in Portuguese, otherwise I'll share a link

~~~
imvetri
Do you have diagrammatic details to share ? That will be easy to understand
irrespective of language.

~~~
atum47
[http://dspace.unipampa.edu.br/bitstream/riu/4849/1/Victor%20...](http://dspace.unipampa.edu.br/bitstream/riu/4849/1/Victor%20Queiroz%20Ribeiro%20-%202019.pdf)

I do intend to take the time to translate it to english.

------
kvonhorn
Are genetic algorithms getting popular again? This was the topic of my senior
project 20 years ago. I had barely heard about them since I left university,
but all of a sudden within the last six months I'm hearing about them again.

~~~
djaque
They've been quite popular in my field for the past decade and I am doing some
work on them right now.

~~~
kvonhorn
What field are you in?

~~~
djaque
Particle accelerator physics. They are used in the optimization of charged
particle optics.

~~~
solaxun
Purely out of curiosity - is there something about them that makes them better
than other optimization algorithms, e.g. simulated annealing, random local
search etc, or for continuous functions gradient descent and the like. Seems
like GA's are always glossed over as a relic of past times, it's pretty
interesting to hear about them in practice somewhere!

~~~
djaque
We use them because they are particularly well suited for multi-objective
optimization. They are also a global techniqe as opposed to gradient based
methods and have great scaling properties. Important because each evaluation
of the objective function takes ten minutes for us.

GAs have found a niche in a lot of "obscure" engineering situations. Anything
where you need to optimize an expensive black box function is at least worth a
try with a GA. I know they are used in analog IC design, civil engineer, and
aerospace.

------
tlarkworthy
Nueral network tech went through a weird period and then back to basics (back
prop) just with massive computation (and simple activation functions) with
fabulous results. I wonder if similar things could be done with other old
school techniques like GA. Does anyone know if we have tried massive ones?

~~~
veets
There is plenty of work running evolutionary algorithms on GPUs, but there are
a number of limiting factors that make it less than ideal. Evolutionary
algorithms in general can be extremely effective, they just solve very
different problems from "is this a picture of a cat?" and aren't as sexy as
neural networks.

In fact, much of "old school" CS is still very much alive and applying modern
techniques and hardware to their problems. It's not that neural networks are
some field of CS that is much more advanced than the rest of CS but rather
neural networks happen to be the current hot topic.

------
imvetri
It looks usable for someone who knows about genetic algorithm. It would be
catchy on your repo if you add gif version of a working demo for simple use
case such as snake game or something similar.

~~~
nyxyn
Thanks so much for your comment. There are some examples here:
[https://github.com/lodenrogue/genetic-algorithm-
js/tree/mast...](https://github.com/lodenrogue/genetic-algorithm-
js/tree/master/examples)

~~~
svantana
If I were you I would take those examples, wrap them in some html and put them
on github.io or somewhere else but with a link at the top of the readme. There
is so much stuff around and only so little time...

------
SomeT
Nice work, I just written an algorithm myself, it’s a quick one in Python.

------
poletopole
A question for the author: is genetic data a thing? If it is what are your
thoughts?

~~~
bmh100
I'm not the author, but DNA can be used to encode data. Interpreting your
question another way, the parameters of each solution are data, and they
metaphorically evolve like genes.

