platypus.operators module

class BitFlip(probability=1)

Bases: Mutation

Bit-flip mutation for binary encodings.

Parameters

probabilityint or float

The probability of flipping an individual bit. If the value is an int, then the probability is divided by the number of bits.

class CompoundMutation(*mutators)

Bases: Mutation

Combines two or more mutation operators.

Parameters

mutatorslist of Mutation

The mutation operators to combine, which are applied sequentially in the order provided.

class CompoundOperator(*variators)

Bases: Variator

Combines two or more variation operators.

Parameters

variatorslist of Variator

The variation operators to combine, which are applied sequentially in the order provided.

class DifferentialEvolution(crossover_rate=0.1, step_size=0.5)

Bases: Variator

Differential evolution (DE) operator.

Parameters

crossover_ratefloat

The crossover rate.

step_sizefloat

The step size.

class GAOperator(variation, mutation)

Bases: Variator

Genetic algorithm operator combining crossover and mutation.

Parameters

variationVariator

The crossover operator.

mutationVariator

The mutation operator.

class HUX(probability=1.0)

Bases: Variator

Half-uniform crossover for binary encodings.

Parameters

probabilityfloat

The probability of applying this operator.

class InjectedPopulation(solutions)

Bases: Generator

Generator for injecting solutions into the initial population.

Any remaining slots in the initial population will be filled with random solutions generated in the same manner as RandomGenerator.

Parameters

solutionsiterable of Solution

The solutions to inject into the pouplation.

class Insertion(probability=0.3)

Bases: Mutation

Insertion mutation for permutations.

Removes the value at a random index and inserts it in a new, random location. This differs slighly from Swap in that only one element is relocated.

Parameters

probabilityfloat

The probability of applying this operator.

class Multimethod(algorithm, variators, update_frequency=100)

Bases: Variator

Multimethod variation.

Given a list of variation operators and their assigned probabilities, picks an operator at random each time evolve() is called. The probabilities initiall start out at 1 / len(variators), but adapts over time to favor operators producing more offspring that survive to future generations.

Parameters

algorithmAlgorithm

The algorithm using this operator.

variatorslist of Variator

The variators to include.

update_frequencyint

Controls how frequently the probabilities change.

class NonUniformMutation(probability, perturbation, max_iterations, algorithm)

Bases: Mutation

Non-uniform mutation used by OMOPSO.

Parameters

probabilityfloat

Probability of applying this operator.

perturbationfloat

Controls the magnitude of the mutation.

max_iterationsint

The maximum number of iterations that OMOPSO is expected to run, which is used to decrease the magnitude of mutations over time.

algorithmAlgorithm

A reference to the OMOPSO instance.

class PCX(nparents=10, noffspring=2, eta=0.1, zeta=0.1)

Bases: Variator

Parent-centric crossover (PCX).

Parameters

nparentsint

The number of parents.

noffspringint

The number of offspring produced.

etafloat

Parameter controlling the shape of the resulting distribution.

zetafloat

Parameter controlling the shape of the resulting distribution.

class PM(probability=1, distribution_index=20.0)

Bases: Mutation

Polynomial mutation (PM).

Parameters

probabilityfloat

Probability of applying this operator to a decision variable.

distribution_indexfloat

Controls the distribution of this operator. Larger values tend to produce offspring nearer the parent.

class PMX(probability=1.0)

Bases: Variator

Partially mapped crossover (PMX) for permutations.

Parameters

probabilityfloat

The probability of applying this operator.

class RandomGenerator

Bases: Generator

Generator for producing random initial populatioins

class Replace(probability=0.3)

Bases: Mutation

Replace mutation for subsets.

Selects a random element in the subset and replaces it with a different element.

Parameters

probabilityfloat

The probability of applying this operator.

class SBX(probability=1.0, distribution_index=15.0)

Bases: Variator

Simulated binary crossover (SBX).

Parameters

probabilityfloat

Probability of applying this operator to a decision variable.

distribution_indexfloat

Controls the distribution of this operator. Larger values tend to produce offspring nearer the parent.

class SPX(nparents=10, noffspring=2, expansion=None)

Bases: Variator

Simplex crossover (SPX).

Parameters

nparentsint

The number of parents.

noffspringint

The number of offspring produced.

expansionfloat

Parameter controlling the shape of the resulting distribution.

class SSX(probability=1.0)

Bases: Variator

Subset crossover.

Randomly swaps elements from the two parent subsets.

Parameters

probabilityfloat

The probability of applying this operator.

class Swap(probability=0.3)

Bases: Mutation

Swap mutation for permutations.

Randomly picks two indices in the permutation and swaps their values.

Parameters

probabilityfloat

The probability of applying this operator.

class TournamentSelector(tournament_size=2, dominance=<platypus.core.ParetoDominance object>)

Bases: Selector

Tournament selection.

Parameters

tournament_sizeint

The size of the tournament, typically 2.

dominanceDominance

The dominance criteria for selecting the winner of the tournament.

select_one(population)

Selects a single member from the population.

Parameters

population: list of Solution

The population of solutions.

class UM(probability=1)

Bases: Mutation

Uniform mutation (UM).

Parameters

probabilityfloat

Probability of applying this operator to a decision variable.

class UNDX(nparents=10, noffspring=2, zeta=0.5, eta=0.35)

Bases: Variator

Unimodal normal distribution crossover (UNDX).

Parameters

nparentsint

The number of parents.

noffspringint

The number of offspring produced.

zetafloat

Parameter controlling the shape of the resulting distribution.

etafloat

Parameter controlling the shape of the resulting distribution.

class UniformMutation(probability, perturbation)

Bases: Mutation

Uniform mutation used by OMOPSO.

Parameters

probabilityfloat

Probability of applying this operator.

perturbationfloat

Controls the magnitude of the mutation.