Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility class for saving history #15

Merged
merged 3 commits into from
May 22, 2024
Merged

Utility class for saving history #15

merged 3 commits into from
May 22, 2024

Conversation

richfitz
Copy link
Member

@richfitz richfitz commented May 20, 2024

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!

@richfitz richfitz mentioned this pull request May 21, 2024
@richfitz richfitz marked this pull request as ready for review May 21, 2024 19:55
@richfitz richfitz requested a review from weshinsley May 21, 2024 19:55
Copy link
Contributor

@weshinsley weshinsley left a comment

Choose a reason for hiding this comment

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

Yeah, this is quite fiddly but I think I understand what we're doing...

@weshinsley weshinsley merged commit 2a20cfd into main May 22, 2024
7 checks passed
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