freneticlib.core.mutation.mutators

Module Contents

Classes

RemoveFront

Mutation operator for removing a range of road points from the front of the test

RemoveBack

Mutation operator for removing a range of road points from the back of the road.

RemoveRandom

Mutation operator for removing a random road points of the road.

AddBack

Mutation operator for adding random road points at the end of the road.

ReplaceRandom

Mutation operator for replacing random road points replaced with new ones.

AlterValues

Mutation operator for altering random road points by multiplying with a factor.

KappaStepAlterValues

Value mutation operator for the KappaRepresentation.

StandardMutator

Default Mutator, applies all operators approach.

FreneticMutator

The default mutator which implements the Frenetic approach.

class freneticlib.core.mutation.mutators.RemoveFront(remove_at_least: int = 1, remove_at_most: int = 5, min_length_for_operator: int = 10)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutationOperator

Mutation operator for removing a range of road points from the front of the test

Parameters:
  • remove_at_least (int) – Minimum number of road points to remove.

  • remove_at_most (int) – Maximum number of road points to remove.

  • min_length_for_operator (int) – Minimum number of road points required for application.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road by removing a range of road points from the front of the road.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

is_applicable(test) bool[source]

Check if test can be mutated.

Parameters:

test – The road (in a given representation).

Returns:

Whether the mutation operator is applicable.

Return type:

(bool)

class freneticlib.core.mutation.mutators.RemoveBack(remove_at_least: int = 1, remove_at_most: int = 5, min_length_for_operator: int = 10)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutationOperator

Mutation operator for removing a range of road points from the back of the road.

Parameters:
  • remove_at_least (int) – Minimum number of road points to remove.

  • remove_at_most (int) – Maximum number of road points to remove.

  • min_length_for_operator (int) – Minimum number of road points required for application.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road by removing a range of road points from the back of the road.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

is_applicable(test) bool[source]

Check if test can be mutated.

Parameters:

test – The road (in a given representation).

Returns:

Whether the mutation operator is applicable.

Return type:

(bool)

class freneticlib.core.mutation.mutators.RemoveRandom(remove_at_least: int = 1, remove_at_most: int = 5, min_length_for_operator: int = 10)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutationOperator

Mutation operator for removing a random road points of the road.

Parameters:
  • remove_at_least (int) – Minimum number of road points to remove.

  • remove_at_most (int) – Maximum number of road points to remove.

  • min_length_for_operator (int) – Minimum number of road points required for application.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road by removing random road points.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

is_applicable(test) bool[source]

Check if test can be mutated.

Parameters:

test – The road (in a given representation).

Returns:

Whether the mutation operator is applicable.

Return type:

(bool)

class freneticlib.core.mutation.mutators.AddBack(add_at_least: int = 1, add_at_most: int = 5)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutationOperator

Mutation operator for adding random road points at the end of the road.

Parameters:
  • add_at_least (int) – Minimum number of road points to add.

  • add_at_most (int) – Maximum number of road points to add.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road with new road points added at the back of the road.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

class freneticlib.core.mutation.mutators.ReplaceRandom(replace_at_least: int = 1, replace_at_most: int = 5)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutationOperator

Mutation operator for replacing random road points replaced with new ones.

Parameters:
  • replace_at_least (int) – Minimum number of road points to add.

  • replace_at_most (int) – Maximum number of road points to add.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road with random road points replaced with new ones.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

class freneticlib.core.mutation.mutators.AlterValues(mutation_factor_low: float = 0.9, mutation_factor_high: float = 1.1, mutation_chance: float = 0.1)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutationOperator

Mutation operator for altering random road points by multiplying with a factor.

Parameters:
  • mutation_factor_low (float) – Minimum factor to apply to a road point.

  • mutation_factor_high (float) – Maximum factor to apply to a road point.

  • mutation_chance (float) – The mutation chance for each road point.

_alter_once(test)[source]
__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road with random road points altered by a random factor.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

class freneticlib.core.mutation.mutators.KappaStepAlterValues(mutation_factor_low: float = 0.9, mutation_factor_high: float = 1.1, mutation_chance: float = 0.1)[source]

Bases: AlterValues

Value mutation operator for the KappaRepresentation. It alters random road points and the steps by multiplying with a factor.

Parameters:
  • mutation_factor_low (float) – Minimum factor to apply to a road point.

  • mutation_factor_high (float) – Maximum factor to apply to a road point.

  • mutation_chance (float) – The mutation chance for each road point.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, test)[source]

Returns a copy of the road with random road points altered by a random factor.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The road (in a given representation).

Returns:

The mutated road.

class freneticlib.core.mutation.mutators.StandardMutator(mutation_operators: List[freneticlib.core.mutation.abstract_operators.AbstractMutationOperator] = None)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutator

Default Mutator, applies all operators approach.

Parameters:

mutation_operators (List[AbstractMutationOperator]) – The operators used for mutation.

__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, parent)[source]

Create a new road by combining road points from two parents.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The parent to be mutated.

Returns:

(List) The mutated tests.

get_all()[source]

Return all operators.

class freneticlib.core.mutation.mutators.FreneticMutator(mutation_operators: List[freneticlib.core.mutation.abstract_operators.AbstractMutationOperator] = None, exploitation_operators: List[freneticlib.core.mutation.abstract_operators.AbstractMutationOperator] = None)[source]

Bases: freneticlib.core.mutation.abstract_operators.AbstractMutator

The default mutator which implements the Frenetic approach.

It distinguishes between exploration and exploitation.

Parameters:
__call__(representation: freneticlib.representations.abstract_representation.RoadRepresentation, parent)[source]

Create a new road by combining road points from two parents.

Parameters:
  • representation (RoadRepresentation) – The road representation used in this search.

  • test – The parent to be mutated.

Returns:

(List) The mutated tests.