I implemented VQE with Blueqat

Isn't VQE coming in the NISQ era? (Is it really coming ...?) So I implemented a simple problem with Blueqat. This time, I will try to solve a trivial combination optimization problem in the sense of checking the program operation.

The problem solved this time

Solve the following combination of $ q (0) $ and $ q (1) $ that minimizes the Hamiltonian $ H . $ H = 1 - q(0) - q(1) $$ Note that $ q (0) $ and $ q (1) $ are either 0 or 1. In this problem setting, when $ q (0) = q (1) = 1 $, Hamiltonian $ H = -1 $ takes the minimum value.

Supplementary information

By the way, Hamiltonian takes the following values for all combinations of $ q (0) and q (1) $.

Source code


from blueqat.pauli import qubo_bit as q
from blueqat.vqe import Vqe, QaoaAnsatz

#Hamiltonian
h = 1.0 - q(0) - q(1)

ansatz = QaoaAnsatz(h, 10)
runner = Vqe(ansatz)
result = runner.run()

print("mode:")
print(result.most_common())
print("minimum value:")
print(runner.ansatz.get_energy(result.circuit, runner.sampler))

I won't explain the details of the source code, but it's fairly easy to write.

Execution result

mode:
(((1, 1), 0.9999999999996781),)
minimum value:
-0.9999999999996781

Combination of solutions of $ (1,1) \ rightarrow q (0) = 1, q (1) = 1 $

Probability of appearance of $ 0.999999999996781 \ rightarrow (1,1) $ (result changes each time execution)

Finally

It was really easy to implement! In the future, I would like to make some applications.

Recommended Posts

I implemented VQE with Blueqat
Qiskit: I implemented VQE
I implemented Attention Seq2Seq with PyTorch
I implemented Shake-Shake Regularization (ShakeNet) with PyTorch
I implemented CycleGAN (1)
I implemented ResNet!
I played with wordcloud!
I implemented Python Logging
I implemented collaborative filtering (recommendation) with redis and python
I tried fp-growth with python
I tried scraping with Python
I wrote GP with numpy
I tried Learning-to-Rank with Elasticsearch!
I made blackjack with python!
Implemented word2vec with Theano + Keras
I tried clustering with PyCaret
Implemented SMO with Python + NumPy
I implemented the FloodFill algorithm with TRON BATTLE of CodinGame.
Implemented Conditional GAN with chainer
I can't search with # google-map. ..
Implemented Efficient GAN with keras
I implemented Extreme learning machine
I measured BMI with tkinter
I tried gRPC with Python
I made COVID19_simulator with JupyterLab
I tried scraping with python
Implemented SmoothGrad with Chainer v2
I made Word2Vec with Pytorch
I made blackjack with Python.
Zura with softmax function implemented
I made wordcloud with Python.
[Text classification] I implemented Convolutional Neural Networks for Sentence Classification with Chainer
I tried to implement Deep VQE
I tried trimming efficiently with OpenCV
Implemented file download with Python + Bottle
I can't install python3 with pyenv-vertualenv
I tried summarizing sentences with summpy
I tried machine learning with liblinear
I tried web scraping with python.
I tried moving food with SinGAN
[Python] I implemented peripheral Gibbs sampling
I can't install mysql-connector-python with anaconda
I made a fortune with Python.
I sent an SMS with Python
I compared Qiskit and Blueqat (beginner)
I implemented a two-layer neural network
I tried implementing DeepPose with PyTorch
I liked the tweet with python. ..
I tried face detection with MTCNN
I played with PyQt5 and Python3
I can't use Japanese with pyperclip
I implemented ChangeFinder (change point detection)
I want to do ○○ with Pandas
I played with Mecab (morphological analysis)!
I couldn't daemonize gunicorn with Fabric
I want to debug with Python
I tried running prolog with python 3.8.2.
I made a daemon with Python
I tried SMTP communication with Python
I tried sentence generation with GPT-2
I tried learning LightGBM with Yellowbrick