ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Rabbit_Population_Manager Class Reference

The class to handle all predator population related matters. More...

#include <Rabbit_Population_Manager.h>

Inheritance diagram for Rabbit_Population_Manager:
Population_Manager

Public Member Functions

 Rabbit_Population_Manager (Landscape *L)
 Rabbit_Population_Manager Constructor. More...
 
virtual ~Rabbit_Population_Manager (void)
 Rabbit_Population_Manager Destructor. More...
 
void CreateObjects (RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
 Method for creating a new individual Rabbit. More...
 
TTypesOfRabbitHabitat ClassifyHabitat (TTypesOfLandscapeElement a_tole)
 Classify a landscape element type according to the rabbit habitat classification. More...
 
Rabbit_WarrenFindClosestWarren (int a_x, int a_y, int a_rank)
 Finds the closest warren as the crow flies. More...
 
void CheckForRabbitBreedingConditions (void)
 Determines whether it is breeding season. More...
 
bool IsBreedingSeason (void)
 Get whether it is breeding season. More...
 
void PesticideDeathRecord (RabbitObjectTypes ob_type)
 Records pesticide poisoning incidents. More...
 
unsigned SupplyAllBigRabbits ()
 Returns the total number of rabbits. More...
 
double GetGrowth (int a_age)
 Get method for the rabbit growth with age. More...
 
bool GetForageDay ()
 Get method for the forage day flag. More...
 
void ReproOutputRecordOutput (Rabbit_Female *a_female)
 Print reproductive record to file. More...
 
void NatalDispersalRecordOutput (Rabbit_Base *a_rabbit)
 Records the natal dispersal. More...
 
- Public Member Functions inherited from Population_Manager
 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual void Run (int NoTSteps)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
int SupplyListNameLength ()
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe ()
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual void TheReallyBigOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
void CloseTheRipleysOutputProbe ()
 
void CloseTheReallyBigOutputProbe ()
 
bool OpenTheCIPEGridOutputProbe ()
 
virtual void TheCIPEGridOutputProbe ()
 
void CloseTheCIPEGridOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 

Protected Member Functions

virtual void DoFirst ()
 Things to do before anything else at the start of a timestep. More...
 
virtual void DoBefore ()
 Things to do before the Step. More...
 
virtual void DoAfter ()
 Things to do before the EndStep. More...
 
virtual void DoLast ()
 Things to do after the EndStep. More...
 
void PreProcessWarrenLocations ()
 This pre-scans the landscape and determines all potential warren locations on start-up. More...
 
bool WarrenLegalPos (int &a_x, int a_y)
 Tests the warrens list to see if this position is legal. More...
 
void SaveWarrenLocations (void)
 Save warren locations. More...
 
void LoadWarrenLocations (void)
 Load warren locations. More...
 
double AssessPctForage (int a_x, int a_y)
 Assesses the percentage of forage for a location assuming max warren size. More...
 
void CreateLocalWarrenNetworkLists (void)
 Forms the local warren network list for this warren. More...
 
void WarrenOccupancyRecordOutput ()
 Print warren occupancy record to file. More...
 
void PesticideDeathRecordOutput ()
 Print pesticide death record to file. More...
 
void PesticideDeathRecordOutputOpen ()
 Opens pesticide death output file. More...
 
void PesticideDeathRecordOutputClose ()
 Closes the pesticide death output file. More...
 
void WarrenOccupancyRecordOutputOpen ()
 Opens the warren occupancy output file. More...
 
void WarrenOccupancyRecordOutputClose ()
 Closes the warren occupancy output file. More...
 
void WarrenOutputAnalysis ()
 Does analysis on the warren output file and saves the results to RabbitPOMSummary.txt. More...
 
void LifetimeReproAnalysis ()
 Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary.txt. More...
 
void NatalDispersalAnalysis ()
 Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary.txt. More...
 
void ReproOutputRecordOutputOpen ()
 Opens the reproductive output file. More...
 
void ReproOutputRecordOutputClose ()
 Closes the reproductive output file. More...
 
void NatalDispersalRecordOutputOpen ()
 Opens the reproductive output file. More...
 
void NatalDispersalRecordOutputClose ()
 Closes the reproductive output file. More...
 
void AssignStaticVariables ()
 Assigns any static variables needing config variable assignment. More...
 
void TheNWordOutputProbe ()
 
- Protected Member Functions inherited from Population_Manager
virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoAlmostLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 
void NWordOutput ()
 The output section for the NWord probe.
. More...
 

Protected Attributes

int m_warrenfixedsize
 Holds an input variable for max warren size in m. More...
 
int m_warrenfixedsizediv2
 Half max warren size in m - for speed. More...
 
bool m_rabbitBreedingSeason
 The breeding season flag. More...
 
int m_reproswitchbuffer
 Prevents continuous breeding season switching. More...
 
double m_RabbitGrowth [3650]
 Holds daily growth potential of rabbits for each day. More...
 
int m_PesticideDeaths [rob_foobar]
 Holds the number of rabbits killed each day by pesticides. More...
 
ofstream m_WarrenOccupancyFile
 The warren occupancy output file. More...
 
ofstream m_NatalDispersalFile
 For recording the natal dispersal of adults from birth to death. More...
 
ofstream m_ReproOutputFile
 For recording the lifetime reproductive success. More...
 
ofstream m_PesticideDeathOFile
 The pesticide death output file. More...
 
bool m_forageday
 Flag to record whether today is a possible forage day. More...
 
- Protected Attributes inherited from Population_Manager
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [10]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [10]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * CIPEGridOutputPrb
 
FILE * CIPEGridOutputPrbB
 
FILE * ReallyBigOutputPrb
 
FILE * NWordOutputPrb
 
int * m_cgridcount
 
int * m_gridcount [4]
 
int m_cgridcountwidth
 
int m_gridcountwidth [4]
 
int m_cipegridsize
 
int m_gridcountsize [4]
 
long int lamdagrid [2][257][257]
 

Additional Inherited Members

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

Detailed Description

The class to handle all predator population related matters.

Definition at line 89 of file Rabbit_Population_Manager.h.

Constructor & Destructor Documentation

Rabbit_Population_Manager::Rabbit_Population_Manager ( Landscape L)

Rabbit_Population_Manager Constructor.

Loads the list of Animal Classes.

Initialises global parameters/variables.

Creates some rabbits by introducing a number of male and female rabbits aged 100 to 365 days old. The number is defined by the input configuration variable cfg_StartNoRabbits.

The population manager needs to pre-process the landscape map for potential warren locations. This is very time consuming and so it is possible to read in a pre-processed list of locations. However, if this is done then it needs to be made very certain that the list being read in is the correct one for that landscape. No auto checking is possible.

Definition at line 118 of file Rabbit_Population_Manager.cpp.

References AssignStaticVariables(), cfg_rabbitdailygrowthparam1, cfg_rabbitdailygrowthparam2, cfg_rabbitdailygrowthparam3, cfg_RabbitStartNos, cfg_RabbitUseNatalDispersalRecord, cfg_RabbitUseReproOutput, cfg_warrenfixedsize, cfg_warrenreadlocations, CreateLocalWarrenNetworkLists(), CreateObjects(), g_land_width, LoadWarrenLocations(), struct_Rabbit::m_age, Rabbit_Base::m_dispersalmortperm, struct_Rabbit::m_L, Population_Manager::m_ListNameLength, Population_Manager::m_ListNames, Rabbit_Warren::m_maxForageHeight, struct_Rabbit::m_NPM, m_rabbitBreedingSeason, m_RabbitGrowth, m_reproswitchbuffer, Population_Manager::m_SimulationName, Population_Manager::m_TheLandscape, struct_Rabbit::m_Warren, m_warrenfixedsize, m_warrenfixedsizediv2, struct_Rabbit::m_weightage, struct_Rabbit::m_x, struct_Rabbit::m_x2, struct_Rabbit::m_y, struct_Rabbit::m_y2, NatalDispersalRecordOutputOpen(), Population_Manager::OpenTheRipleysOutputProbe(), PesticideDeathRecordOutputOpen(), PreProcessWarrenLocations(), ReproOutputRecordOutputOpen(), rob_Female, rob_Male, SaveWarrenLocations(), Population_Manager::SimH, Population_Manager::SimW, Landscape::SupplySimAreaWidth(), CfgInt::value(), CfgFloat::value(), CfgBool::value(), and WarrenOccupancyRecordOutputOpen().

118  : Population_Manager(L)
119 {
121  m_ListNames[0] = "Young";
122  m_ListNames[1] = "Juvenile";
123  m_ListNames[2] = "Male";
124  m_ListNames[3] = "Female";
125  m_ListNames[4] = "Possible Warrens";
126  m_ListNameLength = 5;
128  g_land_width = m_TheLandscape->SupplySimAreaWidth(); // Needs the landscape to be square!!!
129 
130  strcpy( m_SimulationName, "Rabbit Simulation" );
135  struct_Rabbit* sp = new struct_Rabbit;
136  sp->m_NPM = this;
137  sp->m_L = m_TheLandscape;
138  sp->m_age = 100+random(265);
139  sp->m_Warren = NULL;
140  sp->m_x2 = -1;
141  sp->m_y2 = -1;
142  sp->m_weightage = 300; // Should not be weak animals to start with
143 
144  for (int i = 0; i< cfg_RabbitStartNos.value(); i++)
145  {
146  sp->m_x = random(SimW);
147  sp->m_y = random(SimH);
148  CreateObjects(rob_Male,NULL,sp,1); //
149  }
150  for (int i=0; i< cfg_RabbitStartNos.value(); i++)
151  {
152  sp->m_x = random(SimW);
153  sp->m_y = random(SimH);
154  CreateObjects(rob_Female,NULL,sp,1); //
155  }
156  delete sp;
157  // Load parameters
162  m_reproswitchbuffer = 30;
163  m_rabbitBreedingSeason = false;
164 
170  {
172  }
173  else
174  {
177  }
179  // Open output files
182  }
187  // Assign static variable
189  // Create the rabbit growth rate lookup data
190  for (int i = 1; i < 300; i++) {
192  }
193  // Now fill this in for up to 10 years (no rabbit should ever live that long )
194  for (int i = 300; i < 3350; i++) {
196  }
197 
198 }
bool m_rabbitBreedingSeason
The breeding season flag.
int m_warrenfixedsizediv2
Half max warren size in m - for speed.
Rabbit_Warren * m_Warren
A pointer to the current warren.
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
static CfgFloat cfg_rabbitdailygrowthparam2("RABBIT_DAILYGROWTHPARAM_TWO", CFG_CUSTOM,-0.013143202)
Input variable. Parameter two of the rabbit growth curve.
void LoadWarrenLocations(void)
Load warren locations.
void CreateLocalWarrenNetworkLists(void)
Forms the local warren network list for this warren.
void AssignStaticVariables()
Assigns any static variables needing config variable assignment.
static CfgFloat cfg_rabbitdailygrowthparam3("RABBIT_DAILYGROWTHPARAM_THREE", CFG_CUSTOM, 0.0)
Input variable. Parameter three of the rabbit growth curve.
CfgInt cfg_warrenfixedsize("RABBIT_WARRENFIXEDSIZE", CFG_CUSTOM, 45)
Input variable. The maximum size for a warren (length m). Value is 45 for light soil 55 for heavy soi...
int m_y2
y-coord of birth
CfgBool cfg_RabbitUseNatalDispersalRecord("RABBIT_USENATALDISPERSALRECORD", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
static CfgFloat cfg_rabbitdailygrowthparam1("RABBIT_DAILYGROWTHPARAM_ONE", CFG_CUSTOM, 1127.616084)
Input variable. Parameter one of the rabbit growth curve.
double value(void)
Definition: configurator.h:107
int m_warrenfixedsize
Holds an input variable for max warren size in m.
int SupplySimAreaWidth(void)
Definition: landscape.h:1558
void CreateObjects(RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
Method for creating a new individual Rabbit.
Used for creation of a new Rabbit object.
void PreProcessWarrenLocations()
This pre-scans the landscape and determines all potential warren locations on start-up.
bool value(void)
Definition: configurator.h:123
void ReproOutputRecordOutputOpen()
Opens the reproductive output file.
int m_weightage
The rabbit age in terms of weight.
int m_age
The rabbit age.
void WarrenOccupancyRecordOutputOpen()
Opens the warren occupancy output file.
static CfgBool cfg_warrenreadlocations("RABBIT_WARRENREADLOCATIONS", CFG_CUSTOM, true)
Input variable. Should warren locations be calculated or read from a file?
double m_RabbitGrowth[3650]
Holds daily growth potential of rabbits for each day.
void SaveWarrenLocations(void)
Save warren locations.
CfgFloat cfg_maxForageHeight
Input variable. The maximum height desirable for forage vegetation.
static double m_dispersalmortperm
The extra dispersal mortality per m travelled.
Definition: Rabbit.h:172
CfgBool cfg_RabbitUseReproOutput("RABBIT_USEREPROOUTPUT", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
void PesticideDeathRecordOutputOpen()
Opens pesticide death output file.
void NatalDispersalRecordOutputOpen()
Opens the reproductive output file.
CfgFloat cfg_dispersalmortperm
Input variable. The additional mortality rate with distance for between warren dispersal.
CfgBool cfg_RipleysOutput_used
int m_x2
x-coord of birth
int value(void)
Definition: configurator.h:92
Population_Manager(Landscape *L)
static CfgInt cfg_RabbitStartNos("RABBIT_STARTNOS", CFG_CUSTOM, 25000)
The starting number of rabbits.
int m_reproswitchbuffer
Prevents continuous breeding season switching.
static double m_maxForageHeight
The maximum vegetation height assumed for forage potential.
Definition: Rabbit.h:541
const char * m_ListNames[10]
Landscape * m_L
Landscape pointer.
Landscape * m_TheLandscape
Rabbit_Population_Manager::~Rabbit_Population_Manager ( void  )
virtual

Rabbit_Population_Manager Destructor.

Closes the output files created specially for rabbit output. Calls post run analysis routines and then empties any active rabbits from the TheArray deleting the respective rabbit objects.

Definition at line 223 of file Rabbit_Population_Manager.cpp.

References cfg_RabbitUseNatalDispersalRecord, cfg_RabbitUseReproOutput, LifetimeReproAnalysis(), NatalDispersalAnalysis(), NatalDispersalRecordOutputClose(), PesticideDeathRecordOutputClose(), ReproOutputRecordOutputClose(), Population_Manager::TheArray, CfgBool::value(), WarrenOccupancyRecordOutputClose(), and WarrenOutputAnalysis().

224 {
233  }
237  }
239  for (unsigned i = 0; i < TheArray.size(); i++) {
240  for ( unsigned j = 0; j < TheArray[ i ].size(); j++ ) {
241  // This just stops a DEBUG error
242  TheArray[ i ] [ j ]->KillThis();
243  }
244  }
245 }
void ReproOutputRecordOutputClose()
Closes the reproductive output file.
CfgBool cfg_RabbitUseNatalDispersalRecord("RABBIT_USENATALDISPERSALRECORD", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
vector< TListOfAnimals > TheArray
void NatalDispersalRecordOutputClose()
Closes the reproductive output file.
bool value(void)
Definition: configurator.h:123
void WarrenOutputAnalysis()
Does analysis on the warren output file and saves the results to RabbitPOMSummary.txt.
CfgBool cfg_RabbitUseReproOutput("RABBIT_USEREPROOUTPUT", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
void NatalDispersalAnalysis()
Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary.txt.
void LifetimeReproAnalysis()
Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary.txt.
void PesticideDeathRecordOutputClose()
Closes the pesticide death output file.
void WarrenOccupancyRecordOutputClose()
Closes the warren occupancy output file.

Member Function Documentation

double Rabbit_Population_Manager::AssessPctForage ( int  a_x,
int  a_y 
)
protected

Assesses the percentage of forage for a location assuming max warren size.

/**

Parameters
[in]a_xthe x coordinate for the TL corner of the warren.
[in]a_ythe y coordinate for the TL corner of the warren.
Returns
The % of are covered by permanent forage.

Loops through the potential warren area and find all the forage and sums this. Then calculate the percentage.

This is done by getting the polygon references and checking if we had this one already. If not save it with an area of 1 otherwise increment the correct record by 1.

Returns the total forage area divided by the total warren area.

Definition at line 549 of file Rabbit_Population_Manager.cpp.

Referenced by PreProcessWarrenLocations().

550 {
558 
568 
582 
void Rabbit_Population_Manager::AssignStaticVariables ( void  )
protected

Assigns any static variables needing config variable assignment.

This is just needed to make the C++ work. Default variables are assigned to static members at start-up, but any that we actually want to get configuration variable values have to be dealt with here

Definition at line 201 of file Rabbit_Population_Manager.cpp.

References struct_Rabbit::m_age, Rabbit_Base::m_dispersalmortperm, struct_Rabbit::m_L, Rabbit_Warren::m_maxForageHeight, Rabbit_Warren::m_minForageDigestability, struct_Rabbit::m_NPM, Rabbit_Base::m_pesticidedegradationrate, Population_Manager::m_TheLandscape, struct_Rabbit::m_Warren, Rabbit_Female::SetMaxKits(), Rabbit_Female::SetMinKits(), and CfgFloat::value().

Referenced by Rabbit_Population_Manager().

202 {
205  struct_Rabbit* sp = new struct_Rabbit;
206  sp->m_NPM = this;
207  sp->m_L = m_TheLandscape;
208  sp->m_age = 100 + random(265);
209  sp->m_Warren = NULL;
210  Rabbit_Female* rf = new Rabbit_Female(0,0,-1,-1,m_TheLandscape,this,0, 300,NULL);
211  Rabbit_Warren* rw = new Rabbit_Warren(0, 0, m_TheLandscape, this, 0, NULL);
216  rf->SetMaxKits(cfg_rabbitmaxkits.value() - cfg_rabbitminkits.value()); // Here we actually use the difference to calculate range
217  rf->m_pesticidedegradationrate = cfg_rabbit_pesticidedegradationrate.value(); // default of 0.0 will remove all body burden pesticide at the end of each day
218  delete rw;
219  delete rf;
220 }
void SetMaxKits(double a_num)
Definition: Rabbit.h:463
CfgFloat cfg_minForageDigestability
Input variable. Input variable. The minimum digestability desirable for forage vegetation.
The rabbit female class. All special female behaviour is described here.
Definition: Rabbit.h:443
CfgFloat cfg_rabbit_pesticidedegradationrate
Holds 1-proportion of decay of body burden of pesticide per day. Default of 0.0 will remove all body ...
static double m_minForageDigestability
The minimum vegetation digestability allowed for foraging.
Definition: Rabbit.h:543
Rabbit_Warren * m_Warren
A pointer to the current warren.
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
static double m_pesticidedegradationrate
State variable used to hold the daily degredation rate of the pesticide in the body.
Definition: Rabbit.h:174
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
double value(void)
Definition: configurator.h:107
Used for creation of a new Rabbit object.
int m_age
The rabbit age.
CfgFloat cfg_rabbitminkits
The minimum number of kits in a litter.
CfgFloat cfg_maxForageHeight
Input variable. The maximum height desirable for forage vegetation.
static double m_dispersalmortperm
The extra dispersal mortality per m travelled.
Definition: Rabbit.h:172
CfgFloat cfg_dispersalmortperm
Input variable. The additional mortality rate with distance for between warren dispersal.
void SetMinKits(double a_num)
Definition: Rabbit.h:462
static double m_maxForageHeight
The maximum vegetation height assumed for forage potential.
Definition: Rabbit.h:541
Landscape * m_L
Landscape pointer.
Landscape * m_TheLandscape
CfgFloat cfg_rabbitmaxkits
The maximum number of kits in a litter.
void Rabbit_Population_Manager::CheckForRabbitBreedingConditions ( void  )

Determines whether it is breeding season.

Definition at line 732 of file Rabbit_Population_Manager.cpp.

Referenced by DoFirst().

733 {
734  /*
735  * Once the temperature comes up over a certain trigger the breeding seasons starts. Rapid switching is prevented by not making the test again for 120 days.
736  * When the temperature in the future drops down again then the breeding season stops
737  */
738  if (--m_reproswitchbuffer > 0) return;
739 
741  {
743  {
744  m_reproswitchbuffer = 120;
745  m_rabbitBreedingSeason = true;
746 #ifdef __RABBITBREEDINGSEASONCHECK
747  cout << g_date->GetYearNumber() << " " << g_date->DayInYear() << " " << m_TheLandscape->SupplyTempPeriod( g_date->Date()+60, 60 ) << " - " << "Started" << endl;
748 #endif
749  }
750  }
751  else
752  {
754  {
755  m_reproswitchbuffer = 90;
756  m_rabbitBreedingSeason = false;
757 #ifdef __RABBITBREEDINGSEASONCHECK
758  cout << g_date->GetYearNumber() << " " << g_date->DayInYear() << " " << m_TheLandscape->SupplyTempPeriod( g_date->Date()+30, 90 ) << " - " << "Stopped" << endl;
759 #endif
760  }
761  }
762 }
long Date(void)
Definition: calendar.h:57
bool m_rabbitBreedingSeason
The breeding season flag.
int GetYearNumber(void)
Definition: calendar.h:68
double value(void)
Definition: configurator.h:107
int DayInYear(void)
Definition: calendar.h:58
static CfgFloat cfg_rabbitminbreedingtemp("RABBIT_MINBREEDINGTEMP", CFG_CUSTOM, 300.0)
Input variable. The minimum 60 day average temperature for rabbit breeding.
class Calendar * g_date
Definition: calendar.cpp:38
double SupplyTempPeriod(long a_date, int a_period)
Definition: landscape.h:1336
int m_reproswitchbuffer
Prevents continuous breeding season switching.
Landscape * m_TheLandscape
TTypesOfRabbitHabitat Rabbit_Population_Manager::ClassifyHabitat ( TTypesOfLandscapeElement  a_tole)

Classify a landscape element type according to the rabbit habitat classification.

Parameters
[in]a_toleThe type of landscape element
Returns
The type of rabbit habitat represented by the landscape element type.

This is basically a translation function from the element type from the landscape map to the type of habitat it represents for the rabbit. This makes no assessment of the vegetation on the element though.

Definition at line 455 of file Rabbit_Population_Manager.cpp.

References Population_Manager::m_TheLandscape, tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Field, tole_FieldBoundary, tole_FishFarm, tole_Freshwater, tole_Garden, tole_Heath, tole_HedgeBank, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PermPastureTussockyWet, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnknownGrass, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_Vildtager, tole_Wasteland, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, torh_Cover, torh_Forage, torh_Other, torh_TemporaryForage, and Landscape::Warn().

Referenced by Rabbit_Warren::InitEvaluation(), and WarrenLegalPos().

456 {
464  static char error_num[ 20 ];
465  switch (a_tole)
466  {
467  case tole_UnsprayedFieldMargin://31
468  case tole_Field://20&30
469  case tole_RoadsideVerge://13
470  case tole_BeetleBank://141
471  return torh_TemporaryForage;
472  break;
473  case tole_Railway://118
474  case tole_FieldBoundary://160
475  case tole_PermPastureLowYield://26
476  case tole_PermPastureTussocky://27
477  case tole_PermanentSetaside://33
478  case tole_PermPasture://35
479  case tole_NaturalGrassDry://110//case tole11
480  case tole_PitDisused://75
481  case tole_YoungForest://55
482  case tole_HedgeBank://140
483  case tole_Heath://94
484  case tole_Parkland://14
485  case tole_SandDune://101
486  case tole_Orchard://56
487  case tole_RoadsideSlope: //201
488  case tole_HeritageSite: //208
489  case tole_UnknownGrass:
490  case tole_Vildtager:
491  case tole_MownGrass:
492  case tole_Wasteland:
493  return torh_Forage;
494  break;
495  case tole_Hedges://130
496  case tole_Copse://41
497  case tole_Scrub://70
498  case tole_RiversideTrees://97
499  case tole_DeciduousForest://40
500  case tole_MixedForest://60
501  case tole_ConiferousForest://50
502  case tole_WoodlandMargin:
504  return torh_Cover;
505  break;
506  case tole_UrbanPark: //17
508  case tole_Churchyard: //204
509  case tole_Saltmarsh: //206
510  case tole_Stream: //207
511  case tole_Carpark: //203
512  case tole_IndividualTree: //42
513  case tole_MetalledPath: //202
514  case tole_StoneWall://15
515  case tole_Garden://11//case tole20
516  case tole_Track://123
517  case tole_SmallRoad://122
518  case tole_LargeRoad://121
519  case tole_Building://5
520  case tole_ActivePit://115
521  case tole_Pond:
522  case tole_Freshwater://90
523  case tole_FishFarm:
524  case tole_River://96
525  case tole_Saltwater://80
526  case tole_Coast://100
527  case tole_UrbanNoVeg://6
528  case tole_BuiltUpWithParkland://16
529  case tole_AmenityGrass://12
530  case tole_OrchardBand://57
531  case tole_BareRock://59
532  case tole_Marsh://95
533  case tole_RiversidePlants://98
534  case tole_PlantNursery:
535  case tole_Pylon:
536  case tole_WindTurbine:
538  return torh_Other;
539  break;
540  default:
541  sprintf( error_num, "%d", a_tole );
542  m_TheLandscape->Warn("Rabbit_Warren::InitEvaluation Unknown tole type: ", error_num);
543  exit(1);
544  break;
545  }
546 }
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1505
Landscape * m_TheLandscape
void Rabbit_Population_Manager::CreateLocalWarrenNetworkLists ( void  )
protected

Forms the local warren network list for this warren.

Loops through all warrens in a double loop and checks if any warrens are within maxWarrenNetworkDist of each other. If so then they are added to the warren local network for that warren. If no warrens are close, then the nearest one is added, so that the list is not empty. This is not optimised because it is only called once - of course it could be done faster.

Definition at line 637 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

638 {
643  int sz = (int) TheArray[rob_Warren].size();
644  for (int i=0; i< sz; i++)
645  {
646  int closest = -1;
647  int dist = SimH;
648  int mDist = SimH;
649  int ourX = TheArray[rob_Warren][i]->Supply_m_Location_x();
650  int ourY = TheArray[rob_Warren][i]->Supply_m_Location_y();
651  for (int j=0; j< sz; j++)
652  {
653  if (i!=j) // Don't add ourselves
654  {
655  int theirX = TheArray[rob_Warren][j]->Supply_m_Location_x();
656  int theirY = TheArray[rob_Warren][j]->Supply_m_Location_y();
657  dist = (int) sqrt( (double)(((theirX-ourX)*(theirX-ourX)) + ((theirY-ourY)*(theirY - ourY))) );
658  if (dist < cfg_maxWarrenNetworkDist.value())
659  {
660  // Add to the network for this warren
662  LWNE.m_aWarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][j]);
663  LWNE.m_dist = dist;
664  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->AddNetworkConnection( LWNE );
665  }
666  if (dist < mDist)
667  {
668  mDist = dist;
669  closest = j;
670  }
671  }
672  }
673  if (dist > cfg_maxWarrenNetworkDist.value())
674  {
675  // Add the closest warren since there are no others
677  LWNE.m_aWarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][closest]);
678  LWNE.m_dist = dist;
679  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->AddNetworkConnection( LWNE );
680  }
681  }
682  for (int i=0; i< sz; i++)
683  {
684  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->NetworkEvaluation();
685  }
686 }
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
An entry in the local warren network - a helper list of accessibly local warren locations.
Definition: Rabbit.h:140
vector< TListOfAnimals > TheArray
int m_dist
Definition: Rabbit.h:143
static CfgInt cfg_maxWarrenNetworkDist("RABBIT_MAXWARRENNETWORKDIST", CFG_CUSTOM, 1500)
Input variable. The maximum distance between directly connected warrens.
Rabbit_Warren * m_aWarren
Definition: Rabbit.h:142
int value(void)
Definition: configurator.h:92
void Rabbit_Population_Manager::CreateObjects ( RabbitObjectTypes  ob_type,
TAnimal pvo,
struct_Rabbit a_data,
int  a_number 
)

