qns.simulator package
Submodules
qns.simulator.event module
- class qns.simulator.event.Event(t: Time | None = None, name: str | None = None, by: Any | None = None)[source]
Bases:
objectBasic event class in simulator
- property is_canceled: bool
Returns: whether this event has been canceled
- qns.simulator.event.func_to_event(t: Time, fn, name: str | None = None, by: Any | None = None, *args, **kwargs)[source]
Convert a function to an event, the function fn will be called at t. It is a simple method to wrap a function to an event.
- Parameters:
t (Time) – the function will be called at t
fn (Callable) – the function
by – the entity or application that will causes this event
*args – the function’s parameters
**kwargs – the function’s parameters
qns.simulator.pool module
qns.simulator.pool module
qns.simulator.simulator module
- class qns.simulator.simulator.Simulator(start_second: float = 0.0, end_second: float = 60.0, accuracy: int = 1000000, pool_cls: ~typing.Type[~qns.simulator.pool.DefaultEventPool] = <class 'qns.simulator.pool.DefaultEventPool'>, pool_kwargs: ~typing.Dict[str, ~typing.Any] | None = None)[source]
Bases:
objectThe discrete-event driven simulator core
- add_event(event: Event) None[source]
Add an
eventinto simulator event pool. :param event: the inserting event
qns.simulator.ts module
qns.simulator.ts module
Module contents
- class qns.simulator.DefaultEventPool(ts: Time, te: Time)[source]
Bases:
objectThe default implement of the event pool
- class qns.simulator.Event(t: Time | None = None, name: str | None = None, by: Any | None = None)[source]
Bases:
objectBasic event class in simulator
- property is_canceled: bool
Returns: whether this event has been canceled
- class qns.simulator.HashedBucketEventPool(ts: Time, te: Time)[source]
Bases:
DefaultEventPoolAn event pool using a ‘hash bucket (timestamp -> deque)’ + ‘active timestamp heap’.
- class qns.simulator.Simulator(start_second: float = 0.0, end_second: float = 60.0, accuracy: int = 1000000, pool_cls: ~typing.Type[~qns.simulator.pool.DefaultEventPool] = <class 'qns.simulator.pool.DefaultEventPool'>, pool_kwargs: ~typing.Dict[str, ~typing.Any] | None = None)[source]
Bases:
objectThe discrete-event driven simulator core
- add_event(event: Event) None[source]
Add an
eventinto simulator event pool. :param event: the inserting event
- class qns.simulator.Time(time_slot: int = 0, sec: float = 0.0, accuracy: int = 1000000)[source]
Bases:
object- property sec: float
Returns: the timestamp in second
- qns.simulator.func_to_event(t: Time, fn, name: str | None = None, by: Any | None = None, *args, **kwargs)[source]
Convert a function to an event, the function fn will be called at t. It is a simple method to wrap a function to an event.
- Parameters:
t (Time) – the function will be called at t
fn (Callable) – the function
by – the entity or application that will causes this event
*args – the function’s parameters
**kwargs – the function’s parameters