Skip to content

Commit d83ea49

Browse files
Fix 139 (#143)
* added total host to treatments. * added total_hosts to treatment tests * lint and typo fixes. * lint and fix typos * added total hosts to manage in treatments * lint and fix total_host to total_hosts in tests * assigned total hosts in treatment tests in all locations * added check for total_hosts being treated * added checks for total_hosts to rest of tests * remove unnecessary declarations in tests * lint * Update README.md * Update CHANGELOG.md * made internal variable names more straghtforward * updated readme * add missed test of total host update in test on line 87 * lint and add utils to include * lint * add new exposed individual in else statement * match change log to citation in readme
1 parent 619ddb9 commit d83ea49

5 files changed

Lines changed: 207 additions & 100 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ this repository.
2727
* requires 2 new parameters mortality_frequency and mortality_frequency_n
2828

2929
### Changed
30+
3031
- Model class internal attributes and functions are now protected instead of private
3132
to allow derived classes to access them for greater flexibility.
3233
- Model class kernels are now created and returned by protected functions.
@@ -38,6 +39,14 @@ this repository.
3839
* Now moves total_hosts
3940
* Now moves moratility tracked hosts
4041
* Adds a new suitable_cell if a movement creates a new location with hosts.
42+
- Treatments now modify total hosts (Chris Jones)
43+
- Citation updated to PoPS Frontiers paper (Chris Jones)
44+
* Jones, C., Jones, S., Petrasova, A., Petras, V., Gaydos, D.,
45+
Skrip, M., Takeuchi, Y., Bigsby, K., and Meentemeyer, R., 2021.
46+
Iteratively forecasting biological invasions with PoPS and a little help from
47+
our friends.
48+
*Frontiers in Ecology and the Environment*
49+
[DOI: 10.1002/fee.2357](https://doi.org/10.1002/fee.2357)
4150

4251
## [1.0.2] - 2020-10-09
4352

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,12 @@ required version.
2020

2121
If you use this software or code, please cite the following papers:
2222

23-
* Ross K. Meentemeyer, Nik J. Cunniffe, Alex R. Cook, Joao A. N. Filipe,
24-
Richard D. Hunter, David M. Rizzo, and Christopher A. Gilligan, 2011.
25-
Epidemiological modeling of invasion in heterogeneous landscapes:
26-
spread of sudden oak death in California (1990–2030).
27-
*Ecosphere* 2:art17.
28-
[DOI: 10.1890/ES10-00192.1](https://doi.org/10.1890/ES10-00192.1)
29-
30-
* Tonini, Francesco, Douglas Shoemaker, Anna Petrasova, Brendan Harmon,
31-
Vaclav Petras, Richard C. Cobb, Helena Mitasova,
32-
and Ross K. Meentemeyer, 2017.
33-
Tangible geospatial modeling for collaborative solutions
34-
to invasive species management.
35-
*Environmental Modelling & Software* 92: 176-188.
36-
[DOI: 10.1016/j.envsoft.2017.02.020](https://doi.org/10.1016/j.envsoft.2017.02.020)
23+
* Jones, C., Jones, S., Petrasova, A., Petras, V., Gaydos, D.,
24+
Skrip, M., Takeuchi, Y., Bigsby, K., and Meentemeyer, R., 2021.
25+
Iteratively forecasting biological invasions with PoPS and a little help from
26+
our friends.
27+
*Frontiers in Ecology and the Environment*
28+
[DOI: 10.1002/fee.2357](https://doi.org/10.1002/fee.2357)
3729

3830
In case you are using the automatic management feature in rpops or the
3931
steering version of r.pops.spread (from the branch steering), please

include/pops/model.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,13 @@ class Model
329329
// treatments
330330
if (config_.use_treatments) {
331331
bool managed = treatments.manage(
332-
step, infected, exposed, susceptible, resistant, suitable_cells);
332+
step,
333+
infected,
334+
exposed,
335+
susceptible,
336+
resistant,
337+
total_hosts,
338+
suitable_cells);
333339
if (managed && config_.use_mortality) {
334340
// treatments apply to all mortality tracker cohorts
335341
for (auto& raster : mortality_tracker) {

include/pops/treatments.hpp

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "raster.hpp"
2121
#include "date.hpp"
2222
#include "scheduling.hpp"
23+
#include "utils.hpp"
2324

2425
#include <map>
2526
#include <vector>
@@ -87,6 +88,7 @@ class AbstractTreatment
8788
std::vector<IntegerRaster>& exposed,
8889
IntegerRaster& susceptible,
8990
IntegerRaster& resistant,
91+
IntegerRaster& total_hosts,
9092
const std::vector<std::vector<int>>& spatial_indeices) = 0;
9193
virtual void end_treatment(
9294
IntegerRaster& susceptible,
@@ -175,29 +177,45 @@ class SimpleTreatment : public BaseTreatment<IntegerRaster, FloatRaster>
175177
IntegerRaster& infected,
176178
std::vector<IntegerRaster>& exposed,
177179
IntegerRaster& susceptible,
178-
IntegerRaster&,
180+
IntegerRaster& resistant,
181+
IntegerRaster& total_hosts,
179182
const std::vector<std::vector<int>>& suitable_cells) override
180183
{
181184
for (auto indices : suitable_cells) {
182185
int i = indices[0];
183186
int j = indices[1];
187+
int new_exposed_total = 0;
188+
int new_infected = 0;
189+
int new_susceptible = 0;
190+
int new_exposed_individual = 0;
184191
if (this->application_ == TreatmentApplication::Ratio) {
185-
infected(i, j) = infected(i, j) - (infected(i, j) * this->map_(i, j));
192+
new_infected = infected(i, j) - (infected(i, j) * this->map_(i, j));
193+
infected(i, j) = new_infected;
186194
}
187195
else if (this->application_ == TreatmentApplication::AllInfectedInCell) {
188-
infected(i, j) = this->map_(i, j) ? 0 : infected(i, j);
196+
new_infected = this->map_(i, j) ? 0 : infected(i, j);
197+
infected(i, j) = new_infected;
189198
}
190199
for (auto& raster : exposed) {
191200
if (this->application_ == TreatmentApplication::Ratio) {
192-
raster(i, j) = raster(i, j) - (raster(i, j) * this->map_(i, j));
201+
new_exposed_individual =
202+
raster(i, j) - (raster(i, j) * this->map_(i, j));
203+
raster(i, j) = new_exposed_individual;
204+
new_exposed_total += new_exposed_individual;
193205
}
194206
else if (
195207
this->application_ == TreatmentApplication::AllInfectedInCell) {
196-
raster(i, j) = this->map_(i, j) ? 0 : raster(i, j);
208+
new_exposed_individual =
209+
raster(i, j) - (raster(i, j) * this->map_(i, j));
210+
raster(i, j) = new_exposed_individual;
211+
new_exposed_total += new_exposed_individual;
197212
}
198213
}
199-
susceptible(i, j) =
214+
new_susceptible =
200215
susceptible(i, j) - (susceptible(i, j) * this->map_(i, j));
216+
susceptible(i, j) = new_susceptible;
217+
total_hosts(i, j) =
218+
new_infected + new_susceptible + new_exposed_total + resistant(i, j);
201219
}
202220
}
203221
void end_treatment(
@@ -244,8 +262,10 @@ class PesticideTreatment : public BaseTreatment<IntegerRaster, FloatRaster>
244262
std::vector<IntegerRaster>& exposed_vector,
245263
IntegerRaster& susceptible,
246264
IntegerRaster& resistant,
265+
IntegerRaster& total_hosts,
247266
const std::vector<std::vector<int>>& suitable_cells) override
248267
{
268+
UNUSED(total_hosts);
249269
for (auto indices : suitable_cells) {
250270
int i = indices[0];
251271
int j = indices[1];
@@ -370,13 +390,19 @@ class Treatments
370390
std::vector<IntegerRaster>& exposed,
371391
IntegerRaster& susceptible,
372392
IntegerRaster& resistant,
393+
IntegerRaster& total_hosts,
373394
const std::vector<std::vector<int>>& suitable_cells)
374395
{
375396
bool changed = false;
376397
for (unsigned i = 0; i < treatments.size(); i++) {
377398
if (treatments[i]->should_start(current)) {
378399
treatments[i]->apply_treatment(
379-
infected, exposed, susceptible, resistant, suitable_cells);
400+
infected,
401+
exposed,
402+
susceptible,
403+
resistant,
404+
total_hosts,
405+
suitable_cells);
380406
changed = true;
381407
}
382408
else if (treatments[i]->should_end(current)) {

0 commit comments

Comments
 (0)