Reinforcement Learning Algorithms for the quantum speed up in graphs
Project description
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.8
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
Side notes
for the policy gradient, First, the probability is parametrized through $$\sigma(x) = \frac 1 {1+e^{-x}}$$, and its derivative is $$\sigma(x) (1 - \sigma(x))$$.
According to the policy gradient, the policy gradient is equal to $$\mathbb E( \sigma(\theta) (1 - \sigma(\theta)) r ).$$
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qrl-graph-0.0.9.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for qrl_graph-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95a6c84800743271917a34ca9d958cd6f20a77fdb54f21ff2a92c499b124c78b |
|
MD5 | cc02b7ba3dfec128bfc125a128fb8d04 |
|
BLAKE2b-256 | 15931ba3e94a129708b60f4a9dfc91cf9d6fc73fdac1c615171d8694e1a0b485 |