Evolve¶
Name | Mandatory | Description | Default | Type |
---|---|---|---|---|
⬅️ Input |
The input of this shard is ignored. | Any |
||
Output ➡️ |
This shard outputs a [Type::Float Type::Wire] pair. This pair represents the wire configuration from the current generation that scored the best fitness score and the fitness score itself. | [Float Wire] |
||
Wire |
No | The wire to optimize and evolve. | none |
Wire |
Fitness |
No | The fitness wire to run at the end of the main wire evaluation and using its last output; should output a Float fitness value. | none |
Wire |
Population |
No | The population size. | 64 |
Int |
Mutation |
No | The rate of mutation, 0.1 = 10%. | 0.2 |
Float |
Crossover |
No | The rate of crossover, 0.1 = 10%. | 0.2 |
Float |
Extinction |
No | The rate of extinction, 0.1 = 10%. | 0.1 |
Float |
Elitism |
No | The rate of elitism, 0.1 = 10%. | 0.1 |
Float |
Threads |
No | The number of cpu threads to use. | 2 |
Int |
Coroutines |
No | The number of coroutines to run on each thread. | 8 |
Int |
This shard uses genetic algorithm to evolve and change the configuration of the wire specified in the Wire parameter. The evolved wires are given a score based on the fitness wire specified in the Fitness Wire parameter. The shard then outputs the best wire and its fitness score. This shard should be used in conjunction with the Mutant shard.
Details¶
The shard follows a process for evolving the wire specified. 1. Population Initialization - It creates a population of individuals, each containing a copy of the base wire to be evolved. - The population size is determined by the "Population" parameter. 2. Evaluation - For each individual in the population, it runs the base wire and then the fitness wire. - The fitness wire should output a float value representing the fitness of the individual (higher is better). 3. Selection - It sorts the population based on their fitness scores. - The best individuals are kept (elitism), while the worst are marked for replacement. 4. Crossover - It performs crossover operations between individuals, combining their "genetic material" (wire configurations). - The crossover rate is controlled by the "Crossover" parameter. 5. Mutation - It applies mutations to individuals, making small random changes to their wire configurations. - The mutation rate is controlled by the "Mutation" parameter. 6. Iteration - Steps 2-5 are repeated for multiple generations (each call of the Evolve shard represents one generation). 7. Output - After each generation, it returns the best individual's fitness score and wire configuration.
For a wire to be able to evolve, it must be using the Mutant or DShard shards.