All Projects → geatpy-dev → Geatpy

geatpy-dev / Geatpy

Licence: lgpl-3.0
Evolutionary algorithm toolbox and framework with high performance for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Geatpy

Symbolics.jl
A fast and modern CAS for a fast and modern language.
Stars: ✭ 435 (-56.06%)
Mutual labels:  parallel-computing, high-performance
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-98.18%)
Mutual labels:  high-performance, parallel-computing
Pygmo2
A Python platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
Stars: ✭ 134 (-86.46%)
Mutual labels:  parallel-computing, evolutionary-algorithms
Pagmo2
A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
Stars: ✭ 540 (-45.45%)
Mutual labels:  parallel-computing, evolutionary-algorithms
May
rust stackful coroutine library
Stars: ✭ 909 (-8.18%)
Mutual labels:  high-performance
Zato
ESB, SOA, REST, APIs and Cloud Integrations in Python
Stars: ✭ 889 (-10.2%)
Mutual labels:  high-performance
Swift Nio
Event-driven network application framework for high performance protocol servers & clients, non-blocking.
Stars: ✭ 6,777 (+584.55%)
Mutual labels:  high-performance
Lizardfs
LizardFS is an Open Source Distributed File System licensed under GPLv3.
Stars: ✭ 793 (-19.9%)
Mutual labels:  high-performance
Parallel Programming Coursera
Assignments and Quizzes submitted by me.
Stars: ✭ 35 (-96.46%)
Mutual labels:  parallel-computing
Rhashmap
Robin Hood hash map library
Stars: ✭ 33 (-96.67%)
Mutual labels:  high-performance
Stl.fusion
Get real-time UI updates in Blazor apps and 10-1000x faster API responses with a novel approach to distributed reactive computing. Fusion brings computed observables and automatic dependency tracking from Knockout.js/MobX/Vue to the next level by enabling a single dependency graph span multiple servers and clients, including Blazor apps running in browser.
Stars: ✭ 858 (-13.33%)
Mutual labels:  high-performance
Notlitecode
Remote Encrypted Procedure Calling for .Net & .Net Core
Stars: ✭ 16 (-98.38%)
Mutual labels:  high-performance
Koloboke
Java Collections till the last breadcrumb of memory and performance
Stars: ✭ 909 (-8.18%)
Mutual labels:  high-performance
Simple Java Mail
Simple API, Complex Emails (JavaMail smtp wrapper)
Stars: ✭ 821 (-17.07%)
Mutual labels:  high-performance
Awesome Scalability Toolbox
My opinionated list of products and tools used for high-scalability projects
Stars: ✭ 34 (-96.57%)
Mutual labels:  high-performance
Arraymancer
A fast, ergonomic and portable tensor library in Nim with a deep learning focus for CPU, GPU and embedded devices via OpenMP, Cuda and OpenCL backends
Stars: ✭ 793 (-19.9%)
Mutual labels:  parallel-computing
Cicada
🚀 Fast lightweight HTTP service framework.
Stars: ✭ 851 (-14.04%)
Mutual labels:  high-performance
Asyncio
asyncio historical repository
Stars: ✭ 952 (-3.84%)
Mutual labels:  high-performance
Tank
A very high performance distributed log service
Stars: ✭ 927 (-6.36%)
Mutual labels:  high-performance
Mmc
Mesh-based Monte Carlo (MMC)
Stars: ✭ 22 (-97.78%)
Mutual labels:  parallel-computing

Geatpy2

The Genetic and Evolutionary Algorithm Toolbox for Python with high performance.

Travis Package Status Python Pypi Download License Gitter

Introduction

