{"id":15036569,"url":"https://github.com/geatpy-dev/geatpy","last_synced_at":"2025-05-14T04:07:30.678Z","repository":{"id":33469997,"uuid":"145857247","full_name":"geatpy-dev/geatpy","owner":"geatpy-dev","description":"Evolutionary algorithm toolbox and framework with high performance for Python","archived":false,"fork":false,"pushed_at":"2025-01-17T08:53:46.000Z","size":602584,"stargazers_count":2069,"open_issues_count":160,"forks_count":730,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-04-11T14:17:15.229Z","etag":null,"topics":["de","es","evolutionary-algorithms","ga","geatpy","high-performance","moead","nsga","parallel-computing","rvea"],"latest_commit_sha":null,"homepage":"http://www.geatpy.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geatpy-dev.png","metadata":{"files":{"readme":"README.md","changelog":"history.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-23T13:26:31.000Z","updated_at":"2025-04-08T08:04:43.000Z","dependencies_parsed_at":"2022-07-14T08:31:30.572Z","dependency_job_id":"4b4a1094-f0da-44cb-b318-7f876b133464","html_url":"https://github.com/geatpy-dev/geatpy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geatpy-dev%2Fgeatpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geatpy-dev%2Fgeatpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geatpy-dev%2Fgeatpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geatpy-dev%2Fgeatpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geatpy-dev","download_url":"https://codeload.github.com/geatpy-dev/geatpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254069132,"owners_count":22009494,"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":["de","es","evolutionary-algorithms","ga","geatpy","high-performance","moead","nsga","parallel-computing","rvea"],"created_at":"2024-09-24T20:31:35.439Z","updated_at":"2025-05-14T04:07:30.635Z","avatar_url":"https://github.com/geatpy-dev.png","language":"Python","funding_links":[],"categories":["其他_机器学习与深度学习"],"sub_categories":[],"readme":"# **Geatpy2**\nThe Genetic and Evolutionary Algorithm Toolbox for Python with high performance.\n\n[![Package Status](https://img.shields.io/pypi/status/geatpy.svg)](https://pypi.org/project/geatpy/)\n![Python](https://img.shields.io/badge/python-\u003e=3.5-green.svg)\n![Pypi](https://img.shields.io/badge/pypi-2.7.0-blue.svg)\n[![Download](https://img.shields.io/pypi/dm/geatpy.svg)](https://pypi.python.org/pypi/geatpy)\n[![License](https://img.shields.io/pypi/l/geatpy.svg)](https://github.com/geatpy-dev/geatpy/blob/master/LICENSE)\n[![Gitter](https://badges.gitter.im/geatpy2/community.svg)](https://gitter.im/geatpy2/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n## Introduction\n* **Website (including documentation)**: https://geatpy.github.io/\n* **Quickstart**: https://github.com/geatpy-dev/geatpy/blob/master/docs/quickstart.html        \n* **Demo** : https://github.com/geatpy-dev/geatpy/tree/master/demo\n* **Pypi page** : https://pypi.org/project/geatpy/\n* **Bug reports**: https://github.com/geatpy-dev/geatpy/issues\n\n## How to Cite\nJazzbin, J. \"Geatpy: the genetic and evolutionary algorithm toolbox with high performance in python.\" https://github.com/geatpy-dev/geatpy/ (accessed 2020) (2020).\n\nThe features of Geatpy:\n\n* Capability of solving single-objective, multi-objectives, many-objectives and combinatorial optimization problems fast.\n\n* A huge number of operators with high performance of evolutionary algorithms (selection, recombination, mutation, migration...).\n\n* Support numerous encodings for the chromosome of the population.\n\n* Many evolutionary algorithm templates, including GA, DE, ES for single/multi-objective(s) evolution.\n\n* Multiple population evolution.\n\n* Support polysomy evolution.\n\n* Parallelization and distribution of evaluations.\n\n* Testbeds containing most common benchmarks functions.\n\n* Support tracking analysis of the evolution iteration.\n\n* Many evaluation metrics of algorithms.\n\n## Improvement of Geatpy 2.7.0\n\n* Add a new way to define the aim function of the problem.\n\n* Support calculating objectives and constraints for the variables of only one individual.\n\n* Add a optimize function to do the optimization more convenient.\n\n* Add new open-source plotting functions.\n\n* Remove the dependency on scipy.\n\n* A new and faster core.\n\n## Installation\n1.Installing online:\n\n    pip install geatpy\n\n2.From source:\n\n    python setup.py install\n\nor\n\n    pip install \u003cfilename\u003e.whl\n\n**Attention**: Geatpy requires numpy\u003e=1.17.0 and matplotlib\u003e=3.0.0, the installation program won't help you install them so that you have to install both of them by yourselves.\n\n## Versions\n\n**Geatpy** must run under **Python**3.5, 3.6, 3.7, 3.8, 3.9, or 3.10 in Windows x32/x64, Linux x64 or MacOS x64.\n\nThere are different versions for **Windows**, **Linux** and **Mac**, you can download them from http://geatpy.com/\n\nThe version of **Geatpy** on github is the latest version suitable for **Python** \u003e= 3.5\n\nYou can also **update** Geatpy by executing the command:\n\n    pip install --upgrade geatpy\n\nIf something wrong happened, such as decoding error about 'utf8' of pip, run this command instead or execute it as an administrator:\n\n    pip install --upgrade --user geatpy\n\nQuick start\n-----------\n\nHere is the UML figure of Geatpy2.\n\n![image](https://github.com/geatpy-dev/geatpy/blob/master/structure.png)\n\nFor solving a multi-objective optimization problem, you can use **Geatpy** mainly in two steps:\n\n1.Write down the aim function and some relevant settings in a derivative class named **MyProblem**, which is inherited from **Problem** class:\n\n```python\n\"\"\"MyProblem.py\"\"\"\nimport numpy as np\nimport geatpy as ea\nclass MyProblem(ea.Problem): # Inherited from Problem class.\n    def __init__(self, M): # M is the number of objects.\n        name = 'DTLZ1' # Problem's name.\n        maxormins = [1] * M # All objects are need to be minimized.\n        Dim = M + 4 # Set the dimension of decision variables.\n        varTypes = [0] * Dim # Set the types of decision variables. 0 means continuous while 1 means discrete.\n        lb = [0] * Dim # The lower bound of each decision variable.\n        ub = [1] * Dim # The upper bound of each decision variable.\n        lbin = [1] * Dim # Whether the lower boundary is included.\n        ubin = [1] * Dim # Whether the upper boundary is included.\n        # Call the superclass's constructor to complete the instantiation\n        ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin)\n    def aimFunc(self, pop): # Write the aim function here, pop is an object of Population class.\n        Vars = pop.Phen # Get the decision variables\n        XM = Vars[:,(self.M-1):]\n        g = np.array([100 * (self.Dim - self.M + 1 + np.sum(((XM - 0.5)**2 - np.cos(20 * np.pi * (XM - 0.5))), 1))]).T\n        ones_metrix = np.ones((Vars.shape[0], 1))\n        pop.ObjV = 0.5 * np.fliplr(np.cumprod(np.hstack([ones_metrix, Vars[:,:self.M-1]]), 1)) * np.hstack([ones_metrix, 1 - Vars[:, range(self.M - 2, -1, -1)]]) * np.tile(1 + g, (1, self.M))\n    def calReferObjV(self): # Calculate the theoretic global optimal solution here.\n        uniformPoint, ans = ea.crtup(self.M, 10000) # create 10000 uniform points.\n        realBestObjV = uniformPoint / 2\n        return realBestObjV\n```\n\n2.Instantiate **MyProblem** class and a derivative class inherited from **Algorithm** class in a Python script file \"main.py\" then execute it. **For example**, trying to find the pareto front of **DTLZ1**, do as the following:\n\n```python\n\"\"\"main.py\"\"\"\nimport geatpy as ea # Import geatpy\nfrom MyProblem import MyProblem # Import MyProblem class\nif __name__ == '__main__':\n    M = 3                      # Set the number of objects.\n    problem = MyProblem(M)     # Instantiate MyProblem class\n    # Instantiate a algorithm class.\n    algorithm = ea.moea_NSGA3_templet(problem,\n                                      ea.Population(Encoding='RI', NIND=100),  # Set 100 individuals.\n                                      MAXGEN=500,  # Set the max iteration number.\n                                      logTras=1)  # Set the frequency of logging. If it is zero, it would not log.\n    # Do the optimization\n    res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=True, saveFlag=True)\n\n```\n\nRun the \"main.py\" and the part of the result is:\n\n![image](https://github.com/geatpy-dev/geatpy/blob/master/testbed/moea_test/result/Pareto%20Front%20Plot.svg)\n\nExecution time: 0.3650233745574951 s\n\nEvaluation number: 45500\n\nThe number of non-dominated solutions is: 91\n\ngd: 0.00033\n\nigd: 0.02084\n\nhv: 0.84061\n\nspacing: 0.00158\n\nFor solving another problem: **Ackley-30D**, which has only one object and 30 decision variables, what you need to do is almost the same as above.\n\n1.Write the aim function in \"MyProblem.py\".\n\n```python\nimport numpy as np\nimport geatpy as ea\nclass Ackley(ea.Problem): # Inherited from Problem class.\n    def __init__(self, D = 30):\n        name = 'Ackley' # Problem's name.\n        M = 1 # Set the number of objects.\n        maxormins = [1] * M # All objects are need to be minimized.\n        Dim = D # Set the dimension of decision variables.\n        varTypes = [0] * Dim # Set the types of decision variables. 0 means continuous while 1 means discrete.\n        lb = [-32.768] * Dim # The lower bound of each decision variable.\n        ub = [32.768] * Dim # The upper bound of each decision variable.\n        lbin = [1] * Dim # Whether the lower boundary is included.\n        ubin = [1] * Dim # Whether the upper boundary is included.\n        # Call the superclass's constructor to complete the instantiation\n        ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin)\n    def aimFunc(self, pop): # Write the aim function here, pop is an object of Population class.\n        x = pop.Phen # Get the decision variables\n        n = self.Dim\n        f = np.array([-20 * np.exp(-0.2*np.sqrt(1/n*np.sum(x**2, 1))) - np.exp(1/n * np.sum(np.cos(2 * np.pi * x), 1)) + np.e + 20]).T\n        return f, CV\n    def calReferObjV(self): # Calculate the global optimal solution here.\n        realBestObjV = np.array([[0]])\n        return realBestObjV\n```\n\n2.Write \"main.py\" to execute the algorithm templet to solve the problem.\n\n```python\nimport geatpy as ea # import geatpy\nimport numpy as np\nfrom MyProblem import Ackley\nif __name__ == '__main__':\n    # Instantiate MyProblem class.\n    problem = Ackley(30)\n    # Instantiate a algorithm class.\n    algorithm = ea.soea_DE_rand_1_bin_templet(problem,\n                                              ea.Population(Encoding='RI', NIND=20),\n                                              MAXGEN=1000,  # Set the max times of iteration.\n                                              logTras=1)  # Set the frequency of logging. If it is zero, it would not log.\n    algorithm.mutOper.F = 0.5  # Set the F of DE\n    algorithm.recOper.XOVR = 0.2  # Set the Cr of DE (Here it is marked as XOVR)\n    # Do the optimization\n    res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=True, saveFlag=True, dirName='result')\n```\n\nPart of the result is:\n\n![image](https://github.com/geatpy-dev/geatpy/blob/master/testbed/soea_test/result/Trace%20Plot.svg)\n\nExecution time: 0.256328821182251 s\n\nEvaluation number: 20000\n\nThe best objective value is: 3.209895993450118e-08\n\nTo get more tutorials, please link to [http://www.geatpy.com](https://github.com/geatpy-dev/geatpy/tree/master/docs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeatpy-dev%2Fgeatpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeatpy-dev%2Fgeatpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeatpy-dev%2Fgeatpy/lists"}