ALMaSS Rodenticide Model ODdox  1.0
RodenticidePredators_Population_Manager Class Reference

#include <RodenticidePredators.h>

Public Member Functions

int HowManyTerritoriesHere (int a_x, int a_y)
 
void PreCachePoly (int a_poly)
 
 RodenticidePredators_Population_Manager (Landscape *L)
 
vector< RP_Territory > * SupplyTerritories ()
 
void Tick ()
 Updates the rodenticide exposure for all predator territories. More...
 
virtual ~RodenticidePredators_Population_Manager ()
 
- Public Member Functions inherited from Population_Manager
bool BeginningOfMonth ()
 
virtual void BreedingPairsOutput (int)
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual void Catastrophe (int)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
void CloseTheCIPEGridOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
void CloseTheReallyBigOutputProbe ()
 
void CloseTheRipleysOutputProbe ()
 
virtual void DisplayLocations ()
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
virtual void ImpactedProbe ()
 
void ImpactProbeReport (int a_Time)
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
bool IsLast (unsigned listindex)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDeath (int x, int y)
 
void LamdaDumpOutput ()
 
void LOG (const char *fname)
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
bool OpenTheCIPEGridOutputProbe ()
 
virtual bool OpenTheFledgelingProbe ()
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
bool OpenTheRipleysOutputProbe ()
 
 Population_Manager (Landscape *L)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
virtual void Run (int NoTSteps)
 
void SetNoProbes (int a_pn)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
unsigned SupplyListIndexSize ()
 
const char * SupplyListName (int i)
 
int SupplyListNameLength ()
 
unsigned SupplyListSize (unsigned listindex)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
int SupplySimH ()
 
int SupplySimW ()
 
int SupplyState (unsigned listindex, unsigned j)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
int SupplyStepSize ()
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void TheCIPEGridOutputProbe ()
 
virtual int TheFledgelingProbe ()
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void TheNWordOutputProbe ()
 
virtual void TheReallyBigOutputProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual ~Population_Manager (void)
 

Protected Member Functions

void CreateTerritories ()
 Populates the landscape with predatory territories. More...
 
void CreatHabitatQualGrid (void)
 Evaluate the landscape and create the habitat quality grid. More...
 
double EvaluateHabitat (int a_x, int a_y, int a_range)
 Gets the total habitat score for a square UL x,y diameter of range. More...
 
double EvaluatePoly (int a_poly)
 Get the habitat quality based on polygon type. More...
 
bool IsGridPositionValid (int &x, int &y, int range)
 Tests whether a square has any occupied cells. More...
 
void NewTerritory (int a_x, int a_y, int a_range, double a_qual)
 Create a new territory and claim the grid. More...
 
void PredatorTerritoryInput ()
 Output functions for predator territories. More...
 
void PredatorTerritoryOutput (bool a_initial)
 Output functions for predator territories. More...
 
void ReadHabitatValues (int a_type)
 Read in specific predator type habitat scores. More...
 
- Protected Member Functions inherited from Population_Manager
virtual void Catastrophe ()
 
virtual void DoAfter ()
 
virtual void DoAlmostLast ()
 
virtual void DoBefore ()
 
virtual void DoFirst ()
 
virtual void DoLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void NWordOutput ()
 The output section for the NWord probe.
. More...
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 

Protected Attributes

double m_habquals [tole_Foobar]
 
int m_hash_size
 
int m_NoTerritories
 
bool * m_occupancy_grid
 
int m_predator_maxHR
 
int m_predator_minHR
 
double m_predator_targetQual
 
double * m_qual_cache
 
double * m_qual_grid
 
int m_sim_h
 
int m_sim_h_div_10
 
int m_sim_w
 
int m_sim_w_div_10
 
double m_summeddays
 Keeps track of the number of days we have rodenticide exposure summation for. More...
 
vector< RP_Territorym_Territories
 
- Protected Attributes inherited from Population_Manager
unsigned BeforeStepActions [10]
 
FILE * CIPEGridOutputPrb
 
FILE * CIPEGridOutputPrbB
 
