# macop.operators.discrete.mutators — macop v1.0.5 documentation

# macop.operators.discrete.mutators

Mutation implementations for discrete solution

Classes

`SimpleBinaryMutation`() | Mutation implementation for binary solution, swap bit randomly from solution
`SimpleMutation`() | Mutation implementation for binary solution, swap two bits randomly from solution

class `macop.operators.discrete.mutators.``SimpleBinaryMutation`

  Mutation implementation for binary solution, swap bit randomly from solution

  `kind`

    {KindOperator} – specify the kind of operator

  Example:

      >>> # import of solution and simple binary mutation operator
      >>> from macop.solutions.discrete import BinarySolution
      >>> from macop.operators.discrete.mutators import SimpleBinaryMutation
      >>> solution = BinarySolution.random(5)
      >>> list(solution._data)
      [0, 1, 0, 0, 0]
      >>> mutator = SimpleBinaryMutation()
      >>> mutation_solution = mutator.apply(solution)
      >>> list(mutation_solution._data)
      [1, 1, 0, 0, 0]

  `apply`(solution)

    Create new solution based on solution passed as parameter

    Parameters

      solution – {Solution} – the solution to use for generating new solution

    Returns

      {Solution} – new generated solution

class `macop.operators.discrete.mutators.``SimpleMutation`

  Mutation implementation for binary solution, swap two bits randomly from solution

  `kind`

    {KindOperator} – specify the kind of operator

  Example:

      >>> # import of solution and simple mutation operator
      >>> from macop.solutions.discrete import BinarySolution
      >>> from macop.operators.discrete.mutators import SimpleMutation
      >>> solution = BinarySolution.random(5)
      >>> list(solution._data)
      [1, 0, 0, 0, 1]
      >>> mutator = SimpleMutation()
      >>> mutation_solution = mutator.apply(solution)
      >>> list(mutation_solution._data)
      [0, 0, 1, 0, 1]

  `apply`(solution)

    Create new solution based on solution passed as parameter

    Parameters

      solution – {Solution} – the solution to use for generating new solution

    Returns

      {Solution} – new generated solution