The features of Geatpy:

  • Capability of solving single-objective, multi-objectives, many-objectives and combinatorial optimization problems fast.

  • A huge number of operators with high performance of evolutionary algorithms (selection, recombination, mutation, migration...).

  • Support numerous encodings for the chromosome of the population.

  • Many evolutionary algorithm templates, including GA, DE, ES for single/multi-objective(s) evolution.

  • Multiple population evolution.

  • Support polysomy evolution.

  • Parallelization and distribution of evaluations.

  • Testbeds containing most common benchmarks functions.

  • Support tracking analysis of the evolution iteration.

  • Many evaluation metrics of algorithms.

Improvement of Geatpy 2.6.0

  • Add Push and Pull Search Strategy for MOEA/D-DE.

  • Add new cores: 'ri2bs' and 'mergecv'.

  • Support setting more precise parameters in mutation and recombination operators.

  • Support logging and showing log during the evoluation.

  • Speed up the EA framework.

Installation

1.Installing online:

pip install geatpy

2.From source:

python setup.py install

or

pip install <filename>.whl

Attention: Geatpy requires numpy>=1.16.0, matplotlib>=3.0.0 and scipy>=1.0.0, the installation program won't help you install them so that you have to install both of them by yourselves.

Versions

Geatpy must run under Python3.5, 3.6, 3.7 or 3.8 in Windows x32/x64, Linux x64 or Mac OS x64.

There are different versions for Windows, Linux and Mac, you can download them from http://geatpy.com/

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

If something wrong happened, such as decoding error about 'utf8' of pip, run this command instead or execute it as an administrator:

pip install --upgrade --user geatpy

Quick start

Here is the UML figure of Geatpy2.

image

For solving a multi-objective optimization problem, you can use Geatpy mainly in two steps:

1.Write down the aim function and some relevant settings in a derivative class named MyProblem, which is inherited from Problem class:

"""MyProblem.py"""
import numpy as np
import geatpy as ea
class MyProblem(ea.Problem): # Inherited from Problem class.
    def __init__(self, M): # M is the number of objects.
        name = 'DTLZ1' # Problem's name.
        maxormins = [1] * M # All objects are need to be minimized.
        Dim = M + 4 # Set the dimension of decision variables.
        varTypes = [0] * Dim # Set the types of decision variables. 0 means continuous while 1 means discrete.
        lb = [0] * Dim # The lower bound of each decision variable.
        ub = [1] * Dim # The upper bound of each decision variable.
        lbin = [1] * Dim # Whether the lower boundary is included.
        ubin = [1] * Dim # Whether the upper boundary is included.
        # Call the superclass's constructor to complete the instantiation
        ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin)
    def aimFunc(self, pop): # Write the aim function here, pop is an object of Population class.
        Vars = pop.Phen # Get the decision variables
        XM = Vars[:,(self.M-1):]
        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
        ones_metrix = np.ones((Vars.shape[0], 1))
        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))
    def calReferObjV(self): # Calculate the theoretic global optimal solution here.
        uniformPoint, ans = ea.crtup(self.M, 10000) # create 10000 uniform points.
        realBestObjV = uniformPoint / 2
        return realBestObjV

2.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:

"""main.py"""
import geatpy as ea # Import geatpy
from MyProblem import MyProblem # Import MyProblem class
if __name__ == '__main__':
    """=========================Instantiate your problem=========================="""
    M = 3                      # Set the number of objects.
    problem = MyProblem(M)     # Instantiate MyProblem class
    """===============================Population set=============================="""
    Encoding = 'RI'            # Encoding type.
    NIND = 100                 # Set the number of individuals.
    Field = ea.crtfld(Encoding, problem.varTypes, problem.ranges, problem.borders) # Create the field descriptor.
    population = ea.Population(Encoding, Field, NIND) # Instantiate Population class(Just instantiate, not initialize the population yet.)
    """================================Algorithm set==============================="""
    myAlgorithm = ea.moea_NSGA3_templet(problem, population) # Instantiate a algorithm class.
    myAlgorithm.MAXGEN = 500   # Set the max times of iteration.
    myAlgorithm.logTras = 1    # Set the frequency of logging. If it is zero, it would not log.
    myAlgorithm.verbose = True # Set if we want to print the log during the evolution or not.
    myAlgorithm.drawing = 1    # 1 means draw the figure of the result.
    """===============================Start evolution============================="""
    [NDSet, population] = myAlgorithm.run()  # Run the algorithm templet.
    """=============================Analyze the result============================"""
    if myAlgorithm.log is not None and NDSet.sizes != 0:
        print('GD', myAlgorithm.log['gd'][-1])
        print('IGD', myAlgorithm.log['igd'][-1])
        print('HV', myAlgorithm.log['hv'][-1])
        print('Spacing', myAlgorithm.log['spacing'][-1])

