You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering whether it would make sense to convert the integration functions to trait methods on a PlainIntegrator struct (implementing a new trait Integrator) that would hold a random number generator self.rng and a vector of checkpoints self.checkpoints.
This way, it could have additional trait methods from_rng and from_checkpoints, where the first method would construct a new integrator by providing a random number generator and initializing the checkpoints vector to an empty vector. The second method would construct a new integrator from a set of checkpoints, storing them in self.checkpoints and using the rng_after of the last checkpoint as self.rng. The struct could then have a private method that takes care of the integration which in turn is called by the methods of the Integrator trait integrate and resume_from_checkpoints (to reduce code duplication).
Another good point about this would be that there could be another Integrator-trait method store_checkpoints_to_file() which, when called would set a struct member checkpoint_file: Option<File> that would then trigger to store the checkpoints in the file when the integrator goes out of scope. I think this is more secure and robust than doing this manually in the code. If the method is not called, we have self.checkpoint_file == None and no checkpoints are stored upon dropping.
On the other hand, since checkpoint files are somewhat related to presenting examples, I was wondering whether maybe they should be part of a dedicated callback function.
There is a lot of duplicated code in the functions integrators::plain::integrate() and integrators::plain::resume_integration_from_checkpoints() that could potentially be reduced by factoring out the main skeleton in a helper function.
The text was updated successfully, but these errors were encountered: