b_asic.scheduler

Inheritance diagram of b_asic.scheduler

B-ASIC Scheduler Module.

Contains classes for automatic scheduling of SFGs.

class b_asic.scheduler.ALAPScheduler(input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, sort_y_location: bool = True)

Bases: Scheduler

Scheduler that implements the as-late-as-possible (ALAP) algorithm.

Parameters:
input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

The relative times when outputs should be produced.

output_timesdict(GraphID, int), optional

The times when outputs should be produced.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.ASAPScheduler(input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, sort_y_location: bool = True)

Bases: Scheduler

Scheduler that implements the as-soon-as-possible (ASAP) algorithm.

Parameters:
input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

The relative times when outputs should be produced.

output_timesdict(GraphID, int), optional

The times when outputs should be produced.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.CPRecursiveScheduler(solver: str | SolverInterface | None = None, input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, max_time: int | None = None, sort_y_location: bool = True, **kwargs)

Bases: CPScheduler

Constraint programming scheduler for algorithms with feedback through delays.

Minimize the sum of peak resource counts, including I/O, using the same per-connection feedback constraints as ILPRecursiveScheduler. Search the full scheduling horizon rather than restricting start times to ASAP/ALAP bounds, so iterations may overlap even when the period is shorter than the ASAP schedule length.

Accepts the same parameters and solver options as CPScheduler. max_time extends the absolute horizon for cyclic schedules; the Schedule’s schedule_time specifies the iteration period. Without an explicit period, use the ASAP schedule length. Requires the optional cp dependencies (pip install b-asic[cp]).

Compact I/O slack after solving as in ILPRecursiveScheduler, preserving fixed input times and relative output offsets. Fixed output times disable this compaction.

Examples

from b_asic import CPRecursiveScheduler, Schedule

schedule = Schedule(
    sfg, CPRecursiveScheduler(max_time=20),
    schedule_time=10, cyclic=True,
)
class b_asic.scheduler.CPScheduler(solver: str | SolverInterface | None = None, input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, max_time: int | None = None, sort_y_location: bool = True, **kwargs)

Bases: _OptimizationScheduler

Constraint programming scheduler minimizing concurrent operations and I/O.

Minimizes the sum of peak resource counts for each operation type, including I/O. For cyclic schedules, resource constraints count overlap between successive iterations. I/O timing constraints tighten resource bounds, and a feasible ASAP schedule is supplied as a warm start when the solver supports solution hints.

Requires the optional cp dependencies (pip install b-asic[cp]).

Parameters:
solverstr or SolverInterface, optional

CPMpy solver name (default: "ortools") or a fresh solver instance. Constraints and the objective are added to supplied instances in place, preserving native solver settings.

input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

Output offsets relative to a common time chosen by the solver. The outputs may move together within the scheduling horizon.

output_timesdict(GraphID, int), optional

The times when outputs should be produced. For cyclic schedules these specify the time within the schedule period.

max_timeint, optional

The time horizon to schedule for in cyclic scheduling. The iteration period is specified by the Schedule’s schedule_time parameter.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

**kwargsAny

Options passed to the CPMpy solver’s solve() method, for example time_limit=60 or, for OR-Tools, num_search_workers=4.

Examples

Schedule an SFG with a given schedule time:

from b_asic import CPScheduler, Schedule

schedule = Schedule(sfg, CPScheduler(), schedule_time=20)
apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.ILPRecursiveScheduler(solver: LpSolver | None = None, input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, max_time: int | None = None, sort_y_location: bool = True)

Bases: ILPScheduler

ILP scheduler for algorithms with feedback through delays.

Minimize the sum of peak resource counts, including I/O, for a fixed iteration period. Each input connection contributes its own precedence constraint, with one period of available time per intervening Delay. Latency offsets determine data availability; execution times determine resource occupancy, including overlap between cyclic iterations.

Accepts the same parameters as ILPScheduler. max_time is an optional absolute scheduling horizon for cyclic schedules, allowing operations to span several iterations before folding into the period. Without schedule_time, use the ASAP schedule length as the period. Output delta times are relative to a common time chosen by the solver. Unless output times are fixed, compact I/O slack after solving. Unspecified inputs start at zero; the other operations rotate together to remove input slack, and outputs move earlier while preserving specified output deltas.

