Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c412eb2
Add global-best PSO
spline2hg Aug 22, 2025
b8a3f4a
fic parameters
spline2hg Aug 22, 2025
eead60b
expose verbose
spline2hg Aug 22, 2025
3fe000b
use CONVERGENCE_FTOL_REL
spline2hg Aug 22, 2025
e5e4ae5
Add local-best PSO
spline2hg Aug 22, 2025
a451fd4
refactor: simplify return
spline2hg Aug 22, 2025
b21f93e
Add general PSO
spline2hg Aug 24, 2025
9fe6876
docs: improve docstrings of global_best
spline2hg Aug 24, 2025
7f078c6
improve local-best pso docstrings
spline2hg Aug 24, 2025
9848e97
improve general pso docstrings
spline2hg Aug 24, 2025
0d35e8d
fix: particle center scaling
spline2hg Aug 25, 2025
b647fd2
feat: enable parallel eval and history in PySwarms
spline2hg Aug 25, 2025
5a8d0b5
docs: add PySwarms optimizers to algorithms.md
spline2hg Aug 25, 2025
1ca8dcd
refactor: topology – swap string flags for dataclass configs
spline2hg Aug 25, 2025
212b4e8
docs: clarify boundary & velocity strategy choices in docstrings
spline2hg Aug 25, 2025
dc41d46
docs: add PSO citations to algorithm docstrings
spline2hg Aug 26, 2025
5e41346
refactor: drop unused GeneralPSOOptions dataclass
spline2hg Aug 26, 2025
a7fe49f
docs: clarify topology parameter usage
spline2hg Aug 26, 2025
2c2f5ea
format docstrings
spline2hg Aug 26, 2025
19c42eb
feat: expose initial_population and oh_strategy in PySwarms optimizers
spline2hg Aug 27, 2025
47f1342
refactor: simplify bounds handling
spline2hg Aug 27, 2025
76fc623
refactor: infer actual iterations & evals
spline2hg Aug 27, 2025
543b55c
add pyswarms to mypy ignore list
spline2hg Aug 27, 2025
5d6132f
fix: mark PySwarms optimizers as stochastic via seed parameter
spline2hg Aug 27, 2025
9fbabd5
fix: add missing comma to mypy ignore list
spline2hg Aug 27, 2025
2dbd9bf
extend mypy ignores to pyswarms.backend.topology
spline2hg Aug 27, 2025
429fe28
refactor: use dataclasses for PSO hyper-params
spline2hg Aug 28, 2025
375b372
Merge remote-tracking branch 'origin/main' into pyswarms-optimizer
spline2hg Aug 29, 2025
ef7bace
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 29, 2025
2920b82
Merge branch 'main' into pyswarms-optimizer
spline2hg Aug 29, 2025
5ed744f
refactor: rename initial_population to initial_positions and add PyTr…
spline2hg Aug 29, 2025
1ad4424
refactor: use common internal function for all PySwarms optimizers
spline2hg Aug 29, 2025
ea54d69
refactor: move ring topology params into RingTopology dataclass
spline2hg Aug 29, 2025
d825e16
refactor: use local random-state and fix arrangement
spline2hg Aug 29, 2025
f101240
fix: rename VonNeumannTopology.range to range_param
spline2hg Aug 29, 2025
ad53c4d
test: add tests for PySwarms helper functions
spline2hg Aug 29, 2025
388ad86
Merge branch 'main' into pyswarms-optimizer
spline2hg Sep 3, 2025
d472b2b
refactor: use common interface
spline2hg Sep 3, 2025
7609506
docs: display inherited params in pyswarms optimizers
spline2hg Sep 3, 2025
9c9f8f7
Merge branch 'pyswarms-optimizer' of github.com:spline2hg/optimagic_ …
spline2hg Sep 3, 2025
3c96300
fix: update tests
spline2hg Sep 3, 2025
bfe0268
update optimizer param default values
spline2hg Sep 3, 2025
9fb982a
fix: remove STOPPING_MAXITER_GLOBAL, set maxiter to 1000
spline2hg Sep 3, 2025
b8df4af
Merge branch 'main' into pyswarms-optimizer
spline2hg Sep 6, 2025
669cd02
warn: add warning for seed
spline2hg Sep 7, 2025
d25afa2
Merge remote-tracking branch 'origin/pyswarms-optimizer' into pyswarm…
spline2hg Sep 7, 2025
821cac5
Merge branch 'main' into pyswarms-optimizer
spline2hg Sep 10, 2025
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 @@ -39,6 +39,7 @@ dependencies:
- kaleido>=1.0 # dev, tests
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- pandas-stubs # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
Expand Down
3 changes: 2 additions & 1 deletion .tools/envs/testenv-nevergrad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ dependencies:
- kaleido>=1.0 # dev, tests
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- pandas-stubs # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
- types-jinja2 # dev, tests
- sqlalchemy-stubs # dev, tests
- sphinxcontrib-mermaid # dev, tests, docs
- bayesian_optimization==1.4.0
- nevergrad
- sphinxcontrib-mermaid # dev, tests, docs
- -e ../../
1 change: 1 addition & 0 deletions .tools/envs/testenv-numpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
- kaleido>=1.0 # dev, tests
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
- types-jinja2 # 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 @@ -37,6 +37,7 @@ dependencies:
- kaleido>=1.0 # dev, tests
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- pandas-stubs # dev, tests
- types-cffi # dev, tests
- types-openpyxl # 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 @@ -37,6 +37,7 @@ dependencies:
- kaleido>=1.0 # dev, tests
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
- types-jinja2 # dev, tests
Expand Down
3 changes: 2 additions & 1 deletion .tools/envs/testenv-plotly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ dependencies:
- fides==0.7.4 # dev, tests
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- pandas-stubs # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
- types-jinja2 # dev, tests
- sqlalchemy-stubs # dev, tests
- sphinxcontrib-mermaid # dev, tests, docs
- kaleido<0.3
- sphinxcontrib-mermaid # dev, tests, docs
- -e ../../
101 changes: 101 additions & 0 deletions docs/source/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -4885,6 +4885,107 @@ We wrap the pygad optimizer. To use it you need to have
.. autoclass:: optimagic.optimizers.pygad_optimizer.Pygad
```

## PySwarms Optimizers

optimagic supports the following continuous algorithms from the
[PySwarms](https://pyswarms.readthedocs.io/en/latest/) library: (GlobalBestPSO,
LocalBestPSO, GeneralOptimizerPSO). To use these optimizers, you need to have
[the pyswarms package](https://github.com/ljvmiranda921/pyswarms) installed.
(`pip install pyswarms`).

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

**How to use this algorithm:**

.. code-block::

import optimagic as om
om.minimize(
...,
algorithm=om.algos.pyswarms_global_best(n_particles=50, ...)
)

or

.. code-block::

om.minimize(
...,
algorithm="pyswarms_global_best",
algo_options={"n_particles": 50, ...}
)

**Description and available options:**

.. autoclass:: optimagic.optimizers.pyswarms_optimizers.PySwarmsGlobalBestPSO
:members:
:inherited-members: Algorithm, object

```

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

