Until now, no such thing existed. Now you can have my cake, and optimize it too. Is it perfect? Probably. Regardless, this library is my gift to you.
Selects a pair of individuals from a population. Selection
generation(pop, gen, stats)
Called for each generation. Return false to terminate end algorithm (ie- if goal state is reached)
notification(pop, gen, stats, isFinished)
Runs in the calling context. All functions other than this one are run in a web worker.
The optimizer specifies how to rank individuals against each other based on an arbitrary fitness score. For example, minimizing the sum of squared error for a regression curve Genetic.Optimize.Minimize would be used, as a smaller fitness score is indicative of better fit.
The smaller fitness score of two individuals is best
The greater fitness score of two individuals is best
An algorithm can be either genetic or evolutionary depending on which selection operations are used. An algorithm is evolutionary if it only uses a Single (select1) operator. If both Single and Pair-wise operations are used (and if crossover is implemented) it is genetic.
Selects a single individual for survival from a population
Selects two individuals from a population for mating/crossover
Fittest of two random individuals
Fittest of three random individuals
Always selects the Fittest individual
Randomly selects an individual
Select random individual where probability is a linear function of rank
Sequentially selects an individual
Pairs two individuals, each the best from a random pair
Pairs two individuals, each the best from a random triplett
Randomly pairs two individuals
Pairs two individuals, each randomly selected from a linear rank
Selects adjacent pairs
Pairs the most fit individual with random individuals
vargenetic=Genetic.create();// more likely allows the most fit individuals to survive between generationsgenetic.select1=Genetic.Select1.RandomLinearRank;// always mates the most fit individual with random individualsgenetic.select2=Genetic.Select2.FittestRandom;// ...
Probability of crossover
Probability of mutation
Maximum number of iterations before finishing
Prevents losing the best fit between generations
The maximum number of best-fit results that webworkers will send per notification