stochopy

Python library for stochastic numerical optimization

https://github.com/keurfonluu/stochopy

Science Score: 67.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 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.0%) to scientific vocabulary

Keywords

cmaes differential-evolution evolutionary-algorithm mcmc parallel pso stochastic-optimization
Last synced: 6 months ago · JSON representation ·

Repository

Python library for stochastic numerical optimization

Basic Info
Statistics
  • Stars: 97
  • Watchers: 6
  • Forks: 15
  • Open Issues: 0
  • Releases: 5
Topics
cmaes differential-evolution evolutionary-algorithm mcmc parallel pso stochastic-optimization
Created almost 9 years ago · Last pushed over 2 years ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.rst

stochopy
========

|License| |Stars| |Pyversions| |Version| |Downloads| |Code style: black| |Codacy Badge| |Codecov| |Build| |Docs| |DOI|

**stochopy** provides functions for sampling or optimizing objective functions with or without constraints. Its API is directly inspired by **scipy**'s own optimization submodule which should make the switch from one module to another straightforward.

.. figure:: https://raw.githubusercontent.com/keurfonluu/stochopy/master/.github/sample.gif
   :alt: sample-pso
   :width: 100%
   :align: center

   Optimization of 2D multimodal function Styblinski-Tang using PSO.

Features
--------

Sampling algorithms:

-  Hamiltonian (Hybrid) Monte-Carlo (HMC),
-  Markov-Chain Monte-Carlo (McMC).

Stochastic optimizers:

-  Competitive Particle Swarm Optimization (CPSO),
-  Covariance Matrix Adaptation - Evolution Strategy (CMA-ES),
-  Differential Evolution (DE),
-  Neighborhood Algorithm (NA),
-  Particle Swarm Optimization (PSO),
-  VD-CMA.

Parallel backends:

- `joblib `__ (``threading`` and ``loky``),
- `mpi4py `__ (``mpi``).

Installation
------------

The recommended way to install **stochopy** and all its dependencies is through the Python Package Index:

.. code::

   pip install stochopy --user

Otherwise, clone and extract the package, then run from the package location:

.. code::

   pip install . --user

To test the integrity of the installed package, check out this repository and run:

.. code::

   pytest

Documentation
-------------

Refer to the online `documentation `__ for detailed description of the API and examples.

Alternatively, the documentation can be built using `Sphinx `__:

.. code:: bash

   pip install -r doc/requirements.txt
   sphinx-build -b html doc/source doc/build

Usage
-----

Given an optimization problem defined by an objective function and a feasible space:

.. code-block:: python

   import numpy as np

   def rosenbrock(x):
      x = np.asarray(x)
      sum1 = ((x[1:] - x[:-1] ** 2) ** 2).sum()
      sum2 = np.square(1.0 - x[:-1]).sum()
      return 100.0 * sum1 + sum2

   bounds = [[-5.12, 5.12], [-5.12, 5.12]]  # The number of variables to optimize is len(bounds)

The optimal solution can be found following:

.. code-block:: python

   from stochopy.optimize import minimize

   x = minimize(rosenbrock, bounds, method="cmaes", options={"maxiter": 100, "popsize": 10, "seed": 0})

``minimize`` returns a dictionary that contains the results of the optimization:

.. code-block::

        fun: 3.862267657514075e-09
    message: 'best solution value is lower than ftol'
       nfev: 490
        nit: 49
     status: 1
    success: True
          x: array([0.99997096, 0.99993643])

Contributing
------------

Please refer to the `Contributing
Guidelines `__ to see how you can help. This project is released with a `Code of Conduct `__ which you agree to abide by when contributing.

Related projects
----------------

- `stochopy-viewer `__: Graphical User Interface (GUI) for **stochopy**.

.. |License| image:: https://img.shields.io/github/license/keurfonluu/stochopy
   :target: https://github.com/keurfonluu/stochopy/blob/master/LICENSE

.. |Stars| image:: https://img.shields.io/github/stars/keurfonluu/stochopy?logo=github
   :target: https://github.com/keurfonluu/stochopy

.. |Pyversions| image:: https://img.shields.io/pypi/pyversions/stochopy.svg?style=flat
   :target: https://pypi.org/pypi/stochopy/

.. |Version| image:: https://img.shields.io/pypi/v/stochopy.svg?style=flat
   :target: https://pypi.org/project/stochopy

.. |Downloads| image:: https://pepy.tech/badge/stochopy
   :target: https://pepy.tech/project/stochopy

.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
   :target: https://github.com/psf/black

.. |Codacy Badge| image:: https://img.shields.io/codacy/grade/29b21d65d07e40219dcc9ad1c978cbeb.svg?style=flat
   :target: https://www.codacy.com/manual/keurfonluu/stochopy/dashboard?utm_source=github.com&utm_medium=referral&utm_content=keurfonluu/stochopy&utm_campaign=Badge_Grade

.. |Codecov| image:: https://img.shields.io/codecov/c/github/keurfonluu/stochopy.svg?style=flat
   :target: https://codecov.io/gh/keurfonluu/stochopy

.. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4058008.svg?style=flat
   :target: https://doi.org/10.5281/zenodo.4058008

.. |Build| image:: https://img.shields.io/github/actions/workflow/status/keurfonluu/stochopy/ci.yml
   :target: https://github.com/keurfonluu/stochopy

.. |Docs| image:: https://img.shields.io/github/actions/workflow/status/keurfonluu/stochopy/doc.yml?label=docs
   :target: https://keurfonluu.github.io/stochopy/

Owner

  • Name: Keurfon Luu
  • Login: keurfonluu
  • Kind: user
  • Location: Wettingen, Switzerland
  • Company: INTERA Incorporated

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Luu"
  given-names: "Keurfon"
  orcid: "https://orcid.org/0000-0001-7927-0019"
title: "stochopy: Python library for stochastic numerical optimization"
doi: 10.5281/zenodo.4058008
url: https://github.com/keurfonluu/stochopy
license: BSD-3-Clause

GitHub Events

Total
  • Watch event: 7
Last Year
  • Watch event: 7

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 167
  • Total Committers: 1
  • Avg Commits per committer: 167.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Keurfon Luu k****u@o****m 167

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 4
  • Total pull requests: 11
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 7 hours
  • Total issue authors: 4
  • Total pull request authors: 1
  • Average comments per issue: 2.25
  • Average comments per pull request: 0.73
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • esiwgnahz (1)
  • kroscek (1)
  • zunzun (1)
  • SeismoZhou (1)
Pull Request Authors
  • keurfonluu (10)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 2,501 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 23
  • Total maintainers: 1
pypi.org: stochopy

Python library for stochastic numerical optimization

  • Versions: 23
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 2,501 Last month
Rankings
Dependent packages count: 4.8%
Stargazers count: 7.7%
Forks count: 9.1%
Average: 11.4%
Downloads: 13.6%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

doc/requirements.txt pypi
  • matplotlib *
  • pydata-sphinx-theme *
  • sphinx *
  • sphinx-argparse *
  • sphinx-gallery *
  • sphinxcontrib-bibtex *
requirements-dev.txt pypi
  • black * development
  • docformatter * development
  • invoke * development
  • isort * development
  • pytest * development
  • pytest-cov * development
.github/workflows/ci.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • actions/setup-python v1 composite
.github/workflows/doc.yml actions
  • actions/setup-python v4 composite
  • nschloe/action-cached-lfs-checkout v1 composite
  • peaceiris/actions-gh-pages v3 composite
pyproject.toml pypi