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.
Merge after #14, contains those commits (and that PR contains some context for this)
This PR contains a utility class for saving history. We'll create one of these and tell it how many states the particles have, how many particles, groups and timesteps we want to save for. Then we add states in with the
add
method. In the case of the particle filter we'll also add in the particle ordering indicies (https://github.com/mrc-ide/dust2/blob/main/inst/include/dust2/filter.hpp#L143) so that we can reconstruct the tree of history.The algorithm for doing this was worked out on paper a while ago, and is ported across here - see the tests to see that it works. But the idea is that we don't resort the history itself, only the bits that are copied out on export. To do this we start at the last particle and each time we hit a reordering we look back to see who the parents were. It's a fairly horrible bit of bookkeeping but it's also been unchanged since mid 2020!