Skip to content

Commit 1a77b72

Browse files
Merge branch 'develop' into patch-1
2 parents 4271d2e + a6e43fa commit 1a77b72

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

docs/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ As of March 21, help is especially wanted from contributors with experience in K
2828
- Base your work on the `develop` branch.
2929
- Take a few minutes to review this [resource](https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Reviewer_Checklist) for contributors and reviewers, to accelerate the adoption of your contribution (thanks to the good folks at Mozilla for this).
3030
- Submit pull requests from your fork, also against the `develop` branch of the `CodeforPhilly/chime` repo.
31+
- As part of your pull request, please ensure you provide the following information
32+
- References to the issue/PR resolved with your contribution(s) (use key word e.g. Fixes #123, #321 See #213)
33+
- Explicitly identify the scope/area the change impacts (ex: Operations/Deployment/Model/Documentation)
34+
- Describe any necessary follow on work, ideally with links to any already open issues
3135
- Request review from the relevant maintainer(s).
3236
- Check your pull request periodically to see if any changes have been requested or any merge conflicts have arisen.
3337
- If a merge conflict arises, rebase against the latest `develop` branch and force-push the new branch as early as you can. You may need to do this more than once before your changes get merged. Do your best to keep your branch in a mergeable state until it is finished being reviewed and accepted.

src/penn_chime/models.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,40 @@ def __init__(self, p: Parameters):
6464
logger.info('Using doubling_time: %s', p.doubling_time)
6565

6666
intrinsic_growth_rate = get_growth_rate(p.doubling_time)
67-
6867
self.beta = get_beta(intrinsic_growth_rate, gamma, self.susceptible, 0.0)
6968
self.beta_t = get_beta(intrinsic_growth_rate, self.gamma, self.susceptible, p.relative_contact_rate)
7069

71-
self.i_day = 0 # seed to the full length
72-
raw = self.run_projection(p, [(self.beta, p.n_days)])
73-
self.i_day = i_day = int(get_argmin_ds(raw["census_hospitalized"], p.current_hospitalized))
70+
if p.mitigation_date is None:
71+
self.i_day = 0 # seed to the full length
72+
raw = self.run_projection(p, [(self.beta, p.n_days)])
73+
self.i_day = i_day = int(get_argmin_ds(raw["census_hospitalized"], p.current_hospitalized))
7474

75-
self.raw = self.run_projection(p, self.gen_policy(p))
75+
self.raw = self.run_projection(p, self.gen_policy(p))
76+
77+
logger.info('Set i_day = %s', i_day)
78+
else:
79+
projections = {}
80+
best_i_day = -1
81+
best_i_day_loss = float('inf')
82+
for i_day in range(p.n_days):
83+
self.i_day = i_day
84+
raw = self.run_projection(p, self.gen_policy(p))
85+
86+
# Don't fit against results that put the peak before the present day
87+
if raw["census_hospitalized"].argmax() < i_day:
88+
continue
89+
90+
loss = get_loss(raw["census_hospitalized"][i_day], p.current_hospitalized)
91+
if loss < best_i_day_loss:
92+
best_i_day_loss = loss
93+
best_i_day = i_day
94+
self.raw = raw
95+
96+
self.i_day = best_i_day
7697

77-
logger.info('Set i_day = %s', i_day)
78-
p.date_first_hospitalized = p.current_date - timedelta(days=i_day)
7998
logger.info(
8099
'Estimated date_first_hospitalized: %s; current_date: %s; i_day: %s',
81-
p.date_first_hospitalized,
100+
p.current_date - timedelta(days=self.i_day),
82101
p.current_date,
83102
self.i_day)
84103

0 commit comments

Comments
 (0)