qrl-graph


Nameqrl-graph JSON
Version 0.0.13 PyPI version JSON
download
home_pagehttps://github.com/JiahaoYao/QRL_graph
SummaryReinforcement Learning Algorithms for the quantum speed up in graphs
upload_time2023-02-03 23:45:32
maintainer
docs_urlNone
authorJimmy
requires_python
licenseMIT
keywords quantum computing variational quantum algorithms quantum machine learning reinforcement learning quspin graph
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```markdown
pip install qrl_graph==0.0.13
```


### Usage

```python
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 
```markdown
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 

```python
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

```python
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)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JiahaoYao/QRL_graph",
    "name": "qrl-graph",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "quantum computing,variational quantum algorithms,quantum machine learning,Reinforcement Learning,Quspin,Graph",
    "author": "Jimmy",
    "author_email": "jiahaoyao.math@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/98/65/46877e7db33d8f21f83ab4b8c0aed9623b0ab1b8e3781efc93ad366a01c5/qrl-graph-0.0.13.tar.gz",
    "platform": null,
    "description": "# QRL_graph\nReinforcement Learning for the quantum speedup in the graph\n\nGiven 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$. \n\n### Install\n\n```markdown\npip install qrl_graph==0.0.13\n```\n\n\n### Usage\n\n```python\nimport numpy as np\nfrom scipy.sparse.csgraph import laplacian\nimport networkx as nx\nimport matplotlib.pyplot as plt\nimport matplotlib \nfrom qrl_graph.graph_env.graph import Graph\n\ng = np.array([[0, 1, 1, 0],\n              [1, 0, 0, 1],\n              [1, 0, 0, 1],\n              [0, 1, 1, 0]])\n\ng_env = Graph(g=g)\nprint('Laplacian matrix:\\n', g_env.laplacian)\n\nt_cl = g_env.get_classical_time(p0=0.1)\nt_q = g_env.get_quantum_time(p0=0.1)\n\nprint('Classical time:', t_cl)\nprint('Quantum time:', t_q)\nprint('Speed up:', t_cl / t_q)\n\n\n# uncomment to show the graph\n# g_env.show_graph()\n```\n\n\nThe results are \n```markdown\nLaplacian matrix:\n [[ 2 -1 -1  0]\n [-1  2  0 -1]\n [-1  0  2 -1]\n [ 0 -1 -1  2]]\nClassical time: 0.25000000000000006\nQuantum time: 0.6000000000000003\nSpeed up: 0.4166666666666665\n```\n\n\n##### Linear chain \n\n```python\nfrom qrl_graph.graph_env.graph import Graph\nfrom qrl_graph.utils import construct_linear_graph\n\nN = 40\ng = construct_linear_graph(N)\n\ng_env = Graph(g=g)\n# print('Laplacian matrix:\\n', g_env.laplacian)\n\np0 = 1.0/(2*N)\nt_cl = g_env.get_classical_time(p0=p0)\nt_q = g_env.get_quantum_time(p0=p0)\n\nprint('Linear chain, N =', N)\nprint('Classical time:', t_cl)\nprint('Quantum time:', t_q)\nprint('Speed up:', t_cl / t_q)\n```\n\n\n#### glued tree\n\n```python\nfrom qrl_graph.graph_env.graph import Graph\nfrom qrl_graph.utils import construct_glued_tree_graph\n\n# this is the height of binary tree, and total height of the glued tree is 2*height\nh = 3\ng = construct_glued_tree_graph(h)\nN = g.shape[0]\n\ng_env = Graph(g=g)\n# print('Laplacian matrix:\\n', g_env.laplacian)\n\np0 = 1.0/(2*N)\nt_cl = g_env.get_classical_time(p0=p0)\nt_q = g_env.get_quantum_time(p0=p0)\n\nprint('Glued tree, N =', N)\nprint('Classical time:', t_cl)\nprint('Quantum time:', t_q)\nprint('Speed up:', t_cl / t_q)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Reinforcement Learning Algorithms for the quantum speed up in graphs",
    "version": "0.0.13",
    "split_keywords": [
        "quantum computing",
        "variational quantum algorithms",
        "quantum machine learning",
        "reinforcement learning",
        "quspin",
        "graph"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e7a118713687d34a4559964924679e30f33448660fd1eef85935528c8a91371",
                "md5": "95b010c667ae7cbbc6e3f4bb5d5ec08b",
                "sha256": "03bb619f9de2813e6972f105d65c7424c6f2a30046b9ab30079ccf50213e787d"
            },
            "downloads": -1,
            "filename": "qrl_graph-0.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "95b010c667ae7cbbc6e3f4bb5d5ec08b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15855,
            "upload_time": "2023-02-03T23:45:30",
            "upload_time_iso_8601": "2023-02-03T23:45:30.946813Z",
            "url": "https://files.pythonhosted.org/packages/1e/7a/118713687d34a4559964924679e30f33448660fd1eef85935528c8a91371/qrl_graph-0.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "986546877e7db33d8f21f83ab4b8c0aed9623b0ab1b8e3781efc93ad366a01c5",
                "md5": "37a485569a50d86593ecf00d98b2ac90",
                "sha256": "616b463846038fb7fef086d89e899823612e0261a981b2bd52d1f37a7c9eb26b"
            },
            "downloads": -1,
            "filename": "qrl-graph-0.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "37a485569a50d86593ecf00d98b2ac90",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15192,
            "upload_time": "2023-02-03T23:45:32",
            "upload_time_iso_8601": "2023-02-03T23:45:32.579262Z",
            "url": "https://files.pythonhosted.org/packages/98/65/46877e7db33d8f21f83ab4b8c0aed9623b0ab1b8e3781efc93ad366a01c5/qrl-graph-0.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-03 23:45:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "JiahaoYao",
    "github_project": "QRL_graph",
    "lcname": "qrl-graph"
}
        
Elapsed time: 0.50234s