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)[source]

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()[source]

Select randomly the next operator to use

Returns

the selected operator

Return type

{Operator}