对于在实际中如何使用Grover算法,我感到很困惑,我想通过一个示例寻求帮助,以澄清问题。
假设一个元素数据库包含红色,橙色,黄色,绿色,青色,蓝色,靛蓝和紫罗兰色,并且不一定按此顺序排列。我的目标是在数据库中找到Red。
Grover算法的输入为量子位,其中3个量子位编码数据集的索引。我的困惑在这里(可能会对前提感到困惑,所以在这里可能会引起困惑),据我所知,oracle实际上是在搜索数据集的索引之一(由3个量子位的叠加表示),此外, oracle是“硬编码”的,它应该寻找哪个索引。
我的问题是:
- 在这里我怎么了?
- 如果oracle确实在寻找数据库的索引之一,那意味着我们已经知道要寻找哪个索引,那么为什么要搜索呢?
- 给定上述带有颜色的条件,是否有人可以指出,如果Grover可以在非结构化数据集中查找Red?
存在Grover算法的实现,其中的oracle 搜索| 111>,例如(或参见以下相同oracle的R实现):https : //quantumcomputing.stackexchange.com/a/2205
再次,我的困惑是,由于我不知道数据集中元素的位置,因此该算法要求我搜索一个编码N个元素的位置的字符串。我如何知道数据集非结构化时应该寻找哪个位置?
R代码:
#START
a = TensorProd(TensorProd(Hadamard(I2),Hadamard(I2)),Hadamard(I2))
# 1st CNOT
a1= CNOT3_12(a)
# 2nd composite
# I x I x T1Gate
b = TensorProd(TensorProd(I2,I2),T1Gate(I2))
b1 = DotProduct(b,a1)
c = CNOT3_02(b1)
# 3rd composite
# I x I x TGate
d = TensorProd(TensorProd(I2,I2),TGate(I2))
d1 = DotProduct(d,c)
e = CNOT3_12(d1)
# 4th composite
# I x I x T1Gate
f = TensorProd(TensorProd(I2,I2),T1Gate(I2))
f1 = DotProduct(f,e)
g = CNOT3_02(f1)
#5th composite
# I x T x T
h = TensorProd(TensorProd(I2,TGate(I2)),TGate(I2))
h1 = DotProduct(h,g)
i = CNOT3_01(h1)
#6th composite
j = TensorProd(TensorProd(I2,T1Gate(I2)),I2)
j1 = DotProduct(j,i)
k = CNOT3_01(j1)
#7th composite
l = TensorProd(TensorProd(TGate(I2),I2),I2)
l1 = DotProduct(l,k)
#8th composite
n = TensorProd(TensorProd(Hadamard(I2),Hadamard(I2)),Hadamard(I2))
n1 = DotProduct(n,l1)
n2 = TensorProd(TensorProd(PauliX(I2),PauliX(I2)),PauliX(I2))
a = DotProduct(n2,n1)
#repeat the same from 2st not gate
a1= CNOT3_12(a)
# 2nd composite
# I x I x T1Gate
b = TensorProd(TensorProd(I2,I2),T1Gate(I2))
b1 = DotProduct(b,a1)
c = CNOT3_02(b1)
# 3rd composite
# I x I x TGate
d = TensorProd(TensorProd(I2,I2),TGate(I2))
d1 = DotProduct(d,c)
e = CNOT3_12(d1)
# 4th composite
# I x I x T1Gate
f = TensorProd(TensorProd(I2,I2),T1Gate(I2))
f1 = DotProduct(f,e)
g = CNOT3_02(f1)
#5th composite
# I x T x T
h = TensorProd(TensorProd(I2,TGate(I2)),TGate(I2))
h1 = DotProduct(h,g)
i = CNOT3_01(h1)
#6th composite
j = TensorProd(TensorProd(I2,T1Gate(I2)),I2)
j1 = DotProduct(j,i)
k = CNOT3_01(j1)
#7th composite
l = TensorProd(TensorProd(TGate(I2),I2),I2)
l1 = DotProduct(l,k)
#8th composite
n = TensorProd(TensorProd(PauliX(I2),PauliX(I2)),PauliX(I2))
n1 = DotProduct(n,l1)
n2 = TensorProd(TensorProd(Hadamard(I2),Hadamard(I2)),Hadamard(I2))
n3 = DotProduct(n2,n1)
result=measurement(n3)
plotMeasurement(result)
3
Grover算法的
—
DaftWullie
—
glS