Skip to main content

Geatpy is a high-performance GEA toolbox for Python.

Project description

The Genetic and Evolutionary Algorithm Toolbox for Python

Build Status platform versions

Introduction

  1. Website (including documentation): https://www.geatpy.com

  2. Tutorial pdf: https://github.com/geatpy-dev/geatpy/tree/master/geatpy/doc/tutorial

  3. Demo: https://github.com/geatpy-dev/geatpy/tree/master/geatpy/demo

  4. Contact us: http://www.geatpy.com/support

  5. Source code: https://github.com/geatpy-dev/geatpy/tree/master/geatpy/source-code

  6. Bug reports: https://github.com/geatpy-dev/geatpy/issues

  7. Franchised blog https://blog.csdn.net/qq_33353186

It provides:

  1. global optimization capabilities in Python using genetic and evolutionary algorithm to solve problems unsuitable for traditional optimization approaches.

  2. a great many of genetic and evolutionary operators, so that you can deal with single or multi-objective optimization problems.

It can work faster with numpy+mkl. If you want to speed your projects, please install numpy+mkl.

Installation

  1. From pip:

    pip install geatpy
  2. From source:

    python setup.py install

Attention: Geatpy requires numpy>=1.12.1 and matplotlib>=2.0.0, the installation program will help you install all the requires. But if something wrong happened, you have to install all requires by yourselves.

Versions

The version of Geatpy on github is the latest version suitable for Python >= 3.5

You can also update Geatpy by executing the command:

pip install --upgrade geatpy

Quick start

You can use Geatpy to solve single or multi-objective optimization problems mainly in two ways:

  1. Create a script, write all the codes on it and run. It’s the easiest way, but it needs much too codes and is not good for reuse.

  2. Using templets and functional interfaces. For example, we try to find the Pareto front of DTLZ1, do as the following:

2.1) Write DTLZ1 function on a file named “aimfuc.py” as a functional interfaces:

“””aimfuc.py”””

# DTLZ1

def aimfuc(Chrom, LegV): # LegV is a legal-sign column vector for the population

M = 3 # M is the dimensions of DTLZ1.

x = Chrom.T # Chrom is a numpy array standing for the chromosomes of the population

XM = x[M-1:]

k = x.shape[0] - M + 1

gx = 100 * (k + np.sum((XM - 0.5) ** 2 - np.cos(20 * np.pi * (XM - 0.5)), 0))

ObjV = (np.array([[]]).T) * np.zeros((1, Chrom.shape[0])) # define ObjV to recod function values

ObjV = np.vstack([ObjV, 0.5 * np.cumprod(x[:M-1], 0)[-1] * (1 + gx)])

for i in range(2, M):

ObjV = np.vstack([ObjV, 0.5 * np.cumprod(x[: M-i], 0)[-1] * (1 - x[M-i]) * (1 + gx)])

ObjV = np.vstack([ObjV, 0.5 * (1 - x[0]) * (1 + gx)])

return [ObjV.T, LegV] # use ‘.T’ to change ObjV so that each row stands for function values of each individual of the population

2.2) Write the main script using NSGA-II templet of Geatpy to solve the problem.

“””main.py”””

import numpy as np

import geatpy as ga # import geatpy

AIM_M = __import__(‘aimfuc’) # get the address of objective function DTLZ1

AIM_F = ‘DTLZ1’ # You can set DTL1,2,3 or 4

“””==================================variables setting================================”””

ranges = np.vstack([np.zeros((1,7)), np.ones((1,7))]) # define the ranges of variables in DTLZ1

borders = np.vstack([np.ones((1,7)), np.ones((1,7))]) # define the borders of variables in DTLZ1

FieldDR = ga.crtfld(ranges, borders) # create the FieldDR

“””=======================use moea_nsga2_templet to find the Pareto front===================”””

[ObjV, NDSet, NDSetObjV, times] = ga.nsga2_templet(AIM_M, AIM_F, None, None, FieldDR, problem = ‘R’, maxormin = 1, MAXGEN = 1000, MAXSIZE = 2000, NIND = 50, SUBPOP = 1, GGAP = 1, selectStyle = ‘tour’, recombinStyle = ‘xovdprs’, recopt = 0.9, pm = None, distribute = True, drawing = 1)

The partial of the result can be seen in:

https://github.com/geatpy-dev/geatpy/blob/master/geatpy/demo/DTLZ_demo/Pareto%20Front.png

To get more examples and more tutorials, please link to http://www.geatpy.com/tutorials.

There are also some demos in Geatpy’s source. Including ZDT1/2/3/4/6、 DTLZ1/2/3/4、single-objective examples、discrete problem solving and so forth.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geatpy-1.1.0.tar.gz (25.5 MB view details)

Uploaded Source

Built Distribution

geatpy-1.1.0-py3-none-any.whl (25.9 MB view details)

Uploaded Python 3

File details

Details for the file geatpy-1.1.0.tar.gz.

File metadata

  • Download URL: geatpy-1.1.0.tar.gz
  • Upload date:
  • Size: 25.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.4

File hashes

Hashes for geatpy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 570e7b3ef10df1dae30c9132aff448debac4c961e5c530ef4b42f17a3b6a33d6
MD5 37b5849b817db351d87ebd2272ce96a6
BLAKE2b-256 8e3919fd8a6cd1a97976f89b2d82b4e4d5883516db8787bf6fc8f9ff14474971

See more details on using hashes here.

File details

Details for the file geatpy-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: geatpy-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for geatpy-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5bf03653455a128db41e9c23fda10ba451c49b55b22f502ff24f599229aa105
MD5 6e11d03c2a64b7a82ec775493bbbe3b0
BLAKE2b-256 92990cbfe64e4e326717606c006fb6bb287d42d94751d18a95fb2788c710171e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page