Closed rashidalabri closed 9 months ago
Thanks for the report! Luckily, this was fixed yesterday in #383. ArgminRandom::rand_from_range
now accepts a RNG with a seed of choice. The PSO code was adapted accordingly and you can set the RNG with this method. Note that these changes aren't published yet.
Perhaps we can let users set the initial positions and velocities? As long as the initial positions are the same, every step after should be deterministic.
This is not quite correct, because every iteration involves randomness. Btw, it is possible to set an initial population via PopulationState::population
, like this:
let res = Executor::new(cost_function, solver)
.configure(|state| state.population(your_initial_population))
.run()?;
It is not possible to set the initial velocities. If there is a use case which requires this, we can certainly discuss it.
That's awesome! Thanks for the clarification Stefan. Any idea of when it might be published?
Unfortunately, since a new release came out a couple of days ago I'm afraid it won't be very soon.
Currently, the initial positions of the particles in
ParticleSwarm
are acquired through therand_from_range
function from theArgminRandom
trait. The implementation of the trait for standard types usesrand::thread_rng
. Since there is no way to set a seed, we cannot reproduce results.I think it would be really helpful to find a way to allow users to reproduce results. Perhaps we can let users set the initial positions and velocities? As long as the initial positions are the same, every step after should be deterministic.
I'd be happy to create a PR for this!