Checkpoint.py 963 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """Abstract Checkpoint class
  2. """
  3. # main imports
  4. import os
  5. import logging
  6. class Checkpoint():
  7. """
  8. Local Search used as exploitation optimization algorithm
  9. Attributes:
  10. algo: {Algorithm} -- main algorithm instance reference
  11. every: {int} -- checkpoint frequency used (based on number of evaluations)
  12. filepath: {str} -- file path where checkpoints will be saved
  13. """
  14. def __init__(self, _algo, _every, _filepath):
  15. self.algo = _algo
  16. self.every = _every
  17. self.filepath = _filepath
  18. # build path if not already exists
  19. head, _ = os.path.split(self.filepath)
  20. if not os.path.exists(head):
  21. os.makedirs(head)
  22. def run(self):
  23. """
  24. Check if necessary to do backup based on `every` variable
  25. """
  26. pass
  27. def load(self):
  28. """
  29. Load last backup line of solution and set algorithm state at this backup
  30. """
  31. pass