Skip to content

Add support for the user defined rng in ParticleSwarm#1244

Open
ParfenovS wants to merge 2 commits into
JuliaNLSolvers:masterfrom
ParfenovS:master
Open

Add support for the user defined rng in ParticleSwarm#1244
ParfenovS wants to merge 2 commits into
JuliaNLSolvers:masterfrom
ParfenovS:master

Conversation

@ParfenovS

Copy link
Copy Markdown

This PR adds support for the user defined rng in ParticleSwarm procedure. This is useful in the case when, for example, there are several optimizers running in parallel using Threads and one wants to achieve reproducibility.

end
random_index = rand(1:n)
random_index = rand(rng,1:n)
random_value = randn()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this an oversight? I think all random number generators should receive the rng

random_value = randn()
sigma_learn = 1 - (1 - 0.1) * state.iteration / state.iterations

r3 = randn() * sigma_learn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is an oversight. There should be randn(rng). My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants