# macop.policies.classicals — macop v1.0.5 documentation

# macop.policies.classicals

Classical policies classes implementations

Classes

`RandomPolicy`(operators) | Policy class implementation which is used for select operator randomly from the operators list

class `macop.policies.classicals.``RandomPolicy`(operators)

  Policy class implementation which is used for select operator randomly from the operators list

  `operators`

    {[Operator]} – list of selected operators for the algorithm

  Example:

      >>> import random
      >>> random.seed(42)
      >>> from macop.operators.discrete.crossovers import SimpleCrossover
      >>> from macop.operators.discrete.mutators import SimpleMutation
      >>> from macop.policies.classicals import RandomPolicy
      >>> policy = RandomPolicy([SimpleCrossover(), SimpleMutation()])
      >>> operator = policy.select()
      >>> type(operator).__name__
      'SimpleCrossover'

  `select`()

    Select randomly the next operator to use

    Returns

      the selected operator

    Return type

      {Operator}