From 287e1146d287ef1464ae4525b15f4122b9242a25 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 19 Dec 2024 12:25:04 -0500 Subject: [PATCH 1/2] update rounding for overpopulations --- inst/include/actions.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/inst/include/actions.hpp b/inst/include/actions.hpp index 1b05188e..6c74e45e 100644 --- a/inst/include/actions.hpp +++ b/inst/include/actions.hpp @@ -365,9 +365,8 @@ class MoveOverpopulatedPests dispersal_kernel_(generator.overpopulation(), i, j); // for leaving_percentage == 0.5 // 2 infected -> 1 leaving - // 3 infected -> 1 leaving - int leaving = - static_cast(std::floor(original_count * leaving_percentage_)); + // 3 infected -> 2 leaving (assuming always rounding up for .5) + int leaving = std::lround(original_count * leaving_percentage_); leaving = hosts.pests_from(i, j, leaving, generator.overpopulation()); if (row < 0 || row >= rows_ || col < 0 || col >= cols_) { pests.add_outside_dispersers_at(row, col, leaving); From 5f03db00407684977ee1f142fb8ead4ba18fe763 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 19 Dec 2024 13:41:30 -0500 Subject: [PATCH 2/2] update to pops-core with rounding for overpopulation movements. --- inst/cpp/pops-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/cpp/pops-core b/inst/cpp/pops-core index 7133fddb..24bc87bc 160000 --- a/inst/cpp/pops-core +++ b/inst/cpp/pops-core @@ -1 +1 @@ -Subproject commit 7133fddbdfc316f8330827919407a949af612e59 +Subproject commit 24bc87bcb8b42d75b3b38694d0f42121813c67ff