Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exception when emergence is negative in SimpleMPD model #379

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions model/Transmission/Anopheles/SimpleMPDAnophelesModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class SimpleMPDAnophelesModel : public AnophelesModel
{
bool fitted = AnophelesModel::initIterate();

int y1 = sim::oneYear(), y2 = sim::fromYearsI(2), y3 = sim::fromYearsI(3), y4 = sim::fromYearsI(4),
y5 = sim::fromYearsI(5);
int y1 = sim::oneYear(), y2 = sim::fromYearsI(2), y3 = sim::fromYearsI(3), y4 = sim::fromYearsI(4), y5 = sim::fromYearsI(5);

assert((int)mosqEmergeRate.size() == y1);

for (int t = 0; t < y1; t++)
Expand All @@ -123,6 +123,11 @@ class SimpleMPDAnophelesModel : public AnophelesModel

virtual double getEmergenceRate(const SimTime &d0, const std::vector<double> &mosqEmergeRate, double nOvipositing)
{
// // Get emergence at start of step:
// SimTime dYear1 = mod_nn(d0, sim::oneYear());
// // Simple model: fixed emergence scaled by larviciding
// return mosqEmergeRate[dYear1];

// Simple Mosquito Population Dynamics model: emergence depends on the
// adult population, resources available, and larviciding.
// See: A Simple Periodically-Forced Difference Equation Model for
Expand All @@ -133,7 +138,16 @@ class SimpleMPDAnophelesModel : public AnophelesModel
double emergence = probPreadultSurvival * yt / (1.0 + invLarvalResources[mod_nn(d0, sim::oneYear())] * yt);
nOvipositingDelayed[util::mod_nn(d1, developmentDuration)] = nOvipositing;
quinquennialOvipositing[util::mod_nn(d1, sim::fromYearsI(5))] = nOvipositing;
return emergence;

if (emergence < 0)
{
std::ostringstream oss;
oss << "Error: SimpleMPD model: negative emergence at t=" << d0 << ": " << emergence << ". ";
oss << "Check the seasonality and make sure it does not go too low. For monthly EIR values, the lowest point should not be below 1% of the peak EIR.";
throw util::base_exception(oss.str());
}

return std::max(emergence, 0.0);
}

///@brief Interventions and reporting
Expand Down
Loading