b_asic.schedule
¶
B-ASIC Schedule Module.
Contains the schedule class for scheduling operations in an SFG.
- class b_asic.schedule.Schedule(sfg: SFG, schedule_time: int | None = None, cyclic: bool = False, algorithm: Literal['ASAP', 'ALAP', 'provided'] = 'ASAP', start_times: Dict[GraphID, int] | None = None, laps: Dict[GraphID, int] | None = None, max_resources: Dict[TypeName, int] | None = None)¶
Bases:
object
Schedule of an SFG with scheduled Operations.
- Parameters:
- sfg
SFG
The signal flow graph to schedule.
- schedule_timeint, optional
The schedule time. If not provided, it will be determined by the scheduling algorithm.
- cyclicbool, default: False
If the schedule is cyclic.
- algorithm{‘ASAP’, ‘ALAP’, ‘provided’}, default: ‘ASAP’
The scheduling algorithm to use. The following algorithm are available:
'ASAP'
: As-soon-as-possible scheduling.'ALAP'
: As-late-as-possible scheduling.
If ‘provided’, use provided start_times and laps dictionaries.
- start_timesdict, optional
Dictionary with GraphIDs as keys and start times as values. Used when algorithm is ‘provided’.
- lapsdict, optional
Dictionary with GraphIDs as keys and laps as values. Used when algorithm is ‘provided’.
- max_resourcesdict, 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.
- sfg
- backward_slack(graph_id: GraphID) int ¶
Return how much an operation can be moved backward in time.
- Parameters:
- graph_idGraphID
The graph id of the operation.
- Returns:
- int
The number of time steps the operation with graph_id can be moved backward in time.
Note
The backward slack is positive, but a call to
move_operation()
should be negative to move the operation backward.
See also
- decrease_time_resolution(factor: int) Schedule ¶
Decrease time resolution for a schedule.
- Parameters:
- factorint
The time resolution decrement.
- edit(inplace=False) Schedule ¶
Edit schedule in GUI and return new schedule.
- Parameters:
- inplacebool, default: False
If True, replace the current schedule.
- forward_slack(graph_id: GraphID) int ¶
Return how much an operation can be moved forward in time.
- Parameters:
- graph_idGraphID
The graph id of the operation.
- Returns:
- int
The number of time steps the operation with graph_id can be moved forward in time.
See also
- get_memory_variables() ProcessCollection ¶
Return a ProcessCollection containing all memory variables.
- Returns:
- get_operations() ProcessCollection ¶
Return a ProcessCollection containing all operations.
- Returns:
- get_possible_time_resolution_decrements() List[int] ¶
Return a list with possible factors to reduce time resolution.
- get_y_location(graph_id: GraphID) int ¶
Get the y-position of the Operation with GraphID graph_id.
- Parameters:
- graph_idGraphID
The GraphID of the operation.
- Returns:
- int
The y-position of the operation.
- increase_time_resolution(factor: int) Schedule ¶
Increase time resolution for a schedule.
- Parameters:
- factorint
The time resolution increment.
- property laps: Dict[GraphID, int]¶
The number of laps for the start times of the operations in the schedule.
- move_operation(graph_id: GraphID, time: int) Schedule ¶
Move an operation in the schedule.
- Parameters:
- graph_idGraphID
The graph id of the operation to move.
- timeint
The time to move. If positive move forward, if negative move backward.
- move_operation_alap(graph_id: GraphID) Schedule ¶
Move an operation as late as possible in the schedule.
This is basically the same as:
schedule.move_operation(graph_id, schedule.forward_slack(graph_id))
but operations with no succeeding operation (Outputs) will only move to the end of the schedule.
- Parameters:
- graph_idGraphID
The graph id of the operation to move.
- move_operation_asap(graph_id: GraphID) Schedule ¶
Move an operation as soon as possible in the schedule.
This is basically the same as:
schedule.move_operation(graph_id, -schedule.backward_slack(graph_id))
but operations that do not have a preceding operation (Inputs and Constants) will only move to the start of the schedule.
- Parameters:
- graph_idGraphID
The graph id of the operation to move.
- move_y_location(graph_id: GraphID, new_y: int, insert: bool = False) None ¶
Move operation in y-direction and remove any empty rows.
- Parameters:
- graph_idGraphID
The GraphID of the operation to move.
- new_yint
The new y-position of the operation.
- insertbool, optional
If True, all operations on that y-position will be moved one position. The default is False.
- plot(ax: Axes, operation_gap: float = 0.5) None ¶
Plot the schedule in a
matplotlib.axes.Axes
or subclass.- Parameters:
- ax
Axes
The
matplotlib.axes.Axes
to plot in.- operation_gapfloat, optional
The vertical distance between operations in the schedule. The height of the operation is always 1.
- ax
- print_slacks(order: int = 0) None ¶
Print the slack times for all operations in the schedule.
- Parameters:
- orderint, default: 0
Sorting order.
0: alphabetical on Graph ID
1: backward slack
2: forward slack
- set_execution_time_of_type(type_name: TypeName, execution_time: int) None ¶
Set the execution time of all operations with the given type name.
- Parameters:
- type_nameTypeName
The type name of the operation. For example, obtained as
Addition.type_name()
.- execution_timeint
The execution time of the operation.
- set_schedule_time(time: int) Schedule ¶
Set a new schedule time.
- Parameters:
- timeint
The new schedule time. If it is too short, a ValueError will be raised.
See also
get_max_time
- set_y_location(graph_id: GraphID, y_location: int) None ¶
Set the y-position of the Operation with GraphID graph_id to y_location.
- Parameters:
- graph_idGraphID
The GraphID of the operation to move.
- y_locationint
The new y-position of the operation.
- show(operation_gap: float = 0.5, title: str | None = None) None ¶
Show the schedule. Will display based on the current Matplotlib backend.
- Parameters:
- operation_gapfloat, optional
The vertical distance between operations in the schedule. The height of the operation is always 1.
- titlestr, optional
Figure title.
- slacks(graph_id: GraphID) Tuple[int, int] ¶
Return the backward and forward slacks of operation graph_id.
That is, how much the operation can be moved backward and forward in time.
- Parameters:
- graph_idGraphID
The graph id of the operation.
- Returns:
- tuple(int, int)
The backward and forward slacks, respectively.
Note
The backward slack is positive, but a call to
move_operation()
should be negative to move the operation backward.
See also