qns.network package

Subpackages

Submodules

qns.network.network module

exception qns.network.network.QNSNetworkError[source]

Bases: Exception

class qns.network.network.QuantumNetwork(topo: Optional[qns.network.topology.topo.Topology] = None, route: Optional[qns.network.route.route.RouteImpl] = None, classic_topo: Optional[qns.network.topology.topo.ClassicTopology] = ClassicTopology.Empty, name: Optional[str] = None)[source]

Bases: object

QuantumNetwork includes several quantum nodes, channels and a special topology

add_cchannel(cchannel: qns.entity.cchannel.cchannel.ClassicChannel)[source]

add a ClassicChannel into this network.

Parameters

cchannel (qns.entity.cchannel.cchannel.ClassicChannel) – the inserting ClassicChannel

add_memories(capacity: int = 0, decoherence_rate: Optional[float] = 0, store_error_model_args: dict = {})[source]

Add quantum memories to every nodes in this network

Parameters
  • capacity (int) – the capacity of the quantum memory

  • decoherence_rate (float) – the decoherence rate

  • store_error_model_args – the arguments for store_error_model

add_node(node: qns.entity.node.node.QNode)[source]

add a QNode into this network.

Parameters

node (qns.entity.node.node.QNode) – the inserting node

add_qchannel(qchannel: qns.entity.qchannel.qchannel.QuantumChannel)[source]

add a QuantumChannel into this network.

Parameters

qchannel (qns.entity.qchannel.qchannel.QuantumChannel) – the inserting QuantumChannel

add_request(src: qns.entity.node.node.QNode, dest: qns.entity.node.node.QNode, attr: Dict = {})[source]

Add a request (SD-pair) to the network

Parameters
  • src – the source node

  • dest – the destination node

  • attr – other attributions

build_route()[source]

build static route tables for each nodes

get_cchannel(name: str)[source]

get the ClassicChannel by its name

Parameters

name (str) – its name

Returns

the ClassicChannel

get_node(name: str)[source]

get the QNode by its name

Parameters

name (str) – its name

Returns

the QNode

get_qchannel(name: str)[source]

get the QuantumChannel by its name

Parameters

name (str) – its name

Returns

the QuantumChannel

install(s: qns.simulator.simulator.Simulator)[source]

install all nodes (including channels, memories and applications) in this network

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

query_route(src: qns.entity.node.node.QNode, dest: qns.entity.node.node.QNode) List[Tuple[float, qns.entity.node.node.QNode, List[qns.entity.node.node.QNode]]][source]

query the metric, nexthop and the path

Parameters
  • src – the source node

  • dest – the destination node

Returns

A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.

random_requests(number: int, allow_overlay: bool = False, attr: Dict = {})[source]

Generate random requests

Parameters
  • number (int) – the number of requests

  • allow_overlay (bool) – allow a node to be the source or destination in multiple requests

  • attr (Dict) – request attributions

qns.network.requests module

class qns.network.requests.Request(src, dest, attr: Dict = {})[source]

Bases: object

A request is a source-destination pair represents a quantum transmitting request.

Module contents

