NiaPy

NiaPy: Python microframework for building nature-inspired algorithms - Published in JOSS (2018)

https://github.com/niaorg/niapy

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 14 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: arxiv.org, mdpi.com, joss.theoj.org, zenodo.org
  • Committers with academic emails
    1 of 33 committers (3.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

hacktoberfest microframework nature-inspired-algorithms optimization-algorithms python swarm-intelligence

Keywords from Contributors

cryptocurrencies evolutionary-algorithms data-mining pypi metaheuristic association-rules association-rule-mining fuel-cell electrochemistry calibration
Last synced: 4 months ago · JSON representation ·

Repository

Python microframework for building nature-inspired algorithms. Official docs: https://niapy.org

Basic Info
  • Host: GitHub
  • Owner: NiaOrg
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage: https://niapy.org
  • Size: 11.8 MB
Statistics
  • Stars: 268
  • Watchers: 10
  • Forks: 80
  • Open Issues: 44
  • Releases: 34
Topics
hacktoberfest microframework nature-inspired-algorithms optimization-algorithms python swarm-intelligence
Created almost 8 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

NiaPy


PyPI Version PyPI - Python Version PyPI - Status PyPI - Downloads Packaging status Anaconda Badge Fedora package AUR package GitHub license Check codestyle and test build Documentation Status

GitHub commit activity Average time to resolve an issue Percentage of issues still open GitHub contributors

DOI JOSS

🎯 Mission📦 Installation🧠 Algorithms🧪 Problems🚀 Usage🫂 Contributors🙇 Contributing🔑 License📄 Cite us

Nature-inspired algorithms are a very popular tool for solving optimization problems. Numerous variants of nature-inspired algorithms have been developed (paper 1, paper 2) since the beginning of their era. To prove their versatility, those were tested in various domains on various applications, especially when they are hybridized, modified or adapted. However, implementation of nature-inspired algorithms is sometimes a difficult, complex and tedious task. In order to break this wall, NiaPy is intended for simple and quick use, without spending time for implementing algorithms from scratch.

  • Free software: MIT license
  • Documentation: https://niapy.readthedocs.io/en/stable
  • Python versions: 3.9.x, 3.10.x, 3.11.x, 3.12.x
  • Dependencies: listed in CONTRIBUTING.md

🎯 Mission

Our mission is to build a collection of nature-inspired algorithms and create a simple interface for managing the optimization process. NiaPy offers:

  • numerous optimization problem implementations,
  • use of various nature-inspired algorithms without struggle and effort with a simple interface,
  • easy comparison between nature-inspired algorithms, and
  • export of results in various formats such as Pandas DataFrame, JSON or even Excel.

📦 Installation

To install NiaPy with pip, use:

sh pip install niapy

To install NiaPy with conda, use:

sh conda install -c niaorg niapy

To install NiaPy on Fedora, use:

sh dnf install python3-niapy

To install NiaPy on Arch Linux, use an AUR helper:

sh yay -Syyu python-niapy

To install NiaPy on Alpine Linux, enable Community repository and use:

sh apk add py3-niapy

To install NiaPy on NixOS, use:

sh nix-env -iA nixos.python310Packages.niapy

To install NiaPy on Void Linux, use:

sh xbps-install -S python3-niapy

Installation from source

To install NiaPy directly from the source code, use:

sh pip install git+https://github.com/NiaOrg/NiaPy.git

🧠 Algorithms

Click here for the list of implemented algorithms.

🧪 Problems

Click here for the list of implemented test problems.

🚀 Usage

After installation, you can import NiaPy as any other Python module:

```sh $ python

import niapy niapy.version ```

Let's go through a basic and advanced example.

Basic Example

Let’s say, we want to try out PSO against the Pintér problem function. Firstly, we have to create new file, with name, for example basic_example.py. Then we have to import chosen algorithm from NiaPy, so we can use it. Afterwards we initialize ParticleSwarmAlgorithm class instance and run the algorithm. Given bellow is the complete source code of basic example.

```python from niapy.algorithms.basic import ParticleSwarmAlgorithm from niapy.task import Task

we will run 10 repetitions of Weighted, velocity clamped PSO on the Pinter problem

for i in range(10): task = Task(problem='pinter', dimension=10, maxevals=10000) algorithm = ParticleSwarmAlgorithm(populationsize=100, w=0.9, c1=0.5, c2=0.3, minvelocity=-1, maxvelocity=1) bestx, bestfit = algorithm.run(task) print(best_fit) ```

Given example can be run with python basic_example.py command and should give you similar output as following:

sh 0.008773534890863646 0.036616190934621755 186.75116812592546 0.024186452828927896 263.5697469837348 45.420706924365916 0.6946753611091367 7.756100204780568 5.839673314425907 0.06732518679742806

Advanced Example

In this example we will show you how to implement a custom problem class and use it with any of implemented algorithms. First let's create new file named advanced_example.py. As in the previous examples we wil import algorithm we want to use from niapy module.

For our custom optimization function, we have to create new class. Let's name it MyProblem. In the initialization method of MyProblem class we have to set the dimension, lower and upper bounds of the problem. Afterwards we have to override the abstract method _evaluate which takes a parameter x, the solution to be evaluated, and returns the function value. Now we should have something similar as is shown in code snippet bellow.

```python import numpy as np from niapy.task import Task from niapy.problems import Problem from niapy.algorithms.basic import ParticleSwarmAlgorithm

our custom problem class

class MyProblem(Problem): def init(self, dimension, lower=-10, upper=10, args, *kwargs): super().init(dimension, lower, upper, args, *kwargs)

def _evaluate(self, x):
    return np.sum(x ** 2)

```

Now, all we have to do is to initialize our algorithm as in previous examples and pass an instance of our MyProblem class as the problem argument.

```python myproblem = MyProblem(dimension=20) for i in range(10): task = Task(problem=myproblem, maxiters=100) algo = ParticleSwarmAlgorithm(populationsize=100, w=0.9, c1=0.5, c2=0.3, minvelocity=-1, maxvelocity=1)

# running algorithm returns best found minimum
best_x, best_fit = algo.run(task)
# printing best minimum
print(best_fit)

```

Now we can run our advanced example with following command: python advanced_example.py. The results should be similar to those bellow.

sh 0.002455614050761476 0.000557652972392164 0.0029791325679865413 0.0009443595274525336 0.001012658824492069 0.0006837236892816072 0.0026789725774685495 0.005017746993004601 0.0011654473402322196 0.0019074442166293853

For more usage examples please look at examples folder.

More advanced examples can also be found in the NiaPy-examples repository.

🫂 Contributors

Thanks goes to these wonderful people (emoji key):


Grega Vrbančič

💻 📖 🐛 💡 🚧 📦 📆 👀

firefly-cpp

💻 📖 🐛 💡 👀 💬 ⚠️ 📦

Lucija Brezočnik

💻 📖 🐛 💡

mlaky88

💻 📖 💡

rhododendrom

💻 📖 💡 🐛 👀

Klemen

💻 📖 💡 🐛 👀

Jan Popič

💻 📖 💡

Luka Pečnik

💻 📖 💡 🐛

Jan Banko

💻 📖 💡

RokPot

💻 📖 💡

mihaelmika

💻 📖 💡

Jace Browning

💻

Musa Adamu Wakili

💬

Florian Schaefer

🤔

Jan-Hendrik Menke

💬

brett18618

💬

Timotej Zaťko

🐛

sisco0

💻

zStupan

💻 🐛 📖 💡 ⚠️

Tomáš Hrnčiar

💻

Ikko Ashimine

💻

andrazperson

💻

Oromion

📦

This project follows the all-contributors specification. Contributions of any kind are welcome!

🙇 Contributing

We encourage you to contribute to NiaPy! Please check out the Contributing to NiaPy guide for guidelines about how to proceed.

Everyone interacting in NiaPy's codebases, issue trackers, chat rooms and mailing lists is expected to follow the NiaPy code of conduct.

🔑 License

This package is distributed under the MIT License. This license can be found online at http://www.opensource.org/licenses/MIT.

Disclaimer

This framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!

📄 Cite us

Are you using NiaPy in your project or research? Please cite us!

Plain format

Vrbančič, G., Brezočnik, L., Mlakar, U., Fister, D., & Fister Jr., I. (2018). NiaPy: Python microframework for building nature-inspired algorithms. Journal of Open Source Software, 3(23), 613\. <https://doi.org/10.21105/joss.00613>

Bibtex format

bibtex @article{NiaPyJOSS2018, author = {Vrban{\v{c}}i{\v{c}}, Grega and Brezo{\v{c}}nik, Lucija and Mlakar, Uro{\v{s}} and Fister, Du{\v{s}}an and {Fister Jr.}, Iztok}, title = {{NiaPy: Python microframework for building nature-inspired algorithms}}, journal = {{Journal of Open Source Software}}, year = {2018}, volume = {3}, issue = {23}, issn = {2475-9066}, doi = {10.21105/joss.00613}, url = {https://doi.org/10.21105/joss.00613} }

RIS format

TY - JOUR T1 - NiaPy: Python microframework for building nature-inspired algorithms AU - Vrbančič, Grega AU - Brezočnik, Lucija AU - Mlakar, Uroš AU - Fister, Dušan AU - Fister Jr., Iztok PY - 2018 JF - Journal of Open Source Software VL - 3 IS - 23 DO - 10.21105/joss.00613 UR - http://joss.theoj.org/papers/10.21105/joss.00613

Owner

  • Name: NiaOrg
  • Login: NiaOrg
  • Kind: organization
  • Email: niapy.organization@gmail.com

JOSS Publication

NiaPy: Python microframework for building nature-inspired algorithms
Published
March 22, 2018
Volume 3, Issue 23, Page 613
Authors
Grega Vrbančič ORCID
University of Maribor, Faculty of Electrical Engineering and Computer Science
Lucija Brezočnik ORCID
University of Maribor, Faculty of Electrical Engineering and Computer Science
Uroš Mlakar ORCID
University of Maribor, Faculty of Electrical Engineering and Computer Science
Dušan Fister ORCID
University of Maribor, Faculty of Economics and Business
Iztok Fister ORCID
University of Maribor, Faculty of Electrical Engineering and Computer Science
Editor
Arfon Smith ORCID
Tags
nature-inspired algorithms microframework

Citation (CITATION.cff)

# YAML 1.2
---
authors: 
  -
    family-names: "Vrbančič"
    given-names: Grega
  -
    family-names: "Brezočnik"
    given-names: Lucija
  -
    family-names: Mlakar
    given-names: "Uroš"
  -
    family-names: Fister
    given-names: "Dušan"
  -
    family-names: "Fister Jr."
    given-names: Iztok
cff-version: "1.1.0"
date-released: 2018-10-24
doi: "10.21105/joss.00613"
license: MIT
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/NiaOrg/NiaPy"
title: "NiaPy: Python microframework for building nature-inspired algorithms"
version: "1.0.2"
...

GitHub Events

Total
  • Create event: 94
  • Release event: 1
  • Issues event: 9
  • Watch event: 14
  • Delete event: 61
  • Member event: 1
  • Issue comment event: 65
  • Push event: 82
  • Pull request event: 155
  • Fork event: 4
Last Year
  • Create event: 94
  • Release event: 1
  • Issues event: 9
  • Watch event: 14
  • Delete event: 61
  • Member event: 1
  • Issue comment event: 65
  • Push event: 82
  • Pull request event: 155
  • Fork event: 4

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,197
  • Total Committers: 33
  • Avg Commits per committer: 36.273
  • Development Distribution Score (DDS): 0.701
Past Year
  • Commits: 18
  • Committers: 7
  • Avg Commits per committer: 2.571
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
Grega Vrbančič g****c@g****m 358
Klemen r****2@g****m 347
firefly-cpp p****1@g****m 153
zStupan z****n@g****m 105
lucijabrezocnik 3****k 82
rhododendrom d****r@g****m 23
Francisco J. Solis s****a@g****m 17
allcontributors[bot] 4****] 17
AljoM a****c@g****m 15
Luka Pečnik l****6@g****m 13
dependabot[bot] 4****] 8
Uroš Mlakar u****r@g****m 8
Flyzoor j****c@g****m 8
pyup-bot g****t@p****o 5
RokPot r****t@g****m 5
zStupan z****n@l****n 4
Jan Banko 4****n 4
Ales a****r@s****i 4
Tadej Lahovnik t****k@s****i 3
kivancguckiran k****n@g****m 3
Grega K****! 2
Lucija Brezočnik l****a@i****i 2
Carlos Aznarán Laos c****l@u****e 1
Kristian k****a@v****i 1
GregaRubin 8****n 1
Ikko Ashimine e****r@g****m 1
Jace Browning j****g@g****m 1
Matej Moravec m****c@u****i 1
Tomas Hrnciar t****r@r****m 1
andrazperson 3****n 1
and 3 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 55
  • Total pull requests: 392
  • Average time to close issues: 5 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 24
  • Total pull request authors: 17
  • Average comments per issue: 3.35
  • Average comments per pull request: 0.71
  • Merged pull requests: 83
  • Bot issues: 1
  • Bot pull requests: 80
Past Year
  • Issues: 2
  • Pull requests: 193
  • Average time to close issues: 2 days
  • Average time to close pull requests: about 1 month
  • Issue authors: 2
  • Pull request authors: 5
  • Average comments per issue: 2.5
  • Average comments per pull request: 0.49
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 27
Top Authors
Issue Authors
  • firefly-cpp (18)
  • zStupan (7)
  • hanamthang (2)
  • sisco0 (2)
  • karakatic (2)
  • rhododendrom (2)
  • carlosal1015 (2)
  • mlaky88 (2)
  • dg-pb (1)
  • AlesGartner (1)
  • neildhir (1)
  • lahovniktadej (1)
  • todo[bot] (1)
  • hanzigs (1)
  • peacemo (1)
Pull Request Authors
  • pyup-bot (341)
  • dependabot[bot] (113)
  • zStupan (37)
  • firefly-cpp (15)
  • allcontributors[bot] (8)
  • GregaVrbancic (6)
  • lahovniktadej (4)
  • altaregos (2)
  • sisco0 (2)
  • peacemo (2)
  • AlesGartner (1)
  • eltociear (1)
  • matejmoravec (1)
  • hrnciar (1)
  • carlosal1015 (1)
Top Labels
Issue Labels
enhancement (6) bug (2) feature (2) todo :spiral_notepad: (2) help wanted (2) question (1) WIP (1) chore (1) good first issue (1)
Pull Request Labels
dependencies (111) python (107) github_actions (4) WIP (1) chore (1) feature (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 12,144 last-month
  • Total docker downloads: 26
  • Total dependent packages: 18
    (may contain duplicates)
  • Total dependent repositories: 13
    (may contain duplicates)
  • Total versions: 32
  • Total maintainers: 3
pypi.org: niapy

Python micro framework for building nature-inspired algorithms.

  • Versions: 31
  • Dependent Packages: 8
  • Dependent Repositories: 13
  • Downloads: 12,144 Last month
  • Docker Downloads: 26
Rankings
Dependent packages count: 1.3%
Docker downloads count: 3.5%
Dependent repos count: 4.0%
Stargazers count: 4.2%
Average: 4.3%
Forks count: 5.0%
Downloads: 7.4%
Maintainers (2)
Last synced: 4 months ago
alpine-v3.16: py3-niapy

Python micro framework for building nature-inspired algorithms.

  • Versions: 1
  • Dependent Packages: 10
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 5.1%
Average: 6.8%
Forks count: 10.3%
Stargazers count: 11.8%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/all_tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • tespkg/actions-cache v1 composite
.github/workflows/main.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • tespkg/actions-cache v1 composite
.github/workflows/publish_conda.yml actions
  • actions/checkout v2 composite
  • fcakyon/conda-publish-action v1.3 composite
.github/workflows/publish_pypi.yml actions
  • actions/checkout v1 composite
  • actions/setup-python v1 composite
docs/requirements.txt pypi
  • Babel >=2.5.3
  • Jinja2 >=2.10
  • MarkupSafe >=1.0
  • Pygments >=2.2.0
  • alabaster >=0.7.10
  • certifi >=2018.1.18
  • chardet >=3.0.4
  • docutils >=0.14
  • idna >=2.6
  • imagesize >=1.0.0
  • matplotlib >=3.0.2
  • numpy >=1.16.2
  • packaging >=16.8
  • pyparsing >=2.2.0
  • pytz >=2018.3
  • requests >=2.18.4
  • scipy >=1.2.1
  • six >=1.11.0
  • snowballstemmer >=1.2.1
  • sphinx >=1.8.5
  • sphinx-press-theme >=0.5.1
  • sphinxcontrib-napoleon >=0.7
  • sphinxcontrib-websupport >=1.0.1
  • urllib3 >=1.22
  • xlsxWriter >=1.1.5
setup.py pypi
  • matplotlib *
  • numpy *
  • openpyxl *
  • pandas *