edwenger / starsim-bokeh-demo

0 stars 0 forks source link

Abstract out p_infection logic in base-class make_new_cases #4

Open edwenger opened 3 weeks ago

edwenger commented 3 weeks ago
# p_transmit = rel_trans[src] * rel_sus[trg] * beta_per_dt
p_transmit = self.p_transmit(rel_trans[src], rel_sus[trg], beta_per_dt)
def p_transmit(self, rel_trans_src, rel_sus_target, beta_per_dt):
    prob_infection = rel_trans_src * rel_sus_target * beta_per_dt  # ss.Infection base case
    return prob_infection
edwenger commented 2 weeks ago

Mostly possible already with this performance-inspired modification: https://github.com/starsimhub/starsim/commit/9cc1d7c9f1b4e29d80385a9cc8c89227b65619e5

Would still need to pass in self.pars (possibly upstream of staticmethod call in ss.Infection.infect()?) to be able to use the instance-level parameters that shape the dose-response curve, though.

pars = self.pars
alpha = pars.p_transmit['alpha']
gamma = pars.p_transmit['gamma']

prob_infection = (1 - (1 + dose / pars.sabin_scale_parameter) ** (-alpha * (rel_sus_target) ** -gamma)) * pars.strain_take_modifier

Like, for example, here: https://github.com/starsimhub/starsim/blob/v2.0.0/starsim/diseases/hiv.py#L40