QRL_graph
Reinforcement Learning for the quantum speedup in the graph
Given a graph, we try to compute the classical and quantum critical time. The definition of the criticial time is defined as the hitting time of the endpoints with the probility bigger than $p_0$.
Install
pip install qrl_graph==0.0.13
Usage
import numpy as np
from scipy.sparse.csgraph import laplacian
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib
from qrl_graph.graph_env.graph import Graph
g = np.array([[0, 1, 1, 0],
[1, 0, 0, 1],
[1, 0, 0, 1],
[0, 1, 1, 0]])
g_env = Graph(g=g)
print('Laplacian matrix:\n', g_env.laplacian)
t_cl = g_env.get_classical_time(p0=0.1)
t_q = g_env.get_quantum_time(p0=0.1)
print('Classical time:', t_cl)
print('Quantum time:', t_q)
print('Speed up:', t_cl / t_q)
# uncomment to show the graph
# g_env.show_graph()
The results are
Laplacian matrix:
[[ 2 -1 -1 0]
[-1 2 0 -1]
[-1 0 2 -1]
[ 0 -1 -1 2]]
Classical time: 0.25000000000000006
Quantum time: 0.6000000000000003
Speed up: 0.4166666666666665
Linear chain
from qrl_graph.graph_env.graph import Graph
from qrl_graph.utils import construct_linear_graph
N = 40
g = construct_linear_graph(N)
g_env = Graph(g=g)
# print('Laplacian matrix:\n', g_env.laplacian)
p0 = 1.0/(2*N)
t_cl = g_env.get_classical_time(p0=p0)
t_q = g_env.get_quantum_time(p0=p0)
print('Linear chain, N =', N)
print('Classical time:', t_cl)
print('Quantum time:', t_q)
print('Speed up:', t_cl / t_q)
glued tree
from qrl_graph.graph_env.graph import Graph
from qrl_graph.utils import construct_glued_tree_graph
# this is the height of binary tree, and total height of the glued tree is 2*height
h = 3
g = construct_glued_tree_graph(h)
N = g.shape[0]
g_env = Graph(g=g)
# print('Laplacian matrix:\n', g_env.laplacian)
p0 = 1.0/(2*N)
t_cl = g_env.get_classical_time(p0=p0)
t_q = g_env.get_quantum_time(p0=p0)
print('Glued tree, N =', N)
print('Classical time:', t_cl)
print('Quantum time:', t_q)
print('Speed up:', t_cl / t_q)
Metadata
Release files for qrl-graph 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qrl-graph-0.0.13.tar.gz | 15.2 kB | Without provenance | Details for qrl-graph-0.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qrl_graph-0.0.13-py3-none-any.whl | Python 3 | none | any | Details for qrl_graph-0.0.13-py3-none-any.whl |
Total release size: 31.0 kB
Release files / qrl-graph-0.0.13.tar.gz
| Download URL | qrl-graph-0.0.13.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
616b463846038fb7fef086d89e899823612e0261a981b2bd52d1f37a7c9eb26b
|
|
BLAKE2b-256 checksum How to use checksums |
986546877e7db33d8f21f83ab4b8c0aed9623b0ab1b8e3781efc93ad366a01c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / qrl_graph-0.0.13-py3-none-any.whl
| Download URL | qrl_graph-0.0.13-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03bb619f9de2813e6972f105d65c7424c6f2a30046b9ab30079ccf50213e787d
|
|
BLAKE2b-256 checksum How to use checksums |
1e7a118713687d34a4559964924679e30f33448660fd1eef85935528c8a91371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for qrl-graph 0.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.