Skip to main content

Nature Inspired Optimization Algorithms

Project description

NIA

NIA is a python package for Nature Inspired Optimization Algorithms which makes optimization process easy and fast.

Instalation

Check NIA's PyPI page or simply install it using pip:

pip install nia

Usage

Solve Ackley problem using Genetic Algorithm:

from nia.algorithms import GeneticAlgorithm
from nia.problems import ackley


nia = GeneticAlgorithm(cost_function=ackley,
                       lower_bond=[-5,-5],
                       upper_bond=[5,5],
                                )
nia.run()
print(nia.message);

output:

quit criteria reached best answer is: [-0.02618036 -0.03615453] and best fitness is: 0.0006327163637145361 iteration : 11

Plot:

Result gif

Customization:

from nia.algorithms import GeneticAlgorithm
# Specific selection, crossover and muttion algorithms are available under related sub-packages.
from nia.selections import Tournament
from nia.crossovers import RandomSBX
from nia.mutations import Uniform
import numpy as np

def ackley(X):
    x = X[0]
    y = X[1]
    return -20 * np.exp(-0.2 * np.sqrt(0.5 * (x**2 + y**2))) - np.exp(0.5 *
        (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y))) + np.e + 20

def log(ga):
  print(ga.best)

lower = np.array([-5,-5])
upper = np.array([5,5])

nia = GeneticAlgorithm(cost_function=ackley,
                       iteration_function=log,
                       lower_bond=lower,
                       upper_bond=upper,
                       quit_criteria = 0.0001,
                       num_variable = 2,
                       num_population = 20,
                       max_iteration = 100,
                       crossover = RandomSBX(2),
                       mutation = Uniform(0.05),
                       selection = Tournament(20)
                                )
nia.run()
print(nia.message);

output

max iteration reached best answer so far: [-0.02618036 -0.03615453] with best fitness: 0.1786046633597529 iteration : 99

Supported Algorithms :

  • Genetic algorithm (GeneticAlgorithm)
  • Differential Evolution
  • Evolutionary Programming
  • Artificial Immune System
  • Clonal Selection Algorithm
  • Biogeography-based
  • Symbiotic Organisms Search
  • Ant Colony Optimization
  • Artificial Bee Colony (ArtificialBeeColony)
  • Moth Flame Optimization Algorithm
  • Cuckoo Search
  • Green Herons Optimization Algorithm
  • Bat Algorithm
  • Whale Optimization Algorithm
  • Krill Herd
  • Fish-swarm Algorithm
  • Grey Wolf Optimizer
  • Shuffle frog-leaping Algorithm
  • Cat Swarm Optimization
  • Flower Pollination Algorithm
  • Invasive Weed Optimization
  • Water Cycle Algorithm
  • Teaching–Learning-Based Optimization
  • Particle Swarm Optimization (ParticleSwarmOptimization)
  • Simulated Annealing Algorithm
  • Gravitational Search Algorithm
  • Big Bang - Big Crunch

Supported Selection Operators :

  • Rank (Rank)
  • Tournament (Tournament)

Supported Cross Over Operators :

  • K-Point (KPoint)
  • SBX (SBX)
  • Random SBX (RandomSBX)

Supported Mutation Operators :

  • Uniform (Uniform)

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

nia-0.0.3.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

nia-0.0.3-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file nia-0.0.3.tar.gz.

File metadata

  • Download URL: nia-0.0.3.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for nia-0.0.3.tar.gz
Algorithm Hash digest
SHA256 59a55839952a0082b14de8e149a9d990987e1f03b1addc749f258d4550f9f355
MD5 fd5ff3134162de5e45d7ec0c50da7c25
BLAKE2b-256 799018a76ff79ab6b788ccbc403e57ab40aac8314d0fc4b812d1314ae241e6ad

See more details on using hashes here.

File details

Details for the file nia-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nia-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for nia-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 34f6527bbd75f0da17e52b401ab3d6847518a0ff97e045bda39fdbb32d946c46
MD5 b133d93c801883a50c8260fdab0e8d47
BLAKE2b-256 9ae87907190ae2bae026cc8324e1cacc9fd98ec33bbaf52a0cc5b2db9951d9fe

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