{"id":30953121,"url":"https://github.com/ngocbh/geneticpython","last_synced_at":"2025-09-11T08:46:21.500Z","repository":{"id":42055262,"uuid":"255001125","full_name":"ngocbh/geneticpython","owner":"ngocbh","description":"A simple and user-friendly Python framework for genetic-based algorithms","archived":false,"fork":false,"pushed_at":"2023-02-22T16:54:59.000Z","size":160043,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T22:52:27.544Z","etag":null,"topics":["algorithms","evolutionary-algorithms","genetic-algorithm","multiobjective-optimization","nsga-ii","python-framework"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngocbh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-12T03:27:28.000Z","updated_at":"2024-11-17T10:49:10.000Z","dependencies_parsed_at":"2022-08-12T03:31:23.039Z","dependency_job_id":null,"html_url":"https://github.com/ngocbh/geneticpython","commit_stats":null,"previous_names":["ngocjr7/geneticpython"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ngocbh/geneticpython","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngocbh%2Fgeneticpython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngocbh%2Fgeneticpython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngocbh%2Fgeneticpython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngocbh%2Fgeneticpython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngocbh","download_url":"https://codeload.github.com/ngocbh/geneticpython/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngocbh%2Fgeneticpython/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274603175,"owners_count":25315287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","evolutionary-algorithms","genetic-algorithm","multiobjective-optimization","nsga-ii","python-framework"],"created_at":"2025-09-11T08:46:20.395Z","updated_at":"2025-09-11T08:46:21.482Z","avatar_url":"https://github.com/ngocbh.png","language":"Python","readme":"# geneticpython\n\nA simple and friendly Python framework for genetic-based algorithms (strongly supports tree-encoding)\n\n* Supported algorithms: Genetic Algorithm (`GAEngine`), NSGA-ii (`NSGAIIEngine`).\n* An [example](https://github.com/ngocjr7/geneticpython/tree/master/examples) on ZDT1 problem:    \n\n![alt tag](https://raw.githubusercontent.com/ngocjr7/geneticpython/master/examples/zdt1/solutions.gif)\n\n## Installation\n\nThis package requires `python 3.6` or later.\n```\npip install geneticpython\n```\n\n## Getting started\n\nWe can quickly design a genetic algorithm in the following steps:\n\n1. define a individual template with specific encoding\n\n```python\nfrom geneticpython.models import BinaryIndividual\nindv_temp = BinaryIndividual(length=100)\n```\n\n2. define population based on created individual template. This population can uniformly initialize a population or you can define your own by passing `init_population` argument function\n\n```python\nfrom geneticpython import Population\npopulation = Population(indv_temp, pop_size=100)\n```\n3. define some core operators in genetic algorithm\n\n```python\nfrom geneticpython.core.operators import RouletteWheelSelection, UniformCrossover, \\\n                                        FlipBitMutation, RouletteWheelReplacement\nselection = RouletteWheelSelection()\ncrossover = UniformCrossover(pc=0.8, pe=0.5)\nmutation = FlipBitMutation(pm=0.1)\n# this function decides which individuals will be survived\nreplacement = RouletteWheelReplacement()\n```\n\n4. create an engine and register the defined population and operators\n\n```python\nfrom geneticpython import GAEngine\nengine = GAEngine(population, selection=selection,\n                  selection_size=100,\n                  crossover=crossover,\n                  mutation=mutation,\n                  replacement=replacement)\n```\n\n5. register fitness function which gets an individual and returns its fitness value\n\n```python\n@engine.maximize_objective\ndef fitness(indv):\n    return fitness_of_indv\n```\n\n6. run engine\n\n```python\nengine.create_seed(seed)\nhistory = engine.run(generations=1000)\n```\n\n7. get results and plot history\n\n```python\nans = engine.get_best_indv()\nprint(ans)\nplot_single_objective_history({'geneticpython': history})\n```\n\nYou can find more examples [here](https://github.com/ngocjr7/geneticpython/tree/master/examples)\n\n## Issues\nThis project is in development, if you find any issues, please create an issue [here](https://github.com/ngocjr7/geneticpython/issues).\n\n## TODO\n\n* [ ] Create extensive documentation and docs and comments in source-code\n* [ ] Implement other algorithms: `PSO, DE, MOED/A, MOPSO, MODE,...`\n* [ ] Implement other operators: `PMX crossover, ...`\n* [ ] Create unit tests.\n\n## Contributing\n\nThe goal of this project is to be able to build a simple and novice-friendly library yet functional enough to experiment with research projects. It is spontaneous and non-profit and also flawed.\n\nWe appreciate all contributions. If you are interested in contributing this project (including functional implementation or standard examples), please check [Contribution page](https://github.com/ngocjr7/geneticpython/blob/master/CONTRIBUTING.md).\n\nIf you plan to contribute new features, utility functions, fix bugs, or extensions to the core, please first open an issue and discuss the feature with us. \n\n## Contributors\n\nNgoc Bui ([ngocjr7](https://github.com/ngocjr7))\n\n## Acknowledgements\nSpecial thanks to https://github.com/PytLab/gaft for getting me started a great API design.\n\nThis repository includes some parts of the following repos:\n\n* https://github.com/msu-coinlab/pymoo\n* https://github.com/tensorflow/tensorflow\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngocbh%2Fgeneticpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngocbh%2Fgeneticpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngocbh%2Fgeneticpython/lists"}