diff --git a/.github/imgs/firefly_logo.png b/.github/imgs/firefly_logo.png new file mode 100644 index 0000000..9a16dcd Binary files /dev/null and b/.github/imgs/firefly_logo.png differ diff --git a/.github/templates/FEATURE_REQUEST.md b/.github/templates/FEATURE_REQUEST.md new file mode 100644 index 0000000..5a1ccc4 --- /dev/null +++ b/.github/templates/FEATURE_REQUEST.md @@ -0,0 +1,16 @@ +### Feature Request + +**About**: +**Title**: + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/templates/ISSUE_TEMPLATE.md b/.github/templates/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..90325f5 --- /dev/null +++ b/.github/templates/ISSUE_TEMPLATE.md @@ -0,0 +1,18 @@ +### Bug Report + +**About**: +**Title**: + +**Steps to reproduce** +Tell us how to reproduce the bug. + +**Expected behavior** +Tell us what should happen. + +**Actual behavior** +Tell us what happens instead. + +**System configuration** + + - OS: + - Python version: \ No newline at end of file diff --git a/.github/templates/PULL_REQUEST.md b/.github/templates/PULL_REQUEST.md new file mode 100644 index 0000000..9a87d5d --- /dev/null +++ b/.github/templates/PULL_REQUEST.md @@ -0,0 +1,14 @@ +### Summary + +Provide a general description of the code changes in your pull +request... were there any bugs you had fixed? If so, mention them. If +these bugs have open GitHub issues, be sure to tag them here as well, +to keep the conversation linked together. + +### Other Information + +If there's anything else that's important and relevant to your pull +request, mention that information here. This could include +benchmarks, or other information. + +Thanks for contributing to Firefly Algorithm! \ No newline at end of file diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index ed1dee6..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: FireflyAlgorithm - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest numpy - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..493457e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: fireflyalgorithm + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.9', '3.10', '3.11', '3.12'] + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Get full Python version + id: full-python-version + run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") + - name: Install poetry + run: | + curl -sL https://install.python-poetry.org | python - -y + - name: Update path + if: ${{ matrix.os != 'windows-latest' }} + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Update Windows path + if: ${{ matrix.os == 'windows-latest' }} + run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH + - name: Configure poetry + run: poetry config virtualenvs.in-project true + - name: Set up cache + uses: actions/cache@v3 + id: cache + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} + - name: Ensure cache is healthy + if: steps.cache.outputs.cache-hit == 'true' + run: timeout 10s poetry run pip --version || rm -rf .venv + - name: Install dependencies + run: poetry install + - name: Run tests + run: poetry run pytest diff --git a/CHANGELOG.md b/CHANGELOG.md index 889f435..ecb6ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,62 @@ # Changelog +## [0.4.2](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.4.2) (2023-12-04) + +[Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.4.1...0.4.2) + +**Merged pull requests:** + +- Contribution guide [\#20](https://github.com/firefly-cpp/FireflyAlgorithm/pull/20) ([lahovniktadej](https://github.com/lahovniktadej)) + +## [0.4.1](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.4.1) (2023-11-10) + +[Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.4.0...0.4.1) + +**Closed issues:** + +- Create Problems.md [\#18](https://github.com/firefly-cpp/FireflyAlgorithm/issues/18) + +**Merged pull requests:** + +- Add Test Function definitions [\#19](https://github.com/firefly-cpp/FireflyAlgorithm/pull/19) ([zStupan](https://github.com/zStupan)) + +## [0.4.0](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.4.0) (2023-11-06) + +[Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.3.4...0.4.0) + +**Closed issues:** + +- Enhance tests [\#16](https://github.com/firefly-cpp/FireflyAlgorithm/issues/16) +- Provide Command Line Interface \(CLI\) [\#13](https://github.com/firefly-cpp/FireflyAlgorithm/issues/13) +- Add installation instructions for Arch Linux [\#11](https://github.com/firefly-cpp/FireflyAlgorithm/issues/11) + +**Merged pull requests:** + +- Add tests [\#17](https://github.com/firefly-cpp/FireflyAlgorithm/pull/17) ([zStupan](https://github.com/zStupan)) +- Added a Command Line Interface [\#15](https://github.com/firefly-cpp/FireflyAlgorithm/pull/15) ([zStupan](https://github.com/zStupan)) +- Improve workflows [\#14](https://github.com/firefly-cpp/FireflyAlgorithm/pull/14) ([firefly-cpp](https://github.com/firefly-cpp)) +- Add instructions for install FireflyAlgorithm in Arch Linux [\#12](https://github.com/firefly-cpp/FireflyAlgorithm/pull/12) ([carlosal1015](https://github.com/carlosal1015)) + +## [0.3.4](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.3.4) (2022-12-13) + +[Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.3.3...0.3.4) + +**Merged pull requests:** + +- logo add [\#10](https://github.com/firefly-cpp/FireflyAlgorithm/pull/10) ([rhododendrom](https://github.com/rhododendrom)) + +## [0.3.3](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.3.3) (2022-10-31) + +[Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.3.2...0.3.3) + +## [0.3.2](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.3.2) (2022-07-12) + +[Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.3.1...0.3.2) + +**Merged pull requests:** + +- Rename project name in pyproject.toml [\#9](https://github.com/firefly-cpp/FireflyAlgorithm/pull/9) ([firefly-cpp](https://github.com/firefly-cpp)) + ## [0.3.1](https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.3.1) (2022-06-05) [Full Changelog](https://github.com/firefly-cpp/FireflyAlgorithm/compare/0.3...0.3.1) diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..9737ab3 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,21 @@ +abstract: Implementation of Firefly Algorithm in Python +authors: +- family-names: Fister Jr. + given-names: Iztok + orcid: 0000-0002-6418-1272 +- affiliation: '@poviolabs' + family-names: "Pe\u010Dnik" + given-names: Luka + orcid: 0000-0002-3897-9774 +- family-names: Stupan + given-names: "\u017Diga" + orcid: 0000-0001-9847-7306 +cff-version: 1.2.0 +date-released: '2023-12-25' +doi: 10.5281/zenodo.10430919 +license: +- MIT +repository-code: https://github.com/firefly-cpp/FireflyAlgorithm/tree/0.4.4 +title: 'firefly-cpp/FireflyAlgorithm: 0.4.4' +type: software +version: 0.4.4 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..7e77a3a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6162d8d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,54 @@ +# Contributing to Firefly Algorithm +:+1::tada: First off, thanks for taking the time to contribute! :tada::+1: + +## Code of Conduct +This project and everyone participating in it is governed by the [Firefly Algorithm Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [iztok.fister1@um.si](mailto:iztok.fister1@um.si). + +## How Can I Contribute? + +### Reporting Bugs +Before creating bug reports, please check existing issues list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible in the [issue template](.github/templates/ISSUE_TEMPLATE.md). + +### Suggesting Enhancements + +Open new issue using the [feature request template](.github/templates/FEATURE_REQUEST.md). + +### Pull requests + +Fill in the [pull request template](.github/templates/PULL_REQUEST.md) and make sure your code is documented. + +## Setup development environment + +### Requirements + +* Poetry: [https://python-poetry.org/docs](https://python-poetry.org/docs) + +After installing Poetry and cloning the project from GitHub, you should run the following command from the root of the cloned project: + +```sh +poetry install +``` + +All of the project's dependencies should be installed and the project ready for further development. **Note that Poetry creates a separate virtual environment for your project.** + +### Dependencies + +| Package | Version | Platform | +|----------|:-------:|:--------:| +| numpy | ^1.26.1 | All | + +#### Development dependencies + +| Package | Version | Platform | +|---------|:--------:|:--------:| +| pytest | ^7.4.3 | Any | + +## Development Tasks + +### Testing + +Manually run the tests: + +```sh +poetry run pytest +``` \ No newline at end of file diff --git a/LICENSE b/LICENSE index 0500760..0d39b71 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 firefly-cpp +Copyright (c) 2017-2023 firefly-cpp Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Problems.md b/Problems.md new file mode 100644 index 0000000..7bb3ef6 --- /dev/null +++ b/Problems.md @@ -0,0 +1,387 @@ +# Test Functions + +Bellow You'll find the definitions of all the test functions implemented in this package. + +## Ackley +***Function name:*** `ackley` + +```math +f(x) = -20 e^{-0.2 \sqrt{D^{-1} \sum\nolimits_{i=1}^D x_i^2}} - e^{D^{-1} \sum\nolimits_{i=1}^D \cos(2 \pi x_i)} + 20 + e +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Alpine 1 +***Function name:*** `alpine1` + +```math +f(x) = \sum_{i=1}^{D} \lvert {x_i \sin \left( x_i \right) + 0.1 x_i} \rvert +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Alpine 2 +***Function name:*** `alpine2` + +```math +f(x) = \prod_{i=1}^{D} \sqrt{x_i} \sin(x_i) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 2.808^D`$ for $`x_i^* = 7.917`$ + +## Cigar +***Function name:*** `cigar` + +```math +f(x) = x_1^2 + 10^6\sum_{i=2}^{D} x_i^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Cosine Mixture +***Function name:*** `cosine_mixture` + +```math +f(x) = -0.1 \sum_{i=1}^D \cos (5 \pi x_i) - \sum_{i=1}^D x_i^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = -0.1 D`$ for $`x_i^* = 0`$ + +## Csendes +***Function name:*** `csendes` + +```math +f(x) = \sum_{i=1}^D x_i^6 \left( 2 + \sin \frac{1}{x_i}\right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Dixon-Price +***Function name:*** `dixon_price` + +```math +f(x) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 2^{- \frac{(2^i - 2)}{2^i}}`$ + +## Griewank +***Function name:*** `griewank` + +```math +f(x) = \sum_{i=1}^D \frac{x_i^2}{4000} - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Katsuura +***Function name:*** `katsuura` + +```math +\prod_{i=1}^D \left(1 + i \sum_{j=1}^{32} \frac{\lvert 2^j x_i - round\left(2^j x_i \right) \rvert}{2^j} \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 1`$ for $`x_i^* = 0`$ + +## Levy +***Function name:*** `levy` + +```math + \begin{gather} + \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)),\,\text{where}\\ + w_i = 1 + \frac{x_i - 1}{4},\, \text{for all } i = 1, \ldots, D + \end{gather} + +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 1`$ + +## Michalewicz +***Function name:*** `michalewicz` + +```math +f(x) = - \sum_{i = 1}^{D} \sin(x_i) \sin^{2m}\left( \frac{ix_i^2}{\pi} \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`\text{at } D=2,\,f(x^*) = -1.8013`$ for $`x^* = (2.20, 1.57)`$ + +## Perm 1 +***Function name:*** `perm1` + +```math +f(x) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j^i + \beta) \left( \left(\frac{x_j}{j}\right)^i - 1 \right) \right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = i`$ + +## Perm 2 +***Function name:*** `perm2` + +```math +f(x) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = \frac{1}{i}`$ + +## Pinter +***Function name:*** `pinter` + +```math +f(x) = \sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2),\, \text{where} +``` +```math +\begin{align} +A &= (x_{i-1}\sin(x_i)+\sin(x_{i+1})) \\ +B &= (x_{i-1}^2 - 2x_i + 3x_{i+1} - \cos(x_i) + 1) +\end{align} +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Powell +***Function name:*** `powell` + +```math +f(x) = \sum_{i = 1}^{D/4} \left[ (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Qing +***Function name:*** `qing` + +```math +f(x) = \sum_{i=1}^D \left(x_i^2 - i\right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = \pm \sqrt{i}`$ + +## Quintic +***Function name:*** `quintic` + +```math +f(x) = \sum_{i=1}^D \left| x_i^5 - 3x_i^4 + 4x_i^3 + 2x_i^2 - 10x_i - 4\right| +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = -1\quad \text{or} \quad x_i^* = 2`$ + +## Rastrigin +***Function name:*** `rastrigin` + +```math +f(x) = 10D + \sum_{i=1}^D \left[x_i^2 -10\cos(2\pi x_i)\right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Rosenbrock +***Function name:*** `rosenbrock` + +```math +f(x) = \sum_{i=1}^{D-1} \left[100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2 \right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 1`$ + +## Salomon +***Function name:*** `salomon` + +```math +f(x) = 1 - \cos\left(2\pi\sqrt{\sum\nolimits_{i=1}^D x_i^2} \right)+ 0.1 \sqrt{\sum\nolimits_{i=1}^D x_i^2} +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Schaffer 2 +***Function name:*** `schaffer2` + +```math +f(x) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left[ 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right]^2 } +``` + +**Dimensions:** 2 + +**Global optimum:** $`f(x^*) = 0`$ for $`x^* = (0, 0)`$ + +## Schaffer 4 +***Function name:*** `schaffer4` + +```math +f(x) = 0.5 + \frac{ \cos^2 \left( \sin \left( \vert x_1^2 - x_2^2\vert \right) \right)- 0.5 }{ \left[ 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right]^2 } +``` + +**Dimensions:** 2 + +**Global optimum:** $`f(x^*) = 0.292579`$ for $`x^* = (0, \pm 1.25313) \text{or} (\pm 1.25313, 0)`$ + +## Schwefel +***Function name:*** `schwefel` + +```math +f(x) = 418.9829D - \sum_{i=1}^{D} x_i \sin(\sqrt{\lvert x_i \rvert}) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 420.9687`$ + +## Schwefel 2.21 +***Function name:*** `schwefel221` + +```math +f(x) = \max_{1 \leq i \leq D} \vert x_i\vert +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Schwefel 2.22 +***Function name:*** `schwefel222` + +```math +f(x) = \sum_{i=1}^{D} \lvert x_i \rvert +\prod_{i=1}^{D} \lvert x_i \rvert +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Sphere +***Function name:*** `sphere` + +```math +f(x) = \sum_{i=1}^D x_i^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Step +***Function name:*** `step` + +```math +f(x) = \sum_{i=1}^D \left( \lfloor \lvert x_i \rvert \rfloor \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Step 2 +***Function name:*** `step2` + +```math +f(x) = \sum_{i=1}^D \left( \lfloor x_i + 0.5 \rfloor \right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = -0.5`$ + +## Styblinski-Tang +***Function name:*** `styblinski_tang` + +```math + +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = -39.16599 D`$ for $`x_i^* = -2.903534`$ + +## Trid +***Function name:*** `trid` + +```math +f(x) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1} +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = \frac{-D (D + 4) (D - 1)}{6}`$ for $`x_i^* = i (d + 1 - i)`$ + +## Weierstrass +***Function name:*** `weierstrass` + +```math +f(x) = \sum_{i=1}^D \left[ \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right] - D \sum_{k=0}^{k_{max}} a^k \cos \left(\pi b^k \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Whitley +***Function name:*** `whitley` + +```math +f(x) = \sum_{i=1}^D \sum_{j=1}^D \left[\frac{(100(x_i^2-x_j)^2 + (1-x_j)^2)^2}{4000} - \cos(100(x_i^2-x_j)^2 + (1-x_j)^2)+1\right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 1`$ + +## Zakharov +***Function name:*** `zakharov` + +```math +f(x) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + + +# References + +[1] P. Ernesto and U. Diliman, [“MVF–Multivariate Test Functions Library in C for Unconstrained Global Optimization,”](http://www.geocities.ws/eadorio/mvf.pdf) University of the Philippines Diliman, Quezon City, 2005. + +[2] M. Jamil and X.-S. Yang, [“A literature survey of benchmark functions for global optimisation problems,”](https://arxiv.org/abs/1308.4008) International Journal of Mathematical Modelling and Numerical Optimisation, vol. 4, no. 2, p. 150, Jan. 2013, doi: 10.1504/ijmmno.2013.055204. + +[3] J. J. Liang, B. Y. Qu, and P. N. Suganthan, [“Problem definitions and evaluation criteria for the CEC 2014 special session and competition on single objective real-parameter numerical optimization,”](http://bee22.com/manual/tf_images/Liang%20CEC2014.pdf) Computational Intelligence Laboratory, Zhengzhou University, Zhengzhou China and Technical Report, Nanyang Technological University, Singapore, vol. 635, no. 2, 2013. + +[4] S. Surjanovic and D. Bingham, Virtual Library of Simulation Experiments: Test Functions and Datasets. Retrieved November 7, 2023, from https://www.sfu.ca/~ssurjano/. diff --git a/README.md b/README.md index 83f0c30..b0a5485 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,49 @@ -# Firefly Algorithm --- Implementation of Firefly algorithm in Python +

