From d5935e9d614be17586c743feaf3b57833539cc11 Mon Sep 17 00:00:00 2001
From: Simon Bjurek <simbj106@student.liu.se>
Date: Wed, 29 Jan 2025 09:50:23 +0100
Subject: [PATCH] added docstrings for scheduler

---
 b_asic/scheduler.py | 57 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 46 insertions(+), 11 deletions(-)

diff --git a/b_asic/scheduler.py b/b_asic/scheduler.py
index 30089db2..554ce97e 100644
--- a/b_asic/scheduler.py
+++ b/b_asic/scheduler.py
@@ -1,5 +1,5 @@
 from abc import ABC, abstractmethod
-from typing import TYPE_CHECKING, cast
+from typing import TYPE_CHECKING, Optional, cast
 
 from b_asic.port import OutputPort
 from b_asic.special_operations import Delay, Output
@@ -9,17 +9,16 @@ if TYPE_CHECKING:
     from b_asic.schedule import Schedule
 
 
-# class SchedulingAlgorithm(Enum):
-#     ASAP = "ASAP"
-#     ALAP = "ALAP"
-#     EARLIEST_DEADLINE = "earliest_deadline"
-#     # LEAST_SLACK = "least_slack" # to be implemented
-#     PROVIDED = "provided"
-
-
 class Scheduler(ABC):
     @abstractmethod
     def apply_scheduling(self, schedule: "Schedule") -> None:
+        """Applies the scheduling algorithm on the given Schedule.
+
+        Parameters
+        ----------
+        schedule : Schedule
+            Schedule to apply the scheduling algorithm on.
+        """
         pass
 
     def _handle_outputs(self, schedule, non_schedulable_ops) -> None:
@@ -41,7 +40,16 @@ class Scheduler(ABC):
 
 
 class ASAPScheduler(Scheduler):
+    """Scheduler that implements the as-soon-as-possible (ASAP) algorithm."""
+
     def apply_scheduling(self, schedule: "Schedule") -> None:
+        """Applies the scheduling algorithm on the given Schedule.
+
+        Parameters
+        ----------
+        schedule : Schedule
+            Schedule to apply the scheduling algorithm on.
+        """
         prec_list = schedule.sfg.get_precedence_list()
         if len(prec_list) < 2:
             raise ValueError("Empty signal flow graph cannot be scheduled.")
@@ -114,8 +122,16 @@ class ASAPScheduler(Scheduler):
 
 
 class ALAPScheduler(Scheduler):
+    """Scheduler that implements the as-late-as-possible (ALAP) algorithm."""
+
     def apply_scheduling(self, schedule: "Schedule") -> None:
-        # self.schedule_asap()
+        """Applies the scheduling algorithm on the given Schedule.
+
+        Parameters
+        ----------
+        schedule : Schedule
+            Schedule to apply the scheduling algorithm on.
+        """
         ASAPScheduler().apply_scheduling(schedule)
         max_end_time = schedule.get_max_end_time()
 
@@ -137,10 +153,29 @@ class ALAPScheduler(Scheduler):
 
 
 class EarliestDeadlineScheduler(Scheduler):
-    def __init__(self, max_resources: dict[TypeName, int]) -> None:
+    """
+    Scheduler that implements the earliest-deadline-first algorithm.
+
+    Parameters
+    ----------
+    max_resources : dict, optional
+        Dictionary like ``{Addition.type_name(): 2}`` denoting the maximum number of
+        resources for a given operation type if the scheduling algorithm considers
+        that. If not provided, or an operation type is not provided, at most one
+        resource is used.
+    """
+
+    def __init__(self, max_resources: Optional[dict[TypeName, int]]) -> None:
         self._max_resources = max_resources
 
     def apply_scheduling(self, schedule: "Schedule") -> None:
+        """Applies the scheduling algorithm on the given Schedule.
+
+        Parameters
+        ----------
+        schedule : Schedule
+            Schedule to apply the scheduling algorithm on.
+        """
         # ACT BASED ON THE NUMBER OF PEs!
         prec_list = schedule.sfg.get_precedence_list()
         if len(prec_list) < 2:
-- 
GitLab