Skip to main content

Black Widow Optimization

gh-actions-ci GitHub license PyPI pyversions PyPi Version

From the abstract: ...a novel meta-heuristic algorithm suitable for continuous nonlinear optimization problems. The proposed method, Black Widow Optimization Algorithm (BWO), is inspired by the unique mating behavior of black widow spiders. This method includes an exclusive stage, namely, cannibalism. Due to this stage, species with inappropriate fitness are omitted from the circle, thus leading to early convergence. BWO algorithm is evaluated on 51 various benchmark functions to verify its efficiency in obtaining the optimal solutions for the problems. The obtained results indicate that the proposed algorithm has numerous advantages in different aspects such as early convergence and achieving optimized fitness value compared to other algorithms.

Installation

pip install bwo

or

pip install git+https://github.com/nathanrooy/bwo

Usage

As a simple example, let's find the minimum of the single objective sphere function availabel in the Landscapes Python package.

pip install landscapes

Next, let's import everything we need.

from bwo import minimize
from landscapes.single_objective import sphere

Now, we just need to call the minimize function. For this particular example, let's optimize across 5 degrees of freedom.

fbest, xbest = minimize(sphere, dof=5)

Where fbest is the best function value achieved during optimization, and xbest is the function input which yielded fbest.

You can also minimize a function given boundry constraints, represented by a list of tuples. Each tuple must follow the (min, max) format.

bounds = [(-1,1),(-2,2), (-3,3), (-4,4), (-5,5)]
fbest, xbest = minimize(sphere, bounds=bounds, disp=False)

Options

minimize(func, x0=None, dof=None, bounds=None, pp=0.6, cr=0.44, pm=0.4, npop=10, disp=False, maxiter=50)

  • func (callable) : The objective function to be minimized.
  • x0 (list) : Initial guess (optional).
  • dof (int) : degrees of freedom (optional)
  • bounds(list of tuples) : boundary constraints as specified as a list of (xi_min, xi_max) tuples.
  • pp (float) : procreating percentage [0, 1].
  • cr (float) : cannibalism rate [0, 1].
  • pm (float) : mutation rate [0, 1].
  • maxiter (int) : maximum number of iterations.
  • disp (bool) : output intermediate results at each iteration.

References

@article{article,
author = {Hayyolalam, Vahideh and Pourhaji Kazem, Ali Asghar},
year = {2019},
month = {10},
pages = {103249},
title = {Black Widow Optimization Algorithm: A novel meta-heuristic approach for solving engineering optimization problems ✩},
volume = {87},
journal = {Engineering Applications of Artificial Intelligence},
doi = {10.1016/j.engappai.2019.103249}
}

Metadata

Release files for bwo 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bwo 0.1.2
File Size Uploaded
bwo-0.1.2.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bwo 0.1.2
File Interpreter ABI Platform
bwo-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / bwo-0.1.2.tar.gz

Download URL bwo-0.1.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0cd085a02cfde5f48c728c7a55d89b287210742f2d7739e6424891607b31d281
BLAKE2b-256 checksum
How to use checksums
cfdd177660a3a2d58622a15a2c8908fc1a85d39bede2ede6c9d7f6c123b75377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

Release files / bwo-0.1.2-py3-none-any.whl

Download URL bwo-0.1.2-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7da03c61de8e5c69cecbd01da102a25c469d5c20c7fb3be5248e2617c836660d
BLAKE2b-256 checksum
How to use checksums
5523f9c590de80716925dd72a807897d48d4e4e7dc62c3da98c28a1a986a36f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page