ALMaSS Rodenticide ODdox
1.1
The rodenticide model description following ODdox protocol
|
Class for management of bait locations.
More...
#include <Rodenticide.h>
|
| RodenticideManager (string fname, Landscape *a_land) |
| RodenticideManager constructor. More...
|
|
virtual | ~RodenticideManager (void) |
| RodenticideManager destructor. More...
|
|
void | Tick (void) |
| Advance one day. More...
|
|
void | DoPlaceBait () |
| Initiates bait placement for those bait locations necessary. More...
|
|
int | GetBaitStartDate (TTypesBaitLocation) |
| Determines when the bait will be placed within a season. More...
|
|
bool | ShouldPlaceBait (TTypesBaitLocation) |
| Place bait dependent upon a frequency test. More...
|
|
void | DoImmigration (void) |
|
void | Diffuse (int a_x, int a_y) |
| Move poisoned mice around to twin map. More...
|
|
void | DoDiffuse (void) |
|
void | DoDeath (void) |
| Reduce each cell in twin map by m_deathRate. More...
|
|
void | DistributeRing (int a_x, int a_y, double a_amount) |
| Distribute an amount to the twin map in a ring. More...
|
|
double | GetMap (int a_x, int a_y) |
| Get poisoned mice at x,y. More...
|
|
double | GetMapTwin (int a_x, int a_y) |
| Get poisoned mice at x,y on twin map. More...
|
|
void | SetMap (int a_x, int a_y, double a_p) |
| Set poisoned mice at x,y. More...
|
|
void | SetMapTwin (int a_x, int a_y, double a_p) |
| Set poisoned mice at x,y on twin map. More...
|
|
void | SetMapTwinMult (int a_x, int a_y, double a_p) |
| Multiply poisoned mice at x,y on twin map by constant. More...
|
|
void | SetMapTwinP (int a_x, int a_y, double a_p) |
| Add to poisoned mice at x,y on twin map. More...
|
|
double | GetRodenticide (unsigned a_x, int a_y) |
| Return the poisoned mice value at x,y. More...
|
|
void | DumpRodenticideMap (string a_fname) |
| Dumps a map of rodenticide loads per 1m2 cells. More...
|
|
void | InitiateRodenticidePolyData (string a_fname) |
| Opens and initiates the output file for polygon rodenticide information. More...
|
|
void | RecordRodenticidePolyData (string a_fname) |
| Records rodenticide loads per polygon. More...
|
|
Class for management of bait locations.
◆ RodenticideManager()
RodenticideManager::RodenticideManager |
( |
string |
fname, |
|
|
Landscape * |
a_land |
|
) |
| |
RodenticideManager constructor.
Uses the file name to open a file and read in all bait locations required for managemnet
Creates the rodenticide grid with its twin-map and fills them with zeros. The maps have a resolution which is defined by cfg_rodenticide_gridsize Cannot have diffusion of >= map width or height - this needs checking to prevent wrapping around the world.
Read in and handle the probability distributions for seasonal start dates for bait locations. BaitLocationsSeasonalStartProbs.txt holds a column of daily probability for bait placement for each building type ()values range 0.0 to 1.0).
133 ifstream ifile(a_fname.c_str(), ios::in);
134 if ( !ifile.is_open() )
136 cout <<
"Cannot open input file " << a_fname << endl;
141 int noBaits, x, y, blt;
145 for (
int i = 0; i < noBaits; i++)
147 ifile >> x >> y >> blt;
174 ifstream i2file(
"BaitLocationsSeasonalStartProbs.txt", ios::in);
175 if ( !ifile.is_open() )
177 cout <<
"Cannot open input file " <<
"BaitLocationsSeasonalStartProbs.txt" << endl;
183 for (
int i = 0; i < 365; i++)
187 i2file >> temp[j][i];
196 for (
int i = 0; i < 365; i++)
198 int prob = (
int) floor((temp[j][i]*10)+0.5) + index;
199 if (prob>1000) prob=1000;
202 if (index>=1000) i=365;
References cfg_rodenticide_deathRate(), cfg_rodenticide_diffusionRate(), cfg_rodenticide_gridsize(), cfg_rodenticide_immigrationRate(), BaitLocation::SetBLtype(), BaitLocation::SetX(), BaitLocation::SetY(), Landscape::SupplySimAreaWidth(), and tbl_foobar.
◆ ~RodenticideManager()
RodenticideManager::~RodenticideManager |
( |
void |
| ) |
|
|
virtual |
◆ Diffuse()
void RodenticideManager::Diffuse |
( |
int |
a_x, |
|
|
int |
a_y |
|
) |
| |
Move poisoned mice around to twin map.
257 double before =
GetMap(a_x, a_y);
258 if (before < 0.00001)
264 double diff_out = after/8;
◆ DistributeRing()
void RodenticideManager::DistributeRing |
( |
int |
a_x, |
|
|
int |
a_y, |
|
|
double |
a_amount |
|
) |
| |
|
inline |
Distribute an amount to the twin map in a ring.
Distribute a_amount to the eight cells around m_x,m_y
◆ DoDeath()
void RodenticideManager::DoDeath |
( |
void |
| ) |
|
|
inline |
Reduce each cell in twin map by m_deathRate.
◆ DoDiffuse()
void RodenticideManager::DoDiffuse |
( |
void |
| ) |
|
|
inline |
◆ DoImmigration()
void RodenticideManager::DoImmigration |
( |
void |
| ) |
|
243 for (
unsigned i=0; i<sz; i++)
◆ DoPlaceBait()
void RodenticideManager::DoPlaceBait |
( |
void |
| ) |
|
Initiates bait placement for those bait locations necessary.
Depending upon the bait type, whether the bait has been used this year and whether it is destined to be used this method will add mass to the bait locations.
Housekeeping on Jan 1st is to remove all masses and zero all flags for the start of the new year.
The first test is of date, since whether a BL is used is determined by the frequency of that BL type on Jan 1st.
The next test is on the season, determining the start of bait placement.
NB this not so time critical so no optimising of the loops is done here.
347 for (
unsigned i=0; i<sz; i++)
358 for (
unsigned i=0; i<sz; i++)
385 g_msg->Warn( WARN_FILE,
"RodenticideManager::DoPlaceBait(void): Unknown bait type",
"");
References cfg_rodenticide_BLchristmasstrees_Length(), cfg_rodenticide_BLcountry_Length(), cfg_rodenticide_BLgrass_Length(), cfg_rodenticide_BLtown_Length(), cfg_rodenticide_BLwoodland_Length(), tbl_christmasstrees, tbl_country, tbl_grass, tbl_town, and tbl_woodland.
◆ DumpRodenticideMap()
void RodenticideManager::DumpRodenticideMap |
( |
string |
a_fname | ) |
|
Dumps a map of rodenticide loads per 1m2 cells.
Uses the file name to open a file and saves the rodenticide value for each cell at the time this method is called.
404 ofstream ofile(a_fname.c_str(), ios::out);
405 if ( !ofile.is_open() )
407 cout <<
"Cannot open output file for rodenticide map dump " << a_fname << endl;
414 ofile <<
"Width: "<< xext << endl;
415 ofile <<
"Height: "<< yext << endl;
416 for (
int y=0; y<yext; y++)
418 for (
int x=0; x<xext; x++)
◆ GetBaitStartDate()
Determines when the bait will be placed within a season.
References g_rand_uni.
◆ GetMap()
double RodenticideManager::GetMap |
( |
int |
a_x, |
|
|
int |
a_y |
|
) |
| |
|
inline |
Get poisoned mice at x,y.
◆ GetMapTwin()
double RodenticideManager::GetMapTwin |
( |
int |
a_x, |
|
|
int |
a_y |
|
) |
| |
|
inline |
Get poisoned mice at x,y on twin map.
◆ GetRodenticide()
double RodenticideManager::GetRodenticide |
( |
unsigned |
a_x, |
|
|
int |
a_y |
|
) |
| |
|
inline |
Return the poisoned mice value at x,y.
◆ InitiateRodenticidePolyData()
void RodenticideManager::InitiateRodenticidePolyData |
( |
string |
a_fname | ) |
|
Opens and initiates the output file for polygon rodenticide information.
Uses the file name to open a file and saves the rodenticide value for each polygon at the time this method is called.
433 ofstream ofile(a_fname.c_str(), ios::out);
434 if ( !ofile.is_open() )
436 cout <<
"Cannot open output file for rodenticide poly initiate " << a_fname << endl;
442 ofile << noPoly << endl;
443 for (
int p=0; p<(noPoly-1); p++)
448 for (
int p=0; p<(noPoly-1); p++)
453 for (
int p=0; p<(noPoly-1); p++)
456 ofile << area <<
'\t';
◆ RecordRodenticidePolyData()
void RodenticideManager::RecordRodenticidePolyData |
( |
string |
a_fname | ) |
|
Records rodenticide loads per polygon.
Uses the file name to open a file and saves the rodenticide value for each polygon at the time this method is called.
467 ofstream ofile(a_fname.c_str(), ios::app);
468 if ( !ofile.is_open() )
470 cout <<
"Cannot open output file for rodenticide poly data " << a_fname << endl;
476 double* polyR =
new double [noPoly];
477 for (
int p=0; p<(noPoly); p++) polyR[p]=0.0;
480 for (
int y=0; y<yext; y++)
482 for (
int x=0; x<xext; x++)
490 for (
int p=0; p<(noPoly-1); p++)
492 ofile << polyR[p] <<
'\t';
494 ofile << polyR[noPoly-1];
◆ SetMap()
void RodenticideManager::SetMap |
( |
int |
a_x, |
|
|
int |
a_y, |
|
|
double |
a_p |
|
) |
| |
|
inline |
Set poisoned mice at x,y.
◆ SetMapTwin()
void RodenticideManager::SetMapTwin |
( |
int |
a_x, |
|
|
int |
a_y, |
|
|
double |
a_p |
|
) |
| |
|
inline |
Set poisoned mice at x,y on twin map.
◆ SetMapTwinMult()
void RodenticideManager::SetMapTwinMult |
( |
int |
a_x, |
|
|
int |
a_y, |
|
|
double |
a_p |
|
) |
| |
|
inline |
Multiply poisoned mice at x,y on twin map by constant.
◆ SetMapTwinP()
void RodenticideManager::SetMapTwinP |
( |
int |
a_x, |
|
|
int |
a_y, |
|
|
double |
a_p |
|
) |
| |
|
inline |
Add to poisoned mice at x,y on twin map.
◆ ShouldPlaceBait()
Place bait dependent upon a frequency test.
296 #ifdef __RODENTICIDE_DISTRIBUTIONTEST
318 cout <<
"Unknown building type" << endl;
References cfg_rodenticide_BLchristmastrees_AnnFreq(), cfg_rodenticide_BLcountry_AnnFreq(), cfg_rodenticide_BLgrass_AnnFreq(), cfg_rodenticide_BLtown_AnnFreq(), cfg_rodenticide_BLwoodland_AnnFreq(), g_rand_uni, tbl_christmasstrees, tbl_country, tbl_foobar, tbl_grass, tbl_town, and tbl_woodland.
◆ Tick()
void RodenticideManager::Tick |
( |
void |
| ) |
|
◆ m_BaitList
◆ m_deathRate
double RodenticideManager::m_deathRate |
|
protected |
◆ m_diffusionRate
double RodenticideManager::m_diffusionRate |
|
protected |
poisoned mice diffusion rate
◆ m_gridsize
int RodenticideManager::m_gridsize |
|
protected |
rodenticide grid size - also affect diffusion rate
◆ m_height
int RodenticideManager::m_height |
|
protected |
◆ m_heightm1
int RodenticideManager::m_heightm1 |
|
protected |
◆ m_immigrationRate
double RodenticideManager::m_immigrationRate |
|
protected |
poisoned mice immigration rate
◆ m_land
◆ m_pmouse_map_main
vector<double> RodenticideManager::m_pmouse_map_main |
|
protected |
Map of probability of encountering a poisoned mouse.
◆ m_pmouse_map_twin
vector<double> RodenticideManager::m_pmouse_map_twin |
|
protected |
Temporary map for calculation poisoned mouse diffusion.
◆ m_seasonstartprob
season start probability distribution
◆ m_width
int RodenticideManager::m_width |
|
protected |
The documentation for this class was generated from the following files:
double GetMap(int a_x, int a_y)
Get poisoned mice at x,y.
Definition: Rodenticide.h:129
CfgInt cfg_rodenticide_dumppolyinterval("RODENTICIDE_DUMPPOLYINTERVAL", CFG_CUSTOM, 180)
void DumpRodenticideMap(string a_fname)
Dumps a map of rodenticide loads per 1m2 cells.
Definition: Rodenticide.cpp:399
void DistributeRing(int a_x, int a_y, double a_amount)
Distribute an amount to the twin map in a ring.
Definition: Rodenticide.cpp:269
unsigned int SupplyNumberOfPolygons(void)
Definition: landscape.h:1461
void DoPlaceBait()
Initiates bait placement for those bait locations necessary.
Definition: Rodenticide.cpp:333
Definition: Rodenticide.h:13
void SetMapTwinP(int a_x, int a_y, double a_p)
Add to poisoned mice at x,y on twin map.
Definition: Rodenticide.h:139
CfgInt cfg_rodenticide_BLwoodland_Length("RODENTICIDE_BLTYPE_WOODLAND_LENGTH", CFG_CUSTOM, 82)
CfgInt cfg_rodenticide_dumppolystartyear("RODENTICIDE_DUMPPOLYSTARTYEAR", CFG_CUSTOM, 99999)
vector< BaitLocation > m_BaitList
List of bait locations.
Definition: Rodenticide.h:76
CfgFloat cfg_rodenticide_BLwoodland_AnnFreq("RODENTICIDE_BLTYPE_WOODLAND_ANNFREQ", CFG_CUSTOM, 0.01)
CfgInt cfg_rodenticide_BLgrass_Length("RODENTICIDE_BLTYPE_GRASS_LENGTH", CFG_CUSTOM, 82)
vector< double > m_pmouse_map_twin
Temporary map for calculation poisoned mouse diffusion.
Definition: Rodenticide.h:80
CfgFloat cfg_rodenticide_deathRate("RODENTICIDE_DEATHRATE", CFG_CUSTOM, 0.048307)
int m_height
Definition: Rodenticide.h:84
Definition: Rodenticide.h:12
void RecordRodenticidePolyData(string a_fname)
Records rodenticide loads per polygon.
Definition: Rodenticide.cpp:462
Definition: Rodenticide.h:14
CfgFloat cfg_rodenticide_diffusionRate("RODENTICIDE_DIFFUSIONRATE", CFG_CUSTOM, 0.5)
CfgInt cfg_rodenticide_gridsize("RODENTICIDE_GRIDSIZE", CFG_CUSTOM, 5)
CfgInt cfg_rodenticide_BLcountry_Length("RODENTICIDE_BLTYPE_COUNTRY_LENGTH", CFG_CUSTOM, 34)
Definition: Rodenticide.h:10
CfgFloat cfg_rodenticide_immigrationRate("RODENTICIDE_IMMIGRATIONRATE", CFG_CUSTOM, 1.0)
void DoDeath(void)
Reduce each cell in twin map by m_deathRate.
Definition: Rodenticide.h:120
void InitiateRodenticidePolyData(string a_fname)
Opens and initiates the output file for polygon rodenticide information.
Definition: Rodenticide.cpp:428
Class used for describing the rodenticide bait location.
Definition: Rodenticide.h:19
CfgFloat cfg_rodenticide_BLcountry_AnnFreq("RODENTICIDE_BLTYPE_COUNTRY_ANNFREQ", CFG_CUSTOM, 0.33)
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
CfgInt cfg_rodenticide_dumppolyendyear("RODENTICIDE_DUMPPOLYENDYEAR", CFG_CUSTOM,-1)
double m_deathRate
poisoned mice death rate
Definition: Rodenticide.h:92
CfgInt cfg_rodenticide_BLchristmasstrees_Length("RODENTICIDE_BLTYPE_CTREE_LENGTH", CFG_CUSTOM, 82)
vector< double > m_pmouse_map_main
Map of probability of encountering a poisoned mouse.
Definition: Rodenticide.h:78
double SupplyRodenticide(int a_x, int a_y)
Gets total rodenticide for a location.
Definition: Landscape.cpp:492
int SupplyDayInYear(void)
Definition: landscape.h:1596
Definition: Rodenticide.h:15
bool ShouldPlaceBait(TTypesBaitLocation)
Place bait dependent upon a frequency test.
Definition: Rodenticide.cpp:294
int SupplyYearNumber(void)
Definition: landscape.h:1616
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
int SupplyPolyRefVector(unsigned int a_index)
Definition: landscape.h:1451
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
Definition: landscape.h:1104
TTypesBaitLocation
An enumeration listing the types of bait locations possible.
Definition: Rodenticide.h:8
int m_width
Landscape dimensions.
Definition: Rodenticide.h:84
void Diffuse(int a_x, int a_y)
Move poisoned mice around to twin map.
Definition: Rodenticide.cpp:255
void DoImmigration(void)
Definition: Rodenticide.cpp:240
double m_immigrationRate
poisoned mice immigration rate
Definition: Rodenticide.h:90
CfgFloat cfg_rodenticide_BLtown_AnnFreq("RODENTICIDE_BLTYPE_TOWN_ANNFREQ", CFG_CUSTOM, 0.05)
int m_gridsize
rodenticide grid size - also affect diffusion rate
Definition: Rodenticide.h:86
int GetBaitStartDate(TTypesBaitLocation)
Determines when the bait will be placed within a season.
Definition: Rodenticide.cpp:327
CfgFloat cfg_rodenticide_BLchristmastrees_AnnFreq("RODENTICIDE_BLTYPE_CTREES_ANNFREQ", CFG_CUSTOM, 0.05 *(5/9))
int m_heightm1
Definition: Rodenticide.h:84
double m_diffusionRate
poisoned mice diffusion rate
Definition: Rodenticide.h:88
void SetMap(int a_x, int a_y, double a_p)
Set poisoned mice at x,y.
Definition: Rodenticide.h:133
void SetMapTwinMult(int a_x, int a_y, double a_p)
Multiply poisoned mice at x,y on twin map by constant.
Definition: Rodenticide.h:137
CfgFloat cfg_rodenticide_BLgrass_AnnFreq("RODENTICIDE_BLTYPE_GRASS_ANNFREQ", CFG_CUSTOM, 0.05 *(5/9))
double SupplyPolygonAreaVector(int a_polyref)
Returns the area of a polygon using the vector index as a reference.
Definition: landscape.h:1200
Landscape * m_land
Landscape pointer.
Definition: Rodenticide.h:82
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1493
int SupplyLargestPolyNumUsed()
Definition: landscape.h:355
CfgInt cfg_rodenticide_dumpmapstartyear("RODENTICIDE_DUMPMAPSTARTYEAR", CFG_CUSTOM, 99999)
void DoDiffuse(void)
Definition: Rodenticide.h:114
CfgInt cfg_rodenticide_dumpmapday("RODENTICIDE_DUMPMAPDAY", CFG_CUSTOM, 180)
int m_seasonstartprob[tbl_foobar][1000]
season start probability distribution
Definition: Rodenticide.h:94
CfgInt cfg_rodenticide_BLtown_Length("RODENTICIDE_BLTYPE_TOWN_LENGTH", CFG_CUSTOM, 34)
Definition: Rodenticide.h:11