long int lamdagrid [2][257][257]
 
FILE * m_AlleleFreqsFile
 
int m_catastrophestartyear
 
intm_cgridcount
 
int m_cgridcountwidth
 
int m_cipegridsize
 
FILE * m_EasyPopRes
 
FILE * m_GeneticsFile
 
intm_gridcount [4]
 
int m_gridcountsize [4]
 
int m_gridcountwidth [4]
 
unsigned m_ListNameLength
 
const char * m_ListNames [10]
 
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
TTypesOfPopulation m_population_type
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
int m_StepSize
 
FILE * NWordOutputPrb
 
FILE * ReallyBigOutputPrb
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
const char * StateNames [100]
 
unsigned StateNamesLength
 
FILE * TestFile
 
FILE * TestFile2
 
vector< TListOfAnimalsTheArray
 

Additional Inherited Members

- Public Attributes inherited from Population_Manager
int IndexArrayX [5][10000]
 
char m_SimulationName [255]
 
Landscapem_TheLandscape
 
bool ProbesSet
 
int SimH
 
unsigned SimHH
 
int SimW
 
unsigned SimWH
 
probe_dataTheProbe [100]
 

Constructor & Destructor Documentation

RodenticidePredators_Population_Manager::~RodenticidePredators_Population_Manager ( )
virtual

When the manager is destroyed call the output functions for predator territories

References m_occupancy_grid, m_qual_cache, m_qual_grid, and PredatorTerritoryOutput().

61 {
66  delete m_qual_cache;
67  delete m_qual_grid;
68  delete m_occupancy_grid;
69 }
void PredatorTerritoryOutput(bool a_initial)
Output functions for predator territories.
Definition: RodenticidePredators.cpp:395
bool * m_occupancy_grid
Definition: RodenticidePredators.h:73
double * m_qual_grid
Definition: RodenticidePredators.h:72
double * m_qual_cache
Definition: RodenticidePredators.h:71
RodenticidePredators_Population_Manager::RodenticidePredators_Population_Manager ( Landscape L)

On construction the first thing to do is to read the quality scores in from the correct predator input file. This depends on a config variable being correctly set: cfg_RodenticidePredatoryType

Create the habitat quality grid ready for predatory habitat assessment

Now populate the landscape with predatory territories

References cfg_rodenticide_read_predators(), cfg_RodenticidePredatoryMaxTerr(), cfg_RodenticidePredatoryMinTerr(), cfg_RodenticidePredatoryTargetQual(), cfg_RodenticidePredatoryType(), CreateTerritories(), CreatHabitatQualGrid(), m_predator_maxHR, m_predator_minHR, m_predator_targetQual, m_summeddays, PredatorTerritoryInput(), PredatorTerritoryOutput(), and ReadHabitatValues().

71  : Population_Manager(a_L)
72 {
73  m_predator_minHR = cfg_RodenticidePredatoryMinTerr.value() / 10; // Need divind by 10 for the grid (it is in 10 x 10m grids)
76  m_summeddays = 0.0;
90  else
91  {
94  }
95 
96 }
CfgInt cfg_RodenticidePredatoryType("RODPREDATOR_TYPE", CFG_CUSTOM,-1)
Used to set the predator information to read in.
int m_predator_minHR
Definition: RodenticidePredators.h:75
CfgBool cfg_rodenticide_read_predators("RODENTICIDE_READ_PREDATORS", CFG_CUSTOM, false)
Used to flag whether we calculate or read in territory values.
void PredatorTerritoryOutput(bool a_initial)
Output functions for predator territories.
Definition: RodenticidePredators.cpp:395
CfgInt cfg_RodenticidePredatoryTargetQual("RODPREDATOR_TARGETQUAL", CFG_CUSTOM, 100)
Territory minimum quality.
void ReadHabitatValues(int a_type)
Read in specific predator type habitat scores.
Definition: RodenticidePredators.cpp:151
void PredatorTerritoryInput()
Output functions for predator territories.
Definition: RodenticidePredators.cpp:420
void CreateTerritories()
Populates the landscape with predatory territories.
Definition: RodenticidePredators.cpp:255
void CreatHabitatQualGrid(void)
Evaluate the landscape and create the habitat quality grid.
Definition: RodenticidePredators.cpp:99
double m_summeddays
Keeps track of the number of days we have rodenticide exposure summation for.
Definition: RodenticidePredators.h:83
CfgInt cfg_RodenticidePredatoryMinTerr("RODPREDATOR_MINTERR", CFG_CUSTOM, 100)
Minimum territory width.
double m_predator_targetQual
Definition: RodenticidePredators.h:77
int m_predator_maxHR
Definition: RodenticidePredators.h:76
Population_Manager(Landscape *L)
Definition: PopulationManager.cpp:222
CfgInt cfg_RodenticidePredatoryMaxTerr("RODPREDATOR_MAXTERR", CFG_CUSTOM, 500)
Maximum territory width.

