PSO: fix memory mode to preserve full internal state across evolve calls - #628
Merged
Conversation
When memory=true, consecutive evolve() calls with gen=1 should produce the same trajectory as a single call with gen=N. The previous partial fix only preserved particle velocities (m_V), but not the rest of the internal state (current positions X, local bests lbX/lbfit, topology, etc.), causing divergent behaviour between repeated gen=1 calls and a single gen=N call. This commit stores and restores the full internal PSO state via a memory struct (V, X, lbX, fit, lbfit, best_fit, neighb, best_neighb) wrapped in boost::optional, replacing the incomplete mutable m_V approach. Fix contributed by tarcisiofischer (PR esa#487), applied to both pso and pso_gen with serialization support. Closes esa#486
Member
|
Merging this, thanks for the contribution. With the added test we should be safe on intended behaviour. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When memory=true, consecutive evolve() calls with gen=1 should produce the same trajectory as a single call with gen=N. The previous partial fix only preserved particle velocities (m_V), but not the rest of the internal state (current positions X, local bests lbX/lbfit, topology, etc.), causing divergent behaviour between repeated gen=1 calls and a single gen=N call.
This commit stores and restores the full internal PSO state via a memory struct (V, X, lbX, fit, lbfit, best_fit, neighb, best_neighb) wrapped in boost::optional, replacing the incomplete mutable m_V approach.
Fix contributed by tarcisiofischer (PR #487), applied to both pso and pso_gen with serialization support.
Closes #486