requsim.events module
Classes:
|
Abstract base class for events. |
|
Event that executes arbitrary function. |
|
An Event generating an entangled pair. |
|
An event to perform entanglement swapping. |
|
Event to discard a qubit and associated pair. |
|
Short summary. |
|
Unblock a set of quantum objects. |
Provides methods to queue and resolve Events in order. |
- class requsim.events.Event(time, required_objects=None, priority=20, ignore_blocked=False, callback_functions=None, *args, **kwargs)
Bases:
ABCAbstract base class for events.
Events are scheduled in an EventQueue and resolved at a specific time.
- Parameters
time (scalar) – The time at which the event will be resolved.
required_objects (list of QuantumObjects, or None) – Event will only resolve if all of these still exist at time. Default: None
priority (int (expected 0...39)) – prioritize events that happen at the same time according to this (lower number means being resolved first) Default: 20
ignore_blocked (bool) – Whether the event should act even on blocked objects. Default: False
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
- Variables
event_queue (EventQueue) – The event is part of this event queue. (None until added to an event queue.)
type –
time –
required_objects –
priority –
ignore_blocked –
Attributes:
Returns the event type.
Methods:
resolve()Resolve the event.
add_callback(callback_func)Add a callback to this event.
- property type
Returns the event type.
- Returns
str – The event type.
- resolve()
Resolve the event.
- Returns
dict – dict may contain additional information that can be passed to the protocol. The protocol will not necessarily use this information.
- add_callback(callback_func)
Add a callback to this event.
Multiple callbacks added this way will resolve in the order they were added.
- Parameters
callback_func (callable) – This function will be called with the _return_dict as an argument after the event is resolved.
- Returns
None
- class requsim.events.GenericEvent(time, resolve_function, *args, required_objects=None, priority=20, ignore_blocked=False, callback_functions=None, **kwargs)
Bases:
EventEvent that executes arbitrary function.
- Parameters
time (scalar) – Time at which the event will be resolved.
resolve_function (callable) – Function that will be called when the resolve method is called.
*args (any) – args for resolve_function.
required_objects (list of QuantumObjects, or None) – Keyword only argument. Default: None
priority (int) – Keyword only argument. Default: 20
ignore_blocked (bool) – Keyword only argument. Default: False
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
**kwargs (any) – kwargs for resolve_function.
- class requsim.events.SourceEvent(time, source, initial_state, callback_functions=None, *args, **kwargs)
Bases:
EventAn Event generating an entangled pair.
- Parameters
time (scalar) – Time at which the event will be resolved.
source (Source) – The source object generating the entangled pair.
initial_state (np.ndarray) – Density matrix of the two qubit system being generated.
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
*args – additional optional args and kwargs to pass to the the generate_pair method of source
**kwargs – additional optional args and kwargs to pass to the the generate_pair method of source
- Variables
source –
initial_state –
generation_args (additional args for the generate_pair method of source) –
generation_kwargs (additional kwargs for the generate_pair method of source) –
- class requsim.events.EntanglementSwappingEvent(time, pairs, station, callback_functions=None)
Bases:
EventAn event to perform entanglement swapping.
- Parameters
time (scalar) – Time at which the event will be resolved.
pairs (list of Pairs) – The left pair and the right pair.
station (Station) – The station where the entanglement swapping is performed.
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
- Variables
pairs –
station –
- class requsim.events.DiscardQubitEvent(time, qubit, priority=39, ignore_blocked=True, callback_functions=None)
Bases:
EventEvent to discard a qubit and associated pair.
For example if the qubit sat in memory too long and is discarded.
- Parameters
time (scalar) – Time at which the event will be resolved.
qubit (Qubit) – The Qubit that will be discarded.
priority (int) – Default: 39 (because discard events should get processed last)
ignore_blocked (bool) – Whether the event should act on blocked quantum objects. Default: True
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
- Variables
qubit –
- class requsim.events.EntanglementPurificationEvent(time, pairs, communication_time, protocol='dejmps', callback_functions=None)
Bases:
EventShort summary.
- Parameters
time (scalar) – Time at which the event will be resolved.
pairs (list of Pairs) – The pairs involved in the entanglement purification protocol. Make sure these are at the correct stations and have the same qubit ordering.
communication_time (scalar) – how long it takes for the result of the protocol to be communcated the remaining pair will be blocked for that amount of time
protocol ({"dejmps"} or callable) – Can be one of the pre-installed or an arbitrary callable that takes a tensor product of pair states as input and returns a tuple of (success probability, state of a single pair) back. So far only supports n->1 protocols.
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
- Variables
pairs –
protocol –
communication_time –
- class requsim.events.UnblockEvent(time, quantum_objects, priority=0, callback_functions=None)
Bases:
EventUnblock a set of quantum objects.
This is useful to mark the time when necessary classical information has arrived and the quantum objects may be used by the protocol again. (e.g. after entanglement purification)
- Parameters
time (scalar) – Time at which the event will be resolved.
quantum_objects (list of QuantumObjects) – The quantum objects to be unblocked.
priority (int (expected 0...39)) – Default: 0 (because unblocking should happen as soon as possible)
callback_functions (list of callables, or None) – these will be called in order, after the event has been resolved. Callbacks can also be added with the add_callback method. Default: None
- Variables
quantum_objects –
- class requsim.events.EventQueue
Bases:
objectProvides methods to queue and resolve Events in order.
- Variables
queue (list of Events) – An ordered list of future events to resolve.
current_time (scalar) – The current time of the event queue.
Attributes:
Helper property to access next scheduled event.
Methods:
add_event(event)Add an event to the queue.
Remove the next scheduled event from the queue and resolve it.
resolve_until(target_time)Resolve events until target_time is reached.
advance_time(time_interval)Helper method to manually advance time.
Print stats about the events scheduled and resolved so far.
- property next_event
Helper property to access next scheduled event.
- Returns
Event or None – The next scheduled event. None if the event queue is empty.
- add_event(event)
Add an event to the queue.
The queue is sorted again in order to schedule the event at the correct time.
- Parameters
event (Event) – The Event to be added to the queue.
- Returns
None
- Raises
ValueError – If event.time is in the past.
- resolve_next_event()
Remove the next scheduled event from the queue and resolve it.
- Returns
dict – A dict with at least keys “event_type” and “resolve_successful”, may have additional keys with additional information that can be passed to the protocol.
- resolve_until(target_time)
Resolve events until target_time is reached.
- Parameters
target_time (scalar) – Resolve until current_time is this.
- Returns
None
- Raises
ValueError – If target_time lies in the past.
- advance_time(time_interval)
Helper method to manually advance time.
- Parameters
time_interval (int) – The amount of time that passes.
- Returns
None
- Raises
ValueError – If an event is skipped during the time_interval.
- print_stats()
Print stats about the events scheduled and resolved so far.
- Returns
None