Skip to content

Operators

Guide: Native operators.

ypea.operators.SBX

Simulated binary crossover (SBX) in the code space, bounded to [0, 1].

op = ypea.operators.SBX(eta=20, prob=0.9, prob_var=0.5)

Each pair of parents is crossed with probability prob, and then each
component with probability prob_var. A crossed component spreads the
two parent values by a factor drawn from a polynomial distribution
with index eta (larger values keep the children closer to the
parents). The bounded form takes the distance to the bounds into
account, so no child leaves [0, 1], and the two children are swapped
with probability 1/2. Components whose parent values differ by less
than 1e-14 are copied.

The defaults (eta = 20, prob = 0.9) are the NSGA-II settings of Deb
et al. (2002). The bounded form and prob_var = 0.5 follow Deb's
NSGA-II reference code.

References: Deb and Agrawal (1995), Simulated binary crossover for
continuous search space, Complex Systems 9, 115 to 148. Deb, Pratap,
Agarwal and Meyarivan (2002), IEEE Transactions on Evolutionary
Computation 6(2), 182 to 197.

ypea.operators.PolynomialMutation

Polynomial mutation in the code space, bounded to [0, 1].

op = ypea.operators.PolynomialMutation(eta=20, prob=[])

Each component changes with probability prob (empty means 1/d for d
code components). The change follows a polynomial distribution with
index eta (larger values give smaller changes), scaled so that the
result stays in [0, 1].

The defaults (eta = 20, prob = 1/d) are the NSGA-II settings of Deb
et al. (2002). The bounded form follows Deb's NSGA-II reference code.

References: Deb and Goyal (1996), A combined genetic adaptive search
(GeneAS) for engineering design, Computer Science and Informatics
26(4), 30 to 45. Deb et al. (2002).

ypea.operators.NativeCrossover

A crossover on the decoded values of the variables of the classes in types.

op = ypea.operators.NativeCrossover(fn, types)
fn(x1, x2, rng) takes two decoded batches of one variable and returns
two, for example
    ypea.operators.NativeCrossover(@ypea.operators.uniform_crossover, "Integer")

ypea.operators.NativeMutation

A mutation on the decoded values of the variables of the classes in types.

op = ypea.operators.NativeMutation(fn, types)
fn(x, rng) takes a decoded batch of one variable and returns one.

ypea.operators.Operator

Base class of the operators given as crossover= and mutation= settings.

space is "code" (the operator works on whole code batches in [0, 1],
for every variable type) or "native" (it works on the decoded values
of one variable, for the variable classes listed in types).

ypea.operators.Crossover

Base class of crossover operators: [y1, y2] = op.apply(x1, x2, rng).

ypea.operators.Mutation

Base class of mutation operators: y = op.apply(x, rng).

ypea.operators.NativeOperators

The native operators of one run.

For each variable: the user's operators where given (the operators
struct, then the native crossover and mutation operators for the
variable classes they list), otherwise the defaults, otherwise the
algorithm's code operators on that variable's slice of the codes.

ops = ypea.operators.NativeOperators(problem, operators, crossover=[],
    mutation=[], code_types=[], alpha=, rate=, sigma=)

operators is a struct with one field per variable name. Each field
holds an object with crossover and mutate methods (for example
ypea.operators.PermutationOperators), a struct with fields crossover
and mutate (function handles), or a cell {crossover, mutate}. A
missing or empty entry keeps the default.

ypea.operators.check_operator

Check that op is a kind ("crossover" or "mutation") operator that fits.

ypea.operators.check_operator(op, kind, space, problem) checks the
algorithm's space ("encoded" or "native") and, when given, the problem.
An empty op passes.

ypea.operators.RealOperators

Blend crossover (BLX alpha) and Gaussian mutation with a step of sigma * (ub - lb).

ops = ypea.operators.RealOperators(var, alpha=0.1, rate=0.1, sigma=0.1)

ypea.operators.IntegerOperators

Uniform crossover, and a mutation that creeps or resets.

ops = ypea.operators.IntegerOperators(var, alpha=0.1, rate=0.1, sigma=0.1, creep=0.5)
A changed element creeps (with probability creep) by up to
sigma * (ub - lb) steps, at least one, or is reset to a different
value. For Binary the reset is a bit flip.

ypea.operators.PermutationOperators

For each pair one crossover, and for each row one move, picked at random.

ops = ypea.operators.PermutationOperators(var, crossovers=..., mutations=...)
crossovers is a cell array of row crossovers f(p1, p2, i, j), by
default {@order_crossover, @pmx, @cycle_crossover}. mutations is a
cell array of row moves f(x, i, j, rng), by default {@swap,
@inversion, @insertion} (all in ypea.operators).

ypea.operators.PartitionOperators

The permutation operators on the ordering of items and separators.

For Partition and BinaryPartition. The ordering is rebuilt as the
variable's encode builds it: the items of group 1, then a separator,
the items of group 2, and so on, so order crossover and PMX treat
the separators as distinct values.

ypea.operators.SelectionOperators

Operators of an ordered selection of k distinct items.

Crossover takes an item from the other parent at a random half of
the positions, when the child does not hold it yet. Mutation replaces
one item with an unused one, or swaps two positions.

ypea.operators.BinarySelectionOperators

Operators of a 0/1 mask with exactly k ones.

Crossover keeps the common ones and shares the others at random
between the two children. Mutation swaps a one and a zero.

ypea.operators.default_operators

The native operators of a variable, or [] if its class has none.

ops = ypea.operators.default_operators(var, alpha=0.1, rate=0.1, sigma=0.1)
FixedSum has no native operators.

ypea.operators.uniform_crossover

Each element comes from either parent with probability 1/2.

[y1, y2] = ypea.operators.uniform_crossover(x1, x2, rng) works on
batches of any shape and element type. rng is a ypea.Rng.

ypea.operators.one_point_crossover

The children swap the tails of the flattened parents after a random cut.

[y1, y2] = ypea.operators.one_point_crossover(x1, x2, rng). Each row
of the batch (one solution) is flattened in MATLAB's column order.

ypea.operators.order_crossover

Order crossover (OX) of two permutation rows.

child = ypea.operators.order_crossover(p1, p2, i, j) keeps p1(i+1:j)
and fills the other positions with the remaining items in the order of
p2, starting after position j. The cut points satisfy 0 <= i <= j <= n.

ypea.operators.pmx

Partially mapped crossover (PMX) of two permutation rows.

child = ypea.operators.pmx(p1, p2, i, j) keeps p1(i+1:j) and places
the rest of p2 through the mapping between the two segments. The cut
points satisfy 0 <= i <= j <= n. Items are 1 to n.

ypea.operators.cycle_crossover

Cycle crossover (CX) of two permutation rows.

child = ypea.operators.cycle_crossover(p1, p2, i, j): alternate cycles
come from p1 and p2. The cut points are not used. Items are 1 to n.

ypea.operators.swap

Swap the items at positions i and j of a row.

y = ypea.operators.swap(x, i, j, rng)

ypea.operators.inversion

Reverse the segment between positions i and j of a row, both included.

y = ypea.operators.inversion(x, i, j, rng)

ypea.operators.insertion

Move the item at position i of a row to position j.

y = ypea.operators.insertion(x, i, j, rng)

ypea.operators.scramble

Shuffle the segment between positions i and j of a row, both included.

y = ypea.operators.scramble(x, i, j, rng)