# Binary Integer Linear Programming on QAOA using Blueqat

# 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.

# What is Blueqat?

Blueqat is an open source library for quantum computer.

## How to install Blueqat?

Blueqat is provided as Python (ver 3.6+) library. You can install by pip.

`pip install blueqat`

The overlayed state has shifted so that 0 and 1 come to q2 in about half probability.

If you have any questions or suggestions, please feel free to contact us by our Slack community. (Join from here)