+ +

---- +

+Firefly Algorithm --- Implementation of Firefly algorithm in Python +

-[![PyPI Version](https://img.shields.io/pypi/v/fireflyalgorithm.svg)](https://pypi.python.org/pypi/fireflyalgorithm) -![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fireflyalgorithm.svg) -![PyPI - Downloads](https://img.shields.io/pypi/dm/fireflyalgorithm.svg) -[![Downloads](https://pepy.tech/badge/fireflyalgorithm)](https://pepy.tech/project/fireflyalgorithm) -[![GitHub license](https://img.shields.io/github/license/firefly-cpp/FireflyAlgorithm.svg)](https://github.com/firefly-cpp/FireflyAlgorithm/blob/master/LICENSE) -![GitHub commit activity](https://img.shields.io/github/commit-activity/w/firefly-cpp/FireflyAlgorithm.svg) -[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/firefly-cpp/FireflyAlgorithm.svg)](http://isitmaintained.com/project/firefly-cpp/FireflyAlgorithm "Average time to resolve an issue") -[![Percentage of issues still open](http://isitmaintained.com/badge/open/firefly-cpp/FireflyAlgorithm.svg)](http://isitmaintained.com/project/firefly-cpp/FireflyAlgorithm "Percentage of issues still open") -![GitHub contributors](https://img.shields.io/github/contributors/firefly-cpp/FireflyAlgorithm.svg) +

+ PyPI Version + PyPI - Python Version + Downloads + GitHub repo size + AUR package + GitHub license + build +

-## Installation: +

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

+

+ DOI +

+ +

+ 📋 About • + 📦 Installation • + 🚀 Usage • + 📚 Reference Papers • + 📄 Cite us • + 🔑 License +

+ +## 📋 About + +This package implements a nature-inspired algorithm for optimization called Firefly Algorithm (FA) in Python programming language. 🌿🔍💻 + +## 📦 Installation + +To install FireflyAlgorithm with pip, use: ```sh pip install fireflyalgorithm ``` @@ -21,15 +51,20 @@ To install FireflyAlgorithm on Fedora, use: ```sh dnf install python-fireflyalgorithm ``` +To install FireflyAlgorithm on Arch Linux, please use an [AUR helper](https://wiki.archlinux.org/title/AUR_helpers): +```sh +$ yay -Syyu python-fireflyalgorithm +``` +To install FireflyAlgorithm on Alpine Linux, use: +```sh +$ apk add py3-fireflyalgorithm +``` -## Usage: +## 🚀 Usage ```python -import numpy as np from fireflyalgorithm import FireflyAlgorithm - -def sphere(x): - return np.sum(x ** 2) +from fireflyalgorithm.problems import sphere FA = FireflyAlgorithm() best = FA.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000) @@ -37,12 +72,70 @@ best = FA.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000) print(best) ``` -## Reference Papers: +### Test functions 📈 + +In the `fireflyalgorithm.problems` module, you can find the implementations of 33 popular optimization test problems. Additionally, the module provides a utility function, `get_problem`, that allows you to retrieve a specific optimization problem function by providing its name as a string: + +```python +from fireflyalgorithm.problems import get_problem + +# same as from fireflyalgorithm.problems import rosenbrock +rosenbrock = get_problem('rosenbrock') +``` + +For more information about the implemented test functions, [click here](Problems.md). -I. Fister Jr., X.-S. Yang, I. Fister, J. Brest. [Memetic firefly algorithm for combinatorial optimization](http://www.iztok-jr-fister.eu/static/publications/44.pdf) in Bioinspired Optimization Methods and their Applications (BIOMA 2012), B. Filipic and J.Silc, Eds. +### Command line interface 🖥️ + +The package also comes with a simple command line interface which allows you to evaluate the algorithm on several popular test functions. 🔬 + +```shell +firefly-algorithm -h +``` + +```text +usage: firefly-algorithm [-h] --problem PROBLEM -d DIMENSION -l LOWER -u UPPER -nfes MAX_EVALS [-r RUNS] [--pop-size POP_SIZE] [--alpha ALPHA] [--beta-min BETA_MIN] [--gamma GAMMA] [--seed SEED] + +Evaluate the Firefly Algorithm on one or more test functions + +options: + -h, --help show this help message and exit + --problem PROBLEM Test problem to evaluate + -d DIMENSION, --dimension DIMENSION + Dimension of the problem + -l LOWER, --lower LOWER + Lower bounds of the problem + -u UPPER, --upper UPPER + Upper bounds of the problem + -nfes MAX_EVALS, --max-evals MAX_EVALS + Max number of fitness function evaluations + -r RUNS, --runs RUNS Number of runs of the algorithm + --pop-size POP_SIZE Population size + --alpha ALPHA Randomness strength + --beta-min BETA_MIN Attractiveness constant + --gamma GAMMA Absorption coefficient + --seed SEED Seed for the random number generator +``` + +**Note:** The CLI script can also run as a python module (python -m fireflyalgorithm ...). + + +## 📚 Reference Papers + +I. Fister Jr., X.-S. Yang, I. Fister, J. Brest, D. Fister. [A Brief Review of Nature-Inspired Algorithms for Optimization](http://www.iztok-jr-fister.eu/static/publications/21.pdf). Elektrotehniški vestnik, 80(3), 116-122, 2013. + +I. Fister Jr., X.-S. Yang, I. Fister, J. Brest. [Memetic firefly algorithm for combinatorial optimization](http://www.iztok-jr-fister.eu/static/publications/44.pdf) in Bioinspired Optimization Methods and their Applications (BIOMA 2012), B. Filipic and J.Silc, Eds. Jozef Stefan Institute, Ljubljana, Slovenia, 2012 -I. Fister, I. Fister Jr., X.-S. Yang, J. Brest. [A comprehensive review of firefly algorithms](http://www.iztok-jr-fister.eu/static/publications/23.pdf). Swarm and Evolutionary Computation 13 (2013): 34-46. +I. Fister, I. Fister Jr., X.-S. Yang, J. Brest. [A comprehensive review of firefly algorithms](http://www.iztok-jr-fister.eu/static/publications/23.pdf). Swarm and Evolutionary Computation 13 (2013): 34-46. + +## 📄 Cite us + +Fister Jr., I., Pečnik, L., & Stupan, Ž. (2023). firefly-cpp/FireflyAlgorithm: 0.4.3 (0.4.3). Zenodo. [https://doi.org/10.5281/zenodo.10430919](https://doi.org/10.5281/zenodo.10430919) + +## 🔑 License + +This package is distributed under the MIT License. This license can be found online at . ## Disclaimer diff --git a/examples/run.py b/examples/run.py index 8597751..645070a 100644 --- a/examples/run.py +++ b/examples/run.py @@ -1,9 +1,5 @@ -import numpy as np from fireflyalgorithm import FireflyAlgorithm - - -def sphere(x): - return np.sum(x ** 2) +from fireflyalgorithm.problems import sphere FA = FireflyAlgorithm() diff --git a/fireflyalgorithm/__init__.py b/fireflyalgorithm/__init__.py index 7992490..feb6d54 100644 --- a/fireflyalgorithm/__init__.py +++ b/fireflyalgorithm/__init__.py @@ -1,5 +1,5 @@ from fireflyalgorithm.fireflyalgorithm import FireflyAlgorithm -__all__ = ['FireflyAlgorithm'] +__all__ = ["FireflyAlgorithm"] -__version__ = '0.3.2' +__version__ = "0.4.6" diff --git a/fireflyalgorithm/__main__.py b/fireflyalgorithm/__main__.py new file mode 100644 index 0000000..75c1ac9 --- /dev/null +++ b/fireflyalgorithm/__main__.py @@ -0,0 +1,6 @@ +import sys +from fireflyalgorithm import cli + + +if __name__ == "__main__": + sys.exit(cli.main()) diff --git a/fireflyalgorithm/cli.py b/fireflyalgorithm/cli.py new file mode 100644 index 0000000..b08d4fd --- /dev/null +++ b/fireflyalgorithm/cli.py @@ -0,0 +1,79 @@ +import argparse +import numpy as np +from fireflyalgorithm.problems import PROBLEMS, get_problem +from fireflyalgorithm.fireflyalgorithm import FireflyAlgorithm + + +def get_parser(): + parser = argparse.ArgumentParser( + prog="firefly-algorithm", + description="Evaluate the Firefly Algorithm on one or more test functions", + ) + + problem_functions = list(PROBLEMS.keys()) + parser.add_argument( + "--problem", + type=str, + required=True, + choices=problem_functions, + metavar="PROBLEM", + help="Test problem to evaluate", + ) + parser.add_argument( + "-d", "--dimension", type=int, required=True, help="Dimension of the problem" + ) + parser.add_argument( + "-l", "--lower", type=float, required=True, help="Lower bounds of the problem" + ) + parser.add_argument( + "-u", "--upper", type=float, required=True, help="Upper bounds of the problem" + ) + parser.add_argument( + "-nfes", + "--max-evals", + type=int, + required=True, + help="Max number of fitness function evaluations", + ) + parser.add_argument( + "-r", "--runs", type=int, default=1, help="Number of runs of the algorithm" + ) + parser.add_argument("--pop-size", type=int, default=20, help="Population size") + parser.add_argument("--alpha", type=float, default=1.0, help="Randomness strength") + parser.add_argument( + "--beta-min", type=float, default=1.0, help="Attractiveness constant" + ) + parser.add_argument( + "--gamma", type=float, default=0.01, help="Absorption coefficient" + ) + parser.add_argument("--seed", type=int, help="Seed for the random number generator") + return parser + + +def main(): + parser = get_parser() + args = parser.parse_args() + + algorithm = FireflyAlgorithm( + args.pop_size, args.alpha, args.beta_min, args.gamma, args.seed + ) + problem = get_problem(args.problem) + dim = args.dimension + lb = args.lower + ub = args.upper + max_evals = args.max_evals + runs = args.runs + + fitness = np.empty(runs) + for i in range(runs): + fitness[i] = algorithm.run(problem, dim, lb, ub, max_evals) + + if runs == 1: + print(f"Best fitness: {fitness[0]}") + else: + print(f"Best: {fitness.min()}") + print(f"Worst: {fitness.max()}") + print(f"Mean: {fitness.mean()}") + print(f"Std: {fitness.std()}") + + return 0 diff --git a/fireflyalgorithm/problems.py b/fireflyalgorithm/problems.py new file mode 100644 index 0000000..c0718cc --- /dev/null +++ b/fireflyalgorithm/problems.py @@ -0,0 +1,270 @@ +import numpy as np + + +def ackley(x): + a = 20 + b = 0.2 + c = 2 * np.pi + dim = len(x) + + val1 = np.sum(np.square(x)) + val2 = np.sum(np.cos(c * x)) + + temp1 = -b * np.sqrt(val1 / dim) + temp2 = val2 / dim + + return -a * np.exp(temp1) - np.exp(temp2) + a + np.exp(1) + + +def alpine1(x): + return np.sum(np.abs(np.sin(x) + 0.1 * x)) + + +def alpine2(x): + return np.prod(np.sqrt(x) * np.sin(x)) + + +def cigar(x): + return x[0] ** 2 + 1000000 * np.sum(x[1:] ** 2) + + +def cosine_mixture(x): + return -0.1 * np.sum(np.cos(5 * np.pi * x)) - np.sum(x**2) + + +def csendes(x): + mask = x != 0 + return np.sum(np.power(x[mask], 6) * (2 + np.sin(1 / x[mask]))) + + +def dixon_price(x): + dim = len(x) + indices = np.arange(2, dim) + val = np.sum(indices * (2 * x[2:] ** 2 - x[1 : dim - 1]) ** 2) + return (x[0] - 1) ** 2 + val + + +def griewank(x): + dim = len(x) + i = np.arange(1, dim + 1) + val1 = np.sum(x**2 / 4000) + val2 = np.prod(np.cos(x / np.sqrt(i))) + return val1 - val2 + 1 + + +def katsuura(x): + dim = len(x) + k = np.atleast_2d(np.arange(1, 33)).T + i = np.arange(1, dim + 1) + inner = np.round(2**k * x) * (2.0 ** (-k)) + return np.prod(np.sum(inner, axis=0) * i + 1) + + +def levy(x): + w = 1 + (x - 1) / 4 + wi = w[:-1] + term1 = np.sin(np.pi * w[0]) ** 2 + term2 = np.sum((wi - 1) ** 2 * (1 + 10 * np.sin(np.pi * wi + 1))) + term3 = (w[-1] - 1) ** 2 * (1 + np.sin(2 * np.pi * w[-1]) ** 2) + return term1 + term2 + term3 + + +def michalewicz(x): + dim = len(x) + m = 10 + i = np.arange(1, dim + 1) + return -np.sum(np.sin(x) * np.sin(i * x**2 / np.pi) ** (2 * m)) + + +def perm1(x): + dim = len(x) + beta = 0.5 + k = np.atleast_2d(np.arange(dim) + 1).T + j = np.atleast_2d(np.arange(dim) + 1) + s = (j**k + beta) * ((x / j) ** k - 1) + return np.sum(np.sum(s, axis=1) ** 2) + + +def perm2(x): + dim = len(x) + beta = 10 + k = np.atleast_2d(np.arange(dim) + 1).T + j = np.atleast_2d(np.arange(dim) + 1) + s = (j + beta) * (x**k - (1 / j) ** k) + return np.sum(np.sum(s, axis=1) ** 2) + + +def pinter(x): + dim = len(x) + x = np.asarray(x) + sub = np.roll(x, 1) + add = np.roll(x, -1) + indices = np.arange(1, dim + 1) + + a = sub * np.sin(x) + np.sin(add) + b = (sub * sub) - 2 * x + 3 * add - np.cos(x) + 1 + + val1 = np.sum(indices * x * x) + val2 = np.sum(20 * indices * np.power(np.sin(a), 2)) + val3 = np.sum(indices * np.log10(1 + indices * np.power(b, 2))) + + return val1 + val2 + val3 + + +def powell(x): + x1 = x[0::4] + x2 = x[1::4] + x3 = x[2::4] + x4 = x[3::4] + + term1 = (x1 + 10 * x2) ** 2 + term2 = 5 * (x3 - x4) ** 2 + term3 = (x2 - 2 * x3) ** 4 + term4 = 10 * (x1 - x4) ** 4 + return np.sum(term1 + term2 + term3 + term4) + + +def qing(x): + dim = len(x) + return np.sum(np.power(x**2 - np.arange(1, dim + 1), 2)) + + +def quintic(x): + return np.sum(np.abs(x**5 - 3 * x**4 + 4 * x**3 + 2 * x**2 - 10 * x - 4)) + + +def rastrigin(x): + dim = len(x) + return 10 * dim + np.sum(x**2 - 10 * np.cos(2 * np.pi * x)) + + +def rosenbrock(x): + return np.sum(100.0 * (x[1:] - x[:-1] ** 2) ** 2 + (1 - x[:-1]) ** 2, axis=0) + + +def salomon(x): + val = np.sqrt(np.sum(x**2)) + return 1 - np.cos(2 * np.pi * val) + 0.1 * val + + +def schaffer2(x): + return ( + 0.5 + + (np.sin(x[0] ** 2 - x[1] ** 2) ** 2 - 0.5) + / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 + ) + + +def schaffer4(x): + return ( + 0.5 + + (np.cos(np.sin(abs(x[0] ** 2 - x[1] ** 2))) ** 2 - 0.5) + / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 + ) + + +def schwefel(x): + dim = len(x) + return 418.982887272433799807913601398 * dim - np.sum( + x * np.sin(np.sqrt(np.abs(x))) + ) + + +def schwefel221(x): + return np.amax(np.abs(x)) + + +def schwefel222(x): + return np.sum(np.abs(x)) + np.prod(np.abs(x)) + + +def sphere(x): + return np.sum(x**2) + + +def step(x): + return np.sum(np.floor(np.abs(x))) + + +def step2(x): + return np.sum(np.floor(x + 0.5) ** 2) + + +def styblinski_tang(x): + return 0.5 * np.sum(x**4 - 16 * x**2 + 5 * x) + + +def trid(x): + sum1 = np.sum((x - 1) ** 2) + sum2 = np.sum(x[1:] * x[:-1]) + return sum1 - sum2 + + +def weierstrass(x): + dim = len(x) + kmax = 20 + a = 0.5 + b = 3 + + k = np.atleast_2d(np.arange(kmax + 1)).T + t1 = a**k * np.cos(2 * np.pi * b**k * (x + 0.5)) + t2 = dim * np.sum(a**k.T * np.cos(np.pi * b**k.T)) + + return np.sum(np.sum(t1, axis=0)) - t2 + + +def whitley(x): + xi = x + xj = np.atleast_2d(x).T + + temp = 100 * ((xi**2) - xj) + (1 - xj) ** 2 + inner = (temp**2 / 4000) - np.cos(temp) + 1 + return np.sum(np.sum(inner, axis=0)) + + +def zakharov(x): + dim = len(x) + sum1 = np.sum(x**2) + sum2 = 0.5 * np.sum(np.arange(1, dim + 1) * x) + return sum1 + sum2**2 + sum2**4 + + +PROBLEMS = { + "ackley": ackley, + "alpine1": alpine1, + "alpine2": alpine2, + "cigar": cigar, + "cosine_mixture": cosine_mixture, + "csendes": csendes, + "dixon_price": dixon_price, + "griewank": griewank, + "katsuura": katsuura, + "levy": levy, + "michalewicz": michalewicz, + "perm1": perm1, + "perm2": perm2, + "pinter": pinter, + "powell": powell, + "qing": qing, + "quintic": quintic, + "rastrigin": rastrigin, + "rosenbrock": rosenbrock, + "salomon": salomon, + "schaffer2": schaffer2, + "schaffer4": schaffer4, + "schwefel": schwefel, + "schwefel221": schwefel221, + "schwefel222": schwefel222, + "sphere": sphere, + "step": step, + "step2": step2, + "styblinski_tang": styblinski_tang, + "trid": trid, + "weierstrass": weierstrass, + "whitley": whitley, + "zakharov": zakharov, +} + + +def get_problem(name): + return PROBLEMS[name] diff --git a/poetry.lock b/poetry.lock index 01061cd..3c04aca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,76 +1,176 @@ +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. + [[package]] -name = "numpy" -version = "1.21.5" -description = "NumPy is the fundamental package for array computing with Python." -category = "main" +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." optional = false -python-versions = ">=3.7,<3.11" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.2" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] [[package]] name = "numpy" -version = "1.22.0" -description = "NumPy is the fundamental package for array computing with Python." -category = "main" +version = "1.26.4" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.9" +files = [ + {file = "numpy-1.26.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ff0f4f29c51e2803569d7a51c2304de5554655a60c5d776e35b4a41413830d0"}, + {file = "numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2e4ee3380d6de9c9ec04745830fd9e2eccb3e6cf790d39d7b98ffd19b0dd754a"}, + {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d209d8969599b27ad20994c8e41936ee0964e6da07478d6c35016bc386b66ad4"}, + {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f"}, + {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:62b8e4b1e28009ef2846b4c7852046736bab361f7aeadeb6a5b89ebec3c7055a"}, + {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a4abb4f9001ad2858e7ac189089c42178fcce737e4169dc61321660f1a96c7d2"}, + {file = "numpy-1.26.4-cp310-cp310-win32.whl", hash = "sha256:bfe25acf8b437eb2a8b2d49d443800a5f18508cd811fea3181723922a8a82b07"}, + {file = "numpy-1.26.4-cp310-cp310-win_amd64.whl", hash = "sha256:b97fe8060236edf3662adfc2c633f56a08ae30560c56310562cb4f95500022d5"}, + {file = "numpy-1.26.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c66707fabe114439db9068ee468c26bbdf909cac0fb58686a42a24de1760c71"}, + {file = "numpy-1.26.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:edd8b5fe47dab091176d21bb6de568acdd906d1887a4584a15a9a96a1dca06ef"}, + {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ab55401287bfec946ced39700c053796e7cc0e3acbef09993a9ad2adba6ca6e"}, + {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5"}, + {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:96ff0b2ad353d8f990b63294c8986f1ec3cb19d749234014f4e7eb0112ceba5a"}, + {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:60dedbb91afcbfdc9bc0b1f3f402804070deed7392c23eb7a7f07fa857868e8a"}, + {file = "numpy-1.26.4-cp311-cp311-win32.whl", hash = "sha256:1af303d6b2210eb850fcf03064d364652b7120803a0b872f5211f5234b399f20"}, + {file = "numpy-1.26.4-cp311-cp311-win_amd64.whl", hash = "sha256:cd25bcecc4974d09257ffcd1f098ee778f7834c3ad767fe5db785be9a4aa9cb2"}, + {file = "numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b3ce300f3644fb06443ee2222c2201dd3a89ea6040541412b8fa189341847218"}, + {file = "numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:03a8c78d01d9781b28a6989f6fa1bb2c4f2d51201cf99d3dd875df6fbd96b23b"}, + {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b"}, + {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:675d61ffbfa78604709862923189bad94014bef562cc35cf61d3a07bba02a7ed"}, + {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:ab47dbe5cc8210f55aa58e4805fe224dac469cde56b9f731a4c098b91917159a"}, + {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1dda2e7b4ec9dd512f84935c5f126c8bd8b9f2fc001e9f54af255e8c5f16b0e0"}, + {file = "numpy-1.26.4-cp312-cp312-win32.whl", hash = "sha256:50193e430acfc1346175fcbdaa28ffec49947a06918b7b92130744e81e640110"}, + {file = "numpy-1.26.4-cp312-cp312-win_amd64.whl", hash = "sha256:08beddf13648eb95f8d867350f6a018a4be2e5ad54c8d8caed89ebca558b2818"}, + {file = "numpy-1.26.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7349ab0fa0c429c82442a27a9673fc802ffdb7c7775fad780226cb234965e53c"}, + {file = "numpy-1.26.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:52b8b60467cd7dd1e9ed082188b4e6bb35aa5cdd01777621a1658910745b90be"}, + {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5241e0a80d808d70546c697135da2c613f30e28251ff8307eb72ba696945764"}, + {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f870204a840a60da0b12273ef34f7051e98c3b5961b61b0c2c1be6dfd64fbcd3"}, + {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:679b0076f67ecc0138fd2ede3a8fd196dddc2ad3254069bcb9faf9a79b1cebcd"}, + {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:47711010ad8555514b434df65f7d7b076bb8261df1ca9bb78f53d3b2db02e95c"}, + {file = "numpy-1.26.4-cp39-cp39-win32.whl", hash = "sha256:a354325ee03388678242a4d7ebcd08b5c727033fcff3b2f536aea978e15ee9e6"}, + {file = "numpy-1.26.4-cp39-cp39-win_amd64.whl", hash = "sha256:3373d5d70a5fe74a2c1bb6d2cfd9609ecf686d47a2d7b1d37a8f3b6bf6003aea"}, + {file = "numpy-1.26.4-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:afedb719a9dcfc7eaf2287b839d8198e06dcd4cb5d276a3df279231138e83d30"}, + {file = "numpy-1.26.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95a7476c59002f2f6c590b9b7b998306fba6a5aa646b1e22ddfeaf8f78c3a29c"}, + {file = "numpy-1.26.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7e50d0a0cc3189f9cb0aeb3a6a6af18c16f59f004b866cd2be1c14b36134a4a0"}, + {file = "numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010"}, +] + +[[package]] +name = "packaging" +version = "24.2" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, +] + +[[package]] +name = "pluggy" +version = "1.5.0" +description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" +files = [ + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, +] -[metadata] -lock-version = "1.1" -python-versions = "^3.7" -content-hash = "e578f616a2df32b9a4a3e27da71545e65bd1ae9544982e3067f8363e69bf7136" +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] -[metadata.files] -numpy = [ - {file = "numpy-1.21.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:301e408a052fdcda5cdcf03021ebafc3c6ea093021bf9d1aa47c54d48bdad166"}, - {file = "numpy-1.21.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a7e8f6216f180f3fd4efb73de5d1eaefb5f5a1ee5b645c67333033e39440e63a"}, - {file = "numpy-1.21.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fc7a7d7b0ed72589fd8b8486b9b42a564f10b8762be8bd4d9df94b807af4a089"}, - {file = "numpy-1.21.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:58ca1d7c8aef6e996112d0ce873ac9dfa1eaf4a1196b4ff7ff73880a09923ba7"}, - {file = "numpy-1.21.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc4b2fb01f1b4ddbe2453468ea0719f4dbb1f5caa712c8b21bb3dd1480cd30d9"}, - {file = "numpy-1.21.5-cp310-cp310-win_amd64.whl", hash = "sha256:cc1b30205d138d1005adb52087ff45708febbef0e420386f58664f984ef56954"}, - {file = "numpy-1.21.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:08de8472d9f7571f9d51b27b75e827f5296295fa78817032e84464be8bb905bc"}, - {file = "numpy-1.21.5-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4fe6a006557b87b352c04596a6e3f12a57d6e5f401d804947bd3188e6b0e0e76"}, - {file = "numpy-1.21.5-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3d893b0871322eaa2f8c7072cdb552d8e2b27645b7875a70833c31e9274d4611"}, - {file = "numpy-1.21.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:341dddcfe3b7b6427a28a27baa59af5ad51baa59bfec3264f1ab287aa3b30b13"}, - {file = "numpy-1.21.5-cp37-cp37m-win32.whl", hash = "sha256:ca9c23848292c6fe0a19d212790e62f398fd9609aaa838859be8459bfbe558aa"}, - {file = "numpy-1.21.5-cp37-cp37m-win_amd64.whl", hash = "sha256:025b497014bc33fc23897859350f284323f32a2fff7654697f5a5fc2a19e9939"}, - {file = "numpy-1.21.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:3a5098df115340fb17fc93867317a947e1dcd978c3888c5ddb118366095851f8"}, - {file = "numpy-1.21.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:311283acf880cfcc20369201bd75da907909afc4666966c7895cbed6f9d2c640"}, - {file = "numpy-1.21.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b545ebadaa2b878c8630e5bcdb97fc4096e779f335fc0f943547c1c91540c815"}, - {file = "numpy-1.21.5-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:c5562bcc1a9b61960fc8950ade44d00e3de28f891af0acc96307c73613d18f6e"}, - {file = "numpy-1.21.5-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:eed2afaa97ec33b4411995be12f8bdb95c87984eaa28d76cf628970c8a2d689a"}, - {file = "numpy-1.21.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:61bada43d494515d5b122f4532af226fdb5ee08fe5b5918b111279843dc6836a"}, - {file = "numpy-1.21.5-cp38-cp38-win32.whl", hash = "sha256:7b9d6b14fc9a4864b08d1ba57d732b248f0e482c7b2ff55c313137e3ed4d8449"}, - {file = "numpy-1.21.5-cp38-cp38-win_amd64.whl", hash = "sha256:dbce7adeb66b895c6aaa1fad796aaefc299ced597f6fbd9ceddb0dd735245354"}, - {file = "numpy-1.21.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:507c05c7a37b3683eb08a3ff993bd1ee1e6c752f77c2f275260533b265ecdb6c"}, - {file = "numpy-1.21.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:00c9fa73a6989895b8815d98300a20ac993c49ac36c8277e8ffeaa3631c0dbbb"}, - {file = "numpy-1.21.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:69a5a8d71c308d7ef33ef72371c2388a90e3495dbb7993430e674006f94797d5"}, - {file = "numpy-1.21.5-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2d8adfca843bc46ac199a4645233f13abf2011a0b2f4affc5c37cd552626f27b"}, - {file = "numpy-1.21.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:c293d3c0321996cd8ffe84215ffe5d269fd9d1d12c6f4ffe2b597a7c30d3e593"}, - {file = "numpy-1.21.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c978544be9e04ed12016dd295a74283773149b48f507d69b36f91aa90a643e5"}, - {file = "numpy-1.21.5-cp39-cp39-win32.whl", hash = "sha256:2a9add27d7fc0fdb572abc3b2486eb3b1395da71e0254c5552b2aad2a18b5441"}, - {file = "numpy-1.21.5-cp39-cp39-win_amd64.whl", hash = "sha256:1964db2d4a00348b7a60ee9d013c8cb0c566644a589eaa80995126eac3b99ced"}, - {file = "numpy-1.21.5-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a7c4b701ca418cd39e28ec3b496e6388fe06de83f5f0cb74794fa31cfa384c02"}, - {file = "numpy-1.21.5.zip", hash = "sha256:6a5928bc6241264dce5ed509e66f33676fc97f464e7a919edc672fb5532221ee"}, - {file = "numpy-1.22.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3d22662b4b10112c545c91a0741f2436f8ca979ab3d69d03d19322aa970f9695"}, - {file = "numpy-1.22.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:11a1f3816ea82eed4178102c56281782690ab5993251fdfd75039aad4d20385f"}, - {file = "numpy-1.22.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5dc65644f75a4c2970f21394ad8bea1a844104f0fe01f278631be1c7eae27226"}, - {file = "numpy-1.22.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42c16cec1c8cf2728f1d539bd55aaa9d6bb48a7de2f41eb944697293ef65a559"}, - {file = "numpy-1.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a97e82c39d9856fe7d4f9b86d8a1e66eff99cf3a8b7ba48202f659703d27c46f"}, - {file = "numpy-1.22.0-cp310-cp310-win_amd64.whl", hash = "sha256:e41e8951749c4b5c9a2dc5fdbc1a4eec6ab2a140fdae9b460b0f557eed870f4d"}, - {file = "numpy-1.22.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:bece0a4a49e60e472a6d1f70ac6cdea00f9ab80ff01132f96bd970cdd8a9e5a9"}, - {file = "numpy-1.22.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:818b9be7900e8dc23e013a92779135623476f44a0de58b40c32a15368c01d471"}, - {file = "numpy-1.22.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:47ee7a839f5885bc0c63a74aabb91f6f40d7d7b639253768c4199b37aede7982"}, - {file = "numpy-1.22.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a024181d7aef0004d76fb3bce2a4c9f2e67a609a9e2a6ff2571d30e9976aa383"}, - {file = "numpy-1.22.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f71d57cc8645f14816ae249407d309be250ad8de93ef61d9709b45a0ddf4050c"}, - {file = "numpy-1.22.0-cp38-cp38-win32.whl", hash = "sha256:283d9de87c0133ef98f93dfc09fad3fb382f2a15580de75c02b5bb36a5a159a5"}, - {file = "numpy-1.22.0-cp38-cp38-win_amd64.whl", hash = "sha256:2762331de395739c91f1abb88041f94a080cb1143aeec791b3b223976228af3f"}, - {file = "numpy-1.22.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:76ba7c40e80f9dc815c5e896330700fd6e20814e69da9c1267d65a4d051080f1"}, - {file = "numpy-1.22.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0cfe07133fd00b27edee5e6385e333e9eeb010607e8a46e1cd673f05f8596595"}, - {file = "numpy-1.22.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6ed0d073a9c54ac40c41a9c2d53fcc3d4d4ed607670b9e7b0de1ba13b4cbfe6f"}, - {file = "numpy-1.22.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41388e32e40b41dd56eb37fcaa7488b2b47b0adf77c66154d6b89622c110dfe9"}, - {file = "numpy-1.22.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b55b953a1bdb465f4dc181758570d321db4ac23005f90ffd2b434cc6609a63dd"}, - {file = "numpy-1.22.0-cp39-cp39-win32.whl", hash = "sha256:5a311ee4d983c487a0ab546708edbdd759393a3dc9cd30305170149fedd23c88"}, - {file = "numpy-1.22.0-cp39-cp39-win_amd64.whl", hash = "sha256:a97a954a8c2f046d3817c2bce16e3c7e9a9c2afffaf0400f5c16df5172a67c9c"}, - {file = "numpy-1.22.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb02929b0d6bfab4c48a79bd805bd7419114606947ec8284476167415171f55b"}, - {file = "numpy-1.22.0.zip", hash = "sha256:a955e4128ac36797aaffd49ab44ec74a71c11d6938df83b1285492d277db5397"}, +[[package]] +name = "pytest" +version = "7.4.4" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, ] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "tomli" +version = "2.2.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.8" +files = [ + {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, + {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"}, + {file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"}, + {file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"}, + {file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"}, + {file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"}, + {file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"}, + {file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"}, + {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, + {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.9,<3.14" +content-hash = "3cd4e3325b88b677715a63c130cd79d70a3e3586c0df36c5d40aba429342caa7" diff --git a/pyproject.toml b/pyproject.toml index ef08843..c7346a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,26 +1,29 @@ [tool.poetry] name = "fireflyalgorithm" -version = "0.3.2" +version = "0.4.6" description = "Implementation of Firefly Algorithm in Python" -authors = ["firefly-cpp"] +authors = ["Iztok Fister Jr. ", "Luka Pečnik ", "Žiga Stupan "] +keywords = ['computational intelligence', 'firefly algorithm', 'swarm intelligence', 'optimization'] license = "MIT" readme = "README.md" +homepage = "https://github.com/firefly-cpp/FireflyAlgorithm" +repository = "https://github.com/firefly-cpp/FireflyAlgorithm" include = [ - { path="LICENSE", format="sdist" } + { path="LICENSE", format="sdist" }, + { path="Problems.md", format="sdist" } ] - [tool.poetry.dependencies] -python = "^3.7" -numpy = [ - { version = "^1.21.5", python = ">=3.7,<3.11" }, - { version = "^1.22.0", python = "^3.11" } -] +python = "^3.9,<3.14" +numpy = "^1.26.1" + +[tool.poetry.group.test.dependencies] +pytest = "^7.4.3" -[tool.poetry.dev-dependencies] -pytest = "^7.0.1" +[tool.poetry.scripts] +firefly-algorithm = 'fireflyalgorithm.cli:main' [build-system] -requires = ["poetry-core>=1.0.0"] +requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 24ce15a..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -numpy diff --git a/tests/test_firefly.py b/tests/test_firefly.py index cc048b7..3a05a3d 100644 --- a/tests/test_firefly.py +++ b/tests/test_firefly.py @@ -1,15 +1,10 @@ from unittest import TestCase - -import numpy as np from fireflyalgorithm import FireflyAlgorithm - -def sphere(x): - return np.sum(x ** 2) +from fireflyalgorithm.problems import sphere class TestFA(TestCase): - def test_algorithm(self): - FA = FireflyAlgorithm() - best = FA.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000) + algorithm = FireflyAlgorithm() + best = algorithm.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000) self.assertLess(best, 5) diff --git a/tests/test_problems.py b/tests/test_problems.py new file mode 100644 index 0000000..c91fed9 --- /dev/null +++ b/tests/test_problems.py @@ -0,0 +1,214 @@ +from unittest import TestCase +import numpy as np +from fireflyalgorithm.problems import ( + get_problem, + ackley, + alpine1, + alpine2, + cigar, + cosine_mixture, + csendes, + dixon_price, + griewank, + katsuura, + levy, + michalewicz, + perm1, + perm2, + pinter, + powell, + qing, + quintic, + rastrigin, + rosenbrock, + salomon, + schaffer2, + schaffer4, + schwefel, + schwefel221, + schwefel222, + sphere, + step, + step2, + styblinski_tang, + trid, + weierstrass, + whitley, + zakharov, +) + + +class TestProblems(TestCase): + def test_problem_factory(self): + self.assertRaises(KeyError, get_problem, "spherekjl2") + self.assertEqual(get_problem("ackley"), ackley) + self.assertEqual(get_problem("alpine1"), alpine1) + self.assertEqual(get_problem("alpine2"), alpine2) + self.assertEqual(get_problem("cigar"), cigar) + self.assertEqual(get_problem("cosine_mixture"), cosine_mixture) + self.assertEqual(get_problem("csendes"), csendes) + self.assertEqual(get_problem("dixon_price"), dixon_price) + self.assertEqual(get_problem("griewank"), griewank) + self.assertEqual(get_problem("katsuura"), katsuura) + self.assertEqual(get_problem("levy"), levy) + self.assertEqual(get_problem("michalewicz"), michalewicz) + self.assertEqual(get_problem("perm1"), perm1) + self.assertEqual(get_problem("perm2"), perm2) + self.assertEqual(get_problem("pinter"), pinter) + self.assertEqual(get_problem("powell"), powell) + self.assertEqual(get_problem("qing"), qing) + self.assertEqual(get_problem("quintic"), quintic) + self.assertEqual(get_problem("rastrigin"), rastrigin) + self.assertEqual(get_problem("rosenbrock"), rosenbrock) + self.assertEqual(get_problem("salomon"), salomon) + self.assertEqual(get_problem("schaffer2"), schaffer2) + self.assertEqual(get_problem("schaffer4"), schaffer4) + self.assertEqual(get_problem("schwefel"), schwefel) + self.assertEqual(get_problem("schwefel221"), schwefel221) + self.assertEqual(get_problem("schwefel222"), schwefel222) + self.assertEqual(get_problem("sphere"), sphere) + self.assertEqual(get_problem("step"), step) + self.assertEqual(get_problem("step2"), step2) + self.assertEqual(get_problem("styblinski_tang"), styblinski_tang) + self.assertEqual(get_problem("trid"), trid) + self.assertEqual(get_problem("weierstrass"), weierstrass) + self.assertEqual(get_problem("whitley"), whitley) + self.assertEqual(get_problem("zakharov"), zakharov) + + def test_ackley(self): + x = np.zeros(5) + self.assertAlmostEqual(ackley(x), 0.0) + + def test_alpine1(self): + x = np.zeros(5) + self.assertAlmostEqual(alpine1(x), 0.0) + + def test_alpine2(self): + x = np.full(5, 7.9170526982459462172) + self.assertAlmostEqual(alpine2(x), 2.8081311800070053291**5) + + def test_cigar(self): + x = np.zeros(5) + self.assertAlmostEqual(cigar(x), 0.0) + + def test_cosine_mixture(self): + x = np.zeros(5) + self.assertAlmostEqual(cosine_mixture(x), -0.5) + + def test_csendes(self): + x = np.zeros(5) + self.assertAlmostEqual(csendes(x), 0.0) + + def test_dixon_price(self): + x = np.array([2 ** -((2**i - 2) / 2**i) for i in range(1, 6)]) + self.assertAlmostEqual(dixon_price(x), 0.0) + + def test_griewank(self): + x = np.zeros(5) + self.assertAlmostEqual(griewank(x), 0.0) + + def test_katsuura(self): + x = np.zeros(5) + self.assertAlmostEqual(katsuura(x), 1.0) + + def test_levy(self): + x = np.full(5, 1) + self.assertAlmostEqual(levy(x), 0.0) + + def test_michalewicz(self): + x = np.array([2.20290552014618, 1.57079632677565]) + self.assertAlmostEqual(michalewicz(x), -1.80130341009855321) + + def test_perm1(self): + x = np.arange(1, 6) + self.assertAlmostEqual(perm1(x), 0.0) + + def test_perm2(self): + x = 1 / np.arange(1, 6) + self.assertAlmostEqual(perm2(x), 0.0) + + def test_pinter(self): + x = np.zeros(5) + self.assertAlmostEqual(pinter(x), 0.0) + + def test_powell(self): + x = np.zeros(5) + self.assertAlmostEqual(powell(x), 0.0) + + def test_qing(self): + x = np.sqrt(np.arange(1, 6)) + self.assertAlmostEqual(qing(x), 0.0) + + def test_quintic(self): + x = np.full(5, -1) + self.assertAlmostEqual(quintic(x), 0.0) + + def test_rastrigin(self): + x = np.zeros(5) + self.assertAlmostEqual(rastrigin(x), 0.0) + + def test_rosenbrock(self): + x = np.full(5, 1) + self.assertAlmostEqual(rosenbrock(x), 0.0) + + def test_salomon(self): + x = np.zeros(5) + self.assertAlmostEqual(rastrigin(x), 0.0) + + def test_schaffer2(self): + x = np.zeros(5) + self.assertAlmostEqual(schaffer2(x), 0.0) + + def test_schaffer4(self): + x1 = np.array([0, 1.253131828792882]) + x2 = np.array([0, -1.253131828792882]) + x3 = np.array([1.253131828792882, 0]) + x4 = np.array([-1.253131828792882, 0]) + self.assertAlmostEqual(schaffer4(x1), 0.292578632035980) + self.assertAlmostEqual(schaffer4(x2), 0.292578632035980) + self.assertAlmostEqual(schaffer4(x3), 0.292578632035980) + self.assertAlmostEqual(schaffer4(x4), 0.292578632035980) + + def test_schwefel(self): + x = np.full(5, 420.968746) + self.assertAlmostEqual(schwefel(x), 0.0) + + def test_schwefel21(self): + x = np.zeros(5) + self.assertAlmostEqual(schwefel221(x), 0.0) + + def test_schwefel22(self): + x = np.zeros(5) + self.assertAlmostEqual(schwefel222(x), 0.0) + + def test_sphere(self): + x = np.zeros(5) + self.assertAlmostEqual(sphere(x), 0.0) + + def test_step(self): + x = np.full(5, 0.5) + self.assertAlmostEqual(step(x), 0.0) + + def test_step2(self): + x = np.full(5, -0.5) + self.assertAlmostEqual(step2(x), 0.0) + + def test_styblinski_tang(self): + x = np.full(5, -2.903534018185960) + self.assertAlmostEqual(styblinski_tang(x), -39.16616570377142 * 5) + + def test_trid(self): + x = np.array([6, 10, 12, 12, 10, 6]) + self.assertAlmostEqual(trid(x), -50) + + def test_weierstrass(self): + x = np.zeros(5) + self.assertAlmostEqual(weierstrass(x), 0.0) + + def test_whitley(self): + x = np.full(5, 1) + self.assertAlmostEqual(whitley(x), 0.0) + + def test_zakharov(self): + x = np.zeros(5) + self.assertAlmostEqual(zakharov(x), 0.0) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy