HQGA


NameHQGA JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/Quasar-UniNA/HQGA
SummaryA library for implementing Hybrid Quantum Genetic Algorithm (HQGA)
upload_time2023-05-22 21:28:18
maintainer
docs_urlNone
authorAutilia Vitiello
requires_python
licenseMIT
keywords optimization algorithms quantum computing evolutionary algorithms
VCS
bugtrack_url
requirements matplotlib numpy openpyxl qiskit qiskit_aer qiskit_ibmq_provider qiskit_terra sympy tqdm
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HQGA [![Made at Quasar!](https://img.shields.io/badge/Unina-%20QuasarLab-blue)](http://quasar.unina.it) [![Made at Quasar!](https://img.shields.io/badge/Documentation-%20Readthedocs-brightgreen)](https://hqga.readthedocs.io/en/latest/index.html) [![Made at Quasar!](https://img.shields.io/badge/Related-%20Paper-orange)](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.''**


# 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": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Optimization Algorithms,Quantum Computing,Evolutionary Algorithms",
    "author": "Autilia Vitiello",
    "author_email": "autilia.vitiello@unina.it",
    "download_url": "https://files.pythonhosted.org/packages/32/43/36efd6e5b56d1fb61b48fed9d0e9f0963841139243bf5a3da740f92fee4b/HQGA-0.2.0.tar.gz",
    "platform": null,
    "description": "# HQGA [![Made at Quasar!](https://img.shields.io/badge/Unina-%20QuasarLab-blue)](http://quasar.unina.it) [![Made at Quasar!](https://img.shields.io/badge/Documentation-%20Readthedocs-brightgreen)](https://hqga.readthedocs.io/en/latest/index.html) [![Made at Quasar!](https://img.shields.io/badge/Related-%20Paper-orange)](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# 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.2.0",
    "project_urls": {
        "Homepage": "https://github.com/Quasar-UniNA/HQGA"
    },
    "split_keywords": [
        "optimization algorithms",
        "quantum computing",
        "evolutionary algorithms"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f1ca4cfce81277cab6f62a72bcea0fa57d597ec6e6578ee309fdf5528427c4f",
                "md5": "be42c4826326eb3629045068fbac5901",
                "sha256": "20847e47951e0472ce989dc4a9135292459ddfde2a034b41c8d298e3328cd38b"
            },
            "downloads": -1,
            "filename": "HQGA-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be42c4826326eb3629045068fbac5901",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12937,
            "upload_time": "2023-05-22T21:28:16",
            "upload_time_iso_8601": "2023-05-22T21:28:16.974051Z",
            "url": "https://files.pythonhosted.org/packages/6f/1c/a4cfce81277cab6f62a72bcea0fa57d597ec6e6578ee309fdf5528427c4f/HQGA-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "324336efd6e5b56d1fb61b48fed9d0e9f0963841139243bf5a3da740f92fee4b",
                "md5": "cfd4670b7dec2f44e7c81459d7069235",
                "sha256": "c7b28387b75234284cda7aadaa5cecbae04302772c543cf5a9fa01be709e4b38"
            },
            "downloads": -1,
            "filename": "HQGA-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cfd4670b7dec2f44e7c81459d7069235",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11512,
            "upload_time": "2023-05-22T21:28:18",
            "upload_time_iso_8601": "2023-05-22T21:28:18.234894Z",
            "url": "https://files.pythonhosted.org/packages/32/43/36efd6e5b56d1fb61b48fed9d0e9f0963841139243bf5a3da740f92fee4b/HQGA-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-22 21:28:18",
    "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"
}
        
Elapsed time: 0.06766s