Skip to content

Add wrapper for Nevergrad PSO optimizer #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tools/envs/testenv-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies:
- jinja2 # dev, tests
- annotated-types # dev, tests
- pip: # dev, tests, docs
- nevergrad # dev, tests
- DFO-LS>=1.5.3 # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
Expand Down
1 change: 1 addition & 0 deletions .tools/envs/testenv-numpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:
- jinja2 # dev, tests
- annotated-types # dev, tests
- pip: # dev, tests, docs
- nevergrad # dev, tests
- DFO-LS>=1.5.3 # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
Expand Down
1 change: 1 addition & 0 deletions .tools/envs/testenv-others.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:
- jinja2 # dev, tests
- annotated-types # dev, tests
- pip: # dev, tests, docs
- nevergrad # dev, tests
- DFO-LS>=1.5.3 # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
Expand Down
1 change: 1 addition & 0 deletions .tools/envs/testenv-pandas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:
- jinja2 # dev, tests
- annotated-types # dev, tests
- pip: # dev, tests, docs
- nevergrad # dev, tests
- DFO-LS>=1.5.3 # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
Expand Down
55 changes: 55 additions & 0 deletions docs/source/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,61 @@ addition to optimagic when using an NLOPT algorithm. To install nlopt run
10 * (number of parameters + 1).
```

(nevergrad-algorithms)=

## Nevergrad Optimizers

optimagic supports some algorithms from the
[Nevergrad](https://facebookresearch.github.io/nevergrad/index.html) library. To use
these optimizers, you need to have
[the nevergrad package](https://github.com/facebookresearch/nevergrad) installed.
(`pip install nevergrad`).

```{eval-rst}
.. dropdown:: nevergrad_pso

.. code-block::

"nevergrad_pso"

Minimize a scalar function using the Particle Swarm Optimization (PSO) algorithm.

The Particle Swarm Optimization algorithm was originally proposed by
:cite:`Kennedy1995`. The implementation in Nevergrad is based on
:cite:`Zambrano2013`.

Particle Swarm Optimization (PSO) solves a problem by having a population of
candidate solutions, here dubbed particles, and moving these particles around in the
search-space according to simple mathematical formulae over the particle's position
and velocity. Each particle's movement is influenced by its local best known
position (termed "cognitive" component), but is also guided toward the best known
positions (termed "social" component) in the search-space, which are updated as
better positions are found by other particles. This is expected to move the swarm
toward the best solutions.

- **transform** (str): The transform to use to map from PSO optimization space to
R-space.
- **population_size** (int): Population size of the particle swarm.
- **n_cores** (int): Number of cores to use.
- **stopping.maxfun** (int): Maximum number of function evaluations.
- **inertia** (float): Inertia weight. Denoted by :math:`\omega`.
Default is 0.7213475204444817. To prevent divergence, the value must be smaller
than 1. It controls the influence of the particle's previous velocity on its
movement.
- **cognitive** (float): Cognitive coefficient. Denoted by :math:`\phi_p`.
Default is 1.1931471805599454. Typical values range from 1.0 to 3.0. It controls
the influence of its own best known position on the particle's movement.
- **social** (float): Social coefficient. Denoted by :math:`\phi_g`.
Default is 1.1931471805599454. Typical values range from 1.0 to 3.0. It controls
the influence of the swarm's best known position on the particle's movement.
- **quasi_opp_init** (bool): Whether to use quasi-opposition initialization.
Default is False.
- **speed_quasi_opp_init** (bool): Whether to use quasi-opposition initialization
for speed. Default is False.
- **special_speed_quasi_opp_init** (bool): Whether to use special quasi-opposition
initialization for speed. Default is False.
```

## References

```{eval-rst}
Expand Down
23 changes: 23 additions & 0 deletions docs/source/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -893,4 +893,27 @@ @book{Conn2009
URL = {https://epubs.siam.org/doi/abs/10.1137/1.9780898718768},
}


@InProceedings{Kennedy1995,
author={Kennedy, J. and Eberhart, R.},
booktitle={Proceedings of ICNN'95 - International Conference on Neural Networks},
title={Particle swarm optimization},
year={1995},
volume={4},
pages={1942-1948 vol.4},
keywords={Particle swarm optimization;Birds;Educational institutions;Marine animals;Testing;Humans;Genetic algorithms;Optimization methods;Artificial neural networks;Performance evaluation},
doi={10.1109/ICNN.1995.488968},
}


@InProceedings{Zambrano2013,
author = {Zambrano-Bigiarini, Mauricio and Clerc, Maurice and Rojas, Rodrigo},
booktitle = {2013 IEEE Congress on Evolutionary Computation},
title = {Standard Particle Swarm Optimisation 2011 at CEC-2013: A baseline for future PSO improvements},
year = {2013},
pages = {2337-2344},
keywords = {Optimization;Standards;Benchmark testing;Topology;Algorithm design and analysis;Convergence;Equations;particle swarm optimization;SPSO-2011;CEC-2013;random topology;rotational invariance;benchmark testing;evolutionary computation;optimization},
doi = {10.1109/CEC.2013.6557848},
}

@Comment{jabref-meta: databaseType:bibtex;}
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies:
- furo # dev, docs
- annotated-types # dev, tests
- pip: # dev, tests, docs
- nevergrad # dev, tests
- DFO-LS>=1.5.3 # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,6 @@ module = [
"optimagic._version",
"annotated_types",
"pdbp",
"nevergrad",
]
ignore_missing_imports = true
Loading
Loading