diff --git a/docs/build/doctrees/develop.doctree b/docs/build/doctrees/develop.doctree index b43d684..74e5b1d 100644 Binary files a/docs/build/doctrees/develop.doctree and b/docs/build/doctrees/develop.doctree differ diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle index 5dd8374..8bd83aa 100644 Binary files a/docs/build/doctrees/environment.pickle and b/docs/build/doctrees/environment.pickle differ diff --git a/docs/build/doctrees/index.doctree b/docs/build/doctrees/index.doctree index 2f4192a..e70c061 100644 Binary files a/docs/build/doctrees/index.doctree and b/docs/build/doctrees/index.doctree differ diff --git a/docs/build/doctrees/install.doctree b/docs/build/doctrees/install.doctree index ca5a732..8506716 100644 Binary files a/docs/build/doctrees/install.doctree and b/docs/build/doctrees/install.doctree differ diff --git a/docs/build/doctrees/introduction.doctree b/docs/build/doctrees/introduction.doctree index 8910796..024d48c 100644 Binary files a/docs/build/doctrees/introduction.doctree and b/docs/build/doctrees/introduction.doctree differ diff --git a/docs/build/doctrees/modules.doctree b/docs/build/doctrees/modules.doctree index f1d334b..ab634d4 100644 Binary files a/docs/build/doctrees/modules.doctree and b/docs/build/doctrees/modules.doctree differ diff --git a/docs/build/doctrees/qns.doctree b/docs/build/doctrees/qns.doctree index 4908c5a..99177d8 100644 Binary files a/docs/build/doctrees/qns.doctree and b/docs/build/doctrees/qns.doctree differ diff --git a/docs/build/doctrees/qns.entity.cchannel.doctree b/docs/build/doctrees/qns.entity.cchannel.doctree index 3d607b2..c34df61 100644 Binary files a/docs/build/doctrees/qns.entity.cchannel.doctree and b/docs/build/doctrees/qns.entity.cchannel.doctree differ diff --git a/docs/build/doctrees/qns.entity.doctree b/docs/build/doctrees/qns.entity.doctree index 17e7fab..fa38680 100644 Binary files a/docs/build/doctrees/qns.entity.doctree and b/docs/build/doctrees/qns.entity.doctree differ diff --git a/docs/build/doctrees/qns.entity.memory.doctree b/docs/build/doctrees/qns.entity.memory.doctree index f545def..a47370d 100644 Binary files a/docs/build/doctrees/qns.entity.memory.doctree and b/docs/build/doctrees/qns.entity.memory.doctree differ diff --git a/docs/build/doctrees/qns.entity.monitor.doctree b/docs/build/doctrees/qns.entity.monitor.doctree index 935af4d..213411c 100644 Binary files a/docs/build/doctrees/qns.entity.monitor.doctree and b/docs/build/doctrees/qns.entity.monitor.doctree differ diff --git a/docs/build/doctrees/qns.entity.node.doctree b/docs/build/doctrees/qns.entity.node.doctree index 2b02e0a..2798b4e 100644 Binary files a/docs/build/doctrees/qns.entity.node.doctree and b/docs/build/doctrees/qns.entity.node.doctree differ diff --git a/docs/build/doctrees/qns.entity.operator.doctree b/docs/build/doctrees/qns.entity.operator.doctree index 815b9d5..1b1b627 100644 Binary files a/docs/build/doctrees/qns.entity.operator.doctree and b/docs/build/doctrees/qns.entity.operator.doctree differ diff --git a/docs/build/doctrees/qns.entity.qchannel.doctree b/docs/build/doctrees/qns.entity.qchannel.doctree index 7d3f931..609d94c 100644 Binary files a/docs/build/doctrees/qns.entity.qchannel.doctree and b/docs/build/doctrees/qns.entity.qchannel.doctree differ diff --git a/docs/build/doctrees/qns.entity.timer.doctree b/docs/build/doctrees/qns.entity.timer.doctree index d833830..0ed759c 100644 Binary files a/docs/build/doctrees/qns.entity.timer.doctree and b/docs/build/doctrees/qns.entity.timer.doctree differ diff --git a/docs/build/doctrees/qns.models.core.doctree b/docs/build/doctrees/qns.models.core.doctree index 5202805..45039c1 100644 Binary files a/docs/build/doctrees/qns.models.core.doctree and b/docs/build/doctrees/qns.models.core.doctree differ diff --git a/docs/build/doctrees/qns.models.delay.doctree b/docs/build/doctrees/qns.models.delay.doctree index 862b6b1..72017dd 100644 Binary files a/docs/build/doctrees/qns.models.delay.doctree and b/docs/build/doctrees/qns.models.delay.doctree differ diff --git a/docs/build/doctrees/qns.models.doctree b/docs/build/doctrees/qns.models.doctree index 4229d6d..8ad654e 100644 Binary files a/docs/build/doctrees/qns.models.doctree and b/docs/build/doctrees/qns.models.doctree differ diff --git a/docs/build/doctrees/qns.models.epr.doctree b/docs/build/doctrees/qns.models.epr.doctree index 362750d..596b93e 100644 Binary files a/docs/build/doctrees/qns.models.epr.doctree and b/docs/build/doctrees/qns.models.epr.doctree differ diff --git a/docs/build/doctrees/qns.models.qubit.doctree b/docs/build/doctrees/qns.models.qubit.doctree index 58c37ff..3461c82 100644 Binary files a/docs/build/doctrees/qns.models.qubit.doctree and b/docs/build/doctrees/qns.models.qubit.doctree differ diff --git a/docs/build/doctrees/qns.network.doctree b/docs/build/doctrees/qns.network.doctree index 9ec3c01..7b62761 100644 Binary files a/docs/build/doctrees/qns.network.doctree and b/docs/build/doctrees/qns.network.doctree differ diff --git a/docs/build/doctrees/qns.network.protocol.doctree b/docs/build/doctrees/qns.network.protocol.doctree index a5e8519..bcca8f9 100644 Binary files a/docs/build/doctrees/qns.network.protocol.doctree and b/docs/build/doctrees/qns.network.protocol.doctree differ diff --git a/docs/build/doctrees/qns.network.route.doctree b/docs/build/doctrees/qns.network.route.doctree index d8505d8..5cb433e 100644 Binary files a/docs/build/doctrees/qns.network.route.doctree and b/docs/build/doctrees/qns.network.route.doctree differ diff --git a/docs/build/doctrees/qns.network.topology.doctree b/docs/build/doctrees/qns.network.topology.doctree index 3dec123..6825f8e 100644 Binary files a/docs/build/doctrees/qns.network.topology.doctree and b/docs/build/doctrees/qns.network.topology.doctree differ diff --git a/docs/build/doctrees/qns.simulator.doctree b/docs/build/doctrees/qns.simulator.doctree index f9854f7..9ccc968 100644 Binary files a/docs/build/doctrees/qns.simulator.doctree and b/docs/build/doctrees/qns.simulator.doctree differ diff --git a/docs/build/doctrees/qns.utils.doctree b/docs/build/doctrees/qns.utils.doctree index 89adbf0..94f7a6d 100644 Binary files a/docs/build/doctrees/qns.utils.doctree and b/docs/build/doctrees/qns.utils.doctree differ diff --git a/docs/build/doctrees/tutorials.doctree b/docs/build/doctrees/tutorials.doctree index 8fdfd5e..329d28c 100644 Binary files a/docs/build/doctrees/tutorials.doctree and b/docs/build/doctrees/tutorials.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.cchannel.doctree b/docs/build/doctrees/tutorials.entity.cchannel.doctree index 0455add..af8db02 100644 Binary files a/docs/build/doctrees/tutorials.entity.cchannel.doctree and b/docs/build/doctrees/tutorials.entity.cchannel.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.doctree b/docs/build/doctrees/tutorials.entity.doctree index ec6ebba..0b96914 100644 Binary files a/docs/build/doctrees/tutorials.entity.doctree and b/docs/build/doctrees/tutorials.entity.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.memory.doctree b/docs/build/doctrees/tutorials.entity.memory.doctree index 87811e3..af084d4 100644 Binary files a/docs/build/doctrees/tutorials.entity.memory.doctree and b/docs/build/doctrees/tutorials.entity.memory.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.monitor.doctree b/docs/build/doctrees/tutorials.entity.monitor.doctree index 8b41427..1b4c022 100644 Binary files a/docs/build/doctrees/tutorials.entity.monitor.doctree and b/docs/build/doctrees/tutorials.entity.monitor.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.node.doctree b/docs/build/doctrees/tutorials.entity.node.doctree index 6d4c271..78ae42d 100644 Binary files a/docs/build/doctrees/tutorials.entity.node.doctree and b/docs/build/doctrees/tutorials.entity.node.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.operator.doctree b/docs/build/doctrees/tutorials.entity.operator.doctree index 99f18ff..a7736fb 100644 Binary files a/docs/build/doctrees/tutorials.entity.operator.doctree and b/docs/build/doctrees/tutorials.entity.operator.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.other.doctree b/docs/build/doctrees/tutorials.entity.other.doctree index b29b943..2d9a13b 100644 Binary files a/docs/build/doctrees/tutorials.entity.other.doctree and b/docs/build/doctrees/tutorials.entity.other.doctree differ diff --git a/docs/build/doctrees/tutorials.entity.qchannel.doctree b/docs/build/doctrees/tutorials.entity.qchannel.doctree index e2dbd5b..3cbc596 100644 Binary files a/docs/build/doctrees/tutorials.entity.qchannel.doctree and b/docs/build/doctrees/tutorials.entity.qchannel.doctree differ diff --git a/docs/build/doctrees/tutorials.models.delay.doctree b/docs/build/doctrees/tutorials.models.delay.doctree index d5ab4a1..64c3430 100644 Binary files a/docs/build/doctrees/tutorials.models.delay.doctree and b/docs/build/doctrees/tutorials.models.delay.doctree differ diff --git a/docs/build/doctrees/tutorials.models.doctree b/docs/build/doctrees/tutorials.models.doctree index b83e6bf..d67d85b 100644 Binary files a/docs/build/doctrees/tutorials.models.doctree and b/docs/build/doctrees/tutorials.models.doctree differ diff --git a/docs/build/doctrees/tutorials.models.epr.doctree b/docs/build/doctrees/tutorials.models.epr.doctree index 06890ea..853b64b 100644 Binary files a/docs/build/doctrees/tutorials.models.epr.doctree and b/docs/build/doctrees/tutorials.models.epr.doctree differ diff --git a/docs/build/doctrees/tutorials.models.qubit.doctree b/docs/build/doctrees/tutorials.models.qubit.doctree index 3dcc3be..dc80131 100644 Binary files a/docs/build/doctrees/tutorials.models.qubit.doctree and b/docs/build/doctrees/tutorials.models.qubit.doctree differ diff --git a/docs/build/doctrees/tutorials.network.doctree b/docs/build/doctrees/tutorials.network.doctree index b7ffa6b..e954b20 100644 Binary files a/docs/build/doctrees/tutorials.network.doctree and b/docs/build/doctrees/tutorials.network.doctree differ diff --git a/docs/build/doctrees/tutorials.network.request.doctree b/docs/build/doctrees/tutorials.network.request.doctree index d37d385..9a21428 100644 Binary files a/docs/build/doctrees/tutorials.network.request.doctree and b/docs/build/doctrees/tutorials.network.request.doctree differ diff --git a/docs/build/doctrees/tutorials.network.route.doctree b/docs/build/doctrees/tutorials.network.route.doctree index 60bd469..1e31b42 100644 Binary files a/docs/build/doctrees/tutorials.network.route.doctree and b/docs/build/doctrees/tutorials.network.route.doctree differ diff --git a/docs/build/doctrees/tutorials.network.topology.doctree b/docs/build/doctrees/tutorials.network.topology.doctree index b9682eb..d953331 100644 Binary files a/docs/build/doctrees/tutorials.network.topology.doctree and b/docs/build/doctrees/tutorials.network.topology.doctree differ diff --git a/docs/build/doctrees/tutorials.parallel_simulation.doctree b/docs/build/doctrees/tutorials.parallel_simulation.doctree index d564909..b7ca872 100644 Binary files a/docs/build/doctrees/tutorials.parallel_simulation.doctree and b/docs/build/doctrees/tutorials.parallel_simulation.doctree differ diff --git a/docs/build/doctrees/tutorials.quickstart.doctree b/docs/build/doctrees/tutorials.quickstart.doctree index 258fd90..71329f5 100644 Binary files a/docs/build/doctrees/tutorials.quickstart.doctree and b/docs/build/doctrees/tutorials.quickstart.doctree differ diff --git a/docs/build/doctrees/tutorials.simulator.doctree b/docs/build/doctrees/tutorials.simulator.doctree index bfbbfc9..5135965 100644 Binary files a/docs/build/doctrees/tutorials.simulator.doctree and b/docs/build/doctrees/tutorials.simulator.doctree differ diff --git a/docs/build/doctrees/tutorials.util.doctree b/docs/build/doctrees/tutorials.util.doctree index 1e5361e..7ce15e4 100644 Binary files a/docs/build/doctrees/tutorials.util.doctree and b/docs/build/doctrees/tutorials.util.doctree differ diff --git a/docs/build/html/_modules/qns/entity/cchannel/cchannel.html b/docs/build/html/_modules/qns/entity/cchannel/cchannel.html index 99d18f7..221c923 100644 --- a/docs/build/html/_modules/qns/entity/cchannel/cchannel.html +++ b/docs/build/html/_modules/qns/entity/cchannel/cchannel.html @@ -152,7 +152,7 @@
ClassicChannel is the channel for classic message
"""
def __init__(self, name: str = None, node_list: List[QNode] = [],
- bandwidth: int = 0, delay: Union[float, DelayModel] = 0, drop_rate: float = 0,
+ bandwidth: int = 0, delay: Union[float, DelayModel] = 0, length: Optional[float] = 0, drop_rate: float = 0,
max_buffer_size: int = 0):
"""
Args:
@@ -160,6 +160,7 @@ Source code for qns.entity.cchannel.cchannel
node_list (List[QNode]): a list of QNodes that it connects to
bandwidth (int): the byte per second on this channel. 0 represents unlimited
delay (Union[float, DelayModel]): the time delay for transmitting a packet. It is a float number or a ``DelayModel``
+ length (float): the length of this channel
drop_rate (float): the drop rate
max_buffer_size (int): the max buffer size.
If it is full, the next coming packet will be dropped. 0 represents unlimited.
@@ -169,6 +170,7 @@ Source code for qns.entity.cchannel.cchannel
self.bandwidth = bandwidth
self.delay_model = delay if isinstance(delay, DelayModel) else ConstantDelayModel(delay=delay)
self.drop_rate = drop_rate
+ self.length = length
self.max_buffer_size = max_buffer_size
[docs] def install(self, simulator: Simulator) -> None:
diff --git a/docs/build/html/_modules/qns/entity/entity.html b/docs/build/html/_modules/qns/entity/entity.html
index da2b297..b0a21c8 100644
--- a/docs/build/html/_modules/qns/entity/entity.html
+++ b/docs/build/html/_modules/qns/entity/entity.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/entity/memory/event.html b/docs/build/html/_modules/qns/entity/memory/event.html
index af706fc..96a5f50 100644
--- a/docs/build/html/_modules/qns/entity/memory/event.html
+++ b/docs/build/html/_modules/qns/entity/memory/event.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/entity/monitor/monitor.html b/docs/build/html/_modules/qns/entity/monitor/monitor.html
index 34d9b37..cc07296 100644
--- a/docs/build/html/_modules/qns/entity/monitor/monitor.html
+++ b/docs/build/html/_modules/qns/entity/monitor/monitor.html
@@ -88,7 +88,6 @@ Source code for qns.entity.monitor.monitor
import pandas as pd
from typing import Any, Callable, Optional
from qns.entity.entity import Entity
-from qns.network.network import QuantumNetwork
from qns.simulator.event import Event
from qns.simulator.simulator import Simulator
from qns.simulator.ts import Time
@@ -108,7 +107,7 @@ Source code for qns.entity.monitor.monitor
[docs]class Monitor(Entity):
- def __init__(self, name: Optional[str] = None, network: Optional[QuantumNetwork] = None) -> None:
+ def __init__(self, name: Optional[str] = None, network=None) -> None:
"""
Monitor is a virtual entity that helps users to collect network status.
@@ -174,7 +173,7 @@ Source code for qns.entity.monitor.monitor
return self.data
[docs] def add_attribution(self, name: str,
- calculate_func: Callable[[Simulator, Optional[QuantumNetwork], Optional[Event]], Any]) -> None:
+ calculate_func: Callable[[Simulator, Any, Optional[Event]], Any]) -> None:
"""
Set an attribution that will be recorded. For example, an attribution could be the throughput, or the fidelity.
@@ -224,7 +223,7 @@ Source code for qns.entity.monitor.monitor
# record network status every 3 seconds.
m.at_period(3)
"""
- assert(period_time > 0)
+ assert (period_time > 0)
self.watch_period.append(period_time)
[docs] def at_event(self, event_type) -> None:
diff --git a/docs/build/html/_modules/qns/entity/node/app.html b/docs/build/html/_modules/qns/entity/node/app.html
index b117ad7..0823fb3 100644
--- a/docs/build/html/_modules/qns/entity/node/app.html
+++ b/docs/build/html/_modules/qns/entity/node/app.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/entity/node/node.html b/docs/build/html/_modules/qns/entity/node/node.html
index 4cec522..74123d6 100644
--- a/docs/build/html/_modules/qns/entity/node/node.html
+++ b/docs/build/html/_modules/qns/entity/node/node.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -85,7 +85,7 @@ Source code for qns.entity.node.node
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-from typing import List
+from typing import List, Union
from qns.simulator import Simulator
from qns.simulator import Event
from qns.entity import Entity
@@ -122,19 +122,19 @@ Source code for qns.entity.node.node
# initiate sub-entities
for cchannel in self.cchannels:
from qns.entity import ClassicChannel
- assert(isinstance(cchannel, ClassicChannel))
+ assert (isinstance(cchannel, ClassicChannel))
cchannel.install(simulator)
for qchannel in self.qchannels:
from qns.entity import QuantumChannel
- assert(isinstance(qchannel, QuantumChannel))
+ assert (isinstance(qchannel, QuantumChannel))
qchannel.install(simulator)
for memory in self.memories:
from qns.entity import QuantumMemory
- assert(isinstance(memory, QuantumMemory))
+ assert (isinstance(memory, QuantumMemory))
memory.install(simulator)
for operator in self.operators:
from qns.entity import QuantumOperator
- assert(isinstance(operator, QuantumOperator))
+ assert (isinstance(operator, QuantumOperator))
operator.install(simulator)
# initiate applications
@@ -182,6 +182,19 @@ Source code for qns.entity.node.node
memory.node = self
self.memories.append(memory)
+[docs] def get_memory(self, memory: Union[str, int]):
+ """
+ Get the memory by index (in memories) or its name
+
+ Args:
+ memory (Union[str, int]): the index or name of the memory
+ """
+ if isinstance(memory, str):
+ for m in self.memories:
+ if m.name == memory:
+ return m
+ return self.memories[memory]
+
[docs] def add_operator(self, operator):
"""
Add a quantum operator in this node
diff --git a/docs/build/html/_modules/qns/entity/operator/event.html b/docs/build/html/_modules/qns/entity/operator/event.html
index 38f57b9..726c88c 100644
--- a/docs/build/html/_modules/qns/entity/operator/event.html
+++ b/docs/build/html/_modules/qns/entity/operator/event.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/entity/timer/timer.html b/docs/build/html/_modules/qns/entity/timer/timer.html
index e2cfaa7..9f1f9a5 100644
--- a/docs/build/html/_modules/qns/entity/timer/timer.html
+++ b/docs/build/html/_modules/qns/entity/timer/timer.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/models/core/backend.html b/docs/build/html/_modules/qns/models/core/backend.html
index df9bef7..71d2394 100644
--- a/docs/build/html/_modules/qns/models/core/backend.html
+++ b/docs/build/html/_modules/qns/models/core/backend.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/models/delay/uniformdelay.html b/docs/build/html/_modules/qns/models/delay/uniformdelay.html
index 785a9a1..9628a3d 100644
--- a/docs/build/html/_modules/qns/models/delay/uniformdelay.html
+++ b/docs/build/html/_modules/qns/models/delay/uniformdelay.html
@@ -101,7 +101,7 @@ Source code for qns.models.delay.uniformdelay
max_delay (float): the maximum time delay [s]
"""
super().__init__(name)
- assert(max_delay >= min_delay)
+ assert (max_delay >= min_delay)
self._min_delay = min_delay
self._max_delay = max_delay
diff --git a/docs/build/html/_modules/qns/models/epr/entanglement.html b/docs/build/html/_modules/qns/models/epr/entanglement.html
index 87b80d1..641fe90 100644
--- a/docs/build/html/_modules/qns/models/epr/entanglement.html
+++ b/docs/build/html/_modules/qns/models/epr/entanglement.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/models/qubit/const.html b/docs/build/html/_modules/qns/models/qubit/const.html
index d226f97..7d2fd44 100644
--- a/docs/build/html/_modules/qns/models/qubit/const.html
+++ b/docs/build/html/_modules/qns/models/qubit/const.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/models/qubit/decoherence.html b/docs/build/html/_modules/qns/models/qubit/decoherence.html
index 34243ab..296128c 100644
--- a/docs/build/html/_modules/qns/models/qubit/decoherence.html
+++ b/docs/build/html/_modules/qns/models/qubit/decoherence.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -87,198 +87,137 @@ Source code for qns.models.qubit.decoherence
from typing import Optional
+from qns.models.qubit.const import QUBIT_STATE_0
from qns.models.qubit.gate import I, X, Y, Z
import numpy as np
+from qns.models.qubit.qubit import QState
+from qns.utils.rnd import get_rand
-[docs]def PrefectStorageErrorModel(self, t: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
+[docs]def PrefectError(self, p: Optional[float] = 0, **kwargs):
"""
- The default error model for storing a qubit in quantum memory.
- The default behavior is doing nothing
+ The default error model for this qubit.
Args:
- t: the time stored in a quantum memory. The unit it second.
- decoherence_rate (float): the decoherence rate.
- kwargs: other parameters
+ p (float): the error possibility
"""
pass
-[docs]def DephaseStorageErrorModel(self, t: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
+[docs]def DephaseError(self, p: Optional[float] = 0, **kwargs):
"""
- The dephase error model for storing a qubit in quantum memory.
-
- A random Z gate will be operate on the qubit with possibility: 1-e^(-decoherence_rate * t)
+ The dephase error model.
+ A random Z gate will be operate on the qubit with possibility p.
Args:
- t: the time stored in a quantum memory. The unit it second.
- decoherence_rate (float): the decoherence rate
- kwargs: other parameters
+ p (float): the error possibility
"""
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate * t)
+ if p < 0 or p > 1:
+ raise Exception("Error decoherence rate, should be in [0, 1]")
self.stochastic_operate([I, Z], [1-p, p])
-[docs]def DepolarStorageErrorModel(self, t: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
+[docs]def DepolarError(self, p: Optional[float] = 0, **kwargs):
"""
- The depolar error model for storing a qubit in quantum memory.
+ The depolarizing error model.
- One of the random Pauli gate will be operate on the qubit with possibility:
- 1-e^(-decoherence_rate * t)
+ One of the random Pauli gate will be operate on the qubit with possibility p :
Args:
- t: the time stored in a quantum memory. The unit it second.
- decoherence_rate (float): the decoherence rate
+ p (float): the error possibility
kwargs: other parameters
"""
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate * t)
+ if p < 0 or p > 1:
+ raise Exception("Error decoherence rate, should be in [0, 1]")
if 1-3*p > 0:
self.stochastic_operate([I, X, Y, Z], [1-3*p, p, p, p])
else:
self.stochastic_operate([X, Y, Z], [1/3, 1/3, 1/3])
-[docs]def PrefectTransferErrorModel(self, length: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The default error model for transmitting this qubit
- The default behavior is doing nothing
-
- Args:
- length (float): the length of the channel
- decoherence_rate (float): the decoherence rate.
- kwargs: other parameters
- """
- pass
-
-
-[docs]def DephaseTransferErrorModel(self, length: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The dephase error model for transmitting a qubit in quantum channel.
-
- A random Z gate will be operate on the qubit with possibility: 1-e^(-decoherence_rate * length)
-
- Args:
- length: the channel length
- decoherence_rate (float): the decoherence rate
- kwargs: other parameters
- """
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate * length)
- self.stochastic_operate([I, Z], [1-p, p])
-
-
-[docs]def DepolarTransferErrorModel(self, length: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The depolar error model for transmitting a qubit in quantum channel.
-
- One of the random Pauli gate will be operate on the qubit with possibility:
- 1-e^(-decoherence_rate * t)
-
- Args:
- length: the channel length
- decoherence_rate (float): the decoherence rate
- kwargs: other parameters
- """
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate * length)
- if 1-3*p > 0:
- self.stochastic_operate([I, X, Y, Z], [1-3*p, p, p, p])
- else:
- self.stochastic_operate([X, Y, Z], [1/3, 1/3, 1/3])
-
-
-[docs]def PrefectOperateErrorModel(self, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The default error model for operating this qubit.
-
- Args:
- decoherence_rate (float): the decoherence rate
- """
- pass
-
-
-[docs]def DephaseOperateErrorModel(self, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The dephase error model for operating this qubit.
- A random Z gate will be operate on the qubit with possibility: 1-e^(-decoherence_rate)
-
- Args:
- decoherence_rate (float): the decoherence rate
- """
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate)
- self.stochastic_operate([I, Z], [1-p, p])
-
-
-[docs]def DepolarOperateErrorModel(self, decoherence_rate: Optional[float] = 0, **kwargs):
+[docs]def BitFlipError(self, p: Optional[float] = 0, **kwargs):
"""
- The depolar error model for operating on a qubit.
-
- One of the random Pauli gate will be operate on the qubit with possibility:
- 1-e^(-decoherence_rate * t)
+ The bit flip error model.
Args:
- decoherence_rate (float): the decoherence rate
+ p (float): the error possibility, [0, 1]
kwargs: other parameters
"""
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate)
- if 1-3*p > 0:
- self.stochastic_operate([I, X, Y, Z], [1-3*p, p, p, p])
- else:
- self.stochastic_operate([X, Y, Z], [1/3, 1/3, 1/3])
+ if p < 0 or p > 1:
+ raise Exception("Error decoherence rate, should be in [0, 1]")
+ self.stochastic_operate([I, X], [1-p, p])
-[docs]def PrefectMeasureErrorModel(self, decoherence_rate: Optional[float] = 0, **kwargs):
+[docs]def DissipationError(self, p: Optional[float] = 0, **kwargs):
"""
- The default error model for measuring this qubit.
+ The dissipation error model.
Args:
- decoherence_rate (float): the decoherence rate
- """
- pass
-
-
-[docs]def DephaseMeasureErrorModel(self, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The dephase error model for measuring this qubit,
- A random Z gate will be operate on the qubit with possibility: 1-e^(-decoherence_rate)
-
- Args:
- decoherence_rate (float): the decoherence rate
- """
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate)
- self.stochastic_operate([I, Z], [1-p, p])
-
-
-[docs]def DepolarMeasureErrorModel(self, decoherence_rate: Optional[float] = 0, **kwargs):
- """
- The depolar error model for measuring on a qubit.
-
- One of the random Pauli gate will be operate on the qubit with possibility:
- 1-e^(-decoherence_rate * t)
-
- Args:
- decoherence_rate (float): the decoherence rate
+ p (float): the error possibility, [0, 1]
kwargs: other parameters
"""
- if decoherence_rate < 0:
- raise Exception("Error decoherence rate, should be positive")
- p = 1 - np.exp(-decoherence_rate)
- if 1-3*p > 0:
- self.stochastic_operate([I, X, Y, Z], [1-3*p, p, p, p])
- else:
- self.stochastic_operate([X, Y, Z], [1/3, 1/3, 1/3])
+ if p < 0 or p > 1:
+ raise Exception("Error decoherence rate, should be in [0, 1]")
+ real_p = get_rand()
+ if real_p < p:
+ self.measure()
+ self.state = QState([self], state=QUBIT_STATE_0)
+
+
+[docs]def ErrorWithTime(ErrorModel):
+ """generate the error. The error possibility is 1-e^{-decoherence_rate * t}"""
+ def GeneratedErrorWithTime(self, t: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
+ """
+ The error model with time for this qubit. The error possibility is 1-e^{-decoherence_rate * t}.
+
+ Args:
+ t (float): the during time in second.
+ decoherence_rate (float): the decoherence rate.
+ """
+ p = 1 - np.exp(-decoherence_rate * t)
+ ErrorModel(self, p, **kwargs)
+ return GeneratedErrorWithTime
+
+
+[docs]def ErrorWithLength(ErrorModel):
+ """generate the error. The error possibility is 1-e^{-decoherence_rate * length}"""
+ def GeneratedErrorWithLength(self, length: Optional[float] = 0, decoherence_rate: Optional[float] = 0, **kwargs):
+ """
+ The error model with length for this qubit. The error possibility is 1-e^{-decoherence_rate * length}.
+
+ Args:
+ length (float): the transmission length in meter.
+ decoherence_rate (float): the decoherence rate.
+ """
+ p = 1 - np.exp(-decoherence_rate * length)
+ ErrorModel(self, p, **kwargs)
+ return GeneratedErrorWithLength
+
+
+PrefectStorageErrorModel = ErrorWithTime(PrefectError)
+PrefectTransferErrorModel = ErrorWithLength(PrefectError)
+PrefectOperateErrorModel = PrefectError
+PrefectMeasureErrorModel = PrefectError
+
+DephaseStorageErrorModel = ErrorWithTime(DephaseError)
+DephaseTransferErrorModel = ErrorWithLength(DephaseError)
+DephaseOperateErrorModel = DephaseError
+DephaseMeasureErrorModel = DephaseError
+
+DepolarStorageErrorModel = ErrorWithTime(DepolarError)
+DepolarTransferErrorModel = ErrorWithLength(DepolarError)
+DepolarOperateErrorModel = DepolarError
+DepolarMeasureErrorModel = DepolarError
+
+BitFlipStorageErrorModel = ErrorWithTime(BitFlipError)
+BitFilpTransferErrorModel = ErrorWithLength(BitFlipError)
+BitFlipOperateErrorModel = BitFlipError
+BitFlipMeasureErrorModel = BitFlipError
+
+DissipationStorageErrorModel = ErrorWithTime(DissipationError)
+DissipationTransferErrorModel = ErrorWithLength(DissipationError)
+DissipationOperateErrorModel = DissipationError
+DissipationMeasureErrorModel = DissipationError
diff --git a/docs/build/html/_modules/qns/models/qubit/factory.html b/docs/build/html/_modules/qns/models/qubit/factory.html
index cf20849..e1d2ab7 100644
--- a/docs/build/html/_modules/qns/models/qubit/factory.html
+++ b/docs/build/html/_modules/qns/models/qubit/factory.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -90,12 +90,12 @@ Source code for qns.models.qubit.factory
from typing import Optional
import numpy as np
from qns.models.qubit.const import QUBIT_STATE_0
-from qns.models.qubit.decoherence import PrefectMeasureErrorModel, PrefectOperateErrorModel, PrefectStorageErrorModel,\
+from qns.models.qubit.decoherence import PrefectMeasureErrorModel, PrefectOperateErrorModel, PrefectStorageErrorModel, \
PrefectTransferErrorModel
from qns.models.qubit.qubit import Qubit
-[docs]class QubitFactory():
+[docs]class QubitFactory():
"""
QubitFactory is the factory class for building qubits with special error models.
"""
diff --git a/docs/build/html/_modules/qns/models/qubit/gate.html b/docs/build/html/_modules/qns/models/qubit/gate.html
index 4af862b..3fe4c96 100644
--- a/docs/build/html/_modules/qns/models/qubit/gate.html
+++ b/docs/build/html/_modules/qns/models/qubit/gate.html
@@ -87,13 +87,13 @@ Source code for qns.models.qubit.gate
from typing import Any, Optional
import numpy as np
-from qns.models.qubit.const import OPERATOR_HADAMARD, OPERATOR_PAULI_I,\
+from qns.models.qubit.const import OPERATOR_HADAMARD, OPERATOR_PAULI_I, \
OPERATOR_PAULI_X, OPERATOR_PAULI_Y, \
- OPERATOR_PAULI_Z, OPERATOR_PHASE_SHIFT,\
- OPERATOR_RX, OPERATOR_RY, OPERATOR_RZ,\
+ OPERATOR_PAULI_Z, OPERATOR_PHASE_SHIFT, \
+ OPERATOR_RX, OPERATOR_RY, OPERATOR_RZ, \
OPERATOR_S, OPERATOR_T
from qns.models.qubit.qubit import Qubit
-from qns.models.qubit.utils import joint
+from qns.models.qubit.utils import kron, joint
from qns.models.qubit.errors import QGateOperatorNotMatchError, QGateQubitNotInStateError
@@ -240,14 +240,14 @@ Source code for qns.models.qubit.gate
for i in range(state.num):
if i == idx1:
- full_operator_part_0 = np.kron(full_operator_part_0, np.array([[1, 0], [0, 0]]))
- full_operator_part_1 = np.kron(full_operator_part_1, np.array([[0, 0], [0, 1]]))
+ full_operator_part_0 = kron(full_operator_part_0, np.array([[1, 0], [0, 0]]))
+ full_operator_part_1 = kron(full_operator_part_1, np.array([[0, 0], [0, 1]]))
elif i == idx2:
- full_operator_part_0 = np.kron(full_operator_part_0, OPERATOR_PAULI_I)
- full_operator_part_1 = np.kron(full_operator_part_1, operator)
+ full_operator_part_0 = kron(full_operator_part_0, OPERATOR_PAULI_I)
+ full_operator_part_1 = kron(full_operator_part_1, operator)
else:
- full_operator_part_0 = np.kron(full_operator_part_0, OPERATOR_PAULI_I)
- full_operator_part_1 = np.kron(full_operator_part_1, OPERATOR_PAULI_I)
+ full_operator_part_0 = kron(full_operator_part_0, OPERATOR_PAULI_I)
+ full_operator_part_1 = kron(full_operator_part_1, OPERATOR_PAULI_I)
full_operator = full_operator_part_0 + full_operator_part_1
qubit1.state.operate(full_operator)
@@ -351,25 +351,25 @@ Source code for qns.models.qubit.gate
for i in range(state.num):
if i == idx1:
- full_operator_part_00 = np.kron(full_operator_part_00, np.array([[1, 0], [0, 0]]))
- full_operator_part_01 = np.kron(full_operator_part_01, np.array([[1, 0], [0, 0]]))
- full_operator_part_10 = np.kron(full_operator_part_10, np.array([[0, 0], [0, 1]]))
- full_operator_part_11 = np.kron(full_operator_part_11, np.array([[0, 0], [0, 1]]))
+ full_operator_part_00 = kron(full_operator_part_00, np.array([[1, 0], [0, 0]]))
+ full_operator_part_01 = kron(full_operator_part_01, np.array([[1, 0], [0, 0]]))
+ full_operator_part_10 = kron(full_operator_part_10, np.array([[0, 0], [0, 1]]))
+ full_operator_part_11 = kron(full_operator_part_11, np.array([[0, 0], [0, 1]]))
elif i == idx2:
- full_operator_part_00 = np.kron(full_operator_part_00, np.array([[1, 0], [0, 0]]))
- full_operator_part_10 = np.kron(full_operator_part_10, np.array([[1, 0], [0, 0]]))
- full_operator_part_01 = np.kron(full_operator_part_01, np.array([[0, 0], [0, 1]]))
- full_operator_part_11 = np.kron(full_operator_part_11, np.array([[0, 0], [0, 1]]))
+ full_operator_part_00 = kron(full_operator_part_00, np.array([[1, 0], [0, 0]]))
+ full_operator_part_10 = kron(full_operator_part_10, np.array([[1, 0], [0, 0]]))
+ full_operator_part_01 = kron(full_operator_part_01, np.array([[0, 0], [0, 1]]))
+ full_operator_part_11 = kron(full_operator_part_11, np.array([[0, 0], [0, 1]]))
elif i == idx3:
- full_operator_part_00 = np.kron(full_operator_part_00, OPERATOR_PAULI_I)
- full_operator_part_01 = np.kron(full_operator_part_01, OPERATOR_PAULI_I)
- full_operator_part_10 = np.kron(full_operator_part_10, OPERATOR_PAULI_I)
- full_operator_part_11 = np.kron(full_operator_part_11, operator)
+ full_operator_part_00 = kron(full_operator_part_00, OPERATOR_PAULI_I)
+ full_operator_part_01 = kron(full_operator_part_01, OPERATOR_PAULI_I)
+ full_operator_part_10 = kron(full_operator_part_10, OPERATOR_PAULI_I)
+ full_operator_part_11 = kron(full_operator_part_11, operator)
else:
- full_operator_part_00 = np.kron(full_operator_part_00, OPERATOR_PAULI_I)
- full_operator_part_01 = np.kron(full_operator_part_01, OPERATOR_PAULI_I)
- full_operator_part_10 = np.kron(full_operator_part_10, OPERATOR_PAULI_I)
- full_operator_part_11 = np.kron(full_operator_part_11, OPERATOR_PAULI_I)
+ full_operator_part_00 = kron(full_operator_part_00, OPERATOR_PAULI_I)
+ full_operator_part_01 = kron(full_operator_part_01, OPERATOR_PAULI_I)
+ full_operator_part_10 = kron(full_operator_part_10, OPERATOR_PAULI_I)
+ full_operator_part_11 = kron(full_operator_part_11, OPERATOR_PAULI_I)
full_operator = full_operator_part_00 + full_operator_part_01 + full_operator_part_10 + full_operator_part_11
qubit1.state.operate(full_operator)
diff --git a/docs/build/html/_modules/qns/models/qubit/qubit.html b/docs/build/html/_modules/qns/models/qubit/qubit.html
index 3820d4b..8dbc652 100644
--- a/docs/build/html/_modules/qns/models/qubit/qubit.html
+++ b/docs/build/html/_modules/qns/models/qubit/qubit.html
@@ -88,11 +88,11 @@ Source code for qns.models.qubit.qubit
from typing import Any, List, Optional
import numpy as np
-from qns.models.qubit.const import QUBIT_STATE_0, QUBIT_STATE_1,\
+from qns.models.qubit.const import QUBIT_STATE_0, QUBIT_STATE_1, \
QUBIT_STATE_P, QUBIT_STATE_N, QUBIT_STATE_L, QUBIT_STATE_R
-from qns.models.qubit.utils import single_gate_expand, partial_trace
+from qns.models.qubit.utils import single_gate_expand, partial_trace, kron
from qns.models.core.backend import QuantumModel
-from qns.models.qubit.errors import QStateBaseError, QStateQubitNotInStateError,\
+from qns.models.qubit.errors import QStateBaseError, QStateQubitNotInStateError, \
QStateSizeNotMatchError, OperatorNotMatchError
from qns.utils.rnd import get_rand
@@ -124,7 +124,6 @@ Source code for qns.models.qubit.qubit
raise QStateSizeNotMatchError
if abs(1 - rho.trace()) > 0.0000000001:
# trace = 1
- print(2333, 1 - rho.trace())
raise QStateSizeNotMatchError
self.rho = rho
@@ -164,7 +163,7 @@ Source code for qns.models.qubit.qubit
try:
idx = self.qubits.index(qubit)
shift = self.num - idx - 1
- assert(shift >= 0)
+ assert (shift >= 0)
except AssertionError:
raise QStateQubitNotInStateError
@@ -172,11 +171,11 @@ Source code for qns.models.qubit.qubit
Full_M_1 = np.array([[1]])
for i in range(self.num):
if i == idx:
- Full_M_0 = np.kron(Full_M_0, M_0)
- Full_M_1 = np.kron(Full_M_1, M_1)
+ Full_M_0 = kron(Full_M_0, M_0)
+ Full_M_1 = kron(Full_M_1, M_1)
else:
- Full_M_0 = np.kron(Full_M_0, np.array([[1, 0], [0, 1]]))
- Full_M_1 = np.kron(Full_M_1, np.array([[1, 0], [0, 1]]))
+ Full_M_0 = kron(Full_M_0, np.array([[1, 0], [0, 1]]))
+ Full_M_1 = kron(Full_M_1, np.array([[1, 0], [0, 1]]))
poss_0 = np.trace(np.dot(Full_M_0.T.conjugate(), np.dot(Full_M_0, self.rho)))
rn = get_rand()
diff --git a/docs/build/html/_modules/qns/models/qubit/utils.html b/docs/build/html/_modules/qns/models/qubit/utils.html
index 26dbd47..ae26311 100644
--- a/docs/build/html/_modules/qns/models/qubit/utils.html
+++ b/docs/build/html/_modules/qns/models/qubit/utils.html
@@ -90,6 +90,14 @@ Source code for qns.models.qubit.utils
from qns.models.qubit.errors import QGateStateJointError, OperatorError
+[docs]def kron(a: np.ndarray, b: np.ndarray) -> np.ndarray:
+ if a.shape == (1,):
+ a = a.reshape((1, 1))
+ if b.shape == (1,):
+ b = b.reshape((1, 1))
+ return (a[:, None, :, None]*b[None, :, None, :]).reshape(a.shape[0]*b.shape[0], a.shape[1]*b.shape[1])
+
+
[docs]def single_gate_expand(qubit, operator: np.ndarray) -> np.ndarray:
state = qubit.state
if operator.shape != (2, 2):
@@ -103,9 +111,9 @@ Source code for qns.models.qubit.utils
full_operator = np.array([1])
for i in range(state.num):
if i == idx:
- full_operator = np.kron(full_operator, operator)
+ full_operator = kron(full_operator, operator)
else:
- full_operator = np.kron(full_operator, OPERATOR_PAULI_I)
+ full_operator = kron(full_operator, OPERATOR_PAULI_I)
return full_operator
@@ -117,7 +125,7 @@ Source code for qns.models.qubit.utils
from qns.models.qubit.qubit import QState
nq = QState(qubit1.state.qubits+qubit2.state.qubits,
- rho=np.kron(qubit1.state.rho, qubit2.state.rho))
+ rho=kron(qubit1.state.rho, qubit2.state.rho))
for q in nq.qubits:
q.state = nq
diff --git a/docs/build/html/_modules/qns/network/protocol/bb84.html b/docs/build/html/_modules/qns/network/protocol/bb84.html
index 002be72..d72a31e 100644
--- a/docs/build/html/_modules/qns/network/protocol/bb84.html
+++ b/docs/build/html/_modules/qns/network/protocol/bb84.html
@@ -96,6 +96,8 @@ Source code for qns.network.protocol.bb84
from qns.models.qubit import Qubit
import numpy as np
+import random
+import hashlib
from qns.utils.rnd import get_rand, get_choice
@@ -111,7 +113,28 @@ Source code for qns.network.protocol.bb84
[docs]class BB84SendApp(Application):
def __init__(self, dest: QNode, qchannel: QuantumChannel,
- cchannel: ClassicChannel, send_rate=1000):
+ cchannel: ClassicChannel, send_rate=1000,
+ min_length_for_post_processing=5000,
+ proportion_for_estimating_error=0.4, max_cascade_round=4,
+ cascade_alpha=0.73, cascade_beita=2,
+ init_lower_cascade_key_block_size=5,
+ init_upper_cascade_key_block_size=20,
+ security=0.05):
+ """
+ Args:
+ dest: QNode.
+ qchannel: QuantumChannel.
+ cchannel: ClassicChannel.
+ send_rate: the sending rate of qubit.
+ min_length_for_post_processing: threshold to trigger post-processing.
+ proportion_for_estimating_error: what proportion of bits are used for error estimating.
+ max_cascade_round: how many rounds of cascade need to be executed.
+ cascade_alpha: init_cascade_size = cascade_alpha / error_rate.
+ cascade_beita: next_cascade_size = init_cascade_size * 2.
+ init_lower_cascade_key_block_size: lower bound of init_cascade_size.
+ init_upper_cascade_key_block_size: upper bound of init_cascade_size.
+ security: parameter for privacy amplification.
+ """
super().__init__()
self.dest = dest
self.qchannel = qchannel
@@ -126,6 +149,27 @@ Source code for qns.network.protocol.bb84
self.succ_key_pool = {}
self.fail_number = 0
+ # variable used in cascade and error estimate
+ self.min_length_for_post_processing = min_length_for_post_processing
+ self.proportion_for_estimating_error = proportion_for_estimating_error
+ self.max_cascade_round = max_cascade_round
+ self.cascade_alpha = cascade_alpha
+ self.cascade_beita = cascade_beita
+ self.init_lower_cascade_key_block_size = init_lower_cascade_key_block_size
+ self.init_upper_cascade_key_block_size = init_upper_cascade_key_block_size
+
+ self.using_post_processing = False
+ self.cur_error_rate = 1e-6
+ self.cur_cascade_round = 0
+ self.cur_cascade_key_block_size = self.init_lower_cascade_key_block_size
+ self.cascade_key = []
+
+ # variable used in privacy amplification
+ self.security = security
+
+ self.bit_leak = 0
+ self.successful_key = []
+
self.add_handler(self.handleClassicPacket, [RecvClassicPacket], [self.cchannel])
[docs] def install(self, node: QNode, simulator: Simulator):
@@ -145,11 +189,15 @@ Source code for qns.network.protocol.bb84
# self._simulator.add_event(event)
+ return self.check_basis(event) or self.recv_error_estimate_packet(event) or self.recv_cascade_ask_packet(event) or \
+ self.recv_check_error_ask_packet(event) or self.recv_privacy_amplification_ask_packet(event)
[docs] def check_basis(self, event: RecvClassicPacket):
packet = event.packet
msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "check_basis":
+ return False
id = msg.get("id")
basis_dest = msg.get("basis")
@@ -163,9 +211,10 @@ Source code for qns.network.protocol.bb84
# log.info(f"[{self._simulator.current_time}] src check {id} basis fail")
self.fail_number += 1
- packet = ClassicPacket(msg={"id": id, "basis": basis_src,
+ packet = ClassicPacket(msg={"packet_class": "check_basis", "id": id, "basis": basis_src,
"ret": self.measure_list[id]}, src=self._node, dest=self.dest)
- self.cchannel.send(packet, next_hop=self.dest)
+ self.cchannel.send(packet, next_hop=self.dest)
+ return True
[docs] def send_qubit(self):
@@ -193,11 +242,192 @@ Source code for qns.network.protocol.bb84
t = self._simulator.current_time + \
self._simulator.time(sec=1 / self.send_rate)
event = func_to_event(t, self.send_qubit, by=self)
- self._simulator.add_event(event)
+ self._simulator.add_event(event)
+
+[docs] def recv_error_estimate_packet(self, event: RecvClassicPacket):
+ """
+ BB84SendApp recv error estimate packet,and send error_estimate_reply packet.
+
+ Args:
+ event:the error estimate packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "error_estimate":
+ return False
+
+ self.using_post_processing = True
+ self.cur_error_rate = 1e-6
+ self.cur_cascade_round = 0
+ self.cur_cascade_key_block_size = self.init_lower_cascade_key_block_size
+ self.cascade_key = []
+ self.bit_leak = 0
+
+ # get some recvapp error estimate info
+ recv_app_bit_for_estimate = msg.get("bit_for_estimate")
+ recv_app_bit_index_for_estimate = msg.get("bit_index_for_estimate")
+ recv_app_bit_index_for_cascade = msg.get("bit_index_for_cascade")
+ keys = list(self.succ_key_pool.keys())
+ error_in_estimate = 0
+ real_bit_length_for_estimate = 0
+ real_bit_index_for_cascade = []
+
+ # get cascade_key and count errors
+ for i in keys:
+ item_temp = self.succ_key_pool.pop(i)
+ if i in recv_app_bit_index_for_estimate:
+ # find a bit to estimate error
+ bit_index = recv_app_bit_index_for_estimate.index(i)
+ if item_temp == recv_app_bit_for_estimate[bit_index]:
+ real_bit_length_for_estimate += 1
+ else:
+ real_bit_length_for_estimate += 1
+ error_in_estimate += 1
+ elif i in recv_app_bit_index_for_cascade:
+ # find a bit for cascade
+ self.cascade_key.append(item_temp)
+ real_bit_index_for_cascade.append(i)
+
+ # error estimate and set key block size in round1
+ self.cur_error_rate = error_in_estimate/real_bit_length_for_estimate
+
+ if self.cur_error_rate <= (self.cascade_alpha/self.init_upper_cascade_key_block_size):
+ # error rate is smaller than threshold
+ self.cur_cascade_key_block_size = self.init_upper_cascade_key_block_size
+ elif self.cur_error_rate >= (self.cascade_alpha/self.init_lower_cascade_key_block_size):
+ self.cur_cascade_key_block_size = self.init_lower_cascade_key_block_size
+ else:
+ self.cur_cascade_key_block_size = int(self.cascade_alpha/self.cur_error_rate)
+
+ self.cur_cascade_round = 1
+
+ # send error_estimate_reply packet
+ packet = ClassicPacket(msg={"packet_class": "error_estimate_reply",
+ "error_rate": self.cur_error_rate,
+ "real_bit_index_for_cascade": real_bit_index_for_cascade},
+ src=self._node,
+ dest=self.dest)
+ self.cchannel.send(packet, next_hop=self.dest)
+ return True
+
+[docs] def recv_cascade_ask_packet(self, event: RecvClassicPacket):
+ """
+ BB84SendApp recv cascade_ask packet,calculate the parity value of the corresponding block,and send cascade_reply packet.
+
+ Args:
+ event:the cascade_ask packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "cascade_ask":
+ return False
+
+ # get cascade_ask info
+ parity_request = msg.get("parity_request")
+ round_change_flag = msg.get("round_change_flag")
+ shuffle_index = msg.get("shuffle_index")
+
+ # cascade round change and shuffle cascade keys
+ if round_change_flag is True and shuffle_index != []:
+ self.cur_cascade_key_block_size = int(self.cur_cascade_key_block_size * self.cascade_beita)
+ self.cur_cascade_round += 1
+ self.cascade_key = [self.cascade_key[i] for i in shuffle_index]
+
+ parity_answer = []
+ for key_interval in parity_request:
+ temp_parity = cascade_parity(self.cascade_key[key_interval[0]:key_interval[1]+1])
+ parity_answer.append(temp_parity)
+
+ self.bit_leak += len(parity_answer)
+
+ # send cascade_reply packet
+ packet = ClassicPacket(msg={"packet_class": "cascade_reply",
+ "parity_answer": parity_answer},
+ src=self._node, dest=self.dest)
+ self.cchannel.send(packet, next_hop=self.dest)
+ return True
+
+[docs] def recv_check_error_ask_packet(self, event: RecvClassicPacket):
+ """
+ BB84SendApp recv check_error_ask packet,check error,and send check_error_reply packet.
+
+ Args:
+ event:the check_error_ask packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "check_error_ask":
+ return False
+
+ recv_hash_key = msg.get("hash_key")
+ hash_key = hashlib.sha512(bytearray(self.cascade_key)).hexdigest()
+ if hash_key != recv_hash_key:
+ # cascade fail
+ pa_flag = False
+ packet = ClassicPacket(msg={"packet_class": "check_error_reply",
+ "pa_flag": pa_flag},
+ src=self._node, dest=self.dest)
+ else:
+ # cascade succeed
+ pa_flag = True
+ packet = ClassicPacket(msg={"packet_class": "check_error_reply",
+ "pa_flag": pa_flag},
+ src=self._node, dest=self.dest)
+ self.cchannel.send(packet, next_hop=self.dest)
+ return True
+
+[docs] def recv_privacy_amplification_ask_packet(self, event: RecvClassicPacket):
+ """
+ BB84SendApp recv privacy_amplification_ask packet,perform privacy amplification.
+
+ Args:
+ event:the privacy_amplification_ask packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "privacy_amplification_ask":
+ return False
+ pa_flag = msg.get("pa_flag")
+ if pa_flag is True:
+ # Alice's privacy amplification operation
+ first_row = msg.get("first_row")
+ first_col = msg.get("first_col")
+ matrix_row = len(first_row)
+ matrix_col = len(first_col)+1
+ toeplitz_matrix = pa_generate_toeplitz_matrix(matrix_row, matrix_col, first_row, first_col)
+ self.successful_key += list(pa_randomize_key(self.cascade_key, toeplitz_matrix))
+ self.using_post_processing = False
+ # validation output
+ return True
[docs]class BB84RecvApp(Application):
- def __init__(self, src: QNode, qchannel: QuantumChannel, cchannel: ClassicChannel):
+ def __init__(self, src: QNode, qchannel: QuantumChannel, cchannel: ClassicChannel,
+ min_length_for_post_processing=5000,
+ proportion_for_estimating_error=0.4, max_cascade_round=4,
+ cascade_alpha=0.73, cascade_beita=2,
+ init_lower_cascade_key_block_size=5,
+ init_upper_cascade_key_block_size=20,
+ security=0.05):
+ """
+ Args:
+ src: QNode.
+ qchannel: QuantumChannel.
+ cchannel: ClassicChannel.
+ send_rate: the sending rate of qubit.
+ min_length_for_post_processing: threshold to trigger post-processing.
+ proportion_for_estimating_error: what proportion of bits are used for error estimating.
+ max_cascade_round: how many rounds of cascade need to be executed.
+ cascade_alpha: init_cascade_size = cascade_alpha / error_rate.
+ cascade_beita: next_cascade_size = init_cascade_size * 2.
+ init_lower_cascade_key_block_size: lower bound of init_cascade_size.
+ init_upper_cascade_key_block_size: upper bound of init_cascade_size.
+ security: parameter for privacy amplification.
+ """
super().__init__()
self.src = src
self.qchannel = qchannel
@@ -210,6 +440,29 @@ Source code for qns.network.protocol.bb84
self.succ_key_pool = {}
self.fail_number = 0
+ # variable used in cascade and error estimate
+ self.min_length_for_post_processing = min_length_for_post_processing
+ self.proportion_for_estimating_error = proportion_for_estimating_error
+ self.max_cascade_round = max_cascade_round
+ self.cascade_alpha = cascade_alpha
+ self.cascade_beita = cascade_beita
+ self.init_lower_cascade_key_block_size = init_lower_cascade_key_block_size
+ self.init_upper_cascade_key_block_size = init_upper_cascade_key_block_size
+
+ self.using_post_processing = False
+ self.cur_error_rate = 1e-6
+ self.cur_cascade_round = 0
+ self.cur_cascade_key_block_size = self.init_lower_cascade_key_block_size
+ self.post_processing_key = {}
+ self.cascade_key = []
+ self.cascade_binary_set = []
+
+ # variable used in privacy amplification
+ self.security = security
+
+ self.bit_leak = 0
+ self.successful_key = []
+
self.add_handler(self.handleQuantumPacket, [RecvQubitPacket], [self.qchannel])
self.add_handler(self.handleClassicPacket, [RecvClassicPacket], [self.cchannel])
@@ -217,11 +470,15 @@ Source code for qns.network.protocol.bb84
return self.recv(event)
+ return self.check_basis(event) or self.recv_error_estimate_reply_packet(event) or \
+ self.recv_cascade_reply_packet(event) or self.recv_check_error_reply_packet(event)
[docs] def check_basis(self, event: RecvClassicPacket):
packet = event.packet
msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "check_basis":
+ return False
id = msg.get("id")
basis_src = msg.get("basis")
@@ -236,7 +493,12 @@ Source code for qns.network.protocol.bb84
self.succ_key_pool[id] = self.measure_list[id]
else:
# log.info(f"[{self._simulator.current_time}] dest check {id} basis fail")
- self.fail_number += 1
+ self.fail_number += 1
+
+ if self.using_post_processing is False and len(self.succ_key_pool) >= self.min_length_for_post_processing:
+ # enough raw key to start cascade
+ self.send_error_estimate_packet()
+ return True
[docs] def recv(self, event: RecvQubitPacket):
qubit: Qubit = event.qubit
@@ -251,8 +513,295 @@ Source code for qns.network.protocol.bb84
# log.info(f"[{self._simulator.current_time}] recv qubit {qubit.id}, \
# basis: {basis_msg}, ret: {ret}")
packet = ClassicPacket(
- msg={"id": qubit.id, "basis": basis_msg}, src=self._node, dest=self.src)
- self.cchannel.send(packet, next_hop=self.src)
+ msg={"packet_class": "check_basis", "id": qubit.id, "basis": basis_msg}, src=self._node, dest=self.src)
+ self.cchannel.send(packet, next_hop=self.src)
+
+[docs] def send_error_estimate_packet(self):
+ """
+ BB84Recvapp send error estimate ask packet.
+ """
+ self.using_post_processing = True
+ self.cur_cascade_round = 0
+ self.cur_error_rate = 1e-6
+ self.cur_cascade_key_block_size = self.init_lower_cascade_key_block_size
+ self.cascade_key = []
+ self.post_processing_key = {}
+ self.cascade_binary_set = []
+ self.bit_leak = 0
+
+ # info to send
+ bit_for_estimate = {} # []
+ bits_len_for_cascade = len(self.succ_key_pool)
+ keys = list(self.succ_key_pool.keys())[0:bits_len_for_cascade]
+
+ # remove uesd raw key and update cascade_key && bit_for_estimate
+ for i in keys:
+ item_temp = self.succ_key_pool.pop(i)
+ if random.uniform(0, 1) < self.proportion_for_estimating_error:
+ bit_for_estimate[i] = item_temp
+ else:
+ self.post_processing_key[i] = item_temp
+
+ # send error_estimate packet
+ packet = ClassicPacket(msg={"packet_class": "error_estimate",
+ "bit_index_for_estimate": list(bit_for_estimate.keys()),
+ "bit_for_estimate": list(bit_for_estimate.values()),
+ "bit_index_for_cascade": list(self.post_processing_key.keys())},
+ src=self._node, dest=self.src)
+ self.cchannel.send(packet, next_hop=self.src)
+
+[docs] def recv_error_estimate_reply_packet(self, event: RecvClassicPacket):
+ """
+ BB84RecvApp recv error_estimate_reply packet,perform the first round of cascade,send cascade_ask packet.
+
+ Args:
+ event:the error_estimate_reply packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "error_estimate_reply":
+ return False
+
+ # get error estimate info and set block size in round1
+ self.cur_error_rate = msg.get("error_rate")
+ if self.cur_error_rate <= (self.cascade_alpha/self.init_upper_cascade_key_block_size):
+ # error rate is smaller than threshold
+ self.cur_cascade_key_block_size = self.init_upper_cascade_key_block_size
+ elif self.cur_error_rate >= (self.cascade_alpha/self.init_lower_cascade_key_block_size):
+ # error rate is bigger than threshold
+ self.cur_cascade_key_block_size = self.init_lower_cascade_key_block_size
+ else:
+ self.cur_cascade_key_block_size = int(self.cascade_alpha/self.cur_error_rate)
+
+ self.cur_cascade_round = 1
+
+ # remain real_bit_for_cascade
+ real_bit_index_for_cascade = msg.get("real_bit_index_for_cascade")
+ for i in list(self.post_processing_key.keys()):
+ item_temp = self.post_processing_key.pop(i)
+ if i in real_bit_index_for_cascade:
+ self.cascade_key.append(item_temp)
+
+ # start cascade round1,divide into top blocks of size self.keysize
+ count_temp = 0
+ last_index = len(self.cascade_key) - 1
+ while count_temp <= last_index:
+ end = count_temp + self.cur_cascade_key_block_size - 1
+ if end <= last_index:
+ self.cascade_binary_set.append((count_temp, end))
+ count_temp = end + 1
+ else:
+ end = last_index
+ self.cascade_binary_set.append((count_temp, end))
+ break
+
+ # send cascade_ask packet
+ packet = ClassicPacket(msg={"packet_class": "cascade_ask",
+ "parity_request": self.cascade_binary_set,
+ "round_change_flag": False,
+ "shuffle_index": []},
+ src=self._node, dest=self.src)
+ self.cchannel.send(packet, next_hop=self.src)
+
+ return True
+
+[docs] def recv_cascade_reply_packet(self, event: RecvClassicPacket):
+ """
+ BB84RecvApp recv cascade_reply packet,perform next round of cascade,and send cascade_ask packet.
+
+ Args:
+ event:the cascade_reply packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "cascade_reply":
+ return False
+
+ # get cascade_reply info
+ parity_answer = msg.get("parity_answer")
+ self.bit_leak += len(parity_answer)
+
+ # update cascade binary set
+ count_temp = 0
+ # traverse all the blocks need to compare parity
+ copy_cascade_binary_set = self.cascade_binary_set.copy()
+ for key_interval in copy_cascade_binary_set:
+ temp_parity = cascade_parity(self.cascade_key[key_interval[0]:key_interval[1]+1])
+ if temp_parity == parity_answer[count_temp]:
+ # this block have even errors,can not correct in this round
+ self.cascade_binary_set.remove(key_interval)
+ elif key_interval[0] != key_interval[1]:
+ # binary alg
+ self.cascade_binary_set.remove(key_interval)
+ left_temp, right_temp = cascade_binary_divide(key_interval[0], key_interval[1])
+ self.cascade_binary_set.append(left_temp)
+ self.cascade_binary_set.append(right_temp)
+ else:
+ # find the odd error
+ self.cascade_binary_set.remove(key_interval)
+ self.cascade_key[key_interval[0]] = parity_answer[count_temp]
+
+ count_temp += 1
+
+ round_change_flag = False
+ check_error_flag = False
+ shuffle_index = []
+ if len(self.cascade_binary_set) == 0:
+ if self.cur_cascade_round == self.max_cascade_round:
+ # update round info
+ check_error_flag = True
+ # check error
+ hash_key = hashlib.sha512(bytearray(self.cascade_key)).hexdigest()
+ else:
+ # update round info
+ round_change_flag = True
+ self.cur_cascade_round += 1
+ self.cur_cascade_key_block_size = int(self.cur_cascade_key_block_size * self.cascade_beita)
+ # need shuffle
+ shuffle_index = [i for i in range(len(self.cascade_key))]
+ shuffle_index = cascade_key_shuffle(shuffle_index)
+ self.cascade_key = [self.cascade_key[i] for i in shuffle_index]
+ # divide into top blocks of size self.keysize
+ count_temp = 0
+ last_index = len(self.cascade_key) - 1
+ while count_temp <= last_index:
+ end = count_temp + self.cur_cascade_key_block_size - 1
+ if end <= last_index:
+ self.cascade_binary_set.append((count_temp, end))
+ count_temp = end + 1
+ else:
+ end = last_index
+ self.cascade_binary_set.append((count_temp, end))
+ break
+
+ # send cascade_ask packet,distinguish whether privacy amplification is required
+ if check_error_flag is False:
+ packet = ClassicPacket(msg={"packet_class": "cascade_ask",
+ "parity_request": self.cascade_binary_set,
+ "round_change_flag": round_change_flag,
+ "shuffle_index": shuffle_index},
+ src=self._node, dest=self.src)
+ else:
+ # check error
+ packet = ClassicPacket(msg={"packet_class": "check_error_ask",
+ "hash_key": hash_key},
+ src=self._node, dest=self.src)
+ self.cchannel.send(packet, next_hop=self.src)
+ return True
+
+[docs] def recv_check_error_reply_packet(self, event: RecvClassicPacket):
+ """
+ BB84RecvApp recv check_error_reply packet,perform privacy amplification,and send privacy_amplification_ask packet.
+
+ Args:
+ event:the check_error_reply packet.
+ """
+ packet = event.packet
+ msg: dict = packet.get()
+ packet_class = msg.get("packet_class")
+ if packet_class != "check_error_reply":
+ return False
+ pa_flag = msg.get("pa_flag")
+ if pa_flag is True:
+ # check error succeed,Bob's privacy amplification operation
+ matrix_row = len(self.cascade_key)
+ matrix_col = (1-self.security)*len(self.cascade_key)-self.bit_leak
+ first_row = [random.randint(0, 1) for _ in range(matrix_row)]
+ first_col = [random.randint(0, 1) for _ in range(int(matrix_col)-1)]
+ toeplitz_matrix = pa_generate_toeplitz_matrix(matrix_row, matrix_col, first_row, first_col)
+ self.successful_key += list(pa_randomize_key(self.cascade_key, toeplitz_matrix))
+ packet = ClassicPacket(msg={"packet_class": "privacy_amplification_ask",
+ "pa_flag": True,
+ "first_row": first_row,
+ "first_col": first_col},
+ src=self._node, dest=self.src)
+ self.using_post_processing = False
+ else:
+ # check error fail,drop
+ first_row = []
+ first_col = []
+ packet = ClassicPacket(msg={"packet_class": "privacy_amplification_ask",
+ "pa_flag": False,
+ "first_row": first_row,
+ "first_col": first_col},
+ src=self._node, dest=self.src)
+ self.using_post_processing = False
+ self.cchannel.send(packet, next_hop=self.src)
+ return True
+
+
+[docs]def cascade_parity(target: list):
+ """
+ Calculate key block parity.
+
+ Args:
+ target:target key block.
+ """
+ count = sum(target)
+ return count % 2
+
+
+[docs]def cascade_binary_divide(begin: int, end: int):
+ """
+ Evenly divided the key block.
+
+ Args:
+ begin: key block begin index.
+ end: key block end index.
+ """
+ len = end - begin + 1
+ if len % 2 == 1:
+ middle = int(len/2) + begin
+ else:
+ middle = int(len/2) + begin - 1
+ return (begin, middle), (middle+1, end)
+
+
+[docs]def cascade_key_shuffle(index: list):
+ """
+ Shuffle the index.
+
+ Args:
+ index: the index list.
+ """
+ np.random.shuffle(index)
+ return index
+
+
+[docs]def pa_generate_toeplitz_matrix(N: int, M: int, first_row: list, first_col: list):
+ """
+ Generate a Toeplitz matrix of size N x M using two given list of binary values.
+
+ Args:
+ N:col num of the Toeplitz matrix.
+ M:row num of the Toeplitz matrix.
+ first_row:first row of the Toeplitz matrix.
+ first_col:first col of the Toeplitz matrix.
+ """
+ N = int(N)
+ M = int(M)
+ toeplitz_matrix = [[0] * N for _ in range(M)]
+ for i in range(N):
+ toeplitz_matrix[0][i] = first_row[i]
+ for i in range(M-1):
+ toeplitz_matrix[i+1][0] = first_col[i]
+ for i in range(1, M):
+ for j in range(1, N):
+ toeplitz_matrix[i][j] = toeplitz_matrix[i-1][j-1]
+ return toeplitz_matrix
+
+
+[docs]def pa_randomize_key(original_key: list, toeplitz_matrix):
+ """
+ process the original key through the toeplitz matrix.
+
+ Args:
+ original_key: the original key.
+ toeplitz_matrix: the toeplitz matrix.
+ """
+ return np.dot(toeplitz_matrix, original_key) % 2
diff --git a/docs/build/html/_modules/qns/network/protocol/classicforward.html b/docs/build/html/_modules/qns/network/protocol/classicforward.html
index 0b7153f..b630a33 100644
--- a/docs/build/html/_modules/qns/network/protocol/classicforward.html
+++ b/docs/build/html/_modules/qns/network/protocol/classicforward.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -94,7 +94,7 @@ Source code for qns.network.protocol.classicforward
from qns.simulator.event import Event
-[docs]class ClassicPacketForwardApp(Application):
+[docs]class ClassicPacketForwardApp(Application):
"""
This application will generate routing table for classic networks
and allow nodes to forward classic packats to the destination.
@@ -109,10 +109,10 @@ Source code for qns.network.protocol.classicforward
self.route = route
self.add_handler(self.handleClassicPacket, [RecvClassicPacket], [])
-[docs] def install(self, node: QNode, simulator: Simulator):
+
-[docs] def handleClassicPacket(self, node: QNode, event: Event):
+[docs] def handleClassicPacket(self, node: QNode, event: Event):
packet = event.packet
self_node: QNode = self.get_node()
diff --git a/docs/build/html/_modules/qns/network/protocol/entanglement_distribution.html b/docs/build/html/_modules/qns/network/protocol/entanglement_distribution.html
index 3740b89..9153e55 100644
--- a/docs/build/html/_modules/qns/network/protocol/entanglement_distribution.html
+++ b/docs/build/html/_modules/qns/network/protocol/entanglement_distribution.html
@@ -118,7 +118,7 @@ Source code for qns.network.protocol.entanglement_distribution
[docs]class EntanglementDistributionApp(Application):
- def __init__(self, send_rate: Optional[int] = None, init_fidelity: int = 0.99):
+ def __init__(self, send_rate: Optional[int] = None, init_fidelity: float = 0.99):
super().__init__()
self.init_fidelity = init_fidelity
self.net: QuantumNetwork = None
@@ -279,6 +279,18 @@ Source code for qns.network.protocol.entanglement_distribution
transmit.first_epr_name)
second_epr: WernerStateEntanglement = self.memory.read(
transmit.second_epr_name)
+ #change code
+ #Check fidelitu before swapping
+ if first_epr.fidelity < 0.7 or second_epr.fidelity < 0.7:
+ #Inroduce probability of decoherence based on fidelity
+ print("test")
+ decoherence_probability = 1 - min(first_epr.fidelity, second_epr.fidelity) / 0.7
+ if get_rand() < decoherence_probability:
+ log.debug(f"{self.own}:Decoherence occurred, revoking entanglement.")
+ self.revoke_entanglement(transmit, from_node, cchannel)
+ self.restart_request(transmit)
+ return
+ #
new_epr = first_epr.swapping(second_epr, name=uuid.uuid4().hex)
log.debug(
f"{self.own}:perform swap use {first_epr} and {second_epr}")
diff --git a/docs/build/html/_modules/qns/network/protocol/node_process_delay.html b/docs/build/html/_modules/qns/network/protocol/node_process_delay.html
index 0a3d2b7..76d732e 100644
--- a/docs/build/html/_modules/qns/network/protocol/node_process_delay.html
+++ b/docs/build/html/_modules/qns/network/protocol/node_process_delay.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -93,7 +93,7 @@ Source code for qns.network.protocol.node_process_delay
from qns.simulator.ts import Time
-[docs]class NodeProcessDelayApp(Application):
+[docs]class NodeProcessDelayApp(Application):
"""
This application will add an addition delay whenever the node received an event.
It is used to represent the processing delay on quantum nodes.
@@ -111,15 +111,15 @@ Source code for qns.network.protocol.node_process_delay
self.delay_event_list = delay_event_list
self.wait_rehandle_event_list = []
-[docs] def install(self, node: QNode, simulator: Simulator):
+
-[docs] def check_in_delay_event_list(self, event) -> bool:
+[docs] def check_in_delay_event_list(self, event) -> bool:
if self.delay_event_list is None:
return True
return isinstance(event, self.delay_event_list)
-[docs] def handle(self, node: QNode, event: Event) -> bool:
+[docs] def handle(self, node: QNode, event: Event) -> bool:
if not self.check_in_delay_event_list(event):
return False
diff --git a/docs/build/html/_modules/qns/network/requests.html b/docs/build/html/_modules/qns/network/requests.html
index 5ceab53..754dc76 100644
--- a/docs/build/html/_modules/qns/network/requests.html
+++ b/docs/build/html/_modules/qns/network/requests.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/network/route/dijkstra.html b/docs/build/html/_modules/qns/network/route/dijkstra.html
index 13a4aef..2425e2a 100644
--- a/docs/build/html/_modules/qns/network/route/dijkstra.html
+++ b/docs/build/html/_modules/qns/network/route/dijkstra.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -86,6 +86,7 @@ Source code for qns.network.route.dijkstra
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Callable, Dict, List, Tuple, Union
+import math
from qns.entity.node.node import QNode
from qns.entity.qchannel.qchannel import QuantumChannel
@@ -98,6 +99,8 @@ Source code for qns.network.route.dijkstra
This is the dijkstra route algorithm implement
"""
+ INF = math.inf
+
def __init__(self, name: str = "dijkstra",
metric_func: Callable[[Union[QuantumChannel, ClassicChannel]], float] = None) -> None:
"""
@@ -114,7 +117,6 @@ Source code for qns.network.route.dijkstra
self.metric_func = metric_func
[docs] def build(self, nodes: List[QNode], channels: List[Union[QuantumChannel, ClassicChannel]]):
- INF = 999999
for n in nodes:
selected = []
@@ -125,7 +127,7 @@ Source code for qns.network.route.dijkstra
if nn == n:
d[n] = [0, []]
else:
- d[nn] = [INF, [nn]]
+ d[nn] = [self.INF, [nn]]
while len(unselected) != 0:
ms = unselected[0]
@@ -178,8 +180,9 @@ Source code for qns.network.route.dijkstra
path: List[QNode] = le[1]
path = path.copy()
path.reverse()
- if len(path) <= 1:
+ if len(path) <= 1 or metric == self.INF:
next_hop = None
+ return []
else:
next_hop = path[1]
return [(metric, next_hop, path)]
diff --git a/docs/build/html/_modules/qns/network/route/route.html b/docs/build/html/_modules/qns/network/route/route.html
index 008f628..260068f 100644
--- a/docs/build/html/_modules/qns/network/route/route.html
+++ b/docs/build/html/_modules/qns/network/route/route.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/network/topology/basictopo.html b/docs/build/html/_modules/qns/network/topology/basictopo.html
index 4fd90c5..f59b521 100644
--- a/docs/build/html/_modules/qns/network/topology/basictopo.html
+++ b/docs/build/html/_modules/qns/network/topology/basictopo.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/network/topology/gridtopo.html b/docs/build/html/_modules/qns/network/topology/gridtopo.html
index 842711f..f6cc784 100644
--- a/docs/build/html/_modules/qns/network/topology/gridtopo.html
+++ b/docs/build/html/_modules/qns/network/topology/gridtopo.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -104,7 +104,7 @@ Source code for qns.network.topology.gridtopo
super().__init__(nodes_number, nodes_apps, qchannel_args, cchannel_args, memory_args)
size = int(math.sqrt(self.nodes_number))
self.size = size
- assert(size ** 2 == self.nodes_number)
+ assert (size ** 2 == self.nodes_number)
[docs] def build(self) -> Tuple[List[QNode], List[QuantumChannel]]:
nl: List[QNode] = []
diff --git a/docs/build/html/_modules/qns/network/topology/linetopo.html b/docs/build/html/_modules/qns/network/topology/linetopo.html
index 3b371bd..2c54dab 100644
--- a/docs/build/html/_modules/qns/network/topology/linetopo.html
+++ b/docs/build/html/_modules/qns/network/topology/linetopo.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/network/topology/randomtopo.html b/docs/build/html/_modules/qns/network/topology/randomtopo.html
index 5cd33cf..98375f4 100644
--- a/docs/build/html/_modules/qns/network/topology/randomtopo.html
+++ b/docs/build/html/_modules/qns/network/topology/randomtopo.html
@@ -137,7 +137,7 @@ Source code for qns.network.topology.randomtopo
<
while True:
a = get_randint(0, self.nodes_number - 1)
b = get_randint(0, self.nodes_number - 1)
- if mat[a][b] == 0:
+ if a != b and mat[a][b] == 0:
break
mat[a][b] = 1
mat[b][a] = 1
diff --git a/docs/build/html/_modules/qns/network/topology/topo.html b/docs/build/html/_modules/qns/network/topology/topo.html
index 20a2f4f..d4331b8 100644
--- a/docs/build/html/_modules/qns/network/topology/topo.html
+++ b/docs/build/html/_modules/qns/network/topology/topo.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/network/topology/treetopo.html b/docs/build/html/_modules/qns/network/topology/treetopo.html
index 27a57a6..be44e98 100644
--- a/docs/build/html/_modules/qns/network/topology/treetopo.html
+++ b/docs/build/html/_modules/qns/network/topology/treetopo.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/simulator/ts.html b/docs/build/html/_modules/qns/simulator/ts.html
index c1abcbb..64627a9 100644
--- a/docs/build/html/_modules/qns/simulator/ts.html
+++ b/docs/build/html/_modules/qns/simulator/ts.html
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
@@ -91,6 +91,17 @@ Source code for qns.simulator.ts
default_accuracy = 1000000 # {default_accuracy} time slots per second
+[docs]def set_default_accuracy(time_slots: int):
+ """
+ set the default simulation accuracy
+
+ Args:
+ time_slots (int): the time slots per second.
+ """
+ global default_accuracy
+ default_accuracy = time_slots
+
+
[docs]class Time(object):
def __init__(self, time_slot: int = 0, sec: float = 0.0, accuracy: int = default_accuracy):
'''
@@ -118,22 +129,40 @@ Source code for qns.simulator.ts
return self.time_slot / self.accuracy
def __eq__(self, other: object) -> bool:
- return self.time_slot == other.time_slot
+ if isinstance(other, Time):
+ return self.time_slot == other.time_slot
+ other_time = Time(src=other)
+ return self.time_slot == other_time.time_slot
def __lt__(self, other: object) -> bool:
- return self.time_slot < other.time_slot
+ if isinstance(other, Time):
+ return self.time_slot < other.time_slot
+ other_time = Time(src=other)
+ return self.time_slot < other_time.time_slot
def __le__(self, other: object) -> bool:
- return self < other or self == other
+ if isinstance(other, Time):
+ return self.time_slot <= other.time_slot
+ other_time = Time(src=other)
+ return self.time_slot <= other_time.time_slot
def __gt__(self, other: object) -> bool:
- return not (self < other or self == other)
+ if isinstance(other, Time):
+ return self.time_slot > other.time_slot
+ other_time = Time(src=other)
+ return self.time_slot > other_time.time_slot
def __ge__(self, other: object) -> bool:
- return not (self < other)
+ if isinstance(other, Time):
+ return self.time_slot >= other.time_slot
+ other_time = Time(src=other)
+ return self.time_slot >= other_time.time_slot
def __ne__(self, other: object) -> bool:
- return not self == other
+ if isinstance(other, Time):
+ return self.time_slot != other.time_slot
+ other_time = Time(src=other)
+ return self.time_slot != other_time.time_slot
def __add__(self, ts: Union["Time", float]) -> "Time":
"""
@@ -148,6 +177,19 @@ Source code for qns.simulator.ts
tn.time_slot += ts.time_slot
return tn
+ def __sub__(self, ts: Union["Time", float]) -> "Time":
+ """
+ Minus an offset to the Time object
+
+ Args:
+ ts (Union["Time", float]): a Time object or a float indicating time in second
+ """
+ tn = Time(time_slot=self.time_slot, accuracy=self.accuracy)
+ if isinstance(ts, float):
+ ts = Time(sec=ts, accuracy=self.accuracy)
+ tn.time_slot = tn.time_slot - ts.time_slot
+ return tn
+
def __repr__(self) -> str:
return str(self.sec)
diff --git a/docs/build/html/_modules/qns/utils/log.html b/docs/build/html/_modules/qns/utils/log.html
index 00dd724..cd6df35 100644
--- a/docs/build/html/_modules/qns/utils/log.html
+++ b/docs/build/html/_modules/qns/utils/log.html
@@ -1,5 +1,5 @@
-
+
@@ -40,7 +40,7 @@
Install Guide
Tutorials
Develop Guide
-API Reference
+qns
diff --git a/docs/build/html/_modules/qns/utils/multiprocess.html b/docs/build/html/_modules/qns/utils/multiprocess.html
index 2220cbb..f59df34 100644
--- a/docs/build/html/_modules/qns/utils/multiprocess.html
+++ b/docs/build/html/_modules/qns/utils/multiprocess.html
@@ -91,6 +91,8 @@ Source code for qns.utils.multiprocess
import pandas as pd
from qns.utils.log import logger as log
+import signal
+
[docs]class MPSimulations():
"""
@@ -116,7 +118,7 @@ Source code for qns.utils.multiprocess
self.cores = cores if cores > 0 else multiprocessing.cpu_count()
self.data = pd.DataFrame()
- self.aggregated_date = pd.DataFrame()
+ self.aggregated_data = pd.DataFrame()
self._setting_list = []
self._current_simulation_count = 0
@@ -145,28 +147,39 @@ Source code for qns.utils.multiprocess
log.info(f"finish simulation [{setting['_id']+1}/{self._total_simulation_count}] {result}")
return raw
+ def _init_worker(self):
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+
[docs] def start(self):
"""
Start the multiple process simulation
"""
self.prepare_setting()
- pool = multiprocessing.Pool(processes=self.cores)
- result = []
- for setting in self._setting_list:
- result.append(pool.apply_async(self._single_run, (setting,)))
- pool.close()
- pool.join()
+ pool = multiprocessing.Pool(processes=self.cores, initializer=self._init_worker)
+ try:
+ result = []
+ for setting in self._setting_list:
+ result.append(pool.apply_async(self._single_run, (setting,)))
+ pool.close()
+ pool.join()
+ except KeyboardInterrupt:
+ print("terminating simulation")
+ pool.terminate()
+ pool.join()
for r in result:
- raw_data = r.get()
+ try:
+ raw_data = r.get()
+ except Exception:
+ print("[simulator] error in simulation")
+ continue
new_result = {}
for k, v in raw_data.items():
new_result[k] = [v]
result_pd = pd.DataFrame(new_result)
self.data = pd.concat([self.data, result_pd], ignore_index=True)
- if self.aggregate and self.iter_count > 1:
- print(self.data)
+ if self.aggregate:
mean = pd.DataFrame(self.data).drop(columns=["_id", "_group", "_repeat"])
new_name = {}
ck = mean.columns
diff --git a/docs/build/html/_sources/develop.rst.txt b/docs/build/html/_sources/develop.rst.txt
index 64f53a7..e5832d1 100644
--- a/docs/build/html/_sources/develop.rst.txt
+++ b/docs/build/html/_sources/develop.rst.txt
@@ -23,7 +23,7 @@ SimQN is a Python library for quantum networks evaluation. It requires Python >
.. code-block:: bash
pip3 install setuptools wheel twine
- pip3 install -r requirements
+ pip3 install -r requirements.txt
To setup the development environments, the following command install SimQN into the python library so that we can do `import qns`:
@@ -61,6 +61,7 @@ To automatic generate the API documents, use the following command:
To build document website, use the command:
.. code-block:: bash
+
cd docs
make html
diff --git a/docs/build/html/_sources/tutorials.entity.memory.rst.txt b/docs/build/html/_sources/tutorials.entity.memory.rst.txt
index 2c85523..3f84c0f 100644
--- a/docs/build/html/_sources/tutorials.entity.memory.rst.txt
+++ b/docs/build/html/_sources/tutorials.entity.memory.rst.txt
@@ -23,7 +23,7 @@ Quantum memory is an entity that can store qubits. It can be equipped to a quant
q1 = Qubit()
m.write(q1)
- q2 = m.read()
+ q2 = m.read(q1)
The memory can have a limited size. ``is_full`` function returns whether the memory is full:
diff --git a/docs/build/html/_sources/tutorials.models.qubit.rst.txt b/docs/build/html/_sources/tutorials.models.qubit.rst.txt
index ba5b783..cd1d961 100644
--- a/docs/build/html/_sources/tutorials.models.qubit.rst.txt
+++ b/docs/build/html/_sources/tutorials.models.qubit.rst.txt
@@ -85,10 +85,10 @@ SimQN also provides some commonly used decoherence models, including dephase mod
.. code-block:: python
- from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransmitErrorModel
+ from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransferErrorModel
from qns.models.qubit.factory import QubitFactory
- Qubit = QubitFactory(store_error_model=DepolarStorageErrorModel, transfer_error_model=DephaseTransmitErrorModel)
+ Qubit = QubitFactory(store_error_model=DepolarStorageErrorModel, transfer_error_model=DephaseTransferErrorModel)
q1 = Qubit(name="q1")
q2 = Qubit(name="q2")
@@ -96,7 +96,7 @@ SimQN also have error models for operating or measuring on qubits, by implementi
.. code-block:: python
- from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransmitErrorModel
+ from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransferErrorModel
from qns.models.qubit.factory import QubitFactory
Qubit = QubitFactory(operate_decoherence_rate=0.2,
diff --git a/docs/build/html/_sources/tutorials.network.route.rst.txt b/docs/build/html/_sources/tutorials.network.route.rst.txt
index 478da33..be34431 100644
--- a/docs/build/html/_sources/tutorials.network.route.rst.txt
+++ b/docs/build/html/_sources/tutorials.network.route.rst.txt
@@ -30,7 +30,7 @@ An example of using this algorithm is:
.. code-block:: python
- from qns.network.topology import RandomTopology, ClassicTopology
+ from qns.network.topology import RandomTopology
from qns.network.network import QuantumNetwork
from qns.network.route import DijkstraRouteAlgorithm
@@ -39,8 +39,8 @@ An example of using this algorithm is:
lines_number=10,
qchannel_args={"delay": 0.05, "bandwidth": 10},
cchannel_args={"delay": 0.05},
- memory_args=[{"capacity": memory_capacity}],
- nodes_apps=[EntanglementDistributionApp(init_fidelity=init_fidelity)])
+ memory_args=[{"capacity": 50}],
+ nodes_apps=[EntanglementDistributionApp(init_fidelity=0.99)])
# use the ``DijkstraRouteAlgorithm``, using the bandwidth as the ``metric_func``
route = DijkstraRouteAlgorithm(metric_func=lambda qchannel: qchannel.bandwidth)
diff --git a/docs/build/html/_sources/tutorials.network.topology.rst.txt b/docs/build/html/_sources/tutorials.network.topology.rst.txt
index e97e954..ec221ea 100644
--- a/docs/build/html/_sources/tutorials.network.topology.rst.txt
+++ b/docs/build/html/_sources/tutorials.network.topology.rst.txt
@@ -25,8 +25,8 @@ Topology generators may have more parameters. The following example shows how to
lines_number=10,
qchannel_args={"delay": 0.05},
cchannel_args={"delay": 0.05},
- memory_args=[{"capacity": memory_capacity}],
- nodes_apps=[EntanglementDistributionApp(init_fidelity=init_fidelity)])
+ memory_args=[{"capacity": 50}],
+ nodes_apps=[EntanglementDistributionApp(init_fidelity=0.99)])
# build the network
net = QuantumNetwork(topo=topo)
@@ -54,16 +54,17 @@ SimQN is able to generate classic topologies as well. The classic topology is in
.. code-block:: python
- from qns.network.topology import RandomTopology, ClassicTopology
+ from qns.network.topology import RandomTopology
from qns.network.network import QuantumNetwork
+ from qns.network.topology.topo import ClassicTopology
topo = RandomTopology(
nodes_number=5,
lines_number=10,
qchannel_args={"delay": 0.05},
cchannel_args={"delay": 0.05},
- memory_args=[{"capacity": memory_capacity}],
- nodes_apps=[EntanglementDistributionApp(init_fidelity=init_fidelity)])
+ memory_args=[{"capacity": 50}],
+ nodes_apps=[EntanglementDistributionApp(init_fidelity=0.99)])
# build the network, classic topology follows the quantum topology
net = QuantumNetwork(topo=topo, classic_topo=ClassicTopology.Follow)
@@ -91,12 +92,12 @@ The ``QuantumNetwork`` provides the following APIs to get or add nodes, channels
n2 = QNode(name="n2")
net.add_node(n2)
- # get a quantum channel by its name
- l1 = net.get_qchannel("l1")
+ # get a quantum channel by its name
+ l1 = net.get_qchannel("l1,2")
# add a quantum channel
l2 = QuantumChannel("l2")
- net.add_node(l2)
+ net.add_qchannel(l2)
node_list = net.nodes # get all nodes
qchannel_list = net.qchannels # get all quantum channels
diff --git a/docs/build/html/_sources/tutorials.quickstart.rst.txt b/docs/build/html/_sources/tutorials.quickstart.rst.txt
index 7cf0e02..95a6350 100644
--- a/docs/build/html/_sources/tutorials.quickstart.rst.txt
+++ b/docs/build/html/_sources/tutorials.quickstart.rst.txt
@@ -24,11 +24,11 @@ The simulation is last for 10 seconds and the ``accuracy`` is 10,000,000,000 slo
import numpy as np
light_speed = 299791458
- length = 100000 # 100,000 km
+ length = 100000 # 100,000 m
def drop_rate(length):
# drop 0.2 db/KM
- return 1 - np.exp(- length / 50000)
+ return 1 - np.exp(- length / 50000) #or 1 - np.power(10, - length / 50000)
# generate quantum nodes
n1 = QNode(name="n1")
@@ -88,6 +88,7 @@ First, we generate the simulator and produce the network produce:
from qns.network.route.dijkstra import DijkstraRouteAlgorithm
from qns.network.topology.topo import ClassicTopology
import qns.utils.log as log
+ import logging
init_fidelity = 0.99 # the initial entanglement's fidelity
nodes_number = 150 # the number of nodes
@@ -134,7 +135,7 @@ Now, it is possible to run the simulation and get the results:
s.run()
# count the number of successful entanglement distribution for each session
- results = [src.apps[0].success_count for req in net.requests]
+ results = [req.src.apps[0].success_count for req in net.requests]
# log the results
log.monitor(requests_number, nodes_number, results, s.time_spend, sep=" ")
diff --git a/docs/build/html/_sources/tutorials.util.rst.txt b/docs/build/html/_sources/tutorials.util.rst.txt
index 0e4157d..1748335 100644
--- a/docs/build/html/_sources/tutorials.util.rst.txt
+++ b/docs/build/html/_sources/tutorials.util.rst.txt
@@ -19,12 +19,14 @@ Users can set the logging level and record logs:
.. code-block:: Python
+ import logging
+
log.logger.setLevel(logging.INFO)
a = 1
log.debug("debug message")
- log.info("info message", a)
- log.warn("warn message", a+1)
+ log.info("info message %d", a)
+ log.warn("warn message %d", a + 1)
log.error("error message")
log.critical("critical message")
diff --git a/docs/build/html/develop.html b/docs/build/html/develop.html
index f4dcd4f..a6c4cd4 100644
--- a/docs/build/html/develop.html
+++ b/docs/build/html/develop.html
@@ -92,7 +92,7 @@ Code requirements
SimQN is a Python library for quantum networks evaluation. It requires Python > 3.7.0. WE leverage setuptools to build SimQN:
pip3 install setuptools wheel twine
-pip3 install -r requirements
+pip3 install -r requirements.txt
To setup the development environments, the following command install SimQN into the python library so that we can do import qns:
@@ -119,6 +119,10 @@ Compile API documents
To build document website, use the command:
+cd docs
+make html
+
+
Now, the compiled static website is built. Our documents is hosted on the gh-pages branch. Use the following command to publish new documents:
git subtree push --prefix docs/build/html origin gh-pages
diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html
index 891ba5a..ec3f77c 100644
--- a/docs/build/html/genindex.html
+++ b/docs/build/html/genindex.html
@@ -80,6 +80,7 @@ Index
| H
| I
| J
+ | K
| L
| M
| N
@@ -296,6 +297,16 @@ B
(class in qns.models.epr.bell)
+ BitFilpTransferErrorModel() (in module qns.models.qubit.decoherence)
+
+ BitFlipError() (in module qns.models.qubit.decoherence)
+
+ BitFlipMeasureErrorModel() (in module qns.models.qubit.decoherence)
+
+ BitFlipOperateErrorModel() (in module qns.models.qubit.decoherence)
+
+ BitFlipStorageErrorModel() (in module qns.models.qubit.decoherence)
+
build() (qns.network.BasicTopology method)
@@ -398,6 +409,12 @@ C
- (qns.simulator.event.Event method)
+ cascade_binary_divide() (in module qns.network.protocol.bb84)
+
+ cascade_key_shuffle() (in module qns.network.protocol.bb84)
+
+ cascade_parity() (in module qns.network.protocol.bb84)
+
check_basis() (qns.network.protocol.bb84.BB84RecvApp method)
@@ -414,6 +431,8 @@ C
- (qns.network.protocol.NodeProcessDelayApp method)
+
+
- ClassicChannel (class in qns.entity)
@@ -422,8 +441,6 @@ C
- (class in qns.entity.cchannel.cchannel)
-
-
- ClassicPacket (class in qns.entity)
@@ -496,6 +513,8 @@ D
- (class in qns.models.delay.delay)
+ - DephaseError() (in module qns.models.qubit.decoherence)
+
- DephaseMeasureErrorModel() (in module qns.models.qubit)
@@ -520,6 +539,8 @@ D
- (in module qns.models.qubit.decoherence)
+ - DepolarError() (in module qns.models.qubit.decoherence)
+
- DepolarMeasureErrorModel() (in module qns.models.qubit)
@@ -532,14 +553,14 @@ D
- (in module qns.models.qubit.decoherence)
-
-
+
- DepolarTransferErrorModel() (in module qns.models.qubit)
@@ -554,6 +575,16 @@ D
- (class in qns.network.route.dijkstra)
+ - DissipationError() (in module qns.models.qubit.decoherence)
+
+ - DissipationMeasureErrorModel() (in module qns.models.qubit.decoherence)
+
+ - DissipationOperateErrorModel() (in module qns.models.qubit.decoherence)
+
+ - DissipationStorageErrorModel() (in module qns.models.qubit.decoherence)
+
+ - DissipationTransferErrorModel() (in module qns.models.qubit.decoherence)
+
- distillation() (qns.models.epr.BaseEntanglement method)
@@ -618,6 +649,10 @@ E
- (in module qns.utils.log)
+ - ErrorWithLength() (in module qns.models.qubit.decoherence)
+
+ - ErrorWithTime() (in module qns.models.qubit.decoherence)
+
- Event (class in qns.simulator)
@@ -710,6 +745,16 @@ G
- (qns.entity.monitor.monitor.Monitor method)
+ - get_memory() (qns.entity.node.node.QNode method)
+
+
+
+
- get_node() (qns.entity.Application method)
@@ -722,8 +767,6 @@ G
- (qns.network.QuantumNetwork method)
-
-
- get_normal() (in module qns.utils.rnd)
- get_qchannel() (qns.entity.node.node.QNode method)
@@ -856,6 +899,14 @@
H
I
+K
+
+
+
+
L