"""Type hint and base class for all solvers."""importabcfromtypingimportCallableimporttimefromjob_shop_libimportJobShopInstance,Schedule# Every solver should be a callable that takes a JobShopInstance and returns a# Schedule.Solver=Callable[[JobShopInstance],Schedule]
[docs]classBaseSolver(abc.ABC):"""Base class for all solvers implemented as classes. A ``Solver`` is any ``Callable`` that takes a :class:`JobShopInstance` and returns a :class:`Schedule`. Therefore, solvers can be implemented as functions or as classes. This class is provided as a base class for solvers implemented as classes. It provides a default implementation of the ``__call__`` method that measures the time taken to solve the instance and stores it in the schedule's metadata under the key "elapsed_time" if it is not alreadypresent. """
[docs]@abc.abstractmethoddefsolve(self,instance:JobShopInstance)->Schedule:"""Solves the given job shop instance and returns the schedule."""