Skip to content

Commit 7c44a40

Browse files
committed
added seed parameter
1 parent fb9c8aa commit 7c44a40

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

docs/source/algorithms.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4017,9 +4017,13 @@ these optimizers, you need to have
40174017
toward the best solutions.
40184018
40194019
- **transform** (str): The transform to use to map from PSO optimization space to
4020-
R-space.
4020+
R-space. Available options are:
4021+
- "arctan" (default)
4022+
- "identity"
4023+
- "gaussian"
40214024
- **population_size** (int): Population size of the particle swarm.
40224025
- **n_cores** (int): Number of cores to use.
4026+
- **seed** (int): Seed used by the internal random number generator.
40234027
- **stopping.maxfun** (int): Maximum number of function evaluations.
40244028
- **inertia** (float): Inertia weight. Denoted by :math:`\omega`.
40254029
Default is 0.7213475204444817. To prevent divergence, the value must be smaller

docs/source/refs.bib

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -906,19 +906,6 @@ @article{JAMES1975343
906906
author = {F. James and M. Roos}
907907
}
908908

909-
@article{JAMES1975343,
910-
title = {Minuit - a system for function minimization and analysis of the parameter errors and correlations},
911-
journal = {Computer Physics Communications},
912-
volume = {10},
913-
number = {6},
914-
pages = {343-367},
915-
year = {1975},
916-
issn = {0010-4655},
917-
doi = {https://doi.org/10.1016/0010-4655(75)90039-9},
918-
url = {https://www.sciencedirect.com/science/article/pii/0010465575900399},
919-
author = {F. James and M. Roos}
920-
}
921-
922909
@InProceedings{Kennedy1995,
923910
author={Kennedy, J. and Eberhart, R.},
924911
booktitle={Proceedings of ICNN'95 - International Conference on Neural Networks},

src/optimagic/optimizers/nevergrad_optimizers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class NevergradPSO(Algorithm):
3939
transform: Literal["arctan", "gaussian", "identity"] = "arctan"
4040
population_size: int | None = None
4141
n_cores: int = 1
42+
seed: int | None = None
4243
stopping_maxfun: PositiveInt = STOPPING_MAXFUN_GLOBAL
4344
inertia: float = 0.5 / math.log(2.0)
4445
cognitive: float = 0.5 + math.log(2.0)
@@ -64,6 +65,9 @@ def _solve_internal_problem(
6465
)
6566
)
6667

68+
if self.seed is not None:
69+
instrum.random_state.seed(self.seed)
70+
6771
optimizer = ng.optimizers.ConfPSO(
6872
transform=self.transform,
6973
popsize=self.population_size,

0 commit comments

Comments
 (0)