Member Function Documentation

void RodenticidePredators_Population_Manager::CreateTerritories ( )
protected

Populates the landscape with predatory territories.

Starts with a minimum territory size territory and then increases the size until either a occupied square is found or max size is reached, or the quality level has been met.

Referenced by RodenticidePredators_Population_Manager().

256 {
257  m_NoTerritories = 0;
258  int x0 = m_predator_maxHR / 2; // Our starting point x
259  int x = (int) (x0+g_rand_uni()*(m_sim_w_div_10 - x0));
260  int y = x0; // Our starting point y
261  int starty = y;
262  int x1 = m_sim_w_div_10 - x0; // End point x
263  int y1 = m_sim_h_div_10 - x0; // End point y
264  //bool toggle = false;
265  double qual;
266  int range;
270  int tries = m_sim_w_div_10 * m_sim_h_div_10; // the number of grid points in the grid
271  while ( tries-- > 0)
272  {
273  //if (toggle) if (y>=starty) break;
274  range = m_predator_minHR;
275  bool found = false;
276  while ( ( range <= m_predator_maxHR ) && ( !found ))
277  {
278  if ( !IsGridPositionValid( x, y, range ) )
279  {
280  if ( ++x >= x1 )
281  {
282  x = 0; //random( 3 );
283  if ( ++y >= y1 )
284  {
285  tries = 0; // Gone all the way round so stop
286  range = m_predator_maxHR +1;
287  //toggle = true;
288  }
289  }
290  continue;
291  }
292  // Location was OK, ie. not occupied.
293  // Try the smallest possible territory located right at our starting
294  // position.
295  qual = EvaluateHabitat( x, y, range );
296  // Is it suitable?
297  if ( qual >= m_predator_targetQual )
298  {
299  // If so create it and claim the area on the grid
300  // Is OK so create a territory
301  NewTerritory( x, y, range, 0.0 );
302  found = true;
303  }
304  else range++;
305  }
306  // Take a step and try again
307  if (++x >= x1)
308  {
309  x = x0;
310  if (++y >= y1)
311  {
312  tries = 0; // Gone all the way round so stop
313  range = m_predator_maxHR + 1;
314  //toggle = true;
315  }
316  }
317  }
318 }
int m_NoTerritories
Definition: RodenticidePredators.h:79
int m_sim_w_div_10
Definition: RodenticidePredators.h:68
int m_predator_minHR
Definition: RodenticidePredators.h:75
int m_sim_h_div_10
Definition: RodenticidePredators.h:69
bool IsGridPositionValid(int &x, int &y, int range)
Tests whether a square has any occupied cells.
Definition: RodenticidePredators.cpp:321
double EvaluateHabitat(int a_x, int a_y, int a_range)
Gets the total habitat score for a square UL x,y diameter of range.
Definition: RodenticidePredators.cpp:350
double m_predator_targetQual
Definition: RodenticidePredators.h:77
int m_predator_maxHR
Definition: RodenticidePredators.h:76
void NewTerritory(int a_x, int a_y, int a_range, double a_qual)
Create a new territory and claim the grid.
Definition: RodenticidePredators.cpp:370
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
void RodenticidePredators_Population_Manager::CreatHabitatQualGrid ( void  )
protected