Examples

from b_asic import ILPRecursiveScheduler, Schedule

schedule = Schedule(
    sfg, ILPRecursiveScheduler(), schedule_time=10, cyclic=True
)
apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.ILPScheduler(solver: LpSolver | None = None, input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, max_time: int | None = None, sort_y_location: bool = True)

Bases: _OptimizationScheduler

ILP-based scheduler that minimizes the sum of per-type resource counts.

Resource occupancy is determined by execution time. For cyclic schedules, occupancy includes overlap between successive iterations.

Parameters:
solverLpSolver, optional
import pulp

print(pulp.listSolvers(onlyAvailable=True))
input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

Output offsets relative to a common time chosen by the solver. The outputs may move together within the scheduling horizon.

output_timesdict(GraphID, int), optional

The times when outputs should be produced.

max_timeint, optional

The time horizon to schedule for in cyclic scheduling.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.ListScheduler(sort_order: tuple[tuple[int, bool], ...], max_resources: dict[TypeName, int] | None = None, max_concurrent_reads: int | None = None, max_concurrent_writes: int | None = None, input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, sort_y_location: bool = True)

Bases: Scheduler

List-based scheduler with optional constraints.

Important

Only works on non-recursive SFGs. For recursive SFGs use RecursiveListScheduler instead.

Parameters:
sort_ordertuple(tuple(int, bool))

Specifies which columns in the priority table to sort on and in which order, where True is ascending order. There are five columns:

0 - GraphID of the operation.
1 - Deadline, i.e., the clock cycle that the data is required in the ALAP schedule.
2 - Output slack, i.e., the start time of the operation in the ALAP schedule when sorted on.
3 - Fan-out, i.e., the number of operations reading from the output of the operation.
4 - Memory reads, i.e., the number of memory reads required if operation is scheduled in the
    current time slot.
max_resourcesdict[TypeName, int], optional

Max resources available to realize the schedule.

max_concurrent_readsint, optional

Max number of concurrent reads.

max_concurrent_writesint, optional

Max number of concurrent writes.

input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

The relative times when outputs should be produced.

output_timesdict(GraphID, int), optional

The times when outputs should be produced.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.RecursiveListScheduler(sort_order: tuple[tuple[int, bool], ...], max_resources: dict[TypeName, int] | None = None, input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, sort_y_location: bool = True)

Bases: ListScheduler

List-based scheduler for recursive algorithms with optional constraints.

Info

If the SFG does not have any recursive parts, use ListScheduler instead.

Parameters:
sort_ordertuple(tuple(int, bool))

Specifies which columns in the priority table to sort on and in which order, where True is ascending order. There are five columns:

0 - GraphID of the operation.
1 - Deadline, i.e., the clock cycle that the data is required in the ALAP schedule.
2 - Output slack, i.e., the start time of the operation in the ALAP schedule when sorted on.
3 - Fan-out, i.e., the number of operations reading from the output of the operation.
4 - Memory reads, i.e., the number of memory reads required if operation is scheduled in the
    current time slot.
max_resourcesdict[TypeName, int], optional

Max resources available to realize the schedule.

input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

The relative times when outputs should be produced.

output_timesdict(GraphID, int), optional

The times when outputs should be produced.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.

class b_asic.scheduler.Scheduler(input_times: dict[GraphID, int] | None = None, output_delta_times: dict[GraphID, int] | None = None, output_times: dict[GraphID, int] | None = None, sort_y_location: bool = True)

Bases: ABC

Scheduler base class.

Parameters:
input_timesdict(GraphID, int), optional

The times when inputs arrive.

output_delta_timesdict(GraphID, int), optional

The relative times when outputs should be produced.

output_timesdict(GraphID, int), optional

The times when outputs should be produced.

sort_y_locationbool, default: True

If the y-location should be sorted based on start time of operations.

abstractmethod apply_scheduling(schedule: Schedule) → None

Apply the scheduling algorithm on the given Schedule.

Parameters:
scheduleSchedule

Schedule to apply the scheduling algorithm on.