qns.entity.monitor package
Submodules
qns.entity.monitor.monitor module
- class qns.entity.monitor.monitor.Monitor(name: Optional[str] = None, network: Optional[qns.network.network.QuantumNetwork] = None)[source]
Bases:
qns.entity.entity.Entity
- add_attribution(name: str, calculate_func: Callable[[qns.simulator.simulator.Simulator, Optional[qns.network.network.QuantumNetwork], Optional[qns.simulator.event.Event]], Any]) None [source]
Set an attribution that will be recorded. For example, an attribution could be the throughput, or the fidelity.
- Parameters
name (str) – the column’s name, e.g., fidelity, throughput, time …
calculate_func (Callable[[Simulator, Optional[QuantumNetwork], Optional[Event]]) – a function to calculate the value, it has three input parameters (Simulator, QuantumNetwork, Event), and it returns the value.
- Usage:
m = Monitor()
# record the event happening time m.add_attribution(“time”, lambda s,n,e: e.t)
# get the ‘name’ attribution of the last node m.add_attribution(“count”, lambda s,network,e: network.nodes[-1].name)
- at_event(event_type) None [source]
Watch network status whenever the event happends
- Parameters
event_type (Event) – the watching event
- Usage:
# record network status when a node receives a qubit m.at_event(RecvQubitPacket)
- at_period(period_time: float) None [source]
Watch network status at a constant period.
- Parameters
period_time (float) – the period of watching network status [s]
- Usage:
# record network status every 3 seconds. m.at_period(3)
- calculate_date(event: qns.simulator.event.Event)[source]
- handle(event: qns.simulator.event.Event) None [source]
handle
is called to process an receivingEvent
.- Parameters
event (qns.simulator.event.Event) – the event that send to this entity
- install(simulator: qns.simulator.simulator.Simulator) None [source]
install
is called beforesimulator
runs to initialize or set initial events- Parameters
simulator (qns.simulator.simulator.Simulator) – the simulator
- class qns.entity.monitor.monitor.MonitorEvent(t: Optional[qns.simulator.ts.Time], monitor, name: Optional[str] = None, by: Optional[Any] = None)[source]
Bases:
qns.simulator.event.Event
the event that notify the monitor to write down network status
Module contents
- class qns.entity.monitor.Monitor(name: Optional[str] = None, network: Optional[qns.network.network.QuantumNetwork] = None)[source]
Bases:
qns.entity.entity.Entity
- add_attribution(name: str, calculate_func: Callable[[qns.simulator.simulator.Simulator, Optional[qns.network.network.QuantumNetwork], Optional[qns.simulator.event.Event]], Any]) None [source]
Set an attribution that will be recorded. For example, an attribution could be the throughput, or the fidelity.
- Parameters
name (str) – the column’s name, e.g., fidelity, throughput, time …
calculate_func (Callable[[Simulator, Optional[QuantumNetwork], Optional[Event]]) – a function to calculate the value, it has three input parameters (Simulator, QuantumNetwork, Event), and it returns the value.
- Usage:
m = Monitor()
# record the event happening time m.add_attribution(“time”, lambda s,n,e: e.t)
# get the ‘name’ attribution of the last node m.add_attribution(“count”, lambda s,network,e: network.nodes[-1].name)
- at_event(event_type) None [source]
Watch network status whenever the event happends
- Parameters
event_type (Event) – the watching event
- Usage:
# record network status when a node receives a qubit m.at_event(RecvQubitPacket)
- at_period(period_time: float) None [source]
Watch network status at a constant period.
- Parameters
period_time (float) – the period of watching network status [s]
- Usage:
# record network status every 3 seconds. m.at_period(3)
- calculate_date(event: qns.simulator.event.Event)[source]
- handle(event: qns.simulator.event.Event) None [source]
handle
is called to process an receivingEvent
.- Parameters
event (qns.simulator.event.Event) – the event that send to this entity
- install(simulator: qns.simulator.simulator.Simulator) None [source]
install
is called beforesimulator
runs to initialize or set initial events- Parameters
simulator (qns.simulator.simulator.Simulator) – the simulator
- class qns.entity.monitor.MonitorEvent(t: Optional[qns.simulator.ts.Time], monitor, name: Optional[str] = None, by: Optional[Any] = None)[source]
Bases:
qns.simulator.event.Event
the event that notify the monitor to write down network status