# HQGA [](http://quasar.unina.it) [](https://hqga.readthedocs.io/en/latest/index.html) [](https://www.sciencedirect.com/science/article/abs/pii/S002002552100640X)
This repo contains the code for executing Hybrid Quantum Genetic Algorithm (HQGA) proposed in:
**''G. Acampora and A. Vitiello, "Implementing evolutionary optimization on actual quantum processors,"
in Information Sciences, 2021, doi: 10.1016/j.ins.2021.06.049.''**
## How to install
The package can be installed with Python's pip package manager.
```bash
pip install HQGA
```
# Example
This is a basic example to use HQGA for solving Sphere problem on Qasm Simulator.
```python
from HQGA import problems as p, hqga_utils, utils, hqga_algorithm
from HQGA.utils import computeHammingDistance
from qiskit import Aer
import math
simulator = Aer.get_backend('qasm_simulator')
device_features= hqga_utils.device(simulator, False)
params= hqga_utils.ReinforcementParameters(3, 5, math.pi / 16, math.pi / 16, 0.3)
params.draw_circuit=True
problem = p.SphereProblem(num_bit_code=5)
circuit = hqga_utils.setupCircuit(params.pop_size, problem.dim * problem.num_bit_code)
gBest, chromosome_evolution,bests = hqga_algorithm.runQGA(device_features, circuit, params,problem)
dist=computeHammingDistance(gBest.chr, problem)
print("The Hamming distance to the optimum value is: ", dist)
utils.writeBestsXls("Bests.xlsx", bests)
utils.writeChromosomeEvolutionXls("ChromosomeEvolution.xlsx", chromosome_evolution)
```
## Credits
Please cite the work using the following Bibtex entry:
```text
@article{ACAMPORA2021542,
title = {Implementing evolutionary optimization on actual quantum processors},
journal = {Information Sciences},
volume = {575},
pages = {542-562},
year = {2021},
issn = {0020-0255},
doi = {https://doi.org/10.1016/j.ins.2021.06.049},
url = {https://www.sciencedirect.com/science/article/pii/S002002552100640X},
author = {Giovanni Acampora and Autilia Vitiello}
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Quasar-UniNA/HQGA",
"name": "HQGA",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "Optimization Algorithms, Quantum Computing, Evolutionary Algorithms",
"author": "Autilia Vitiello",
"author_email": "autilia.vitiello@unina.it",
"download_url": "https://files.pythonhosted.org/packages/07/87/ee344455a6074334c0af50db95488ae20fd63679f98ee66c89664e86fda6/hqga-0.3.2.tar.gz",
"platform": null,
"description": "# HQGA [](http://quasar.unina.it) [](https://hqga.readthedocs.io/en/latest/index.html) [](https://www.sciencedirect.com/science/article/abs/pii/S002002552100640X)\n\nThis repo contains the code for executing Hybrid Quantum Genetic Algorithm (HQGA) proposed in:\n\n**''G. Acampora and A. Vitiello, \"Implementing evolutionary optimization on actual quantum processors,\"\n in Information Sciences, 2021, doi: 10.1016/j.ins.2021.06.049.''**\n \n \n## How to install\n\nThe package can be installed with Python's pip package manager.\n\n```bash\npip install HQGA\n```\n\n# Example\nThis is a basic example to use HQGA for solving Sphere problem on Qasm Simulator.\n\n```python\nfrom HQGA import problems as p, hqga_utils, utils, hqga_algorithm\nfrom HQGA.utils import computeHammingDistance\n\nfrom qiskit import Aer\nimport math\n\nsimulator = Aer.get_backend('qasm_simulator')\ndevice_features= hqga_utils.device(simulator, False)\n\nparams= hqga_utils.ReinforcementParameters(3, 5, math.pi / 16, math.pi / 16, 0.3)\nparams.draw_circuit=True\n\nproblem = p.SphereProblem(num_bit_code=5)\n\ncircuit = hqga_utils.setupCircuit(params.pop_size, problem.dim * problem.num_bit_code)\n\ngBest, chromosome_evolution,bests = hqga_algorithm.runQGA(device_features, circuit, params,problem)\n\ndist=computeHammingDistance(gBest.chr, problem)\nprint(\"The Hamming distance to the optimum value is: \", dist)\nutils.writeBestsXls(\"Bests.xlsx\", bests)\nutils.writeChromosomeEvolutionXls(\"ChromosomeEvolution.xlsx\", chromosome_evolution)\n```\n\n\n## Credits\n\nPlease cite the work using the following Bibtex entry:\n\n```text\n@article{ACAMPORA2021542,\ntitle = {Implementing evolutionary optimization on actual quantum processors},\njournal = {Information Sciences},\nvolume = {575},\npages = {542-562},\nyear = {2021},\nissn = {0020-0255},\ndoi = {https://doi.org/10.1016/j.ins.2021.06.049},\nurl = {https://www.sciencedirect.com/science/article/pii/S002002552100640X},\nauthor = {Giovanni Acampora and Autilia Vitiello}\n}\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A library for implementing Hybrid Quantum Genetic Algorithm (HQGA)",
"version": "0.3.2",
"project_urls": {
"Homepage": "https://github.com/Quasar-UniNA/HQGA"
},
"split_keywords": [
"optimization algorithms",
" quantum computing",
" evolutionary algorithms"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "14cc4a79a0945b34fb4c83ae6dbba312f782b73762d95810ee58b4805809cd18",
"md5": "18a62c87de4bcac3cbbd98dc6b01c4a5",
"sha256": "0f8fea9bf12eaea4cd0e4f4f6363e979e3750b3e4812a4edbcbb59ca74978eb9"
},
"downloads": -1,
"filename": "HQGA-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "18a62c87de4bcac3cbbd98dc6b01c4a5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13173,
"upload_time": "2025-02-14T10:33:25",
"upload_time_iso_8601": "2025-02-14T10:33:25.687600Z",
"url": "https://files.pythonhosted.org/packages/14/cc/4a79a0945b34fb4c83ae6dbba312f782b73762d95810ee58b4805809cd18/HQGA-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0787ee344455a6074334c0af50db95488ae20fd63679f98ee66c89664e86fda6",
"md5": "49adcc6f1b17f18a17aa7728339cd6f3",
"sha256": "f05ddaa3fd16201fe0a03e3bf1b25a1da44bdb9e42cb9f139bcf7ec036dec9b5"
},
"downloads": -1,
"filename": "hqga-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "49adcc6f1b17f18a17aa7728339cd6f3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11787,
"upload_time": "2025-02-14T10:33:26",
"upload_time_iso_8601": "2025-02-14T10:33:26.751579Z",
"url": "https://files.pythonhosted.org/packages/07/87/ee344455a6074334c0af50db95488ae20fd63679f98ee66c89664e86fda6/hqga-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-14 10:33:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Quasar-UniNA",
"github_project": "HQGA",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "matplotlib",
"specs": [
[
"==",
"3.7.1"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.23.5"
]
]
},
{
"name": "openpyxl",
"specs": [
[
"==",
"3.1.2"
]
]
},
{
"name": "qiskit",
"specs": [
[
"==",
"0.42.0"
]
]
},
{
"name": "qiskit_aer",
"specs": [
[
"==",
"0.12.0"
]
]
},
{
"name": "qiskit_ibmq_provider",
"specs": [
[
"==",
"0.20.2"
]
]
},
{
"name": "qiskit_terra",
"specs": [
[
"==",
"0.23.2"
]
]
},
{
"name": "sympy",
"specs": [
[
"==",
"1.11.1"
]
]
},
{
"name": "tqdm",
"specs": [
[
"==",
"4.65.0"
]
]
}
],
"lcname": "hqga"
}