Skip to content

Commit

Permalink
Use rounding for quarantine
Browse files Browse the repository at this point in the history
Replaces flooring in quarantine by rounding.

The tests here still pass. The r.pops.spread test requires adjustment which can be previewed here: #218
  • Loading branch information
wenzeslaus committed Oct 1, 2024
1 parent 194b51c commit ea6ba30
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/pops/quarantine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,20 @@ class QuarantineEscapeAction
DistDir closest;
if (directions_.at(Direction::N)
&& (i - n) * north_south_resolution_ < mindist) {
mindist = static_cast<int>(std::floor((i - n) * north_south_resolution_));
mindist = std::lround((i - n) * north_south_resolution_);
closest = std::make_tuple(mindist, Direction::N);
}
if (directions_.at(Direction::S)
&& (s - i) * north_south_resolution_ < mindist) {
mindist = static_cast<int>(std::floor((s - i) * north_south_resolution_));
mindist = std::lround((s - i) * north_south_resolution_);
closest = std::make_tuple(mindist, Direction::S);
}
if (directions_.at(Direction::E) && (e - j) * west_east_resolution_ < mindist) {
mindist = static_cast<int>(std::floor((e - j) * west_east_resolution_));
mindist = std::lround((e - j) * west_east_resolution_);
closest = std::make_tuple(mindist, Direction::E);
}
if (directions_.at(Direction::W) && (j - w) * west_east_resolution_ < mindist) {
mindist = static_cast<int>(std::floor((j - w) * west_east_resolution_));
mindist = std::lround((j - w) * west_east_resolution_);
closest = std::make_tuple(mindist, Direction::W);
}
return closest;
Expand Down

0 comments on commit ea6ba30

Please sign in to comment.