starsimhub / starsim

Starsim disease modeling framework
http://starsim.org
MIT License
15 stars 9 forks source link

Prenatal pairs should be removed even if postnatal layer not specified #625

Open edwenger opened 1 month ago

edwenger commented 1 month ago

If simulation is initialized with networks=[ss.PrenatalNet()] (i.e. without also ss.PostnatalNet()) the prenatal links are not removed at delivery. That would seem to be a valid scenario where one would expect the prenatal links not to persist indefinitely.

https://github.com/starsimhub/starsim/blob/main/starsim/demographics.py#L412

I suspect it would be more appropriate to refactor most of the logic in that block (including prenatalnet.end_pairs()) to just be inside an if self.n_births block.

And then to have the following lines inside a block that does the for lkey, layer in self.sim.networks.items() if layer.postnatal loop + check:

durs = self.dur_postpartum[new_mother_uids]
start = np.full(self.n_births, fill_value=self.sim.ti)
layer.add_pairs(new_mother_uids, new_infant_uids, dur=durs, start=start)
edwenger commented 1 month ago

I see they already have beta=0 set here with some consideration of cleanup being owned by the network: https://github.com/starsimhub/starsim/blob/main/starsim/network.py#L936