class qns.network.BasicTopology(nodes_number, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: qns.network.topology.topo.Topology

BasicTopology includes nodes_number Qnodes. None of them are connected with each other

build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel

class qns.network.DijkstraRouteAlgorithm(name: str = 'dijkstra', metric_func: Optional[Callable[[Union[qns.entity.qchannel.qchannel.QuantumChannel, qns.entity.cchannel.cchannel.ClassicChannel]], float]] = None)[source]

Bases: qns.network.route.route.RouteImpl

This is the dijkstra route algorithm implement

build(nodes: List[qns.entity.node.node.QNode], channels: List[Union[qns.entity.qchannel.qchannel.QuantumChannel, qns.entity.cchannel.cchannel.ClassicChannel]])[source]

build static route tables for each nodes

Parameters

channels – a list of quantum channels or classic channels

query(src: qns.entity.node.node.QNode, dest: qns.entity.node.node.QNode) List[Tuple[float, qns.entity.node.node.QNode, List[qns.entity.node.node.QNode]]][source]

query the metric, nexthop and the path

Parameters
  • src – the source node

  • dest – the destination node

Returns

A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.

class qns.network.GridTopology(nodes_number, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: qns.network.topology.topo.Topology

GridTopology includes nodes_number Qnodes. nodes_number should be a perfect square number. The topology is a square grid pattern, where each node has 4 neighbors.

build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel

class qns.network.LineTopology(nodes_number, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: qns.network.topology.topo.Topology

LineTopology includes nodes_number Qnodes. The topology is a line pattern.

build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel

exception qns.network.NetworkRouteError[source]

Bases: Exception

exception qns.network.QNSNetworkError[source]

Bases: Exception

class qns.network.QuantumNetwork(topo: Optional[qns.network.topology.topo.Topology] = None, route: Optional[qns.network.route.route.RouteImpl] = None, classic_topo: Optional[qns.network.topology.topo.ClassicTopology] = ClassicTopology.Empty, name: Optional[str] = None)[source]

Bases: object

QuantumNetwork includes several quantum nodes, channels and a special topology

add_cchannel(cchannel: qns.entity.cchannel.cchannel.ClassicChannel)[source]

add a ClassicChannel into this network.

Parameters

cchannel (qns.entity.cchannel.cchannel.ClassicChannel) – the inserting ClassicChannel

add_memories(capacity: int = 0, decoherence_rate: Optional[float] = 0, store_error_model_args: dict = {})[source]

Add quantum memories to every nodes in this network

Parameters
  • capacity (int) – the capacity of the quantum memory

  • decoherence_rate (float) – the decoherence rate

  • store_error_model_args – the arguments for store_error_model

add_node(node: qns.entity.node.node.QNode)[source]

add a QNode into this network.

Parameters

node (qns.entity.node.node.QNode) – the inserting node

add_qchannel(qchannel: qns.entity.qchannel.qchannel.QuantumChannel)[source]

add a QuantumChannel into this network.

Parameters

qchannel (qns.entity.qchannel.qchannel.QuantumChannel) – the inserting QuantumChannel

add_request(src: qns.entity.node.node.QNode, dest: qns.entity.node.node.QNode, attr: Dict = {})[source]

Add a request (SD-pair) to the network

Parameters
  • src – the source node

  • dest – the destination node

  • attr – other attributions

build_route()[source]

build static route tables for each nodes

get_cchannel(name: str)[source]

get the ClassicChannel by its name

Parameters

name (str) – its name

Returns

the ClassicChannel

get_node(name: str)[source]

get the QNode by its name

Parameters

name (str) – its name

Returns

the QNode

get_qchannel(name: str)[source]

get the QuantumChannel by its name

Parameters

name (str) – its name

Returns

the QuantumChannel

install(s: qns.simulator.simulator.Simulator)[source]

install all nodes (including channels, memories and applications) in this network

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

query_route(src: qns.entity.node.node.QNode, dest: qns.entity.node.node.QNode) List[Tuple[float, qns.entity.node.node.QNode, List[qns.entity.node.node.QNode]]][source]

query the metric, nexthop and the path

Parameters
  • src – the source node

  • dest – the destination node

Returns

A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.

random_requests(number: int, allow_overlay: bool = False, attr: Dict = {})[source]

Generate random requests

Parameters
  • number (int) – the number of requests

  • allow_overlay (bool) – allow a node to be the source or destination in multiple requests

  • attr (Dict) – request attributions

class qns.network.RandomTopology(nodes_number, lines_number: int, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: qns.network.topology.topo.Topology

RandomTopology includes nodes_number Qnodes. The topology is randomly generated.

build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel

class qns.network.Request(src, dest, attr: Dict = {})[source]

Bases: object

A request is a source-destination pair represents a quantum transmitting request.

class qns.network.RouteImpl(name: str = 'route')[source]

Bases: object

This is the route protocol interface

build(nodes: List[qns.entity.node.node.QNode], channels: List[Union[qns.entity.qchannel.qchannel.QuantumChannel, qns.entity.cchannel.cchannel.ClassicChannel]])[source]

build static route tables for each nodes

Parameters

channels – a list of quantum channels or classic channels

query(src: qns.entity.node.node.QNode, dest: qns.entity.node.node.QNode) List[Tuple[float, qns.entity.node.node.QNode, List[qns.entity.node.node.QNode]]][source]

query the metric, nexthop and the path

Parameters
  • src – the source node

  • dest – the destination node

Returns

A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.

class qns.network.Topology(nodes_number: int, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: object

Topology is a factory for QuantumNetwork

add_cchannels(classic_topo: qns.network.topology.topo.ClassicTopology = ClassicTopology.Empty, nl: List[qns.entity.node.node.QNode] = [], ll: Optional[List[qns.entity.qchannel.qchannel.QuantumChannel]] = None)[source]

build classic network topology

Parameters
build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel

class qns.network.TreeTopology(nodes_number, children_number: int = 2, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: qns.network.topology.topo.Topology

TreeTopology includes nodes_number Qnodes. The topology is a tree pattern, where each parent has children_num children.

build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel

class qns.network.WaxmanTopology(nodes_number: int, size: float, alpha: float, beta: float, nodes_apps: List[qns.entity.node.app.Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: Optional[List[Dict]] = {})[source]

Bases: qns.network.topology.topo.Topology

WaxmanTopology is the random topology generator using Waxman’s model.

build() Tuple[List[qns.entity.node.node.QNode], List[qns.entity.qchannel.qchannel.QuantumChannel]][source]

build the special topology

Returns

the list of QNodes and the list of QuantumChannel