Evaluate the landscape and create the habitat quality grid.

Need to do the basic read and quality assessment for the landscape, before creating and allocating the predatory territories. The first step is to get the map dimensions saved to local attributes.

Following that all the polygons in the landscape are pre-cached for their quality score - this is important for speed because it only needs to be done once per polygon.

Finally go through the whole landscape in 10x10m blocks and fill in the quality grid scoresas a the mean of 100m2 i.e. 10 x 10 m squares

References m_hash_size, m_occupancy_grid, m_qual_cache, m_qual_grid, m_sim_h, m_sim_h_div_10, m_sim_w, m_sim_w_div_10, Population_Manager::m_TheLandscape, Landscape::RodenticidePredatorsEvaluation(), Landscape::SupplyLargestPolyNumUsed(), Landscape::SupplyPolyRef(), Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

Referenced by RodenticidePredators_Population_Manager().

100 {
108  m_sim_w_div_10 = m_sim_w / 10;
109  m_sim_h_div_10 = m_sim_h / 10;
114  m_qual_cache = new double[m_hash_size];
116  /*
117  * Next the memory required for operations is reserved for the quality grid and occupancy grid that we need for the territory finding operations.
118  * The occupancy grid also needs all elements set to false.
119  */
120  int totalgrids = m_sim_w_div_10 * m_sim_h_div_10;
121  m_qual_grid = new double[ totalgrids ];
122  m_occupancy_grid = new bool [ totalgrids ];
123  for (int i=0; i<totalgrids; i++)
124  {
125  m_occupancy_grid[ i ] = false;
126  }
130  for (int x=0; x< m_sim_w_div_10; x++)
131  {
132  for (int y = 0; y < m_sim_h_div_10; y++)
133  {
134  int cx = x*10;
135  int cy = y*10;
136  double qual = 0.0;
137  for (int xx = cx; xx < cx+10; xx++)
138  {
139  for (int yy = cy; yy < cy+10; yy++)
140  {
141  int poly = m_TheLandscape->SupplyPolyRef(xx,yy);
142  qual += m_qual_cache[poly];
143  }
144  }
145  m_qual_grid[x + (y * m_sim_w_div_10)] = qual/=100.0;
146  }
147  }
148 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1412
int SupplyLargestPolyNumUsed()
Definition: landscape.h:334
int m_hash_size
Definition: RodenticidePredators.h:70
int m_sim_w_div_10
Definition: RodenticidePredators.h:68
int SupplySimAreaWidth(void)
Definition: landscape.h:1556
int m_sim_h_div_10
Definition: RodenticidePredators.h:69
void RodenticidePredatorsEvaluation(RodenticidePredators_Population_Manager *a_rppm)
Definition: Landscape.cpp:2807
bool * m_occupancy_grid
Definition: RodenticidePredators.h:73
int SupplySimAreaHeight(void)
Definition: landscape.h:1561
double * m_qual_grid
Definition: RodenticidePredators.h:72
int m_sim_w
Definition: RodenticidePredators.h:66
int m_sim_h
Definition: RodenticidePredators.h:67
Landscape * m_TheLandscape
Definition: PopulationManager.h:486
double * m_qual_cache
Definition: RodenticidePredators.h:71
double RodenticidePredators_Population_Manager::EvaluateHabitat ( int  a_x,
int  a_y,
int  a_range 
)
protected

Gets the total habitat score for a square UL x,y diameter of range.

Looks through the area summing all scores.

351 {
353  double l_qual = 0.0;
354  int r2 = a_range / 2;
355  int l_min_x = a_x - r2;
356  int l_min_y = a_y - r2;
357  int l_max_x = a_x + r2;
358  int l_max_y = a_y + r2;
359  for (int x = l_min_x; x < l_max_x; x++)
360  {
361  for ( int y = l_min_y; y < l_max_y; y++ )
362  {
363  l_qual += m_qual_grid[ x + y * m_sim_w_div_10 ];
364  }
365  }
366  return l_qual;
367 }
int m_sim_w_div_10
Definition: RodenticidePredators.h:68
double * m_qual_grid
Definition: RodenticidePredators.h:72
double RodenticidePredators_Population_Manager::EvaluatePoly ( int  a_poly)
protected

Get the habitat quality based on polygon type.

Returns the specific score for this polygon based on the polygon type and the score stored in m_habquals

References m_habquals, Population_Manager::m_TheLandscape, and Landscape::SupplyElementType().

185 {
189  TTypesOfLandscapeElement l_type = m_TheLandscape->SupplyElementType( a_poly );
190  return m_habquals[(int) l_type];
191 }
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
double m_habquals[tole_Foobar]
Definition: RodenticidePredators.h:74
Landscape * m_TheLandscape
Definition: PopulationManager.h:486
int RodenticidePredators_Population_Manager::HowManyTerritoriesHere ( int  a_x,
int  a_y 
)
474 {
475  int sum = 0;
476  int sz = (int) m_Territories.size();
477  for (int t=0; t< sz; t++)
478  {
479  int r = m_Territories[t].m_range;
480  int x = m_Territories[t].m_x - (r / 2);
481  int y = m_Territories[t].m_y - (r / 2);
482  if ((a_x>=x) && (a_x<x+r) && (a_y>=y) &&(a_y<=y+r)) sum++;
483  }
484  return sum;
485 }
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:78
bool RodenticidePredators_Population_Manager::IsGridPositionValid ( int x,
int y,
int  range 
)
protected

Tests whether a square has any occupied cells.

Returns
false if any occupied grid cell is found If we are too near the edge then do not evaluate,

otherwise test each potential location to see if they are occupied - if so return false

322 {
327  int r2 = a_range / 2;
328  int l_min_x = a_x - r2;
329  int l_min_y = a_y - r2;
330  int l_max_x = a_x + r2;
331  int l_max_y = a_y + r2;
335  for (int i = l_min_x; i < l_max_x; i++)
336  {
337  for (int j = l_min_y; j < l_max_y; j++)
338  {
339  if ( m_occupancy_grid[ i + j * m_sim_w_div_10 ] )
340  {
341  return false;
342  }
343  }
344  }
345  // No occupied squares found so return true
346  return true;
347 }
int m_sim_w_div_10
Definition: RodenticidePredators.h:68
bool * m_occupancy_grid
Definition: RodenticidePredators.h:73
void RodenticidePredators_Population_Manager::NewTerritory ( int  a_x,
int  a_y,
int  a_range,
double  a_qual 
)
protected

Create a new territory and claim the grid.

371 {
372  RP_Territory rpt;
373  rpt.m_exposure = a_exposure;
374  rpt.m_range = (int) floor(0.5+(a_range * 10 * cfg_RodenticidePredatoryTerrOverlap.value()));
375  rpt.m_x = a_x * 10;
376  rpt.m_y = a_y * 10;
377  m_Territories.push_back(rpt);
378  // Claim the territory in the grid
379  int r2 = a_range / 2;
380  int l_min_x = a_x - r2;
381  int l_min_y = a_y - r2;
382  int l_max_x = a_x + r2;
383  int l_max_y = a_y + r2;
384 
385  for (int i = l_min_x; i < l_max_x; i++)
386  {
387  for (int j = l_min_y; j < l_max_y; j++)
388  {
389  m_occupancy_grid[ i + j * m_sim_w_div_10 ] = true;
390  }
391  }
392 }
int m_sim_w_div_10
Definition: RodenticidePredators.h:68
CfgFloat cfg_RodenticidePredatoryTerrOverlap("RODPREDATOR_TERR_OVERLAP", CFG_CUSTOM, 1.0)
Unused.
A data struct to hold RodenticidePredatory territory details.
Definition: RodenticidePredators.h:40
int m_range
Definition: RodenticidePredators.h:44
bool * m_occupancy_grid
Definition: RodenticidePredators.h:73
int m_x
Definition: RodenticidePredators.h:42
int m_y
Definition: RodenticidePredators.h:43
double m_exposure
Definition: RodenticidePredators.h:45
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:78
void RodenticidePredators_Population_Manager::PreCachePoly ( int  a_poly)
inline

Referenced by Landscape::RodenticidePredatorsEvaluation().

59  {
60  m_qual_cache[a_poly] = EvaluatePoly(a_poly);
61  }
double EvaluatePoly(int a_poly)
Get the habitat quality based on polygon type.
Definition: RodenticidePredators.cpp:184
double * m_qual_cache
Definition: RodenticidePredators.h:71
void RodenticidePredators_Population_Manager::PredatorTerritoryInput ( )
protected

Output functions for predator territories.

Opens a standard output tab-delimited text file and reads all predatory territory information in the format:
Number of entries
Entry 1 x, Entry 1 y, Entry 1 size, Entry 1 exposure
Entry 2 x, Entry 2 y, Entry 2 size, Entry 2 exposure
Entry 3 x etc....

Referenced by RodenticidePredators_Population_Manager().

421 {
428  ifstream ifile("PredatorTerritoryOutputInfo.txt",ios::in);
429  int sz;
430  ifile >> sz;
431  double skip;
432  int x,y,range;
433  m_Territories.resize(0);
434  for (int i=0; i< sz; i++)
435  {
436  ifile >> x >> y >> range >> skip;
437  RP_Territory rpt;
438  rpt.m_exposure = 0.0;
439  rpt.m_range = range;
440  rpt.m_x = x;
441  rpt.m_y = y;
442  m_Territories.push_back(rpt);
443  }
444  ifile.close();
445 }
A data struct to hold RodenticidePredatory territory details.
Definition: RodenticidePredators.h:40
int m_range
Definition: RodenticidePredators.h:44
int m_x
Definition: RodenticidePredators.h:42
int m_y
Definition: RodenticidePredators.h:43
double m_exposure
Definition: RodenticidePredators.h:45
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:78
void RodenticidePredators_Population_Manager::PredatorTerritoryOutput ( bool  a_initial)
protected

Output functions for predator territories.

Opens a standard output tab-delimited text file and dumps all predatory territory information in the format:
Number of entries
Entry 1 x, Entry 1 y, Entry 1 size, Entry 1 exposure
Entry 2 x, Entry 2 y, Entry 2 size, Entry 2 exposure
Entry 3 x etc....

Referenced by RodenticidePredators_Population_Manager(), and ~RodenticidePredators_Population_Manager().

396 {
403  ofstream ofile("PredatorTerritoryOutputInfo.txt",ios::out);
404  int sz = (int) m_Territories.size();
405  ofile << sz << endl;
406  double asum=0.0;
407  for (int i=0; i< sz; i++) asum+=m_Territories[i].m_exposure;
408  if ((asum==0.0) || (m_summeddays<1)) a_initial = true;
409  for (int i=0; i< sz; i++)
410  {
411  ofile << m_Territories[i].m_x << '\t';
412  ofile << m_Territories[i].m_y << '\t';
413  ofile << m_Territories[i].m_range << '\t';
414  if (a_initial) ofile << 0.0 << endl; else ofile << m_Territories[i].m_exposure/m_summeddays << endl;
415  }
416  ofile.close();
417 }
double m_summeddays
Keeps track of the number of days we have rodenticide exposure summation for.
Definition: RodenticidePredators.h:83
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:78
void RodenticidePredators_Population_Manager::ReadHabitatValues ( int  a_type)
protected

Read in specific predator type habitat scores.

This method picks the input file based on the parameter a_type and reads in the scores for each habitat for that predator type. These are stored in m_habquals for later use in habitat evaluation.

References m_habquals, Population_Manager::m_TheLandscape, and Landscape::Warn().

Referenced by RodenticidePredators_Population_Manager().

152 {
157  fstream ifile;
158  switch (a_type)
159  {
160  case 0:
161  ifile.open("RodenticidePredator0_HabitatScores.txt",ios::in);
162  break;
163  default:
164  ifile.open("RodenticidePredatorNone_HabitatScores.txt",ios::in);
165  }
166  if (!ifile)
167  {
168  m_TheLandscape->Warn("RodenticidePredators_Population_Manager::ReadHabitatValues","Could Not Open Predator Habitat Scores File");
169  exit(0);
170  }
171  int n_values;
172  ifile >> n_values;
173  if (n_values != tole_Foobar)
174  {
175  m_TheLandscape->Warn("RodenticidePredators_Population_Manager::ReadHabitatValues"," - wrong number of habitat scores in RodenticidePredator_HabitatScores.txt");
176  exit(0);
177  }
178  for (int i = 0; i< tole_Foobar; i++) ifile >> m_habquals[i];
179  ifile.close();
180 }
double m_habquals[tole_Foobar]
Definition: RodenticidePredators.h:74
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1503
Landscape * m_TheLandscape
Definition: PopulationManager.h:486
vector<RP_Territory>* RodenticidePredators_Population_Manager::SupplyTerritories ( )
inline
62 { return &m_Territories; }
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:78
void RodenticidePredators_Population_Manager::Tick ( void  )

Updates the rodenticide exposure for all predator territories.

Runs through all the territories and sums up the rodenticide exposure and accumulates this in each territory

449 {
453  int sz = (int) m_Territories.size();
454  for (int t=0; t< sz; t++)
455  {
456  int x = m_Territories[t].m_x;
457  int y = m_Territories[t].m_y;
458  int r = m_Territories[t].m_range;
459  int xr = x+r;
460  int yr = y+r;
461  if (xr >= m_sim_w ) xr = m_sim_w-1;
462  if (yr >= m_sim_h ) yr = m_sim_h-1;
463  for (int i=x; i<xr; i++)
464  for (int j=y; j< yr; j++)
465  {
466  m_Territories[t].m_exposure += m_TheLandscape->SupplyRodenticide(i,j);
467  }
468  }
469  m_summeddays++;
470 }
double m_summeddays
Keeps track of the number of days we have rodenticide exposure summation for.
Definition: RodenticidePredators.h:83
double SupplyRodenticide(int a_x, int a_y)
Gets total rodenticide for a location.
Definition: Landscape.cpp:470
int m_sim_w
Definition: RodenticidePredators.h:66
int m_sim_h
Definition: RodenticidePredators.h:67
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:78
Landscape * m_TheLandscape
Definition: PopulationManager.h:486

Member Data Documentation

double RodenticidePredators_Population_Manager::m_habquals[tole_Foobar]
protected

Referenced by EvaluatePoly(), and ReadHabitatValues().

int RodenticidePredators_Population_Manager::m_hash_size
protected

Referenced by CreatHabitatQualGrid().

int RodenticidePredators_Population_Manager::m_NoTerritories
protected
bool* RodenticidePredators_Population_Manager::m_occupancy_grid
protected
int RodenticidePredators_Population_Manager::m_predator_maxHR
protected
int RodenticidePredators_Population_Manager::m_predator_minHR
protected
double RodenticidePredators_Population_Manager::m_predator_targetQual
protected
double* RodenticidePredators_Population_Manager::m_qual_cache
protected
double* RodenticidePredators_Population_Manager::m_qual_grid
protected
int RodenticidePredators_Population_Manager::m_sim_h
protected

Referenced by CreatHabitatQualGrid().

int RodenticidePredators_Population_Manager::m_sim_h_div_10
protected

Referenced by CreatHabitatQualGrid().

int RodenticidePredators_Population_Manager::m_sim_w
protected

Referenced by CreatHabitatQualGrid().

int RodenticidePredators_Population_Manager::m_sim_w_div_10
protected

Referenced by CreatHabitatQualGrid().

double RodenticidePredators_Population_Manager::m_summeddays
protected

Keeps track of the number of days we have rodenticide exposure summation for.

Referenced by RodenticidePredators_Population_Manager().

vector<RP_Territory> RodenticidePredators_Population_Manager::m_Territories
protected

The documentation for this class was generated from the following files: