{"id":20859775,"url":"https://github.com/stefanofioravanzo/map-elites","last_synced_at":"2025-05-12T08:32:47.008Z","repository":{"id":77066984,"uuid":"159215443","full_name":"StefanoFioravanzo/MAP-Elites","owner":"StefanoFioravanzo","description":"Python implementation of the genetic algorithm MAP-Elites with applications in constrained optimization","archived":false,"fork":false,"pushed_at":"2020-10-16T07:22:34.000Z","size":2580,"stargazers_count":43,"open_issues_count":0,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2023-10-20T23:14:44.769Z","etag":null,"topics":["constrained-optimization","evolutionary-algorithms","genetic-programming","novelty-search"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StefanoFioravanzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-11-26T18:36:33.000Z","updated_at":"2023-10-20T23:14:50.491Z","dependencies_parsed_at":null,"dependency_job_id":"b1cacbae-c72e-4379-9b75-be66cbbb6174","html_url":"https://github.com/StefanoFioravanzo/MAP-Elites","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoFioravanzo%2FMAP-Elites","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoFioravanzo%2FMAP-Elites/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoFioravanzo%2FMAP-Elites/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoFioravanzo%2FMAP-Elites/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefanoFioravanzo","download_url":"https://codeload.github.com/StefanoFioravanzo/MAP-Elites/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225130714,"owners_count":17425506,"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","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":["constrained-optimization","evolutionary-algorithms","genetic-programming","novelty-search"],"created_at":"2024-11-18T04:53:06.452Z","updated_at":"2024-11-18T04:53:07.058Z","avatar_url":"https://github.com/StefanoFioravanzo.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"## MAP-Elites for Constrained Optimization\n\nPython implementation of the [MAP Elites algorithm](https://arxiv.org/abs/1504.04909) (originally devised for unconstrained optimization), for constrained optimization problems. More details can be found in our original [GECCO paper](https://dl.acm.org/doi/10.1145/3319619.3321939) and its [extended arXiv version](https://arxiv.org/abs/1902.00703).\n\n#### Implementation\n\n```\n.\n├── controller.py\n├── map_elites\n│   ├── mapelites.py\n│   ├── plot_utils.py\n│   └── ea_operators.py\n├── functions.py\n├── config.ini\n├── mapelites_continuous_opt.py\n├── notebooks\n│   ├── plotter.ipynb\n│   └── n_dim_plotter.ipynb\n└── utils\n    └── fcnsuite.c\n```\n\nThe algorithm is implemented to be as general as possible and applicable to any setting. The main MAPElites class in `mapelites.py` is an abstract class implementing all the base logic common to any instance of the algorithm.  \nTo run the algorithm you need to subclass `MapElites` and implement `map_x_to_b()`, `performance_measure()`, `generate_random_solution()`, `generate_feature_dimensions()`. Refer to the functions documentation and the example below for more details.\n\nMAP-Elites was designed to have a visual impact by showing its results in a heatmap plot in the feature dimensions. This implementation supports up to 4 dimensional heatmap plotting, with nested dimensions in the same plot. Refer to the `plot_heatmap()` function in `plot_utils.py` for more details.\n\nCrossover and mutation evolutionary operators are implemented in `ea_operators.py`, you can extend that source file to add more custom evolutionary operators.\n\n#### Configuration\n\nAll the configuration can be done using the `config.ini` file provided at the root of the project. Here is an example configuration file:\n\n```ini\n[mapelites]\n; random seed\nseed = 54\n; number of initial random samples\nbootstrap_individuals = 100\n; numer of map elites iterations\niterations = 10000\n; True: solve a minimization problem. False: solve a maximization problem\nminimization = True\n\n[opt_function]\n; Define the optimization function.\n; This must be the name of a class subclassing the abstract class ConstrainedFunction. See functions.py for reference\nname = C16\n; Number of dimensions of the optimization function\ndimensions = 4\n; Define heatmap bins for feature dimensions\n; Name each bin as `bin_{name of constraint}` where `name_of_constraint` is the name of the constraint\n; function implemented in the specified optimization function class\n; If you want to define ONE bin for all constraints, name it `bin_all`\n; Note: The bins must be defined by numbers, except for the `inf` label which can be defined ether at the beginning\n; of at the end of the bins.\n; bin_all = inf,0.0,1.0,2.0,3.0,4.0,inf\nbin_g1 = inf,0.0,1.0,2.0,3.0,4.0,inf\nbin_g2 = inf,0.0,1.0,2.0,3.0,inf\nbin_h1 = inf,0.0,1.0,2.0,3.0,4.0,5.0,inf\nbin_h2 = inf,0.0,1.0,2.0,inf\n\n[crossover]\n; Crossover function taken from ea_operators.py file.\n; Name of called function is {type}_crossover(). If `type = UNIFORM` then the function call is `uniform_crossover()`\ntype = UNIFORM\n; list of arguments to the above function\nindpb = 0.5\n\n[mutation]\n; mutation function taken from ea_operators.py file.\n; name of called function is {type}_mutation(). If `type = GAUSSIAN` then the function call is `gaussian_mutation()`\ntype = GAUSSIAN\n; Define how to manage the boundaries during mutation, meaning how the algorithm should behave in case it mutates outside of the function domain.\n; There are three possible cases:\n; - `saturation`: x in [a,b], if after mutation x\u003eb -\u003e x=b; if x\u003ca -\u003e x=a\n; - `bounce`: if x is mutated outside [a, b] it is bounced back by the remaining delta\n; - `toroidal`: if x is mutated outside [a, b], x is bounced to the other bound by the remaining delta, 'pac-man' style\nboundary = saturation\n; list of arguments to the above function\nmu = 0\nsigma = 0.2\n; probability of each attribute to be mutated\nindpb = 0.5\n```\n\n## Example: Continuous Constrained Optimization\n\nIn this project we extended the core MAP-Elites algorithm to solve continuous constrained optimization problem. Specifically, the problem setting is defined by an objective function subject to some constraints, some examples [here](https://en.wikipedia.org/wiki/Test_functions_for_optimization#Test_functions_for_constrained_optimization).\n\n## Reference\n\nIf you use this code (or any modified version of it), please add the following reference:\n\n```\nStefano Fioravanzo and Giovanni Iacca. 2019. Evaluating MAP-Elites\non constrained optimization problems. In Proceedings of the Genetic \nand Evolutionary Computation Conference Companion (GECCO '19). \nAssociation for Computing Machinery, New York, NY, USA, 253–254. \nDOI:https://doi.org/10.1145/3319619.3321939\n\n@inproceedings{fioravanzo2019evaluating,\n  title={Evaluating MAP-Elites on Constrained Optimization Problems},\n  author={Fioravanzo, Stefano and Iacca, Giovanni},\n  booktitle={Genetic and Evolutionary Computation Conference Companion},\n  pages={253--254},\n  year={2019},\n  organization={ACM}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanofioravanzo%2Fmap-elites","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanofioravanzo%2Fmap-elites","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanofioravanzo%2Fmap-elites/lists"}