Method for creating a new individual Rabbit.

Parameters
[in]ob_typeThe type of rabbit to create.
[in]pvounused unless a young is created in which case this points to the mother.
[in]a_dataA data structure containing the information needed to create the rabbit object.
[in]a_numberThe number of objects to create using a_data.

Creates a_number of new rabbit objects of type ob_type using the information about the rabbit passed in a_data. All rabbit objects created are added to the appropriate rabbit lists held in TheArray. Note that rabbit warrens are also created here to take advantage of the code in TAnimal and population manager handling - I know they are not actually rabbits themselves :)

Warren size is assumed to be 4x the fixed area, this is because low fixed area means low change of less than 100% forage, and rabbits forage quite a distance from the burrow

Definition at line 248 of file Rabbit_Population_Manager.cpp.

References Rabbit_Warren::GetCarryingCapacity(), struct_Rabbit::m_age, struct_Rabbit::m_L, struct_Rabbit::m_NPM, struct_Rabbit::m_soil, struct_Rabbit::m_Warren, m_warrenfixedsize, struct_Rabbit::m_weightage, struct_Rabbit::m_x, struct_Rabbit::m_x2, struct_Rabbit::m_y, struct_Rabbit::m_y2, rob_Female, rob_Juvenile, rob_Male, rob_Warren, rob_Young, and Population_Manager::TheArray.

Referenced by DoFirst(), PreProcessWarrenLocations(), Rabbit_Population_Manager(), Rabbit_Juvenile::st_BecomeAdult(), Rabbit_Young::st_BecomeJuvenile(), and Rabbit_Female::st_GiveBirth().

249 {
259  switch (ob_type)
260  {
261  case rob_Young:
262  Rabbit_Young* new_RabbitY;
263  for (int i=0; i<a_number; i++)
264  {
265  new_RabbitY = new Rabbit_Young(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, dynamic_cast<Rabbit_Female*>(pvo), a_data->m_L, a_data->m_NPM, a_data->m_Warren);
266  TheArray[ob_type].push_back(new_RabbitY);
267  dynamic_cast<Rabbit_Female*>(pvo)->AddYoung(new_RabbitY);
268  }
269  break;
270  case rob_Juvenile:
271  Rabbit_Juvenile* new_RabbitJ;
272  for (int i=0; i<a_number; i++)
273  {
274  new_RabbitJ = new Rabbit_Juvenile(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, dynamic_cast<Rabbit_Female*>(pvo), a_data->m_L, a_data->m_NPM, a_data->m_age, a_data->m_weightage, a_data->m_Warren);
275  TheArray[ob_type].push_back(new_RabbitJ);
276  }
277  break;
278  case rob_Male:
279  Rabbit_Male* new_RabbitM;
280  for (int i=0; i<a_number; i++)
281  {
282  new_RabbitM = new Rabbit_Male(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, a_data->m_L, a_data->m_NPM, a_data->m_age, a_data->m_weightage, a_data->m_Warren);
283  TheArray[ob_type].push_back(new_RabbitM);
284  }
285  break;
286  case rob_Female:
287  Rabbit_Female* new_RabbitF;
288  for (int i=0; i<a_number; i++)
289  {
290  new_RabbitF = new Rabbit_Female(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, a_data->m_L, a_data->m_NPM, a_data->m_age, a_data->m_weightage, a_data->m_Warren);
291  TheArray[ob_type].push_back(new_RabbitF);
292  }
293  break;
294  case rob_Warren:
295  Rabbit_Warren* new_RabbitW;
296  for (int i=0; i<a_number; i++)
297  {
301  new_RabbitW = new Rabbit_Warren(a_data->m_x, a_data->m_y, a_data->m_L, a_data->m_NPM, m_warrenfixedsize, a_data->m_soil);
302  if (new_RabbitW->GetCarryingCapacity()>0) TheArray[ob_type].push_back(new_RabbitW);
303  else delete new_RabbitW;
304  }
305  break;
306  }
307 }
The rabbit young class. All special young behaviour is described here.
Definition: Rabbit.h:319
The rabbit female class. All special female behaviour is described here.
Definition: Rabbit.h:443
Rabbit_Warren * m_Warren
A pointer to the current warren.
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
The rabbit male class. All special male behaviour is described here.
Definition: Rabbit.h:422
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
int m_y2
y-coord of birth
int m_warrenfixedsize
Holds an input variable for max warren size in m.
vector< TListOfAnimals > TheArray
The rabbit juvenile class. All special juvenile behaviour is described here.
Definition: Rabbit.h:347
int m_weightage
The rabbit age in terms of weight.
int m_age
The rabbit age.
int m_soil
The current warren soil type.
int m_x2
x-coord of birth
Landscape * m_L
Landscape pointer.
int GetCarryingCapacity()
Returns the carrying capacity in burrows.
Definition: Rabbit.h:578
virtual void Rabbit_Population_Manager::DoAfter ( )
inlineprotectedvirtual

Things to do before the EndStep.

Reimplemented from Population_Manager.

Definition at line 156 of file Rabbit_Population_Manager.h.

156 {}
virtual void Rabbit_Population_Manager::DoBefore ( )
inlineprotectedvirtual

Things to do before the Step.

Reimplemented from Population_Manager.

Definition at line 154 of file Rabbit_Population_Manager.h.

154 {}
void Rabbit_Population_Manager::DoFirst ( )
protectedvirtual

Things to do before anything else at the start of a timestep.

Reimplemented from Population_Manager.

Definition at line 310 of file Rabbit_Population_Manager.cpp.

References cfg_rabbitdiseasedensitydependencedelay, cfg_rabbitmaxforagerainfall, cfg_rabbitminimumforagetemp, CheckForRabbitBreedingConditions(), CreateObjects(), struct_Rabbit::m_age, m_forageday, struct_Rabbit::m_L, struct_Rabbit::m_NPM, m_PesticideDeaths, Population_Manager::m_TheLandscape, struct_Rabbit::m_Warren, struct_Rabbit::m_weightage, struct_Rabbit::m_x, struct_Rabbit::m_x2, struct_Rabbit::m_y, struct_Rabbit::m_y2, rob_Female, rob_foobar, rob_Male, rob_Warren, rob_Young, Population_Manager::SimH, Population_Manager::SimW, Landscape::SupplyDayInYear(), Landscape::SupplyRain(), Landscape::SupplyTemp(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), and CfgFloat::value().

