diff --git a/cpp/models/ode_secir/model.h b/cpp/models/ode_secir/model.h index 664d26f09c..61ee912ffa 100644 --- a/cpp/models/ode_secir/model.h +++ b/cpp/models/ode_secir/model.h @@ -300,7 +300,7 @@ class Simulation : public BaseT FP delay_npi_implementation; FP t = BaseT::get_result().get_last_time(); - while (t < tmax) { + while (floating_point_less(t, tmax, 1e-10)) { if (t > 0) { delay_npi_implementation = FP(dyn_npis.get_implementation_delay()); } @@ -311,11 +311,11 @@ class Simulation : public BaseT if (dyn_npis.get_thresholds().size() > 0) { FP direc_begin = FP(dyn_npis.get_directive_begin()); FP direc_end = FP(dyn_npis.get_directive_end()); - if (floating_point_greater_equal(t, direc_begin, 1e-10) && t < direc_end) { + if (floating_point_greater_equal(t, direc_begin, 1e-10) && t < direc_end) { auto inf_rel = get_infections_relative(*this, t, this->get_result().get_last_value()) * dyn_npis.get_base_value(); auto exceeded_threshold = dyn_npis.get_max_exceeded_threshold(inf_rel); - const bool npi_expired = floating_point_greater_equal(t, FP(m_dynamic_npi.second), 1e-10); + const bool npi_expired = floating_point_greater_equal(t, FP(m_dynamic_npi.second), 1e-10); if (exceeded_threshold != dyn_npis.get_thresholds().end() && (exceeded_threshold->first > m_dynamic_npi.first || npi_expired)) { // old npi was weaker or is expired diff --git a/cpp/models/ode_secirts/model.h b/cpp/models/ode_secirts/model.h index 78119b3c17..c89b95314a 100644 --- a/cpp/models/ode_secirts/model.h +++ b/cpp/models/ode_secirts/model.h @@ -768,7 +768,7 @@ class Simulation : public BaseT FP delay_npi_implementation; FP t = BaseT::get_result().get_last_time(); - while (t < tmax) { + while (floating_point_less(t, tmax, 1e-10)) { if (t > 0) { delay_npi_implementation = FP(dyn_npis.get_implementation_delay()); @@ -781,11 +781,11 @@ class Simulation : public BaseT if (dyn_npis.get_thresholds().size() > 0) { FP direc_begin = FP(dyn_npis.get_directive_begin()); FP direc_end = FP(dyn_npis.get_directive_end()); - if (floating_point_greater_equal(t, direc_begin, 1e-10) && t < direc_end) { + if (floating_point_greater_equal(t, direc_begin, 1e-10) && t < direc_end) { auto inf_rel = get_infections_relative(*this, t, this->get_result().get_last_value()) * dyn_npis.get_base_value(); auto exceeded_threshold = dyn_npis.get_max_exceeded_threshold(inf_rel); - const bool npi_expired = floating_point_greater_equal(t, FP(m_dynamic_npi.second), 1e-10); + const bool npi_expired = floating_point_greater_equal(t, FP(m_dynamic_npi.second), 1e-10); if (exceeded_threshold != dyn_npis.get_thresholds().end() && (exceeded_threshold->first > m_dynamic_npi.first || npi_expired)) { //old npi was weaker or is expired diff --git a/cpp/models/ode_secirvvs/model.h b/cpp/models/ode_secirvvs/model.h index 9ed73d0abb..2e7806a463 100644 --- a/cpp/models/ode_secirvvs/model.h +++ b/cpp/models/ode_secirvvs/model.h @@ -690,7 +690,7 @@ class Simulation : public BaseT FP delay_npi_implementation; FP t = BaseT::get_result().get_last_time(); - while (t < tmax) { + while (floating_point_less(t, tmax, 1e-10)) { if (t > 0) { delay_npi_implementation = FP(dyn_npis.get_implementation_delay()); @@ -706,11 +706,11 @@ class Simulation : public BaseT if (dyn_npis.get_thresholds().size() > 0) { FP direc_begin = FP(dyn_npis.get_directive_begin()); FP direc_end = FP(dyn_npis.get_directive_end()); - if (floating_point_greater_equal(t, direc_begin, 1e-10) && t < direc_end) { + if (floating_point_greater_equal(t, direc_begin, 1e-10) && t < direc_end) { auto inf_rel = get_infections_relative(*this, t, this->get_result().get_last_value()) * dyn_npis.get_base_value(); auto exceeded_threshold = dyn_npis.get_max_exceeded_threshold(inf_rel); - const bool npi_expired = floating_point_greater_equal(t, FP(m_dynamic_npi.second), 1e-10); + const bool npi_expired = floating_point_greater_equal(t, FP(m_dynamic_npi.second), 1e-10); if (exceeded_threshold != dyn_npis.get_thresholds().end() && (exceeded_threshold->first > m_dynamic_npi.first || npi_expired)) { //old npi was weaker or is expired