Operator.py 756 B

123456789101112131415161718192021222324252627282930313233
  1. # main imports
  2. from enum import Enum
  3. # enumeration which stores kind of operator
  4. class KindOperator(Enum):
  5. MUTATOR = 1
  6. CROSSOVER = 2
  7. class Operator():
  8. def __init__(self):
  9. pass
  10. def apply(self, solution):
  11. """Apply the current operator transformation
  12. Args:
  13. solution (Solution): Solution instance
  14. Raises:
  15. NotImplementedError: if method not implemented into child class
  16. """
  17. raise NotImplementedError
  18. def setAlgo(self, algo):
  19. """Keep into operator reference of the whole algorithm
  20. The reason is to better manage operator instance
  21. Args:
  22. algo (Algorithm): the algorithm reference runned
  23. """
  24. self.algo = algo