looiise / QuantumGeneticAlgorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implementation of a Genetic Quantum Algorithm on a variational circuit

This repository contains all the code used for the article.

Repository structure:
.
├── GQA
│   ├── classical   /* Contains Genetic classical algorithms*/
│   │
│   ├── functions   /* Used functions for experiments*/
│   │   ├── crossintray.py
│   │   ├── eggholder.py
│   │   ├── function.py
│   │   ├── input_functions /* User defined */
│   │   │   └── func1.txt
│   │   ├── knapsack.py     /* For constrained optimization exp.*/
│   │   ├── multimodal.py
│   │   ├── peaks.py
│   │   └── rastrigin.py
│   ├── knapsack_instances
│   │   ├── instance1.txt 
│   │   ├── large_scale
│   │   └── low-dimensional
│   │       
│   ├── quantum /* Contains the GQA and classes used to simulate qubits behaviour*/
│   │   ├── compact.py  /* single chromosome variant for the GQA*/
│   │   ├── compact_knapsack.py
│   │   ├── compact_knapsack_qiskit.py
│   │   ├── gqa_function.py
│   │   ├── gqa_function_qiskit.py /* implementation using Qiskit library */
│   │   ├── gqa_knapsack.py
│   │   ├── gqa_qiskit.py
│   │   ├── population.py 
│   │   └── qbit.py
│   │
│   └── utils
│   
├── Knapsack_results_qiskit
├── GuideNotebook_function.ipynb
├── GuideNotebook_knapsack.ipynb
├── classical_vs_quantum_function.py
├── experiments.py
├── experiments_knapsack.py
├── experiments_knapsack_thetas.py
├── experiments_mutation_crossover.py
├── exploration_exploitation.py
├── real_implementation.py
├── qiskit_knapsack.py
└── hyperparameters_benchmark_function.py

Mapping between experiments reported in the article and used scripts.

Tables 8 and 9:

experiments_mutation_crossover.py

Figure 6 and table 7:

 experiments.py

Figures 7 to 9:

exploration_exploitation.py

Table 10 and Figure 10:

qiskit_knapsack.py

and other plots are in the folder:

├── Knapsack_results_qiskit

Figures 11 to 13:

real_implementation.py

For an introdoction on how to use the defined algorithms, please refer to:

├── GuideNotebook_function.ipynb
├── GuideNotebook_knapsack.ipynb

To run the code on a quantum device:

├── real_implementation.py

Dependencies

Python 3.x.x : https://www.python.org/downloads/

To verify the installation, in Windows write in the terminal/cmd/powershell:

python

alternatively

py

This should appear:

..informations about python version, day, etc.
>>> | 

Used python libraries: Qiskit, Tqdm, Matplotlib, numpy.

To install them, write in the terminal (after a succesful installation of python):

pip install qiskit
pip install tqdm 
pip install matplotlib
pip install numpy

Alternatively:

pip3 install qiskit
pip3 install tqdm 
pip3 install matplotlib
pip3 install numpy

Run

To run the scripts simply execute in the terminal/cmd/powershell:

py "script_name".py

About

License:MIT License


Languages

Language:Jupyter Notebook 98.2%Language:Python 1.8%