From 9c57421181205b4ebca7ed10b9d253210386482d Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 23 Jul 2026 09:19:44 +0000 Subject: [PATCH 1/2] Add missing FP template --- cpp/models/ode_secir/model.h | 4 ++-- cpp/models/ode_secirts/model.h | 4 ++-- cpp/models/ode_secirvvs/model.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/models/ode_secir/model.h b/cpp/models/ode_secir/model.h index 664d26f09c..ab6103a028 100644 --- a/cpp/models/ode_secir/model.h +++ b/cpp/models/ode_secir/model.h @@ -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..848cbd59fe 100644 --- a/cpp/models/ode_secirts/model.h +++ b/cpp/models/ode_secirts/model.h @@ -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..815514864c 100644 --- a/cpp/models/ode_secirvvs/model.h +++ b/cpp/models/ode_secirvvs/model.h @@ -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 From c92fba934891ff57002cb47424f3570702ba7d5a Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 23 Jul 2026 09:21:27 +0000 Subject: [PATCH 2/2] Add tolerance to while condition --- cpp/models/ode_secir/model.h | 2 +- cpp/models/ode_secirts/model.h | 2 +- cpp/models/ode_secirvvs/model.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/models/ode_secir/model.h b/cpp/models/ode_secir/model.h index ab6103a028..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()); } diff --git a/cpp/models/ode_secirts/model.h b/cpp/models/ode_secirts/model.h index 848cbd59fe..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()); diff --git a/cpp/models/ode_secirvvs/model.h b/cpp/models/ode_secirvvs/model.h index 815514864c..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());