@yuichirominato 2019.02.18更新 154views

[QAOA]Binary Integer Linear Programming on QAOA


Introduction

BIL(Binary Integer Linear Programming) is to find out maximum number of binary qubits x, satisfy Sx=b and maximize c⋅x.

Cost function

The cost function is

Example

Let’s solve an example. When x1,x2,x3 satisfy this,

Let’s find out combination of x1,x2,x3 to maximize,

Blueqat

Try to solve on blueqat

pip install blueqat

opt.optm is making the QUBO matrix directly from the equation.

from blueqat import opt
from blueqat import vqe

#to qubo matrix
E = opt.optm("(3*q0+2*q1+q2-3)^2+(5*q0+2*q1+3*q2-5)^2-2*(q0+2*q1+q2)",3)

and convert it to pauli operator on qaoa

E = opt.pauli(E)

and decide the step params as 4

step = 4
result = vqe.Vqe(vqe.QaoaAnsatz(E, step)).run()
print(result.most_common(5))

finally we have

from blueqat import opt
from blueqat import vqe

#to qubo matrix
E = opt.optm("(3*q0+2*q1+q2-3)^2+(5*q0+2*q1+3*q2-5)^2-2*(q0+2*q1+q2)",3)
E = opt.pauli(E)

step = 4
result = vqe.Vqe(vqe.QaoaAnsatz(E, step)).run()
print(result.most_common(5))

#=>
(((0, 1, 1), 0.8571008889203714), ((1, 1, 0), 0.08134053938905932), ((0, 1, 0), 0.031757569458734695), ((1, 0, 0), 0.011712997948251888), ((1, 0, 1), 0.010846834513550044))

Let’s .run() it and we have 011 as the best answer.

x1=0,x2=1,x3=1 is the best answer to solve this BIL.

Recommend


Back To Top