66waits the sampled delay (and any resource wait) before delivering the
77message to the target node's inbox.
88"""
9-
109from collections .abc import Generator
10+ from typing import TYPE_CHECKING
1111
1212import numpy as np
1313import simpy
1717from app .core .event_samplers .common_helpers import general_sampler
1818from app .schemas .system_topology_schema .full_system_topology_schema import Edge
1919
20+ if TYPE_CHECKING :
21+ from app .schemas .random_variables_config import RVConfig
22+
23+
2024
2125class EdgeRuntime :
2226 """definining the logic to handle the edges during the simulation"""
@@ -37,16 +41,16 @@ def __init__(
3741
3842 def _deliver (self , state : RequestState ) -> Generator [simpy .Event , None , None ]:
3943 """Function to deliver the state to the next node"""
40- # assign a probability that the network will drop the request
41- distribution = self .edge_config .latency . distribution
44+ # extract the random variables defining the latency of the edge
45+ random_variable : RVConfig = self .edge_config .latency
4246
4347 uniform_variable = self .rng .uniform ()
4448 if uniform_variable < NetworkParameters .DROPOUT_RATE :
4549 state .finish_time = self .env .now
4650 state .record_hop (f"{ self .edge_config .id } -dropped" )
4751 return
4852
49- transit_time = general_sampler (distribution , self .rng )
53+ transit_time = general_sampler (random_variable , self .rng )
5054 yield self .env .timeout (transit_time )
5155 state .record_hop (self .edge_config .id , self .env .now )
5256 self .target_box .put (state )
0 commit comments