leap_ec.distrib package
Submodules
leap_ec.distrib.asynchronous module
leap_ec.distrib.evaluate module
leap_ec.distrib.individual module
Subclass of core.Individual that adds some state relevant for distrib runs.
Adds:
uuid for each individual
birth ID, a unique birth number; first individual has ID 0, the last N-1.
- class leap_ec.distrib.individual.DistributedIndividual(genome, decoder=None, problem=None)
Bases:
RobustIndividual
- birth_id = count(0)
Core individual that has unique UUID and birth ID.
- clone()
Create a ‘clone’ of this Individual, copying the genome, but not fitness.
The fitness of the clone is set to None. A new UUID is generated and assigned to sefl.uuid. The parents set is updated to include the UUID of the parent. A shallow copy of the parent is made, too, so that ancillary state is also copied.
A deep copy of the genome will be created, so if your Individual has a custom genome type, it’s important that it implements the __deepcopy__() method.
>>> from leap_ec.binary_rep.problems import MaxOnes >>> from leap_ec.decoder import IdentityDecoder >>> import numpy as np >>> genome = np.array([0, 1, 1, 0]) >>> ind = Individual(genome, IdentityDecoder(), MaxOnes()) >>> ind_copy = ind.clone() >>> ind_copy.genome == ind.genome array([ True, True, True, True]) >>> ind_copy.problem == ind.problem True >>> ind_copy.decoder == ind.decoder True
leap_ec.distrib.logger module
leap_ec.distrib.probe module
A collection of probe functions tailored for distrib evaluation
- leap_ec.distrib.probe.log_pop(update_interval, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, header=True)
Regularly update a CSV formatted stream with snapshots of the given population.
This is useful for asynchronous.steady_state() to regularly probe the regularly updated population.
- Parameters
update_interval – how often should we write a row?
stream – open stream to which to write rows
header – True if we want a header for the CSV file
- Returns
a function for saving regular population snapshots
- leap_ec.distrib.probe.log_worker_location(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, header=True)
When debugging dask distribution configurations, this function can be used to track what machine and process was used to evaluate a given individual. Accumulates this information to the given stream as a CSV.
Suitable for being passed as the evaluated_probe argument for leap.distrib.asynchronous.steady_state().
- Parameters
stream – to which we want to write the machine details
header – True if we want a header for the CSV file
- Returns
a function for recording where individuals are evaluated