311 {
312 #ifdef __RABBITDEBUG2
313  if (m_TheLandscape->SupplyYearNumber()== 1000)
314  if (m_TheLandscape->SupplyDayInYear() == 1) {
319  struct_Rabbit* sp = new struct_Rabbit;
320  sp->m_NPM = this;
321  sp->m_L = m_TheLandscape;
322  sp->m_age = 100 + random( 265 );
323  sp->m_Warren = NULL;
324  sp->m_x2 = -1;
325  sp->m_y2 = -1;
326  sp->m_weightage = 300; // Should not be weak animals to start with
327 
328  for (int i = 0; i< 500; i++) {
329  sp->m_x = random( SimW );
330  sp->m_y = random( SimH );
331  CreateObjects( rob_Male, NULL, sp, 1 ); //
332  }
333  for (int i = 0; i< 500; i++) {
334  sp->m_x = random( SimW );
335  sp->m_y = random( SimH );
336  CreateObjects( rob_Female, NULL, sp, 1 ); //
337  }
338  delete sp;
339  }
340 #endif
342  for (int r = (int)rob_Young; r < (int)rob_foobar; r++)
343  {
344  m_PesticideDeaths[r] = 0;
345  }
346  // Manage warren disease
348  {
349  for (unsigned i = 0; i < TheArray[rob_Warren].size(); i++) dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->CalcDisease();
350  }
351  // Determine whether today is forage day
352  double rainfall = m_TheLandscape->SupplyRain();
353  double temp = m_TheLandscape->SupplyTemp();
354  if ((temp<cfg_rabbitminimumforagetemp.value()) || (rainfall>cfg_rabbitmaxforagerainfall.value())) m_forageday = false; else m_forageday = true;
355 }
static CfgFloat cfg_rabbitminimumforagetemp("RABBIT_MINFORAGETEMP", CFG_CUSTOM,-0.83)
Input variable. The minimum forage temperature for rabbits.
bool m_forageday
Flag to record whether today is a possible forage day.
Rabbit_Warren * m_Warren
A pointer to the current warren.
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
int m_y2
y-coord of birth
double value(void)
Definition: configurator.h:107
vector< TListOfAnimals > TheArray
void CreateObjects(RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
Method for creating a new individual Rabbit.
void CheckForRabbitBreedingConditions(void)
Determines whether it is breeding season.
Used for creation of a new Rabbit object.
CfgInt cfg_rabbitdiseasedensitydependencedelay("RABBITDISEASEDENDEPPERIOD", CFG_CUSTOM, 90)
Input variable. The period between recalculation of rabbit disease probability.
int SupplyYearNumber(void)
Definition: landscape.h:1542
int m_weightage
The rabbit age in terms of weight.
int m_age
The rabbit age.
double SupplyRain(void)
Definition: landscape.h:1291
int m_PesticideDeaths[rob_foobar]
Holds the number of rabbits killed each day by pesticides.
int SupplyDayInYear(void)
Definition: landscape.h:1522
int m_x2
x-coord of birth
int value(void)
Definition: configurator.h:92
static CfgFloat cfg_rabbitmaxforagerainfall("RABBIT_MAXFORAGERAINFALL", CFG_CUSTOM, 3.6)
Input variable. The maximum rainfall before rabbits are assumed not to forage.
Landscape * m_L
Landscape pointer.
Landscape * m_TheLandscape
double SupplyTemp(void)
Definition: landscape.h:1312
void Rabbit_Population_Manager::DoLast ( )
protectedvirtual

Things to do after the EndStep.

For POM testing the following records have been added to the output:

  • The mean number of litters per female
  • Natal dispersal% for each sex
  • Lifetime reproductive success (no kits and mean litter size) (on death of rabbit)

Reimplemented from Population_Manager.

Definition at line 358 of file Rabbit_Population_Manager.cpp.

References cfg_warrenoccupancyrecordday, Population_Manager::m_TheLandscape, PesticideDeathRecordOutput(), Landscape::SupplyDayInYear(), CfgInt::value(), and WarrenOccupancyRecordOutput().

359 {
360  int today = m_TheLandscape->SupplyDayInYear();
361  // Do the output jobs
362  // Pesticide deaths
364  // Warren occupancy
373 }
void WarrenOccupancyRecordOutput()
Print warren occupancy record to file.
int SupplyDayInYear(void)
Definition: landscape.h:1522
static CfgInt cfg_warrenoccupancyrecordday("RABBIT_WARRENOCCUPANCYRECORDDAY", CFG_CUSTOM, 60)
Output control - the day in year for recording warren and population data.
void PesticideDeathRecordOutput()
Print pesticide death record to file.
int value(void)
Definition: configurator.h:92
Landscape * m_TheLandscape
Rabbit_Warren * Rabbit_Population_Manager::FindClosestWarren ( int  a_x,
int  a_y,
int  a_rank 
)

Finds the closest warren as the crow flies.

Parameters
[in]a_xthe x coordinate for the TL corner of the warren.
[in]a_ythe y coordinate for the TL corner of the warren.
[in]a_rankthe nth rank closest warren to return
Returns
a pointer to the nth rank closest warren. If none returns NULL.

Loops through all warrens and calculates the distance to a_x, a_y. Returns the one ranked 'a_rank' closest as the crow flies. Can handle up to 10 ranks - it will cause an error to ask for more. This is used for the occaisions where the closest warren is one the rabbit knows already, so don't ask for that one.

Definition at line 689 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Male::st_EvaluateTerritory(), and Rabbit_Female::st_EvaluateTerritory().

690 {
700  int results[10];
701  int dist;
702  TAnimal* ptrs[10];
703  for (int r = 0; r < 10; r++) {
704  results[ r ] = SimH*SimW;
705  ptrs[ r ] = NULL;
706  }
707  int sz = (int) TheArray[rob_Warren].size();
708  for (int i=0; i< sz; i++)
709  {
710  int X = TheArray[rob_Warren][i]->Supply_m_Location_x();
711  int Y = TheArray[rob_Warren][i]->Supply_m_Location_y();
712  dist = (int)sqrt( ((double( X - a_x )*double( X - a_x )) + (double( Y - a_y )*double( Y - a_y ))) );
713  for (int r=0; r<10; r++)
714  {
715  if (dist<=results[r])
716  {
717  for (int t=r+1; t<10; t++)
718  {
719  results[t]=results[t-1];
720  ptrs[t]=ptrs[t-1];
721  }
722  results[r]=dist;
723  ptrs[r]=TheArray[rob_Warren][i];
724  break;
725  }
726  }
727  }
728  Rabbit_Warren* rw = dynamic_cast<Rabbit_Warren*>(ptrs[ a_rank ]);
729  return rw;
730 }
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
vector< TListOfAnimals > TheArray
The base class for all ALMaSS animal classes.
bool Rabbit_Population_Manager::GetForageDay ( )
inline

Get method for the forage day flag.

Definition at line 123 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Adult::EndStep(), Rabbit_Young::st_Develop(), Rabbit_Juvenile::st_Develop(), and Rabbit_Warren::st_WarrenBeing().

123  {
124  return m_forageday;
125  }
bool m_forageday
Flag to record whether today is a possible forage day.
double Rabbit_Population_Manager::GetGrowth ( int  a_age)
inline

Get method for the rabbit growth with age.

Definition at line 116 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Adult::EndStep(), Rabbit_Adult::Rabbit_Adult(), Rabbit_Juvenile::Rabbit_Juvenile(), Rabbit_Young::st_Develop(), and Rabbit_Juvenile::st_Develop().

116  {
117 // if ((a_age < 0) || (a_age >= 3650)) {
118 // int rubbish = 1;
119 // }
120  return m_RabbitGrowth[ a_age ];
121  }
double m_RabbitGrowth[3650]
Holds daily growth potential of rabbits for each day.
bool Rabbit_Population_Manager::IsBreedingSeason ( void  )
inline

Get whether it is breeding season.

Definition at line 106 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Female::st_GiveBirth(), Rabbit_Female::st_UpdateBreedingStatus(), and Rabbit_Warren::st_WarrenBeing().

106 { return m_rabbitBreedingSeason; }
bool m_rabbitBreedingSeason
The breeding season flag.
void Rabbit_Population_Manager::LifetimeReproAnalysis ( )
protected

Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary.txt.

Definition at line 1058 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

1058  {
1059  /*
1060  % Success 0.66
1061  Average litters( of reproducers ) 4.39
1062  Av.Total Offspring 21.13
1063  Mean Repro Age 348.26
1064  Max Repro Age 2069.00
1065  */
1066  int Year, Day, Age, Offspring, Litter;
1067  double NoSuccessfulReproducers = 0;
1068  double NoOffspring = 0;
1069  double TotalAdults = 0;
1070  double ZeroLitters = 0;
1071  double TotalLitters = 0;
1072  double AvNoYoungLitter = 0;
1073  double AvLittersPerFemale = 0;
1074  double AvTotalOffspring = 0;
1075  double pctSuccess = 0;
1076  double MeanReproAge = 0;
1077  double SumReproAge = 0;
1078  double MaxReproAge = 0;
1079  double sumunderage = 0;
1080  double sumunderageoffspring = 0;
1081 
1082  ifstream ReproFile( "RabbitLifetimeReproRecord.txt", ios::in );
1083  // Read the header line
1084  char st[ 2000 ];
1085  ReproFile.getline( st, 2000 );
1086  ReproFile >> Year >> Day >> Age >> Offspring >> Litter;
1087  while (!ReproFile.eof()) {
1088  if (Year > 2000) {
1089  if (Age >= 304) {
1090  TotalAdults++;
1091  SumReproAge += Age - 304;
1092  if (Litter > 0) {
1093  TotalLitters += Litter;
1094  NoSuccessfulReproducers++;
1095  if (MaxReproAge < Age - 304) MaxReproAge = Age - 304;
1096  }
1097  else ZeroLitters++;
1098  NoOffspring += Offspring;
1099  }
1100  else if (Litter > 0) {
1101  sumunderage++;
1102  sumunderageoffspring += Offspring;
1103  }
1104  }
1105  ReproFile >> Year >> Day >> Age >> Offspring >> Litter;
1106  }
1107  if (TotalLitters > 0) AvNoYoungLitter = NoOffspring / TotalLitters;
1108  if (TotalAdults > 0) {
1109  MeanReproAge = SumReproAge / TotalAdults;
1110  pctSuccess = NoSuccessfulReproducers / TotalAdults;
1111  AvLittersPerFemale = TotalLitters / NoSuccessfulReproducers;
1112  }
1113  AvTotalOffspring = AvLittersPerFemale * AvNoYoungLitter;
1114  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1115  ofile << NoSuccessfulReproducers
1116  << '\t' << TotalLitters
1117  << '\t' << NoOffspring
1118  << '\t' << pctSuccess
1119  << '\t' << AvTotalOffspring
1120  << '\t' << AvNoYoungLitter
1121  << '\t' << AvLittersPerFemale
1122  << '\t' << MeanReproAge
1123  << '\t' << MaxReproAge
1124  << '\t' << sumunderage
1125  << '\t' << sumunderageoffspring << '\t';
1126  ofile.close();
1127 }
void Rabbit_Population_Manager::LoadWarrenLocations ( void  )
protected

Load warren locations.

If warren locations are not to be calculated then they are loaded from a standard file called "RabbitWarrenLocations.txt". If the wrong file is used there is no error checking and the result is usually a mysterious crash or strange results. Great care must be taken to ensure this does not happen.

Definition at line 607 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

608 {
613  ifstream ifile(cfg_warrenlocationsfile.value());
614  if ( !ifile.is_open() )
615  {
616  g_msg->Warn("Rabbit_Population_Manager::LoadWarrenLocations() Cannot open file: ", cfg_warrenlocationsfile.value());
617  exit( 1 );
618  }
619  int sz;
620  ifile >> sz;
621  for (int i=0; i< sz; i++)
622  {
623  int x,y,s;
624  ifile >> x >> y >> s;
625  struct_Rabbit sR;
626  sR.m_NPM = this;
627  sR.m_L = m_TheLandscape;
628  sR.m_x = x;
629  sR.m_y = y;
630  sR.m_soil = s;
631  CreateObjects(rob_Warren,NULL,&sR,1);
632  }
633  ifile.close();
634 }
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
static CfgStr cfg_warrenlocationsfile("RABBIT_WARRENLOCATIONSFILE", CFG_CUSTOM,"RabbitWarrenLocations.txt")
Input variable. The warren locations file.
void CreateObjects(RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
Method for creating a new individual Rabbit.
Used for creation of a new Rabbit object.
const char * value(void)
Definition: configurator.h:139
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
int m_soil
The current warren soil type.
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
Landscape * m_L
Landscape pointer.
Landscape * m_TheLandscape
void Rabbit_Population_Manager::NatalDispersalAnalysis ( )
protected

Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary.txt.

Definition at line 1130 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

1130  {
1131  int year, day, bornx, borny, newx, newy, sex;
1132  int sedmales = 0;
1133  int sedfemales = 0;
1134  int dispmales = 0;
1135  int dispfemales = 0;
1136  double malenataldisp = 0;
1137  double femalenataldisp = 0;
1138  ifstream DispFile( "RabbitNatalDispersalRecord.txt", ios::in );
1139  // Read the header line
1140  char st[ 2000 ];
1141  DispFile.getline( st, 2000 );
1142  DispFile >> year >> day >> bornx >> borny >> newx >> newy >> sex;
1143  while (!DispFile.eof()) {
1144  if (year > 2000) {
1145  if ((bornx != newx) || (borny != newy)) {
1146  if (sex == 2) dispmales++; else dispfemales++;
1147  }
1148  else if (sex == 2) sedmales++; else sedfemales++;
1149  }
1150  DispFile >> year >> day >> bornx >> borny >> newx >> newy >> sex;
1151  }
1152  if ((dispmales + sedmales)>0) malenataldisp = dispmales / double( dispmales + sedmales );
1153  if ((dispfemales + sedfemales)>0) femalenataldisp = dispfemales / double( dispfemales + sedfemales );
1154  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1155  ofile << malenataldisp << '\t' << femalenataldisp << '\t';
1156  ofile.close();
1157 }
void Rabbit_Population_Manager::NatalDispersalRecordOutput ( Rabbit_Base a_rabbit)

Records the natal dispersal.

If this method is called it records the current location as well as the location of birth to allow natal dispersal calculations.

Definition at line 909 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Base::BeginStep().

910 {
915  APoint pt = a_rabbit->GetBornLocation();
916  m_NatalDispersalFile << pt.m_x << '\t' << pt.m_y << '\t' << a_rabbit->Supply_m_Location_x() << '\t' << a_rabbit->Supply_m_Location_y() << '\t' << a_rabbit->GetRabbitType() << endl;
917 }
APoint GetBornLocation()
Get location of birth.
Definition: Rabbit.h:258
int Supply_m_Location_y()
int Supply_m_Location_x()
int SupplyDayInYear(void)
Definition: landscape.h:1522
int SupplyYear(void)
Definition: landscape.h:1537
RabbitObjectTypes GetRabbitType(void)
Get rabbit type.
Definition: Rabbit.h:218
Landscape * m_TheLandscape
ofstream m_NatalDispersalFile
For recording the natal dispersal of adults from birth to death.
void Rabbit_Population_Manager::NatalDispersalRecordOutputClose ( )
protected

Closes the reproductive output file.

Definition at line 928 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

929 {
930  m_NatalDispersalFile.close();
931 }
ofstream m_NatalDispersalFile
For recording the natal dispersal of adults from birth to death.
void Rabbit_Population_Manager::NatalDispersalRecordOutputOpen ( )
protected

Opens the reproductive output file.

Definition at line 920 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

921 {
922  m_NatalDispersalFile.open("RabbitNatalDispersalRecord.txt", ios::out);
923  m_NatalDispersalFile << "Year" << '\t' << "Day" << '\t';
924  m_NatalDispersalFile << "Born_X" << '\t' << "Born_Y" << '\t' << "New_X" << '\t' << "New_Y" << '\t' << "Rabbit_Type" << endl;
925 }
ofstream m_NatalDispersalFile
For recording the natal dispersal of adults from birth to death.
void Rabbit_Population_Manager::PesticideDeathRecord ( RabbitObjectTypes  ob_type)

Records pesticide poisoning incidents.

Definition at line 765 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Base::GeneralOrganoPhosphate(), and Rabbit_Female::st_GiveBirth().

766 {
767  m_PesticideDeaths[a_ob]++;
768 }
int m_PesticideDeaths[rob_foobar]
Holds the number of rabbits killed each day by pesticides.
void Rabbit_Population_Manager::PesticideDeathRecordOutput ( )
protected

Print pesticide death record to file.

Simply records the number of different types of rabbits that died of direct pesticide poisoning and the date it happened.

Definition at line 849 of file Rabbit_Population_Manager.cpp.

Referenced by DoLast().

850 {
855  for (int r = (int)rob_Young; r < (int)rob_foobar; r++)
856  {
858  }
859  m_PesticideDeathOFile << endl;
860 }
ofstream m_PesticideDeathOFile
The pesticide death output file.
int m_PesticideDeaths[rob_foobar]
Holds the number of rabbits killed each day by pesticides.
int SupplyDayInYear(void)
Definition: landscape.h:1522
int SupplyYear(void)
Definition: landscape.h:1537
Landscape * m_TheLandscape
void Rabbit_Population_Manager::PesticideDeathRecordOutputClose ( )
protected

Closes the pesticide death output file.

Definition at line 879 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

880 {
881  m_PesticideDeathOFile.close();
882 }
ofstream m_PesticideDeathOFile
The pesticide death output file.
void Rabbit_Population_Manager::PesticideDeathRecordOutputOpen ( )
protected

Opens pesticide death output file.

Definition at line 863 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

864 {
865  m_PesticideDeathOFile.open("RabbitPesticideDeathRecord.txt", ios::out);
866 }
ofstream m_PesticideDeathOFile
The pesticide death output file.
void Rabbit_Population_Manager::PreProcessWarrenLocations ( )
protected

This pre-scans the landscape and determines all potential warren locations on start-up.

Scans the landscape from random,random to width,height, then 0,0 to start location. Moves left to right, then top to bottom. At every location a rabbit warren is possible one is created with no population. Soil type determines the density of burrows possible and alters the requirements for fixed forage. Two options are availabe, 1. calculate the soiltype from the information present in the landscape (if this is present); 2. Read the soil type from a config variable and assume the whole landscape is of this type. see cfg_rabbit_fix_soiltype and cfg_rabbit_use_fixed_soiltype Warrens cannot overlap their fixed areas (they can overlap forage though) and must contain a minimum proportion of fixed forage which varies with soil type.

If the warren position is possible then we need to assess the element contents. This should be above a minimum % fixed forage.

If forage percentages is OK then we can make a warren here, so an empty warren location is created. Note that the Rabbit_Warren constructor takes care of ensuring the warren is intiated to being 'virgin'.

Definition at line 376 of file Rabbit_Population_Manager.cpp.

References AssessPctForage(), cfg_rabbit_fix_soiltype, cfg_rabbit_use_fixed_soiltype, CreateObjects(), struct_Rabbit::m_L, struct_Rabbit::m_NPM, struct_Rabbit::m_soil, Population_Manager::m_TheLandscape, m_warrenfixedsize, struct_Rabbit::m_x, struct_Rabbit::m_y, rob_Warren, Population_Manager::SimH, Population_Manager::SimW, Landscape::SupplySoilTypeR(), Population_Manager::TheArray, CfgInt::value(), CfgBool::value(), and WarrenLegalPos().

Referenced by Rabbit_Population_Manager().

377 {
386  cout << "Preprocessing Warren Locations" << endl;
387  int x = 0;
388  int y = 0;
389  int soil = 0;
390  for (int j=y; j<SimH-m_warrenfixedsize; j++)
391  {
392  for (int i=x; i<SimW-m_warrenfixedsize; i++)
393  {
394  if ( WarrenLegalPos(i,j) )
395  {
397  else
398  {
399  soil = m_TheLandscape->SupplySoilTypeR(i, j);
400  }
402  double pct = AssessPctForage(i,j);
403  if ((soil) != 3) // Soil type 3 is unsuitable therefore skipped
404  {
405  // Soil type 1 is sandy, 0 is chalk or otherwise hard soil
406  if (pct >= 1.0)
407  {
412  struct_Rabbit sR;
413  sR.m_NPM = this;
414  sR.m_L = m_TheLandscape;
415  sR.m_x = i;
416  sR.m_y = j;
417  sR.m_soil = soil;
418  CreateObjects(rob_Warren, NULL, &sR, 1);
419  --i += m_warrenfixedsize;
420  if (static_cast<unsigned>(TheArray.size()) % 1000 == 0) cout << TheArray.size() << '\t';
421  }
422  }
423  }
424  }
425  }
426 }
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
int m_warrenfixedsize
Holds an input variable for max warren size in m.
vector< TListOfAnimals > TheArray
int SupplySoilTypeR(int a_x, int a_y)
Returns the soil type in rabbit warren reference numbers.
Definition: landscape.h:430
void CreateObjects(RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
Method for creating a new individual Rabbit.
bool WarrenLegalPos(int &a_x, int a_y)
Tests the warrens list to see if this position is legal.
Used for creation of a new Rabbit object.
double AssessPctForage(int a_x, int a_y)
Assesses the percentage of forage for a location assuming max warren size.
static CfgInt cfg_rabbit_fix_soiltype("RABBIT_FIX_SOIL_TYPE", CFG_CUSTOM, 0)
Input variable. The soil type applied to all warrens.
static CfgBool cfg_rabbit_use_fixed_soiltype("RABBIT_USE_FIXED_SOIL_TYPE", CFG_CUSTOM, true)
Input variable. Assume fixed soil type or use landscape info?
bool value(void)
Definition: configurator.h:123
int m_soil
The current warren soil type.
int value(void)
Definition: configurator.h:92
Landscape * m_L
Landscape pointer.
Landscape * m_TheLandscape
void Rabbit_Population_Manager::ReproOutputRecordOutput ( Rabbit_Female a_female)

Print reproductive record to file.

Records the age and reproductive output of the rabbit and the date it died

Definition at line 885 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Female::st_Dying().

886 {
891  m_ReproOutputFile << '\t' << a_female->GetAge() << '\t' << a_female->GetTotalOffspring() << '\t' << a_female->GetTotalLitters() << endl;
892 }
int GetTotalLitters()
Definition: Rabbit.h:465
ofstream m_ReproOutputFile
For recording the lifetime reproductive success.
int SupplyDayInYear(void)
Definition: landscape.h:1522
int SupplyYear(void)
Definition: landscape.h:1537
int GetTotalOffspring()
Definition: Rabbit.h:464
int GetAge(void)
Get age method.
Definition: Rabbit.h:222
Landscape * m_TheLandscape
void Rabbit_Population_Manager::ReproOutputRecordOutputClose ( )
protected

Closes the reproductive output file.

Definition at line 903 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

904 {
905  m_ReproOutputFile.close();
906 }
ofstream m_ReproOutputFile
For recording the lifetime reproductive success.
void Rabbit_Population_Manager::ReproOutputRecordOutputOpen ( )
protected

Opens the reproductive output file.

Definition at line 895 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

896 {
897  m_ReproOutputFile.open( "RabbitLifetimeReproRecord.txt", ios::out );
898  m_ReproOutputFile << "Year" << '\t' << "Day" << '\t';
899  m_ReproOutputFile << '\t' << "Age" << '\t' << "Offpring" << '\t' << "Litters" << endl;
900 }
ofstream m_ReproOutputFile
For recording the lifetime reproductive success.
void Rabbit_Population_Manager::SaveWarrenLocations ( void  )
protected

Save warren locations.

Save the warren locations to "RabbitWarrenLocations.txt" so that these can be loaded again without having to go through the pre-process warren network step each time a landscape is used.

Definition at line 585 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

586 {
591  ofstream ofile(cfg_warrenlocationsfile.value());
592  if ( !ofile.is_open() )
593  {
594  g_msg->Warn("Rabbit_Population_Manager::SaveWarrenLocations() Cannot open file: ", cfg_warrenlocationsfile.value());
595  exit( 1 );
596  }
597  int sz = (int) TheArray[rob_Warren].size();
598  ofile << sz << endl;
599  for (int i=0; i< sz; i++)
600  {
601  Rabbit_Warren* awarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i]);
602  ofile << awarren->Supply_m_Location_x() - m_warrenfixedsizediv2 << '\t' << awarren->Supply_m_Location_y() - m_warrenfixedsizediv2 << '\t' << awarren->GetSoilType() << endl;
603  }
604  ofile.close();
605 }
int m_warrenfixedsizediv2
Half max warren size in m - for speed.
static CfgStr cfg_warrenlocationsfile("RABBIT_WARRENLOCATIONSFILE", CFG_CUSTOM,"RabbitWarrenLocations.txt")
Input variable. The warren locations file.
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
vector< TListOfAnimals > TheArray
const char * value(void)
Definition: configurator.h:139
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
int Supply_m_Location_y()
int Supply_m_Location_x()
int GetSoilType(void)
Gets the warren soil type.
Definition: Rabbit.h:632
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
unsigned Rabbit_Population_Manager::SupplyAllBigRabbits ( )
inline

Returns the total number of rabbits.

Definition at line 110 of file Rabbit_Population_Manager.h.

References rob_foobar, and rob_Male.

Referenced by Rabbit_Warren::CalcDisease().

110  {
111  unsigned sum = 0;
112  for (unsigned r = rob_Male; r < rob_foobar; r++) sum += (unsigned) TheArray[r].size();
113  return sum;
114  }
vector< TListOfAnimals > TheArray
void Rabbit_Population_Manager::TheNWordOutputProbe ( )
protectedvirtual

Calculates the AOR data for output for the Rabbit

Output file facility added in November 2009

Reimplemented from Population_Manager.

Definition at line 1160 of file Rabbit_Population_Manager.cpp.

1160  {
1162  Rabbit_Female* FS;
1163  unsigned int totalF = (unsigned int)TheArray[ rob_Female ].size();
1164  int x, y;
1165  int totalcells[ 4 ];
1166  for (int grid = 0; grid<4; grid++) {
1167  totalcells[ grid ] = m_gridcountwidth[ grid ] * m_gridcountwidth[ grid ];
1168  for (int i = 0; i<totalcells[ grid ]; i++) m_gridcount[ grid ][ i ] = 0;
1169  for (unsigned j = 0; j<totalF; j++) //adult females
1170  {
1171  FS = dynamic_cast<Rabbit_Female*>(TheArray[ rob_Female ][ j ]);
1172  x = FS->Supply_m_Location_x();
1173  y = FS->Supply_m_Location_y();
1174  int gx = x / m_gridcountsize[ grid ]; // 50, 100, 200, 400
1175  int gy = y / m_gridcountsize[ grid ];
1176  m_gridcount[ grid ][ gx + gy*m_gridcountwidth[ grid ] ]++;
1177  }
1178  }
1179  NWordOutput();
1180 }
The rabbit female class. All special female behaviour is described here.
Definition: Rabbit.h:443
void NWordOutput()
The output section for the NWord probe. .
vector< TListOfAnimals > TheArray
int Supply_m_Location_y()
int Supply_m_Location_x()
bool Rabbit_Population_Manager::WarrenLegalPos ( int &  a_x,
int  a_y 
)
protected

Tests the warrens list to see if this position is legal.

Parameters
[in]a_xThe x-coordinate to assess
[in]a_yThe x-coordinate to assess
Returns
Whether the location is a legal one for a warren

Loops through all warrens and asks whether they are closer than m_warrenfixedsize, if so returns false. Must loop through all warrens to return true.

Todo:
Use a temporary binary map to achieve this without the loop - speed optimisation if we have time.

Definition at line 429 of file Rabbit_Population_Manager.cpp.

References ClassifyHabitat(), Population_Manager::m_TheLandscape, m_warrenfixedsize, m_warrenfixedsizediv2, rob_Warren, Landscape::SupplyElementType(), Population_Manager::TheArray, and torh_Forage.

Referenced by PreProcessWarrenLocations().

430 {
440  // If it is not in a warren already then we are legal here.
441  int sz = (int) TheArray[rob_Warren].size();
442  for (int i=0; i< sz; i++)
443  {
444  APoint pt = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->SupplyPoint();
445  if ((abs(pt.m_x-a_x) < m_warrenfixedsize) && (abs(pt.m_y-a_y) < m_warrenfixedsize))
446  {
447  a_x += m_warrenfixedsize;
448  return false;
449  }
450  }
451  return true;
452 }
int m_warrenfixedsizediv2
Half max warren size in m - for speed.
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1031
int m_warrenfixedsize
Holds an input variable for max warren size in m.
vector< TListOfAnimals > TheArray
TTypesOfRabbitHabitat ClassifyHabitat(TTypesOfLandscapeElement a_tole)
Classify a landscape element type according to the rabbit habitat classification. ...
Landscape * m_TheLandscape
void Rabbit_Population_Manager::WarrenOccupancyRecordOutput ( )
protected

Print warren occupancy record to file.

Produces a record of mean warren occupancy, number of burrows, disease level, and a a measure of variation in occupancy (CV of occupancy).
For convenience some global stats on population numbers are also produced here.

Definition at line 771 of file Rabbit_Population_Manager.cpp.

Referenced by DoLast().

771  {
776  ofstream warrenrecord( "WarrenOccupancyRecord.txt", ios::app );
777  double occupancy = 0;
778  double var_occupancy = 0;
779  double sumsqr = 0.0;
780  double totalrabbits = 0;
781  double burrows = 0;
782  double disease = 0;
783  int warrensoccupied = 0;
784  int kits = 0;
785  int juvs = 0;
786  int ads = 0;
787  int breedingfemales = 0;
788  double breedingfemalesAv = 0;
789  int oneyroldfemales = 0;
790  int nonbreedingfemales = 0;
791  int litters = 0;
792  double lrc = 0;
793  double n = (double)TheArray[ rob_Warren ].size();
794  for (unsigned i = 0; i < TheArray[ rob_Warren ].size(); i++) {
795  Rabbit_Warren* warren = dynamic_cast<Rabbit_Warren*>(TheArray[ rob_Warren ][ i ]);
796  double occ = warren->GetCarryingCapacityRatio();
797  occupancy += occ;
798  sumsqr += occ * occ;
799  totalrabbits += warren->GetPopulationSize();
800  if (warren->GetPopulationSize()>0) warrensoccupied++;
801  burrows += warren->GetCarryingCapacity();
802  disease += warren->GetDiseaseConstant();
803  kits += warren->GetRabbitProductionRecord( rob_Young );
804  juvs += warren->GetRabbitProductionRecord( rob_Juvenile );
805  ads += warren->GetRabbitProductionRecord( rob_Male );
806  ads += warren->GetRabbitProductionRecord( rob_Female );
807  warren->UpdateThisYearsBreeders();
808  breedingfemales += warren->GetThisYearsBreeders();
809  breedingfemalesAv += warren->GetThisYearsBreedersAv();
810  oneyroldfemales += warren->GetThisYears1yrOldFemales();
811  nonbreedingfemales += warren->GetThisYearsNonBreeders();
812  litters += warren->GetLittersThisYear();
813  lrc += warren->GetLitterReabsortionConst();
815  }
816  double littersperfemale = 0;
817  double CV_occ = 0;
818  if ((occupancy > 0) && (ads > 0)) {
819  var_occupancy = (sumsqr - (occupancy*occupancy) / n) / (n - 1);
820  if (var_occupancy < 0) var_occupancy = 0.0; // Rounding errors cause this
821  occupancy /= n;
822  burrows /= n;
823  disease /= n;
824  totalrabbits /= n;
825  kits /= (int)n;
826  juvs /= (int)n;
827  ads /= (int)n;
828  CV_occ = sqrt( var_occupancy ) / occupancy;
829  if (breedingfemales > 0) littersperfemale = litters / double( breedingfemales );
830  }
831  else {
832  var_occupancy = 0;
833  occupancy = 0;
834  burrows = 0;
835  disease = 0;
836  totalrabbits = 0;
837  kits = 0;
838  juvs = 0;
839  ads = 0;
840  CV_occ = 0;
841  }
842  lrc /= n;
843  warrenrecord << m_TheLandscape->SupplyYearNumber() << '\t' << m_TheLandscape->SupplyDayInYear() << '\t' << (int)n << '\t' << warrensoccupied << '\t' << burrows << '\t' << totalrabbits << '\t' << disease << '\t' << occupancy << '\t' << CV_occ << '\t' << kits << '\t' << juvs << '\t' << ads;
844  for (int r = (int)rob_Young; r < rob_Warren; r++) warrenrecord << '\t' << TheArray[ r ].size();
845  warrenrecord << '\t' << breedingfemales << '\t' << breedingfemalesAv << '\t' << oneyroldfemales << '\t' << nonbreedingfemales << '\t' << littersperfemale << '\t' << lrc << '\t' << litters << endl;
846 }
double GetCarryingCapacityRatio()
Checks whether all possible burrows are filled with rabbits. This is updated daily by Rabbit_Warren::...
Definition: Rabbit.h:576
int GetPopulationSize()
Gets the total warren population of rabbits.
Definition: Rabbit.h:572
double GetLitterReabsortionConst(void)
Returns litter reabsorption chance.
Definition: Rabbit.h:650
int GetThisYearsBreeders()
Returns the number of females breeding this year.
Definition: Rabbit.h:654
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
void ResetAllRabbitProductionRecord(void)
Reset data about production of rabbits throughout year.
Definition: Rabbit.h:588
vector< TListOfAnimals > TheArray
int GetLittersThisYear()
Returns the number litters produced in the last 12 months.
Definition: Rabbit.h:670
int SupplyYearNumber(void)
Definition: landscape.h:1542
void UpdateThisYearsBreeders()
Calculates and stores the number of breeders and non-breeders.
Definition: Rabbit.cpp:1815
int GetThisYearsNonBreeders()
Returns the number of females not breeding this year but older than 1 year.
Definition: Rabbit.h:674
int SupplyDayInYear(void)
Definition: landscape.h:1522
int GetRabbitProductionRecord(RabbitObjectTypes YoungType)
Get data about production of rabbits throughout year.
Definition: Rabbit.h:584
int GetThisYears1yrOldFemales()
Returns the number of 1yr old females.
Definition: Rabbit.h:666
double GetThisYearsBreedersAv()
Returns the number of females breeding this year.
Definition: Rabbit.h:658
int GetCarryingCapacity()
Returns the carrying capacity in burrows.
Definition: Rabbit.h:578
Landscape * m_TheLandscape
double GetDiseaseConstant(void)
Returns the warrens current disease constant.
Definition: Rabbit.h:580
void Rabbit_Population_Manager::WarrenOccupancyRecordOutputClose ( )
protected

Closes the warren occupancy output file.

Definition at line 934 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

935 {
936  m_WarrenOccupancyFile.close();
937 }
ofstream m_WarrenOccupancyFile
The warren occupancy output file.
void Rabbit_Population_Manager::WarrenOccupancyRecordOutputOpen ( )
protected

Opens the warren occupancy output file.

Definition at line 869 of file Rabbit_Population_Manager.cpp.

Referenced by Rabbit_Population_Manager().

870 {
871  m_WarrenOccupancyFile.open("WarrenOccupancyRecord.txt", ios::out);
872  m_WarrenOccupancyFile << "Year" << '\t' << "Day" << '\t' << "No. Warrens" << '\t' << "No.Occ.Warrens" << '\t' << "Mean Burrows" << '\t' << "Mean Rabbits" << '\t' << "Mean Disease"
873  << '\t' << "Mean Occupancy" << '\t' << "CV Occupancy" << '\t' << "Mean Kits" << '\t' << "Mean Juvs" << '\t' << "Mean Ads" << '\t' << "TotalYoung" << '\t' << "TotalJuvs"
874  << '\t' << "TotalMales" << '\t' << "TotalFemales" << '\t' << "BreedingFemales" << '\t' << "BreedingDensityAv" << '\t' << "1yr old females" << '\t' << "NonBreedingFems.>1yr"
875  << '\t' << "Littersperfemale" << '\t' << "lrc" << '\t' << "litters" << endl;
876 }
ofstream m_WarrenOccupancyFile
The warren occupancy output file.
void Rabbit_Population_Manager::WarrenOutputAnalysis ( )
protected

Does analysis on the warren output file and saves the results to RabbitPOMSummary.txt.

Definition at line 940 of file Rabbit_Population_Manager.cpp.

Referenced by ~Rabbit_Population_Manager().

940  {
941  double Year, Day, NoWarrens, NoOccWarrens, MeanBurrows, MeanRabbits, MeanDisease, MeanOccupancy, CVOccupancy, MeanKits, MeanJuvs, MeanAds, TotalYoung, TotalJuvs, TotalMales,
942  TotalFemales, BreedingFemales, yroldfemales, NonBreedingFems;
943  vector<double> totalfemales;
944  vector<double> totalbrfemalesdensity;
945  vector<double> nonbreedingdensity;
946  vector<double> yrolddensity;
947  vector<double> breedingdensity;
948  vector<double> yearlingpct;
949  vector<double> kitsperfemale;
950 
951  double meantotalbrpop;
952  double maxbreedingpop = -1;
953  double minbreedingpop = 100000;
954  double maxyroldspct = -1;
955  double minyroldspct = 100000;
956  double correlation;
957  double correlation_b;
958  double littersperfemale;
959  double lrc;
960  double BreedingDensityAv;
961  double litters;
962 
963 
964  ifstream WarrenOccupancyFile( "WarrenOccupancyRecord.txt", ios::in );
965  // Read the header line
966  char st[ 2000 ];
967  WarrenOccupancyFile.getline( st, 2000 );
968  while (!WarrenOccupancyFile.eof()) {
969  WarrenOccupancyFile >> Year >> Day >> NoWarrens >> NoOccWarrens >> MeanBurrows >> MeanRabbits >> MeanDisease
970  >> MeanOccupancy >> CVOccupancy >> MeanKits >> MeanJuvs >> MeanAds >> TotalYoung >> TotalJuvs
971  >> TotalMales >> TotalFemales >> BreedingFemales >> BreedingDensityAv >> yroldfemales >> NonBreedingFems >> littersperfemale >> lrc >> litters;
972  // Here we create the actual data that we need
973  // We want:
974  // - correlation between total breeding pop and 1yr olds
975  // - mean of total breeding pop
976  // - mean of 1yr olds
977  // - range max-min of total breeding pop
978  // - range max-min of 1yr olds
979  if ((yroldfemales + BreedingFemales + NonBreedingFems) > 0) {
980  yearlingpct.push_back( yroldfemales / (yroldfemales + BreedingFemales + NonBreedingFems) );
981  totalbrfemalesdensity.push_back( (yroldfemales + BreedingFemales + NonBreedingFems) / 2.0 );
982  totalfemales.push_back( (BreedingFemales + NonBreedingFems) / 2.0 );
983  breedingdensity.push_back( BreedingFemales / 2.0 );
984  nonbreedingdensity.push_back( NonBreedingFems / 2.0 );
985  yrolddensity.push_back( yroldfemales / 2.0 );
986  kitsperfemale.push_back( littersperfemale );
987  }
988  else {
989  // All dead so save the results
990  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
991  ofile << 0
992  << '\t' << 0
993  << '\t' << 0
994  << '\t' << 0
995  << '\t' << 0
996  << '\t' << 0
997  << '\t' << 0 << endl;
998  ofile.close();
999  return;
1000  }
1001  }
1002  WarrenOccupancyFile.close();
1003  // Now we have all the useful data we can create the stats for this analysis
1004  //
1005  // Get the ranges skipping the first 10 years
1006  int sz = static_cast<int>(yearlingpct.size());
1007  double sumx = 0;
1008  double sumx2 = 0;
1009  double sumy = 0;
1010  double sumy2 = 0;
1011  double sumxy = 0;
1012  double sumx_b = 0;
1013  double sumx2_b = 0;
1014  double sumy_b = 0;
1015  double sumy2_b = 0;
1016  double sumxy_b = 0;
1017  double n = sz - 1 - 10;
1018  // Do the correlation for yearlingpct and total female density
1019  for (int i = 10; i < sz - 1; i++) {
1020  if (totalbrfemalesdensity[ i ]>maxbreedingpop)maxbreedingpop = totalbrfemalesdensity[ i ];
1021  if (totalbrfemalesdensity[ i ] < minbreedingpop)minbreedingpop = totalbrfemalesdensity[ i ];
1022  if (yearlingpct[ i ] > maxyroldspct) maxyroldspct = yearlingpct[ i ];
1023  if (yearlingpct[ i ] < minyroldspct) minyroldspct = yearlingpct[ i ];
1024  sumx += totalbrfemalesdensity[ i ];
1025  sumx2 += totalbrfemalesdensity[ i ] * totalbrfemalesdensity[ i ];
1026  sumy += yearlingpct[ i ];
1027  sumy2 += yearlingpct[ i ] * yearlingpct[ i ];
1028  sumxy += totalbrfemalesdensity[ i ] * yearlingpct[ i ];
1029  }
1030  meantotalbrpop = sumx / n;
1031  double intermediate = (n*sumxy) - (sumx*sumy);
1032  correlation = intermediate / sqrt( ((n*sumx2) - (sumx*sumx))*((n*sumy2) - (sumy*sumy)) );
1033  //
1034  n = n - 1;
1035  for (int i = 10; i < sz - 2; i++) {
1036  // Here we need the numbers from the year before
1037  sumx_b += totalfemales[ i ];
1038  sumx2_b += totalfemales[ i ] * totalfemales[ i ];
1039  sumy_b += kitsperfemale[ i+1 ];
1040  sumy2_b += kitsperfemale[ i+1 ] * kitsperfemale[ i+1 ];
1041  sumxy_b += totalfemales[ i ] * kitsperfemale[ i+1 ];
1042  }
1043  intermediate = (n*sumxy_b) - (sumx_b*sumy_b);
1044  correlation_b = intermediate / sqrt( ((n*sumx2_b) - (sumx_b*sumx_b))*((n*sumy2_b) - (sumy_b*sumy_b)) );
1045  // Now save the results
1046  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1047  ofile << meantotalbrpop
1048  << '\t' << maxbreedingpop
1049  << '\t' << minbreedingpop
1050  << '\t' << maxyroldspct
1051  << '\t' << minyroldspct
1052  << '\t' << correlation
1053  << '\t' << correlation_b << endl;
1054  ofile.close();
1055 }

Member Data Documentation

bool Rabbit_Population_Manager::m_forageday
protected

Flag to record whether today is a possible forage day.

Definition at line 149 of file Rabbit_Population_Manager.h.

Referenced by DoFirst().

ofstream Rabbit_Population_Manager::m_NatalDispersalFile
protected

For recording the natal dispersal of adults from birth to death.

Definition at line 143 of file Rabbit_Population_Manager.h.

ofstream Rabbit_Population_Manager::m_PesticideDeathOFile
protected

The pesticide death output file.

Definition at line 147 of file Rabbit_Population_Manager.h.

int Rabbit_Population_Manager::m_PesticideDeaths[rob_foobar]
protected

Holds the number of rabbits killed each day by pesticides.

Definition at line 139 of file Rabbit_Population_Manager.h.

Referenced by DoFirst().

bool Rabbit_Population_Manager::m_rabbitBreedingSeason
protected

The breeding season flag.

Definition at line 133 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Population_Manager().

double Rabbit_Population_Manager::m_RabbitGrowth[3650]
protected

Holds daily growth potential of rabbits for each day.

Definition at line 137 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Population_Manager().

ofstream Rabbit_Population_Manager::m_ReproOutputFile
protected

For recording the lifetime reproductive success.

Definition at line 145 of file Rabbit_Population_Manager.h.

int Rabbit_Population_Manager::m_reproswitchbuffer
protected

Prevents continuous breeding season switching.

Definition at line 135 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Population_Manager().

int Rabbit_Population_Manager::m_warrenfixedsize
protected

Holds an input variable for max warren size in m.

Definition at line 129 of file Rabbit_Population_Manager.h.

Referenced by CreateObjects(), PreProcessWarrenLocations(), Rabbit_Population_Manager(), and WarrenLegalPos().

int Rabbit_Population_Manager::m_warrenfixedsizediv2
protected

Half max warren size in m - for speed.

Definition at line 131 of file Rabbit_Population_Manager.h.

Referenced by Rabbit_Population_Manager(), and WarrenLegalPos().

ofstream Rabbit_Population_Manager::m_WarrenOccupancyFile
protected

The warren occupancy output file.

Definition at line 141 of file Rabbit_Population_Manager.h.


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