TrivialImplementation.py#
- TrivialImplementation.FakeHardwareTrivialEvaluateMeasurements(measurements: Iterable[Measurement]) None[source]#
perform the measurements and edit them in place. This would normally be done by the H
- TrivialImplementation.FakeMeasuringFitnessTrivialImplemention(unevaluated_population: Population) Population[source]#
This is a function that prevents me from having to use async & hardware while testing out TrivialEvolution. This returns the same population, it just evaluates it.
- class TrivialImplementation.TrivialCircuit(inherent_fitness: int)[source]#
This is a very simple circuit that is also the Individual evolution is performed on
- TrivialImplementation.TrivialEvaluatePopulationFitness(population: Population, measurement_dependants: dict[Measurement, list[tuple[Population, Individual]]])[source]#
Turns measurements into fitness values and applies them to the provided population, completely evaluating the population, and only editing that population.
- class TrivialImplementation.TrivialEvolution(generation_data_factory: GenDataFactory, reproducer: Reproducer, generate_intial_population: GenerateInitialPopulation)[source]#
Utilizes the protocols defined to run experiments.
This is an example that should be generalized for a more general solution. There should be different versions of Evolution for structurally different experiments (e.g. multiple populations of individuals evolved simultaneously, bacterial populations where only some individuals are evaluated and reproduce each loop).
Any other evolution implementations should try to maintain as similar of function signatures as possible, with arguments communicated with protocols that are as general as possible.
This implementation generates, evaluates, and reproduces entire populations at once, and does so in discrete timesteps.
- __init__(generation_data_factory: GenDataFactory, reproducer: Reproducer, generate_intial_population: GenerateInitialPopulation)[source]#
Initializes the Evolution with all of the objects and functions needed for it to carry out it the evolution. This does not execute any functions passed in.
- TrivialImplementation.TrivialGenerateInitialPopulation(population_size: int, random: Random, min_fitness: int, max_fitness: int) Population[source]#
Generates a a list of two populations which have fitnesses numbered from zero and population_size sorted in descending order
Here min & max fitness refers to the minimum and maximum inherent fitnesses that can be generated for an individual.
- class TrivialImplementation.TrivialHardware(FPGAs: list[str] = ['FAKE_FPGA1', 'FAKE FPGA2'])[source]#
- TrivialImplementation.TrivialReproduceWithMutation(population: Population, random: Random) Population[source]#
Return a population where the top half are kept and each gets a mutated child.
Each child is the parent incremented or decremented randomly. This primarily ensures the population remains the same size. If an odd-length population is passed, the next individual is kept but does not reproduce or mutate. The output population has all of its fitnesses unevaluated (None).