I've been doing some simulations where the set of particles involved changes quite frequently. This has raised some issues with how IMP should handle particles being created and destroyed
1) When can you change the set of particles being optimized? My current opinion is that OptimizerStates should be allowed to change the set of particles, but ScoreStates should not. With that rule, the space being optimized can change between optimizer steps, but not during one. I added a constructor to BrownianDynamics which allows you to explicitly provide the set of the particles to optimize (via a SingletonList), but I think simply rescanning the model might not be noticeably less efficient.
2) How to handle saving and restoring state? The model_io functions don't work when the number of particles changes. The reason for this is that there is no way to insert extra particles read into restraints and things. One possible solution to this is to have the List{Singleton,Pair}Container objects use a Particle as their underlying storage mechanism. Then their sets of particles can be easily saved and restored by the model_io functions (or anything else which looks at all the particles). Since restraints (should) use these containers as their underlying storage, then restraints could have their state restored too. Making such a change would result in much more data being stored as particle attributes, so we would have to be careful that it didn't result in a performance penalty.
Anyone have any thoughts on these questions?