Source(env, id, in_edges=None, out_edges=None, item_length=1, flow_item_type='item', inter_arrival_time=0, blocking=False, out_edge_selection='FIRST_AVAILABLE')
¶
Bases: Node
Parameters: |
|
---|
Behavior:
The Source node is responsible for generating items that flow in the simulation model. It operates in two modes: blocking and non-blocking.
when blocking=True
:
- After each inter_arrival_time
, the source generates an item.
- If the selected out edge is full, the source waits until space is available.
- Once space is available, the item is transferred to the selected edge.
- inter_arrival_time
must not be None
.
when blocking=False
:
- After each inter_arrival_time
, the source generates an item.
- If the selected out edge is full, the item is discarded immediately.
- If space is available, the item is transferred without waiting.
- inter_arrival_time
must not be 0.
Raises: |
|
---|
Output performance metrics:
The key performance metrics of the Source node is captured in stats
attribute (dict) during a simulation run.
last_state_change_time : Time when the state was last changed.
num_item_generated : Total number of items generated.
num_item_discarded : Total number of items discarded due to lack of space in out edge.
total_time_spent_in_states: Dictionary with total time spent in each state.
add_out_edges(edge)
¶
Adds an out_edge to the source node. Raises an error if the source already has an out_edge or if the edge already exists in the out_edges list.
Parameters: |
|
---|
update_state(new_state, current_time)
¶
Update node state and track the time spent in the previous state.
Parameters: |
|
---|