**How to use this algorithm:**

.. code-block::

import optimagic as om
om.minimize(
...,
algorithm=om.algos.pyswarms_local_best(n_particles=50, k_neighbors=3, ...)
)

or

.. code-block::

om.minimize(
...,
algorithm="pyswarms_local_best",
algo_options={"n_particles": 50, "k_neighbors": 3, ...}
)

**Description and available options:**

.. autoclass:: optimagic.optimizers.pyswarms_optimizers.PySwarmsLocalBestPSO
:members:
:inherited-members: Algorithm, object

```

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

**How to use this algorithm:**

.. code-block::

import optimagic as om
om.minimize(
...,
algorithm=om.algos.pyswarms_general(n_particles=50, topology_type="star", ...)
)

or

.. code-block::

om.minimize(
...,
algorithm="pyswarms_general",
algo_options={"n_particles": 50, "topology_type": "star", ...}
)

**Description and available options:**

.. autoclass:: optimagic.optimizers.pyswarms_optimizers.PySwarmsGeneralPSO
:members:
:inherited-members: Algorithm, object

```

## References

```{eval-rst}
Expand Down
36 changes: 36 additions & 0 deletions docs/source/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1077,4 +1077,40 @@ @article{gad2023pygad
publisher={Springer}
}

@INPROCEEDINGS{EberhartKennedy1995,
author = {Eberhart, R. and Kennedy, J.},
booktitle = {MHS'95. Proceedings of the Sixth International Symposium on Micro Machine and Human Science},
title = {A new optimizer using particle swarm theory},
year = {1995},
pages = {39-43},
keywords = {Particle swarm optimization;Genetic algorithms;Testing;Acceleration;Particle tracking;Optimization methods;Artificial neural networks;Evolutionary computation;Performance evaluation;Statistics},
doi = {10.1109/MHS.1995.494215}
}

@INPROCEEDINGS{Lane2008SpatialPSO,
author={Lane, James and Engelbrecht, Andries and Gain, James},
booktitle={2008 IEEE Swarm Intelligence Symposium},
title={Particle swarm optimization with spatially meaningful neighbours},
year={2008},
volume={},
number={},
pages={1-8},
keywords={Particle swarm optimization;Topology;Birds;Convergence;Computer science;USA Councils;Cities and towns;Africa;Cultural differences;Data structures;Delaunay Triangulation;Neighbour Topology;Particle Swarm Optimization;Heuristics},
doi={10.1109/SIS.2008.4668281}
}

@article{Ni2013,
author = {Ni, Qingjian and Deng, Jianming},
title = {A New Logistic Dynamic Particle Swarm Optimization Algorithm Based on Random Topology},
journal = {The Scientific World Journal},
volume = {2013},
number = {1},
pages = {409167},
doi = {https://doi.org/10.1155/2013/409167},
url = {https://onlinelibrary.wiley.com/doi/abs/10.1155/2013/409167},
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1155/2013/409167},
abstract = {Population topology of particle swarm optimization (PSO) will directly affect the dissemination of optimal information during the evolutionary process and will have a significant impact on the performance of PSO. Classic static population topologies are usually used in PSO, such as fully connected topology, ring topology, star topology, and square topology. In this paper, the performance of PSO with the proposed random topologies is analyzed, and the relationship between population topology and the performance of PSO is also explored from the perspective of graph theory characteristics in population topologies. Further, in a relatively new PSO variant which named logistic dynamic particle optimization, an extensive simulation study is presented to discuss the effectiveness of the random topology and the design strategies of population topology. Finally, the experimental data are analyzed and discussed. And about the design and use of population topology on PSO, some useful conclusions are proposed which can provide a basis for further discussion and research.},
year = {2013}
}

@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 @@ -51,6 +51,7 @@ dependencies:
- pre-commit>=4 # dev
- bayes_optim # dev, tests
- gradient_free_optimizers # dev, tests
- pyswarms # dev, tests
- -e . # dev
# type stubs
- pandas-stubs # dev, tests
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ module = [
"iminuit",
"nevergrad",
"pygad",
"pyswarms",
"pyswarms.backend.topology",
"yaml",
"gradient_free_optimizers",
"gradient_free_optimizers.optimizers.base_optimizer",
Expand Down
Loading
Loading