MathCancer / PhysiCell

PhysiCell: Scientist end users should use latest release! Developers please fork the development branch and submit PRs to the dev branch. Thanks!
http://PhysiCell.org
137 stars 92 forks source link

Restart a simulation from where it stopped #55

Open idontgetoutmuch opened 3 years ago

idontgetoutmuch commented 3 years ago

In http://www.mathcancer.org/blog/saving-multicellds-data-from-biofvm/ I see

Future releases of BioFVM will support reading MultiCellDS snapshots (for model initialization).

I'd like to be able to restart a simulation from where it stopped. Is this now possible?

I found this: https://github.com/idontgetoutmuch/PhysiCell/blob/master/BioFVM/BioFVM_MultiCellDS.h#L191-L200 which suggests that I will have to implement read_BioFVM_to_MultiCellDS_xml_pugi myself?

MathCancer commented 2 years ago

Hi! This is on my radar now for perhaps 1.10.1.

idontgetoutmuch commented 2 years ago

@MathCancer from the point of view of inference, I have a function with this type

Particles (a, d) ->
(a -> m a) ->
(a -> b) ->
(b -> b -> d) ->
b ->
m (Particles (a, d))

Here a is the state of the simulation and d is a double indicating how likely this particular state is. b is what you are allowed to observe, e.g., the diameter of the tumour. Particles just means you have a collection of states and their respective weights (the samples are historically called particles).

The idea is you start with a set of guesses (samples) and then use a parameter, the function a -> m a, to update the state to the time at which the next observation is available. In PhysiCell terms this means starting PhysiCell with a known state and then returning the new state (which is then used as the old state for the next step). The m denotes that PhysiCell is stochastic (actually it means more but that would detract).

The parameter a -> b (which is a function) takes the state and returns a measurement. The parameter b -> b -> d is the likelihood of the predicted observation given the actual observation. b is the actual observation.

Finally the function returns a new set of states and weights (unnormalised probabilities) and the whole process can be repeated.

I am in the middle of writing a blog post on how all this works. I might post a draft here when it's actually readable as it might help illuminate what is required.

  1. Would it be possible to have a C function that takes the current PhysiCell state and returns the new state?
  2. Can multiple PhysiCell simulations be run in parallel?

@adriannejnner FYI

MathCancer commented 1 year ago

Hello, I wanted to follow up / touch base.

This is in fact on our radar, and we are inching towards a full read, and this is an area that a hackathon team worked on at ws2022. (We should check in with them ... )

I don't envision writing a run_physicell( ) function around main at this time, but I can definitely see where it woudl be helpful for the scenarios you point out!! I'm concerned that the memory model may make this very difficult ot do in practice without some significant and careful software engineering. So I'm inclined to tiptoe for now ...

idontgetoutmuch commented 1 year ago

Great to know it is still on your radar. I have an intern working on ABMs in Haskell and I am working on a probabilistic programming language (in Haskell). One of the things we can now do is track processes in real time using particle filtering. One of the applications for this was adjusting treatments for patients.

I don't have any immediate requirement to run complex biological models but sometimes customers pop up unexpectedly.

It would be interesting to know where the hackathon team got to. Perhaps they have a summary or presentation?