diff --git a/cpp/memilio/epidemiology/lct_populations.h b/cpp/memilio/epidemiology/lct_populations.h index 6e1c783c4c..114569a8ef 100644 --- a/cpp/memilio/epidemiology/lct_populations.h +++ b/cpp/memilio/epidemiology/lct_populations.h @@ -168,8 +168,12 @@ class LctPopulations bool corrected = false; for (int i = 0; i < m_y.array().size(); i++) { if (m_y.array()[i] < 0.0) { - log_warning("Constraint check: Compartment size {:d} changed from {:.4f} to {:d}", i, m_y.array()[i], - 0); + if (m_y.array()[i] > -1e-10) { + log_warning("Constraint check: Compartment number {} changed from {} to {}", i, m_y.array()[i], 0); + } + else { + log_error("Constraint check: Compartment number {} changed from {} to {}", i, m_y.array()[i], 0); + } m_y.array()[i] = 0.; corrected = true; } diff --git a/cpp/memilio/epidemiology/populations.h b/cpp/memilio/epidemiology/populations.h index 5c0f918633..f2da6092ad 100644 --- a/cpp/memilio/epidemiology/populations.h +++ b/cpp/memilio/epidemiology/populations.h @@ -231,7 +231,8 @@ class Populations : public CustomIndexArray, Categories...> /** * @brief Checks whether all compartments have non-negative values. * This function can be used to prevent slighly negative function values in compartment sizes that came out - * due to roundoff errors if, e.g., population sizes were computed in a complex way. + * due to roundoff errors if, e.g., population sizes were computed in a complex way. If negative values + * which are smaller than -1e-10 are found, an error is logged, otherwise, only a warning is logged. * * Attention: This function should be used with care. It can not and will not set model parameters and * compartments to meaningful values. In most cases it is preferable to use check_constraints, @@ -245,8 +246,13 @@ class Populations : public CustomIndexArray, Categories...> bool corrected = false; for (int i = 0; i < this->array().size(); i++) { if (this->array()[i] < 0.0) { - log_warning("Constraint check: Compartment size {:d} changed from {:.4f} to {:d}", i, this->array()[i], - 0); + if (this->array()[i] > -1e-10) { + log_warning("Constraint check: Compartment number {} changed from {} to {}", i, this->array()[i], + 0); + } + else { + log_error("Constraint check: Compartment number {} changed from {} to {}", i, this->array()[i], 0); + } this->array()[i] = 0.0; corrected = true; } @@ -263,7 +269,7 @@ class Populations : public CustomIndexArray, Categories...> for (int i = 0; i < this->array().size(); i++) { FP value = this->array()[i]; if (value < 0.0) { - log_error("Constraint check: Compartment size {} is {} and smaller {}", i, value, 0); + log_error("Constraint check: Compartment number {} is {} and smaller {}", i, value, 0); return true; } } diff --git a/cpp/models/abm/parameters.h b/cpp/models/abm/parameters.h index be5bd886da..8806904895 100644 --- a/cpp/models/abm/parameters.h +++ b/cpp/models/abm/parameters.h @@ -799,8 +799,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0) { log_error("Constraint check: Mean of parameter TimeExposedToNoSymptoms of virus variant {} and " - "age group {:.0f} smaller " - "than {:.4f}", + "age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -808,8 +808,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedNoSymptomsToSymptoms " "of virus variant " - "{} and age group {:.0f} smaller " - "than {:d}", + "{} and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -817,8 +817,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedNoSymptomsToRecovered of " "virus variant " - "{} and age group {:.0f} smaller " - "than {:d}", + "{} and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -826,8 +826,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedSymptomsToSevere of virus " "variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -835,8 +835,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedSymptomsToRecovered of virus " "variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -844,8 +844,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedSevereToCritical of virus " "variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -853,8 +853,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedSevereToRecovered of virus " "variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -862,16 +862,16 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedSevereToDead of virus " "variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedCriticalToDead of virus variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -879,8 +879,8 @@ class Parameters : public ParametersBase if (this->get()[{v, i}].params()[0] < 0.0) { log_error("Constraint check: Mean of parameter TimeInfectedCriticalToRecovered of virus " "variant {} " - "and age group {:.0f} smaller " - "than {:d}", + "and age group {} smaller " + "than {}", (uint32_t)v, (size_t)i, 0); return true; } @@ -888,7 +888,7 @@ class Parameters : public ParametersBase if (this->get()[{v, i}] < 0.0 || this->get()[{v, i}] > 1.0) { log_error("Constraint check: Parameter SymptomsPerInfectedNoSymptoms of virus variant {} and age " - "group {:.0f} smaller than {:d} or larger than {:d}", + "group {} smaller than {} or larger than {}", (uint32_t)v, (size_t)i, 0, 1); return true; } @@ -896,7 +896,7 @@ class Parameters : public ParametersBase if (this->get()[{v, i}] < 0.0 || this->get()[{v, i}] > 1.0) { log_error("Constraint check: Parameter SeverePerInfectedSymptoms of virus variant {} and age group " - "{:.0f} smaller than {:d} or larger than {:d}", + "{} smaller than {} or larger than {}", (uint32_t)v, (size_t)i, 0, 1); return true; } @@ -904,15 +904,15 @@ class Parameters : public ParametersBase if (this->get()[{v, i}] < 0.0 || this->get()[{v, i}] > 1.0) { log_error("Constraint check: Parameter CriticalPerInfectedSevere of virus variant {} and age group " - "{:.0f} smaller than {:d} or larger than {:d}", + "{} smaller than {} or larger than {}", (uint32_t)v, (size_t)i, 0, 1); return true; } if (this->get()[{v, i}] < 0.0 || this->get()[{v, i}] > 1.0) { - log_error("Constraint check: Parameter DeathsPerInfectedSevere of age group {:.0f} smaller than " - "{:d} or larger than {:d}", + log_error("Constraint check: Parameter DeathsPerInfectedSevere of age group {} smaller than " + "{} or larger than {}", (uint32_t)v, (size_t)i, 0, 1); return true; } @@ -920,24 +920,24 @@ class Parameters : public ParametersBase if ((this->get()[{v, i}] + this->get()[{v, i}]) > 1.0) { log_error("Constraint check: Sum of parameters DeathsPerInfectedSevere and " - "CriticalPerInfectedSevere of age group {:.0f} larger than " - "{:d}", + "CriticalPerInfectedSevere of age group {} larger than " + "{}", (uint32_t)v, (size_t)i, 1); return true; } if (this->get()[{v, i}] < 0.0 || this->get()[{v, i}] > 1.0) { - log_error("Constraint check: Parameter DeathsPerInfectedCritical of age group {:.0f} smaller than " - "{:d} or larger than {:d}", + log_error("Constraint check: Parameter DeathsPerInfectedCritical of age group {} smaller than " + "{} or larger than {}", (uint32_t)v, (size_t)i, 0, 1); return true; } if (this->get()[{v, i}] < 0.0 || this->get()[{v, i}] > 1.0) { - log_error("Constraint check: Parameter DetectInfection of virus variant {} and age group {:.0f} " - "smaller than {:d} or " - "larger than {:d}", + log_error("Constraint check: Parameter DetectInfection of virus variant {} and age group {} " + "smaller than {} or " + "larger than {}", (uint32_t)v, (size_t)i, 0, 1); return true; } @@ -945,15 +945,15 @@ class Parameters : public ParametersBase if (this->get()[i].seconds() < 0.0 || this->get()[i].seconds() > this->get()[i].seconds()) { - log_error("Constraint check: Parameter GotoWorkTimeMinimum of age group {:.0f} smaller {:d} or " - "larger {:d}", + log_error("Constraint check: Parameter GotoWorkTimeMinimum of age group {} smaller {} or " + "larger {}", (size_t)i, 0, this->get()[i].seconds()); return true; } if (this->get()[i].seconds() < this->get()[i].seconds() || this->get()[i] > days(1)) { - log_error("Constraint check: Parameter GotoWorkTimeMaximum of age group {:.0f} smaller {:d} or larger " + log_error("Constraint check: Parameter GotoWorkTimeMaximum of age group {} smaller {} or larger " "than one day time span", (size_t)i, this->get()[i].seconds()); return true; @@ -961,15 +961,15 @@ class Parameters : public ParametersBase if (this->get()[i].seconds() < 0.0 || this->get()[i].seconds() > this->get()[i].seconds()) { - log_error("Constraint check: Parameter GotoSchoolTimeMinimum of age group {:.0f} smaller {:d} or " - "larger {:d}", + log_error("Constraint check: Parameter GotoSchoolTimeMinimum of age group {} smaller {} or " + "larger {}", (size_t)i, 0, this->get()[i].seconds()); return true; } if (this->get()[i].seconds() < this->get()[i].seconds() || this->get()[i] > days(1)) { - log_error("Constraint check: Parameter GotoWorkTimeMaximum of age group {:.0f} smaller {:d} or larger " + log_error("Constraint check: Parameter GotoWorkTimeMaximum of age group {} smaller {} or larger " "than one day time span", (size_t)i, this->get()[i].seconds()); return true; @@ -979,31 +979,31 @@ class Parameters : public ParametersBase if (this->get()[MaskType::Community] < 0.0 || this->get()[MaskType::Community] > 1.0) { log_error( - "Constraint check: Parameter MaskProtection for MaskType Community is smaller {:d} or larger {:d}", 0, + "Constraint check: Parameter MaskProtection for MaskType Community is smaller {} or larger {}", 0, 1); return true; } if (this->get()[MaskType::FFP2] < 0.0 || this->get()[MaskType::FFP2] > 1.0) { - log_error("Constraint check: Parameter MaskProtection for MaskType FFP2 is smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter MaskProtection for MaskType FFP2 is smaller {} or larger {}", 0, 1); return true; } if (this->get()[MaskType::Surgical] < 0.0 || this->get()[MaskType::Surgical] > 1.0) { - log_error("Constraint check: Parameter MaskProtection for MaskType Surgical smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter MaskProtection for MaskType Surgical smaller {} or larger {}", 0, 1); return true; } if (this->get().seconds() < 0.0) { - log_error("Constraint check: Parameter LockdownDate smaller {:d}", 0); + log_error("Constraint check: Parameter LockdownDate smaller {}", 0); return true; } if (this->get() < 0.0 || this->get() > 1.0) { - log_error("Constraint check: Parameter QuarantineEffectiveness not between {:d,:d}", 0.0, 1.0); + log_error("Constraint check: Parameter QuarantineEffectiveness not between {:d,:d}", 0, 1); return true; } diff --git a/cpp/models/glct_secir/parameters.h b/cpp/models/glct_secir/parameters.h index adb7932072..9172ffe123 100644 --- a/cpp/models/glct_secir/parameters.h +++ b/cpp/models/glct_secir/parameters.h @@ -488,24 +488,24 @@ class Parameters : public ParametersBase // --- Parameters affecting the transmission of the virus. --- if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {} or larger {}", 0, 1); return true; } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {} or larger {}", 0, 1); return true; } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {} or larger {}", 0, 1); return true; } if (this->template get>() < 0.0 || this->template get>() > 0.5) { - log_warning("Constraint check: Parameter Seasonality should lie between {:0.4f} and {:.4f}", 0.0, 0.5); + log_warning("Constraint check: Parameter Seasonality should lie between {} and {}", 0.0, 0.5); return true; } diff --git a/cpp/models/ide_secir/parameters.h b/cpp/models/ide_secir/parameters.h index de0aa5c85e..6d057f850b 100644 --- a/cpp/models/ide_secir/parameters.h +++ b/cpp/models/ide_secir/parameters.h @@ -232,8 +232,8 @@ class Parameters : public ParametersBase for (size_t i = 0; i < infectious_window_check; i++) { if (this->get()[group].eval((ScalarType)i) < 0.0 || this->get()[group].eval((ScalarType)i) > 1.0) { - log_error("Constraint check: TransmissionProbabilityOnContact smaller {:d} or larger {:d} at some " - "time {:d}", + log_error("Constraint check: TransmissionProbabilityOnContact smaller {} or larger {} at some " + "time {}", 0, 1, i); return true; } @@ -242,8 +242,8 @@ class Parameters : public ParametersBase for (size_t i = 0; i < infectious_window_check; i++) { if (this->get()[group].eval((ScalarType)i) < 0.0 || this->get()[group].eval((ScalarType)i) > 1.0) { - log_error("Constraint check: RelativeTransmissionNoSymptoms smaller {:d} or larger {:d} at some " - "time {:d}", + log_error("Constraint check: RelativeTransmissionNoSymptoms smaller {} or larger {} at some " + "time {}", 0, 1, i); return true; } @@ -252,8 +252,8 @@ class Parameters : public ParametersBase for (size_t i = 0; i < infectious_window_check; i++) { if (this->get()[group].eval((ScalarType)i) < 0.0 || this->get()[group].eval((ScalarType)i) > 1.0) { - log_error("Constraint check: RiskOfInfectionFromSymptomatic smaller {:d} or larger {:d} at some " - "time {:d}", + log_error("Constraint check: RiskOfInfectionFromSymptomatic smaller {} or larger {} at some " + "time {}", 0, 1, i); return true; } @@ -262,7 +262,7 @@ class Parameters : public ParametersBase for (size_t i = 0; i < (int)InfectionTransition::Count; i++) { if (this->get()[group][i] < 0.0 || this->get()[group][i] > 1.0) { - log_error("Constraint check: One parameter in TransitionProbabilities smaller {:d} or larger {:d}", + log_error("Constraint check: One parameter in TransitionProbabilities smaller {} or larger {}", 0, 1); return true; } @@ -271,7 +271,7 @@ class Parameters : public ParametersBase if (!floating_point_equal( this->get()[group][(int)InfectionTransition::SusceptibleToExposed], 1.0, 1e-14)) { - log_error("Constraint check: Parameter transition probability for SusceptibleToExposed unequal to {:d}", + log_error("Constraint check: Parameter transition probability for SusceptibleToExposed unequal to {}", 1); return true; } @@ -280,7 +280,7 @@ class Parameters : public ParametersBase this->get()[group][(int)InfectionTransition::ExposedToInfectedNoSymptoms], 1.0, 1e-14)) { log_error("Constraint check: Parameter transition probability for ExposedToInfectedNoSymptoms unequal " - "to {:d}", + "to {}", 1); return true; } @@ -292,7 +292,7 @@ class Parameters : public ParametersBase 1.0, 1e-14)) { log_error( "Constraint check: Sum of transition probability for InfectedNoSymptomsToInfectedSymptoms and " - "InfectedNoSymptomsToRecovered not equal to {:d}", + "InfectedNoSymptomsToRecovered not equal to {}", 1); return true; } @@ -303,7 +303,7 @@ class Parameters : public ParametersBase int)InfectionTransition::InfectedSymptomsToRecovered], 1.0, 1e-14)) { log_error("Constraint check: Sum of transition probability for InfectedSymptomsToInfectedSevere and " - "InfectedSymptomsToRecovered not equal to {:d}", + "InfectedSymptomsToRecovered not equal to {}", 1); return true; } @@ -314,7 +314,7 @@ class Parameters : public ParametersBase int)InfectionTransition::InfectedSevereToRecovered], 1.0, 1e-14)) { log_error("Constraint check: Sum of transition probability for InfectedSevereToInfectedCritical and " - "InfectedSevereToRecovered not equal to {:d}", + "InfectedSevereToRecovered not equal to {}", 1); return true; } @@ -325,7 +325,7 @@ class Parameters : public ParametersBase [(int)InfectionTransition::InfectedCriticalToRecovered], 1.0, 1e-14)) { log_error("Constraint check: Sum of transition probability for InfectedCriticalToDead and " - "InfectedCriticalToRecovered not equal to {:d}", + "InfectedCriticalToRecovered not equal to {}", 1); return true; } @@ -342,7 +342,7 @@ class Parameters : public ParametersBase } if (this->get() < 0.0 || this->get() > 0.5) { - log_warning("Constraint check: Parameter Seasonality should lie between {:0.4f} and {:.4f}", 0.0, 0.5); + log_warning("Constraint check: Parameter Seasonality should lie between {} and {}", 0.0, 0.5); return true; } diff --git a/cpp/models/lct_secir/parameters.h b/cpp/models/lct_secir/parameters.h index 956fccf219..ff21322d21 100644 --- a/cpp/models/lct_secir/parameters.h +++ b/cpp/models/lct_secir/parameters.h @@ -326,79 +326,79 @@ class Parameters : public ParametersBase bool check_constraints() const { if (this->template get>() < 0.0 || this->template get>() > 0.5) { - log_warning("Constraint check: Parameter Seasonality should lie between {:0.4f} and {:.4f}", 0.0, 0.5); + log_warning("Constraint check: Parameter Seasonality should lie between {} and {}", 0.0, 0.5); return true; } for (size_t i = 0; i < m_num_groups; ++i) { if (this->template get>()[i] < 1.0) { - log_error("Constraint check: Parameter TimeExposed is smaller than {:.4f}", 1.0); + log_error("Constraint check: Parameter TimeExposed is smaller than {}", 1.0); return true; } if (this->template get>()[i] < 1.0) { - log_error("Constraint check: Parameter TimeInfectedNoSymptoms is smaller than {:.4f}", 1.0); + log_error("Constraint check: Parameter TimeInfectedNoSymptoms is smaller than {}", 1.0); return true; } if (this->template get>()[i] < 1.0) { - log_error("Constraint check: Parameter TimeInfectedSymptoms is smaller than {:.4f}", 1.0); + log_error("Constraint check: Parameter TimeInfectedSymptoms is smaller than {}", 1.0); return true; } if (this->template get>()[i] < 1.0) { - log_error("Constraint check: Parameter TimeInfectedSevere is smaller than {:.4f}", 1.0); + log_error("Constraint check: Parameter TimeInfectedSevere is smaller than {}", 1.0); return true; } if (this->template get>()[i] < 1.0) { - log_error("Constraint check: Parameter TimeInfectedCritical is smaller than {:.4f}", 1.0); + log_error("Constraint check: Parameter TimeInfectedCritical is smaller than {}", 1.0); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter RecoveredPerInfectedNoSymptoms smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter RecoveredPerInfectedNoSymptoms smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter SeverePerInfectedSymptoms smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter SeverePerInfectedSymptoms smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter CriticalPerSevere smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter CriticalPerSevere smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter DeathsPerCritical smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter DeathsPerCritical smaller {} or larger {}", 0, 1); return true; } } diff --git a/cpp/models/ode_mseirs4/parameters.h b/cpp/models/ode_mseirs4/parameters.h index 540de58f64..0ddc1e0f4b 100644 --- a/cpp/models/ode_mseirs4/parameters.h +++ b/cpp/models/ode_mseirs4/parameters.h @@ -192,6 +192,12 @@ class Parameters : public ParametersBase bool corrected = false; auto clamp_nonneg = [&](auto& v) { if (v < 0) { + if (v > -1e-10) { + log_warning("Constraint check: Parameter was found negative. Changed from {} to {} ", v, 0); + } + else { + log_error("Constraint check: Parameter was found negative. Changed from {} to {} ", v, 0); + } v = 0; corrected = true; } @@ -215,10 +221,31 @@ class Parameters : public ParametersBase bool check_constraints() const { - if (this->template get>() < 0 || this->template get>() > 1) - return true; - return false; + bool violated = false; + + auto check_nonneg = [&](auto& v) { + if (v < 0) { + log_error("Constraint check: Parameter was found to be {} and should not be smaller than {}.", v, 0); + violated = true; + } + }; + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + check_nonneg(this->template get>()); + if (this->template get>() < 0 || this->template get>() > 1) { + log_error("Constraint check: Parameter SeasonalAmplitude was found to be out of [0, 1]."); + violated = true; + } + return violated; } + private: Parameters(ParametersBase&& base) : ParametersBase(std::move(base)) diff --git a/cpp/models/ode_seair/parameters.h b/cpp/models/ode_seair/parameters.h index 952d8a462e..482f374f6c 100644 --- a/cpp/models/ode_seair/parameters.h +++ b/cpp/models/ode_seair/parameters.h @@ -186,18 +186,18 @@ class Parameters : public ParametersBase bool check_constraints() const { if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter SocialDistancing smaller {:d}", 0); + log_error("Constraint check: Parameter SocialDistancing smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter Quarantined smaller {:d}", 0); + log_error("Constraint check: Parameter Quarantined smaller {}", 0); return true; } const FP tol_times = 1e-1; // accepted tolerance for compartment stays if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeExposed {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeExposed {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>(), tol_times); @@ -205,27 +205,27 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter RecoveryRateFromAsymptomatic smaller {:d}", 0); + log_error("Constraint check: Parameter RecoveryRateFromAsymptomatic smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter TestingRate smaller {:d}", 0); + log_error("Constraint check: Parameter TestingRate smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter RecoveryRate smaller {:d}", 0); + log_error("Constraint check: Parameter RecoveryRate smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter DeathRate smaller {:d}", 0); + log_error("Constraint check: Parameter DeathRate smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter TimeRecoveredInv smaller {:d}", 0); + log_error("Constraint check: Parameter TimeRecoveredInv smaller {}", 0); return true; } diff --git a/cpp/models/ode_secir/parameters.h b/cpp/models/ode_secir/parameters.h index 76c06b6ffd..c7bc194645 100644 --- a/cpp/models/ode_secir/parameters.h +++ b/cpp/models/ode_secir/parameters.h @@ -478,14 +478,14 @@ class Parameters : public ParametersBase int corrected = false; if (this->template get>() < 0.0 || this->template get>() > 0.5) { - log_warning("Constraint check: Parameter Seasonality changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter Seasonality changed from {} to {}", this->template get>(), 0); this->template set>(0); corrected = true; } if (this->template get>() < 0.0) { - log_warning("Constraint check: Parameter ICUCapacity changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter ICUCapacity changed from {} to {}", this->template get>(), 0); this->template set>(0); corrected = true; @@ -499,14 +499,14 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0) { - log_warning("Constraint check: Parameter TestAndTraceCapacity changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter TestAndTraceCapacity changed from {} to {}", this->template get>(), 0); this->template get>() = 0; corrected = true; } if (this->template get>() < 0.0) { - log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRisk changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRisk changed from {} to {}", this->template get>(), 0); this->template get>() = 0; corrected = true; @@ -514,7 +514,7 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeExposed changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeExposed changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -523,7 +523,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -532,7 +532,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedSymptoms changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeInfectedSymptoms changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -541,7 +541,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedSevere changed from {:.4f} to {:.4f}. Please note " + log_warning("Constraint check: Parameter TimeInfectedSevere changed from {} to {}. Please note " "that unreasonably small compartment stays lead to massively increased run time. Consider " "to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -550,7 +550,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedCritical changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeInfectedCritical changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -561,14 +561,14 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { log_warning( - "Constraint check: Parameter TransmissionProbabilityOnContact changed from {:0.4f} to {:d} ", - this->template get>()[i], 0.0); + "Constraint check: Parameter TransmissionProbabilityOnContact changed from {} to {} ", + this->template get>()[i], 0); this->template get>()[i] = 0.0; corrected = true; } if (this->template get>()[i] < 0.0) { - log_warning("Constraint check: Parameter RelativeTransmissionNoSymptoms changed from {:0.4f} to {:d} ", + log_warning("Constraint check: Parameter RelativeTransmissionNoSymptoms changed from {} to {} ", this->template get>()[i], 0); this->template get>()[i] = 0; corrected = true; @@ -576,7 +576,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_warning("Constraint check: Parameter RecoveredPerInfectedNoSymptoms changed from {:0.4f} to {:d} ", + log_warning("Constraint check: Parameter RecoveredPerInfectedNoSymptoms changed from {} to {} ", this->template get>()[i], 0); this->template get>()[i] = 0; corrected = true; @@ -584,7 +584,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_warning("Constraint check: Parameter RiskOfInfectionFromSymptomatic changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter RiskOfInfectionFromSymptomatic changed from {} to {}", this->template get>()[i], 0); this->template get>()[i] = 0; corrected = true; @@ -592,7 +592,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_warning("Constraint check: Parameter SeverePerInfectedSymptoms changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter SeverePerInfectedSymptoms changed from {} to {}", this->template get>()[i], 0); this->template get>()[i] = 0; corrected = true; @@ -600,7 +600,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_warning("Constraint check: Parameter CriticalPerSevere changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter CriticalPerSevere changed from {} to {}", this->template get>()[i], 0); this->template get>()[i] = 0; corrected = true; @@ -608,7 +608,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_warning("Constraint check: Parameter DeathsPerCritical changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter DeathsPerCritical changed from {} to {}", this->template get>()[i], 0); this->template get>()[i] = 0; corrected = true; @@ -625,27 +625,27 @@ class Parameters : public ParametersBase bool check_constraints() const { if (this->template get>() < 0.0 || this->template get>() > 0.5) { - log_error("Constraint check: Parameter Seasonality smaller {:d} or larger {:d}", 0, 0.5); + log_error("Constraint check: Parameter Seasonality smaller {} or larger {}", 0, 0.5); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter ICUCapacity smaller {:d}", 0); + log_error("Constraint check: Parameter ICUCapacity smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter TestAndTraceCapacity smaller {:d}", 0); + log_error("Constraint check: Parameter TestAndTraceCapacity smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter TestAndTraceCapacityMaxRisk smaller {:d}", 0); + log_error("Constraint check: Parameter TestAndTraceCapacityMaxRisk smaller {}", 0); return true; } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {:d}", 0); + log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {}", 0); return true; } @@ -653,7 +653,7 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeExposed {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeExposed {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -661,7 +661,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeInfectedNoSymptoms {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeInfectedNoSymptoms {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -669,7 +669,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeInfectedSymptoms {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeInfectedSymptoms {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -677,7 +677,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeInfectedSevere {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeInfectedSevere {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -685,7 +685,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeInfectedCritical {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeInfectedCritical {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -694,45 +694,45 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0) { - log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {:d}", 0); + log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {}", 0); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter RecoveredPerInfectedNoSymptoms smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter RecoveredPerInfectedNoSymptoms smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {:d} or larger {:d}", 0, + log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter SeverePerInfectedSymptoms smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter SeverePerInfectedSymptoms smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter CriticalPerSevere smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter CriticalPerSevere smaller {} or larger {}", 0, 1); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter DeathsPerCritical smaller {:d} or larger {:d}", 0, 1); + log_error("Constraint check: Parameter DeathsPerCritical smaller {} or larger {}", 0, 1); return true; } } diff --git a/cpp/models/ode_secirts/parameters.h b/cpp/models/ode_secirts/parameters.h index 878aef6431..74beb69228 100644 --- a/cpp/models/ode_secirts/parameters.h +++ b/cpp/models/ode_secirts/parameters.h @@ -892,7 +892,7 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeExposed changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeExposed changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -901,7 +901,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -1143,14 +1143,14 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {:d}", 0); + log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {}", 0); return true; } for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeExposed {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeExposed {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -1158,7 +1158,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeInfectedNoSymptoms {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeInfectedNoSymptoms {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); diff --git a/cpp/models/ode_secirvvs/parameters.h b/cpp/models/ode_secirvvs/parameters.h index 2034817803..c9640bbfe0 100644 --- a/cpp/models/ode_secirvvs/parameters.h +++ b/cpp/models/ode_secirvvs/parameters.h @@ -767,7 +767,7 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeExposed changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeExposed changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -776,7 +776,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {:.4f} to {:.4f}. Please " + log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {} to {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -980,14 +980,14 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0) { - log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {:d}", 0); + log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {}", 0); return true; } for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeExposed {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeExposed {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); @@ -995,7 +995,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { - log_error("Constraint check: Parameter TimeInfectedNoSymptoms {:.4f} smaller {:.4f}. Please " + log_error("Constraint check: Parameter TimeInfectedNoSymptoms {} smaller {}. Please " "note that unreasonably small compartment stays lead to massively increased run time. " "Consider to cancel and reset parameters.", this->template get>()[i], tol_times); diff --git a/cpp/models/ode_seir/parameters.h b/cpp/models/ode_seir/parameters.h index 8a590b7d04..0198685020 100644 --- a/cpp/models/ode_seir/parameters.h +++ b/cpp/models/ode_seir/parameters.h @@ -144,7 +144,7 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) { if (this->template get>()[i] < tol_times) { log_warning( - "Constraint check: Parameter TimeExposed changed from {:.4f} to {:.4f}. Please note that " + "Constraint check: Parameter TimeExposed changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>()[i], tol_times); @@ -153,7 +153,7 @@ class Parameters : public ParametersBase } if (this->template get>()[i] < tol_times) { log_warning( - "Constraint check: Parameter TimeInfected changed from {:.4f} to {:.4f}. Please note that " + "Constraint check: Parameter TimeInfected changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>()[i], tol_times); @@ -163,7 +163,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { log_warning( - "Constraint check: Parameter TransmissionProbabilityOnContact changed from {:0.4f} to {:d} ", + "Constraint check: Parameter TransmissionProbabilityOnContact changed from {} to {} ", this->template get>()[i], 0.0); this->template get>()[i] = 0.0; corrected = true; @@ -183,25 +183,25 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < m_num_groups; i++) { if (this->template get>()[i] < tol_times) { - log_error( - "Constraint check: Parameter TimeExposed {:.4f} smaller or equal {:.4f}. Please note that " + log_warning( + "Constraint check: Parameter TimeExposed {} smaller or equal {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", - this->template get>()[i], 0.0); + this->template get>()[i], tol_times); return true; } if (this->template get>()[i] < tol_times) { - log_error( - "Constraint check: Parameter TimeInfected {:.4f} smaller or equal {:.4f}. Please note that " + log_warning( + "Constraint check: Parameter TimeInfected {} smaller or equal {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", - this->template get>()[i], 0.0); + this->template get>()[i], tol_times); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContact {:.4f} smaller {:.4f} or " - "greater {:.4f}", + log_error("Constraint check: Parameter TransmissionProbabilityOnContact {} smaller {} or " + "greater {}", this->template get>()[i], 0.0, 1.0); return true; } diff --git a/cpp/models/ode_sir/parameters.h b/cpp/models/ode_sir/parameters.h index 2d2700305d..c0ca98470c 100644 --- a/cpp/models/ode_sir/parameters.h +++ b/cpp/models/ode_sir/parameters.h @@ -127,7 +127,7 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); i++) { if (this->template get>()[i] < tol_times) { log_warning( - "Constraint check: Parameter TimeInfected changed from {:.4f} to {:.4f}. Please note that " + "Constraint check: Parameter TimeInfected changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>()[i], tol_times); @@ -137,7 +137,7 @@ class Parameters : public ParametersBase if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { log_warning( - "Constraint check: Parameter TransmissionProbabilityOnContact changed from {:0.4f} to {:d} ", + "Constraint check: Parameter TransmissionProbabilityOnContact changed from {} to {} ", this->template get>()[i], 0.0); this->template get>() = 0.0; corrected = true; @@ -158,17 +158,17 @@ class Parameters : public ParametersBase for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); i++) { if (this->template get>()[i] < tol_times) { - log_error( - "Constraint check: Parameter TimeInfected {:.4f} smaller or equal {:.4f}. Please note that " + log_warning( + "Constraint check: Parameter TimeInfected {} smaller or equal {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", - this->template get>()[i], 0.0); + this->template get>()[i], tol_times); return true; } if (this->template get>()[i] < 0.0 || this->template get>()[i] > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContact {:.4f} smaller {:.4f} or " - "greater {:.4f}", + log_error("Constraint check: Parameter TransmissionProbabilityOnContact {} smaller {} or " + "greater {}", this->template get>()[i], 0.0, 1.0); return true; } diff --git a/cpp/models/sde_seirvv/parameters.h b/cpp/models/sde_seirvv/parameters.h index 534289d0c8..9e2bdfc227 100644 --- a/cpp/models/sde_seirvv/parameters.h +++ b/cpp/models/sde_seirvv/parameters.h @@ -184,7 +184,7 @@ class Parameters : public ParametersBase int corrected = false; if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeExposedV1 changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeExposedV1 changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -192,7 +192,7 @@ class Parameters : public ParametersBase corrected = true; } if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeExposedV2 changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeExposedV2 changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -200,7 +200,7 @@ class Parameters : public ParametersBase corrected = true; } if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedV1 changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeInfectedV1 changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -208,7 +208,7 @@ class Parameters : public ParametersBase corrected = true; } if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeInfectedV2 changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeInfectedV2 changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -217,14 +217,14 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_warning("Constraint check: Parameter TransmissionProbabilityOnContactV1 changed from {:0.4f} to {:d} ", + log_warning("Constraint check: Parameter TransmissionProbabilityOnContactV1 changed from {} to {} ", this->template get>(), 0.0); this->template get>() = 0.0; corrected = true; } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_warning("Constraint check: Parameter TransmissionProbabilityOnContactV2 changed from {:0.4f} to {:d} ", + log_warning("Constraint check: Parameter TransmissionProbabilityOnContactV2 changed from {} to {} ", this->template get>(), 0.0); this->template get>() = 0.0; corrected = true; @@ -242,44 +242,44 @@ class Parameters : public ParametersBase FP tol_times = 1e-1; if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeExposedV1 {:.4f} smaller or equal {:.4f}. Please note that " - "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " - "and reset parameters.", - this->template get>(), 0.0); + log_warning("Constraint check: Parameter TimeExposedV1 {} smaller or equal {}. Please note that " + "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " + "and reset parameters.", + this->template get>(), tol_times); return true; } if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeExposedV2 {:.4f} smaller or equal {:.4f}. Please note that " - "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " - "and reset parameters.", - this->template get>(), 0.0); + log_warning("Constraint check: Parameter TimeExposedV2 {} smaller or equal {}. Please note that " + "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " + "and reset parameters.", + this->template get>(), tol_times); return true; } if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeInfectedV1 {:.4f} smaller or equal {:.4f}. Please note that " - "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " - "and reset parameters.", - this->template get>(), 0.0); + log_warning("Constraint check: Parameter TimeInfectedV1 {} smaller or equal {}. Please note that " + "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " + "and reset parameters.", + this->template get>(), tol_times); return true; } if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeInfectedV2 {:.4f} smaller or equal {:.4f}. Please note that " - "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " - "and reset parameters.", - this->template get>(), 0.0); + log_warning("Constraint check: Parameter TimeInfectedV2 {} smaller or equal {}. Please note that " + "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " + "and reset parameters.", + this->template get>(), tol_times); return true; } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContactV1 {:.4f} smaller {:.4f} or greater " - "{:.4f}", + log_error("Constraint check: Parameter TransmissionProbabilityOnContactV1 {} smaller {} or greater " + "{}", this->template get>(), 0.0, 1.0); return true; } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_error("Constraint check: Parameter TransmissionProbabilityOnContactV2 {:.4f} smaller {:.4f} or greater " - "{:.4f}", + log_error("Constraint check: Parameter TransmissionProbabilityOnContactV2 {} smaller {} or greater " + "{}", this->template get>(), 0.0, 1.0); return true; } diff --git a/cpp/models/sde_sir/parameters.h b/cpp/models/sde_sir/parameters.h index ea4b115ee0..deb57d719d 100644 --- a/cpp/models/sde_sir/parameters.h +++ b/cpp/models/sde_sir/parameters.h @@ -116,7 +116,7 @@ class Parameters : public ParametersBase int corrected = false; if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeInfected changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeInfected changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -125,7 +125,7 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_warning("Constraint check: Parameter TransmissionProbabilityOnContact changed from {:0.4f} to {:d} ", + log_warning("Constraint check: Parameter TransmissionProbabilityOnContact changed from {} to {} ", this->template get>(), 0.0); this->template get>() = 0.0; corrected = true; @@ -143,16 +143,16 @@ class Parameters : public ParametersBase FP tol_times = 1e-1; if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeInfected {:.4f} smaller or equal {:.4f}. Please note that " - "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " - "and reset parameters.", - this->template get>(), 0.0); + log_warning("Constraint check: Parameter TimeInfected {} smaller or equal {}. Please note that " + "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " + "and reset parameters.", + this->template get>(), tol_times); return true; } if (this->template get>() < 0.0 || this->template get>() > 1.0) { log_error( - "Constraint check: Parameter TransmissionProbabilityOnContact {:.4f} smaller {:.4f} or greater {:.4f}", + "Constraint check: Parameter TransmissionProbabilityOnContact {} smaller {} or greater {}", this->template get>(), 0.0, 1.0); return true; } diff --git a/cpp/models/sde_sirs/parameters.h b/cpp/models/sde_sirs/parameters.h index fbf49b70b1..0b63e90aac 100644 --- a/cpp/models/sde_sirs/parameters.h +++ b/cpp/models/sde_sirs/parameters.h @@ -170,13 +170,13 @@ class Parameters : public ParametersBase int corrected = false; if (this->template get>() < 0.0 || this->template get>() > 0.5) { - log_warning("Constraint check: Parameter Seasonality changed from {:0.4f} to {:d}", + log_warning("Constraint check: Parameter Seasonality changed from {} to {}", this->template get>(), 0); this->template set>(0); corrected = true; } if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeInfected changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeInfected changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -184,7 +184,7 @@ class Parameters : public ParametersBase corrected = true; } if (this->template get>() < tol_times) { - log_warning("Constraint check: Parameter TimeInfected changed from {:.4f} to {:.4f}. Please note that " + log_warning("Constraint check: Parameter TimeInfected changed from {} to {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), tol_times); @@ -193,7 +193,7 @@ class Parameters : public ParametersBase } if (this->template get>() < 0.0 || this->template get>() > 1.0) { - log_warning("Constraint check: Parameter TransmissionProbabilityOnContact changed from {:0.4f} to {:d} ", + log_warning("Constraint check: Parameter TransmissionProbabilityOnContact changed from {} to {} ", this->template get>(), 0.0); this->template get>() = 0.0; corrected = true; @@ -211,18 +211,18 @@ class Parameters : public ParametersBase FP tol_times = 1e-1; if (this->template get>() < 0.0 || this->template get>() > 0.5) { - log_error("Constraint check: Parameter Seasonality smaller {:d} or larger {:d}", 0, 0.5); + log_error("Constraint check: Parameter Seasonality smaller {} or larger {:4f}", 0, 0.5); return true; } if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeInfected {:.4f} smaller or equal {:.4f}. Please note that " + log_error("Constraint check: Parameter TimeInfected {} smaller or equal {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), 0.0); return true; } if (this->template get>() < tol_times) { - log_error("Constraint check: Parameter TimeInfected {:.4f} smaller or equal {:.4f}. Please note that " + log_error("Constraint check: Parameter TimeInfected {} smaller or equal {}. Please note that " "unreasonably small compartment stays lead to massively increased run time. Consider to cancel " "and reset parameters.", this->template get>(), 0.0); @@ -231,7 +231,7 @@ class Parameters : public ParametersBase if (this->template get>() < 0.0 || this->template get>() > 1.0) { log_error( - "Constraint check: Parameter TransmissionProbabilityOnContact {:.4f} smaller {:.4f} or greater {:.4f}", + "Constraint check: Parameter TransmissionProbabilityOnContact {} smaller {} or greater {}", this->template get>(), 0.0, 1.0); return true; }