BitstreamIndividual.py#

Individual representation for evolutionary bitstream experiments.

Each individual wraps a boolean bitstream that maps to an FPGA circuit configuration. Provides mutation, crossover, and randomization operators used by the population initialization and reproduction strategies.

class Individual.BitstreamIndividual.BitstreamIndividual(bitstream_sz: int, rand: Random, mutation_probability: float)[source]#

A genetic individual whose genome is a list of boolean bits.

Used by GenerateBitstreamPopulation to create populations, and by reproducers to generate offspring.

__init__(bitstream_sz: int, rand: Random, mutation_probability: float)[source]#

Create an individual with a zeroed bitstream of the given size.

copy_from(other: BitstreamIndividual)[source]#

Deep-copy the bitstream from other into this individual.

crossover(parent: BitstreamIndividual, crossover_point: int)[source]#

Single-point crossover: take bits before crossover_point from self and the rest from parent.

get_bitstream() list[bool][source]#

Return the current bitstream.

mutate()[source]#

Flip each bit independently with the configured mutation probability.

randomize()[source]#

Set every bit to a uniformly random value.

set_bitstream(bitstream: list[bool])[source]#

Replace the entire bitstream with the provided list.