量子コンピュータを触るスレ

ea663471 anonymous 2018-10-11 22:14 1539263656.png (53KB)
```python
import matplotlib.pyplot as plt
import networkx as nx
from dimod.reference.samplers import ExactSolver
from dwave.system.samplers import DWaveSampler
from dwave.system.composites import EmbeddingComposite
import dwave_networkx as dnx
from time import time
from random import shuffle


G = nx.DiGraph()
L = list(range(20))
shuffle(L)
G.add_path(L)
shuffle(L)
G.add_path(L)

nx.draw_networkx(G)
plt.show()

# by CPU 5.9Sec
s = time()
line = dnx.min_vertex_cover(G, ExactSolver())
print(line, "by CPU", round((time()-s), 3), "Sec")

# By QPU 1.994Sec (0.008Sec)
sampler = EmbeddingComposite(DWaveSampler())
s = time()
line = dnx.min_vertex_cover(G, sampler)
print(line, "by QPU", round((time()-s), 3), "Sec")
```
実際に弄ってみた (コードハイライトしないかな?
https://docs.ocean.dwavesys.com/projects/dwave-networkx/en/latest/reference/algorithms/generated/dwave_networkx.algorithms.cover.min_vertex_cover.html
20個のノードから構成されるネットワークがあって、その中でエッジと思われる項を取得するプログラム。
CPUだと5.9SecかかるがQPUだと0.008Secかかる (PingとWaitで1.9Secかかるのを引く

Top of this page. | <<last

limit: 15360KB

(量子コンピュータを触るスレ/60/0.9MB)


Powered by shinGETsu.