Run the "main.py" and the part of the result is:

image

The number of non-dominated result: 91

GD 0.00022198303156041217

IGD 0.02068151005217868

HV 0.8402294516563416

Spacing 0.00045354439805786744

For 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.

1.Write the aim function in "MyProblem.py".

import numpy as np
import geatpy as ea
class Ackley(ea.Problem): # Inherited from Problem class.
    def __init__(self, D = 30):
        name = 'Ackley' # Problem's name.
        M = 1 # Set the number of objects.
        maxormins = [1] * M # All objects are need to be minimized.
        Dim = D # Set the dimension of decision variables.
        varTypes = [0] * Dim # Set the types of decision variables. 0 means continuous while 1 means discrete.
        lb = [-32.768] * Dim # The lower bound of each decision variable.
        ub = [32.768] * Dim # The upper bound of each decision variable.
        lbin = [1] * Dim # Whether the lower boundary is included.
        ubin = [1] * Dim # Whether the upper boundary is included.
        # Call the superclass's constructor to complete the instantiation
        ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin)
    def aimFunc(self, pop): # Write the aim function here, pop is an object of Population class.
        x = pop.Phen # Get the decision variables
        n = self.Dim
        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
        return f, CV
    def calReferObjV(self): # Calculate the global optimal solution here.
        realBestObjV = np.array([[0]])
        return realBestObjV

2.Write "main.py" to execute the algorithm templet to solve the problem.

import geatpy as ea # import geatpy
import numpy as np
from MyProblem import Ackley
if __name__ == '__main__':
    """=========================Instantiate your problem=========================="""
    problem = Ackley(30) # Instantiate MyProblem class.
    """===============================Population set=============================="""
    Encoding = 'RI'                # Encoding type.
    NIND = 20                      # Set the number of individuals.
    Field = ea.crtfld(Encoding, problem.varTypes, problem.ranges, problem.borders) # Create the field descriptor.
    population = ea.Population(Encoding, Field, NIND) # Instantiate Population class(Just instantiate, not initialize the population yet.)
    """================================Algorithm set==============================="""
    myAlgorithm = ea.soea_DE_rand_1_bin_templet(problem, population) # Instantiate a algorithm class.
    myAlgorithm.MAXGEN = 1000      # Set the max times of iteration.
    myAlgorithm.mutOper.F = 0.5    # Set the F of DE
    myAlgorithm.recOper.XOVR = 0.2 # Set the Cr of DE (Here it is marked as XOVR)
    myAlgorithm.logTras = 1        # Set the frequency of logging. If it is zero, it would not log.
    myAlgorithm.verbose = True     # Set if we want to print the log during the evolution or not.
    myAlgorithm.drawing = 1        # 1 means draw the figure of the result.
    """===============================Start evolution=============================="""
    [BestIndi, population] = myAlgorithm.run() # Run the algorithm templet.
    """==============================Output the result============================="""
    print('The number of evolution is: %s'%(myAlgorithm.evalsNum))
    if BestIndi.sizes != 0:
        print('The objective value of the best solution is: %s' % BestIndi.ObjV[0][0])
    else:
        print('Did not find any feasible solution.')

Part of the result is:

image

The number of evolution is: 20000

The objective value of the best solution is: 2.7631678278794425e-08

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].