Skip to content

Commit 3a06d82

Browse files
authored
1144 handle case when group size is equal to 0 for the LCT model (#1156)
Catch case where the subpopulation size is zero.
1 parent f76d14f commit 3a06d82

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cpp/models/lct_secir/model.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,10 @@ class Model
321321
.sum();
322322
// Size of the Subpopulation Group2 without dead people.
323323
double N_2 = pop.segment(first_index_group2, LctStateGroup2::Count - 1).sum();
324+
const double divN_2 = (N_2 < Limits<ScalarType>::zero_tolerance()) ? 0.0 : 1.0 / N_2;
324325
ScalarType season_val = 1 + params.template get<Seasonality>() *
325326
sin(3.141592653589793 * ((params.template get<StartDay>() + t) / 182.5 + 0.5));
326-
dydt[Si_1] += -y[Si_1] / N_2 * season_val * params.template get<TransmissionProbabilityOnContact>()[Group1] *
327+
dydt[Si_1] += -y[Si_1] * divN_2 * season_val * params.template get<TransmissionProbabilityOnContact>()[Group1] *
327328
params.template get<ContactPatterns>().get_cont_freq_mat().get_matrix_at(t)(
328329
static_cast<Eigen::Index>(Group1), static_cast<Eigen::Index>(Group2)) *
329330
(params.template get<RelativeTransmissionNoSymptoms>()[Group2] * infectedNoSymptoms_2 +

0 commit comments

Comments
 (0)