pg.evolution.mutators.Uniform

Accessible via pg.evolution.mutators.Uniform.

class Uniform(where=None, seed=None)[source]

Bases: pg.evolution.Mutator

Mutates a DNA by randomizing a branch of the DNA.

This is a minimal mutator. It acts as follows. PyGlove represents a DNA as a tree, with information at each node, where child nodes are conditional on the value of parent nodes. This mutator will pick a node uniformly at random and mutate the subtree rooted at that node (inclusive), respecting dependencies specified in the DNASpec.

However, in general, we recommended that you write your own Mutator subclass so you can tailor it to your search space. This would allow you, for example: i) to modify a value drawing from a custom distribution: e.g. a gaussian-distributed additive change may be more appropriate in many cases. ii) to choose a node in the tree with a non-uniform distribution. E.g. you may want to modify some nodes more frequently if they encode areas of the space that should be explored more thoroughly. iii) perform mutations that implement a different type of locality than that represented by the tree structure. E.g. if two nodes at the same level need to be modified in a coordinated way.

Methods:

mutate(dna[, step])

Mutates the DNA at a given step.

mutate(dna, step=0)[source]

Mutates the DNA at a given step.

Return type:

pg.DNA