Skip to content

Commit 7f36b26

Browse files
committed
+1 time offset for dynamic npis
1 parent b05d080 commit 7f36b26

4 files changed

Lines changed: 107 additions & 62 deletions

File tree

cpp/models/ode_secir/model.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,17 @@ class Simulation : public BaseT
322322

323323
if (t + delay_npi_implementation < direc_end) {
324324
auto t_start = SimulationTime<FP>(t + delay_npi_implementation);
325-
// set the end to the minimum of start+delay and the end of the directive
325+
// set the end to the minimum of start+duration and the end of the directive
326326
auto t_end = SimulationTime<FP>(min<FP>(direc_end, FP(t_start + dyn_npis.get_duration())));
327327
m_dynamic_npi = std::make_pair(exceeded_threshold->first, t_end);
328+
// For t_start > 0: shift dampings by +1 so the smooth transition window
329+
// [t_start, t_start+1] lies in the future, consistent with predefined dampings.
330+
// For t_start = 0: window [-1, 0] is in the past, so keep as is.
331+
auto t_start_damping =
332+
(FP(t_start) > FP(0)) ? SimulationTime<FP>(FP(t_start) + FP(1)) : t_start;
333+
auto t_end_damping = (FP(t_start) > FP(0)) ? SimulationTime<FP>(FP(t_end) + FP(1)) : t_end;
328334
implement_dynamic_npis<FP>(contact_patterns.get_cont_freq_mat(), exceeded_threshold->second,
329-
t_start, t_end, [](auto& g) {
335+
t_start_damping, t_end_damping, [](auto& g) {
330336
return make_contact_damping_matrix(g);
331337
});
332338
}

cpp/models/ode_secirts/model.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,13 +792,19 @@ class Simulation : public BaseT
792792

793793
if (t + delay_npi_implementation < direc_end) {
794794
auto t_start = SimulationTime<FP>(t + delay_npi_implementation);
795-
// set the end to the minimum of start+delay and the end of the directive
795+
// set the end to the minimum of start+duration and the end of the directive
796796
auto t_end = SimulationTime<FP>(min<FP>(direc_end, FP(t_start + dyn_npis.get_duration())));
797797
this->get_model().parameters.get_start_commuter_detection() = (FP)t_start;
798798
this->get_model().parameters.get_end_commuter_detection() = (FP)t_end;
799799
m_dynamic_npi = std::make_pair(exceeded_threshold->first, t_end);
800+
// For t_start > 0: shift dampings by +1 so the smooth transition window
801+
// [t_start, t_start+1] lies in the future, consistent with predefined dampings.
802+
// For t_start = 0: window [-1, 0] is in the past, so keep as is.
803+
auto t_start_damping =
804+
(FP(t_start) > FP(0)) ? SimulationTime<FP>(FP(t_start) + FP(1)) : t_start;
805+
auto t_end_damping = (FP(t_start) > FP(0)) ? SimulationTime<FP>(FP(t_end) + FP(1)) : t_end;
800806
implement_dynamic_npis(contact_patterns.get_cont_freq_mat(), exceeded_threshold->second,
801-
t_start, t_end, [](auto& g) {
807+
t_start_damping, t_end_damping, [](auto& g) {
802808
return make_contact_damping_matrix(g);
803809
});
804810
}

cpp/models/ode_secirvvs/model.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,19 @@ class Simulation : public BaseT
717717

718718
if (t + delay_npi_implementation < direc_end) {
719719
auto t_start = SimulationTime<FP>(t + delay_npi_implementation);
720-
// set the end to the minimum of start+delay and the end of the directive
720+
// set the end to the minimum of start+duration and the end of the directive
721721
auto t_end = SimulationTime<FP>(min<FP>(direc_end, FP(t_start + dyn_npis.get_duration())));
722722
this->get_model().parameters.get_start_commuter_detection() = (FP)t_start;
723723
this->get_model().parameters.get_end_commuter_detection() = (FP)t_end;
724724
m_dynamic_npi = std::make_pair(exceeded_threshold->first, t_end);
725+
// For t_start > 0: shift dampings by +1 so the smooth transition window
726+
// [t_start, t_start+1] lies in the future, consistent with predefined dampings.
727+
// For t_start = 0: window [-1, 0] is in the past, so keep as is.
728+
auto t_start_damping =
729+
(FP(t_start) > FP(0)) ? SimulationTime<FP>(FP(t_start) + FP(1)) : t_start;
730+
auto t_end_damping = (FP(t_start) > FP(0)) ? SimulationTime<FP>(FP(t_end) + FP(1)) : t_end;
725731
implement_dynamic_npis(contact_patterns.get_cont_freq_mat(), exceeded_threshold->second,
726-
t_start, t_end, [](auto& g) {
732+
t_start_damping, t_end_damping, [](auto& g) {
727733
return make_contact_damping_matrix(g);
728734
});
729735
}

0 commit comments

Comments
 (0)