ALMaSS Rabbit ODdox  1.1
The rabbit model description following ODdox protocol
Rabbit_Population_Manager.cpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 
4 Copyright (c) 2015, Christopher John Topping, Faarupvej 54, DK-8410 Rønde
5 ADAMA Makhteshim Ltd., PO Box 60, Beer-Sheva 84100, Israel
6 
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
11 
12 1. Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 The views and conclusions contained in the software and documentation are those
30 of the authors and should not be interpreted as representing official policies,
31 either expressed or implied, of the FreeBSD Project.
32 
33 ********************************************************************************************************
34 
35 */
44 //---------------------------------------------------------------------------
45 
46 //#define __RABBITBREEDINGSEASONCHECK
47 //#define __RABBITDEBUG2
48 
49 
50 #include <iostream>
51 #include <fstream>
52 #include <vector>
53 #include <math.h>
54 #include "../BatchALMaSS/ALMaSS_Setup.h"
55 #include "../ALMaSSDefines.h"
56 #include "../Landscape/ls.h"
57 #include "../BatchALMaSS/PopulationManager.h"
58 #include "../BatchALMaSS/AOR_Probe.h"
59 #include "../Rabbit/Rabbit.h"
60 #include "../Rabbit/Rabbit_Population_Manager.h"
61 #include "../BatchALMaSS/BoostRandomGenerators.h"
62 //---------------------------------------------------------------------------------------
63 
64 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> > g_rand_uni;
73 //---------------------------------------------------------------------------------------
74 
76 static CfgInt cfg_RabbitStartNos("RABBIT_STARTNOS",CFG_CUSTOM,25000);
78 CfgInt cfg_warrenfixedsize("RABBIT_WARRENFIXEDSIZE",CFG_CUSTOM,45);
80 static CfgBool cfg_warrenreadlocations("RABBIT_WARRENREADLOCATIONS", CFG_CUSTOM, true);
82 static CfgStr cfg_warrenlocationsfile("RABBIT_WARRENLOCATIONSFILE", CFG_CUSTOM, "RabbitWarrenLocations.txt");
84 static CfgInt cfg_warrenoccupancyrecordday("RABBIT_WARRENOCCUPANCYRECORDDAY", CFG_CUSTOM, 60);
86 static CfgInt cfg_maxWarrenNetworkDist("RABBIT_MAXWARRENNETWORKDIST",CFG_CUSTOM,1500);
88 static CfgFloat cfg_rabbitminbreedingtemp("RABBIT_MINBREEDINGTEMP",CFG_CUSTOM,300.0);
90 static CfgBool cfg_rabbit_use_fixed_soiltype("RABBIT_USE_FIXED_SOIL_TYPE", CFG_CUSTOM, true);
92 static CfgInt cfg_rabbit_fix_soiltype("RABBIT_FIX_SOIL_TYPE", CFG_CUSTOM, 0); // 0 chalk, 1 sand
94 CfgInt cfg_rabbitdensitydependencedelay( "RABBIT_DENDEPPERIOD", CFG_CUSTOM, 53 );
96 CfgInt cfg_rabbitdiseasedensitydependencedelay( "RABBITDISEASEDENDEPPERIOD", CFG_CUSTOM, 90 );
98 static CfgFloat cfg_rabbitdailygrowthparam1("RABBIT_DAILYGROWTHPARAM_ONE", CFG_CUSTOM, 1127.616084);
100 static CfgFloat cfg_rabbitdailygrowthparam2("RABBIT_DAILYGROWTHPARAM_TWO", CFG_CUSTOM, -0.013143202);
102 static CfgFloat cfg_rabbitdailygrowthparam3("RABBIT_DAILYGROWTHPARAM_THREE", CFG_CUSTOM, 0.0);
104 static CfgFloat cfg_rabbitminimumforagetemp( "RABBIT_MINFORAGETEMP", CFG_CUSTOM, -0.83 );
106 static CfgFloat cfg_rabbitmaxforagerainfall( "RABBIT_MAXFORAGERAINFALL", CFG_CUSTOM, 3.6 );
108 CfgBool cfg_RabbitUseNatalDispersalRecord( "RABBIT_USENATALDISPERSALRECORD", CFG_CUSTOM, false );
110 CfgInt cfg_RabbitUseNatalDispersalRecordAge( "RABBIT_USENATALDISPERSALRECORDAGE", CFG_CUSTOM, 30*6 );
112 CfgBool cfg_RabbitUseReproOutput("RABBIT_USEREPROOUTPUT", CFG_CUSTOM, false);
113 // Globals created from input parameters - this is just to avoid unnecessary calculations later. NB these must be initialized in the code after program start
114 int g_land_width = 0;
115 
116 //***************************************************************************
117 //*************** RABBIT POPULATION MANAGER CODE ****************************
118 //***************************************************************************
119 
121 {
123  m_ListNames[0] = "Young";
124  m_ListNames[1] = "Juvenile";
125  m_ListNames[2] = "Male";
126  m_ListNames[3] = "Female";
127  m_ListNames[4] = "Possible Warrens";
128  m_ListNameLength = 5;
130  g_land_width = m_TheLandscape->SupplySimAreaWidth(); // Needs the landscape to be square!!!
131 
132  strcpy( m_SimulationName, "Rabbit Simulation" );
137  struct_Rabbit* sp = new struct_Rabbit;
138  sp->m_NPM = this;
139  sp->m_L = m_TheLandscape;
140  sp->m_age = 100+random(265);
141  sp->m_Warren = NULL;
142  sp->m_x2 = -1;
143  sp->m_y2 = -1;
144  sp->m_weightage = 300; // Should not be weak animals to start with
145 
146  for (int i = 0; i< cfg_RabbitStartNos.value(); i++)
147  {
148  sp->m_x = random(SimW);
149  sp->m_y = random(SimH);
150  CreateObjects(rob_Male,NULL,sp,1); //
151  }
152  for (int i=0; i< cfg_RabbitStartNos.value(); i++)
153  {
154  sp->m_x = random(SimW);
155  sp->m_y = random(SimH);
156  CreateObjects(rob_Female,NULL,sp,1); //
157  }
158  delete sp;
159  // Load parameters
164  m_reproswitchbuffer = 30;
165  m_rabbitBreedingSeason = false;
166 
172  {
174  }
175  else
176  {
179  }
181  // Open output files
184  }
189  // Assign static variable
191  // Create the rabbit growth rate lookup data
192  for (int i = 1; i < 300; i++) {
194  }
195  // Now fill this in for up to 10 years (no rabbit should ever live that long )
196  for (int i = 300; i < 3350; i++) {
198  }
199 
200 }
201 //---------------------------------------------------------------------------
202 
204 {
207  struct_Rabbit* sp = new struct_Rabbit;
208  sp->m_NPM = this;
209  sp->m_L = m_TheLandscape;
210  sp->m_age = 100 + random(265);
211  sp->m_Warren = NULL;
212  Rabbit_Female* rf = new Rabbit_Female(0,0,-1,-1,m_TheLandscape,this,0, 300,NULL);
213  Rabbit_Warren* rw = new Rabbit_Warren(0, 0, m_TheLandscape, this, 0, NULL);
218  rf->SetMaxKits(cfg_rabbitmaxkits.value() - cfg_rabbitminkits.value()); // Here we actually use the difference to calculate range
219  rf->m_pesticidedegradationrate = cfg_rabbit_pesticidedegradationrate.value(); // default of 0.0 will remove all body burden pesticide at the end of each day
220  delete rw;
221  delete rf;
222 }
223 //---------------------------------------------------------------------------
224 
226 {
235  }
239  }
241  for (unsigned i = 0; i < TheArray.size(); i++) {
242  for ( unsigned j = 0; j < TheArray[ i ].size(); j++ ) {
243  // This just stops a DEBUG error
244  TheArray[ i ] [ j ]->KillThis();
245  }
246  }
247 }
248 //---------------------------------------------------------------------------
249 
251 {
261  switch (ob_type)
262  {
263  case rob_Young:
264  Rabbit_Young* new_RabbitY;
265  for (int i=0; i<a_number; i++)
266  {
267  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);
268  TheArray[ob_type].push_back(new_RabbitY);
269  dynamic_cast<Rabbit_Female*>(pvo)->AddYoung(new_RabbitY);
270  }
271  break;
272  case rob_Juvenile:
273  Rabbit_Juvenile* new_RabbitJ;
274  for (int i=0; i<a_number; i++)
275  {
276  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);
277  TheArray[ob_type].push_back(new_RabbitJ);
278  }
279  break;
280  case rob_Male:
281  Rabbit_Male* new_RabbitM;
282  for (int i=0; i<a_number; i++)
283  {
284  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);
285  TheArray[ob_type].push_back(new_RabbitM);
286  }
287  break;
288  case rob_Female:
289  Rabbit_Female* new_RabbitF;
290  for (int i=0; i<a_number; i++)
291  {
292  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);
293  TheArray[ob_type].push_back(new_RabbitF);
294  }
295  break;
296  case rob_Warren:
297  Rabbit_Warren* new_RabbitW;
298  for (int i=0; i<a_number; i++)
299  {
303  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);
304  if (new_RabbitW->GetCarryingCapacity()>0) TheArray[ob_type].push_back(new_RabbitW);
305  else delete new_RabbitW;
306  }
307  break;
308  }
309 }
310 //---------------------------------------------------------------------------
311 
313 {
314 #ifdef __RABBITDEBUG2
315  if (m_TheLandscape->SupplyYearNumber()== 1000)
316  if (m_TheLandscape->SupplyDayInYear() == 1) {
321  struct_Rabbit* sp = new struct_Rabbit;
322  sp->m_NPM = this;
323  sp->m_L = m_TheLandscape;
324  sp->m_age = 100 + random( 265 );
325  sp->m_Warren = NULL;
326  sp->m_x2 = -1;
327  sp->m_y2 = -1;
328  sp->m_weightage = 300; // Should not be weak animals to start with
329 
330  for (int i = 0; i< 500; i++) {
331  sp->m_x = random( SimW );
332  sp->m_y = random( SimH );
333  CreateObjects( rob_Male, NULL, sp, 1 ); //
334  }
335  for (int i = 0; i< 500; i++) {
336  sp->m_x = random( SimW );
337  sp->m_y = random( SimH );
338  CreateObjects( rob_Female, NULL, sp, 1 ); //
339  }
340  delete sp;
341  }
342 #endif
344  for (int r = (int)rob_Young; r < (int)rob_foobar; r++)
345  {
346  m_PesticideDeaths[r] = 0;
347  }
348  // Manage warren disease
350  {
351  for (unsigned i = 0; i < TheArray[rob_Warren].size(); i++) dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->CalcDisease();
352  }
353  // Determine whether today is forage day
354  double rainfall = m_TheLandscape->SupplyRain();
355  double temp = m_TheLandscape->SupplyTemp();
356  if ((temp<cfg_rabbitminimumforagetemp.value()) || (rainfall>cfg_rabbitmaxforagerainfall.value())) m_forageday = false; else m_forageday = true;
357 }
358 //---------------------------------------------------------------------------
359 
361 {
362  int today = m_TheLandscape->SupplyDayInYear();
363  // Do the output jobs
364  // Pesticide deaths
366  // Warren occupancy
375 }
376 //---------------------------------------------------------------------------
377 
379 {
388  cout << "Preprocessing Warren Locations" << endl;
389  int x = 0;
390  int y = 0;
391  int soil = 0;
392  for (int j=y; j<SimH-m_warrenfixedsize; j++)
393  {
394  for (int i=x; i<SimW-m_warrenfixedsize; i++)
395  {
396  if ( WarrenLegalPos(i,j) )
397  {
399  else
400  {
401  soil = m_TheLandscape->SupplySoilTypeR(i, j);
402  }
404  double pct = AssessPctForage(i,j);
405  if ((soil) != 3) // Soil type 3 is unsuitable therefore skipped
406  {
407  // Soil type 1 is sandy, 0 is chalk or otherwise hard soil
408  if (pct >= 1.0)
409  {
414  struct_Rabbit sR;
415  sR.m_NPM = this;
416  sR.m_L = m_TheLandscape;
417  sR.m_x = i;
418  sR.m_y = j;
419  sR.m_soil = soil;
420  CreateObjects(rob_Warren, NULL, &sR, 1);
421  --i += m_warrenfixedsize;
422  if (static_cast<unsigned>(TheArray.size()) % 1000 == 0) cout << TheArray.size() << '\t';
423  }
424  }
425  }
426  }
427  }
428 }
429 //---------------------------------------------------------------------------
430 
432 {
442  // If it is not in a warren already then we are legal here.
443  int sz = (int) TheArray[rob_Warren].size();
444  for (int i=0; i< sz; i++)
445  {
446  APoint pt = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->SupplyPoint();
447  if ((abs(pt.m_x-a_x) < m_warrenfixedsize) && (abs(pt.m_y-a_y) < m_warrenfixedsize))
448  {
449  a_x += m_warrenfixedsize;
450  return false;
451  }
452  }
453  return true;
454 }
455 //---------------------------------------------------------------------------
456 
458 {
466  static char error_num[ 20 ];
467  switch (a_tole)
468  {
469  case tole_UnsprayedFieldMargin://31
470  case tole_Field://20&30
471  case tole_RoadsideVerge://13
472  case tole_BeetleBank://141
473  return torh_TemporaryForage;
474  break;
475  case tole_Railway://118
476  case tole_FieldBoundary://160
477  case tole_PermPastureLowYield://26
478  case tole_PermPastureTussocky://27
479  case tole_PermanentSetaside://33
480  case tole_PermPasture://35
481  case tole_NaturalGrassDry://110//case tole11
482  case tole_PitDisused://75
483  case tole_YoungForest://55
484  case tole_HedgeBank://140
485  case tole_Heath://94
486  case tole_Parkland://14
487  case tole_SandDune://101
488  case tole_Orchard://56
489  case tole_RoadsideSlope: //201
490  case tole_HeritageSite: //208
491  case tole_UnknownGrass:
492  case tole_Vildtager:
493  case tole_MownGrass:
494  case tole_Wasteland:
495  return torh_Forage;
496  break;
497  case tole_Hedges://130
498  case tole_Copse://41
499  case tole_Scrub://70
500  case tole_RiversideTrees://97
501  case tole_DeciduousForest://40
502  case tole_MixedForest://60
503  case tole_ConiferousForest://50
504  case tole_WoodlandMargin:
506  return torh_Cover;
507  break;
508  case tole_UrbanPark: //17
510  case tole_Churchyard: //204
511  case tole_Saltmarsh: //206
512  case tole_Stream: //207
513  case tole_Carpark: //203
514  case tole_IndividualTree: //42
515  case tole_MetalledPath: //202
516  case tole_StoneWall://15
517  case tole_Fence: //225
518  case tole_Garden://11//case tole20
519  case tole_Track://123
520  case tole_SmallRoad://122
521  case tole_LargeRoad://121
522  case tole_Building://5
523  case tole_ActivePit://115
524  case tole_Pond:
525  case tole_Freshwater://90
526  case tole_FishFarm:
527  case tole_River://96
528  case tole_Saltwater://80
529  case tole_Coast://100
530  case tole_UrbanNoVeg://8
531  case tole_BuiltUpWithParkland://16
532  case tole_AmenityGrass://12
533  case tole_OrchardBand://57
534  case tole_BareRock://59
535  case tole_Marsh://95
536  case tole_RiversidePlants://98
537  case tole_PlantNursery:
538  case tole_Pylon:
539  case tole_WindTurbine:
541  return torh_Other;
542  break;
543  default:
544  sprintf( error_num, "%d", a_tole );
545  m_TheLandscape->Warn("Rabbit_Warren::InitEvaluation Unknown tole type: ", error_num);
546  exit(1);
547  break;
548  }
549 }
550 //---------------------------------------------------------------------------
551 
553 {
561  int total = 0;
562  int add = 0;
563  int oldpoly = -1;
564  for (int i=a_x; i<a_x + m_warrenfixedsize; i++)
565  {
566  for (int j=a_y; j<a_y + m_warrenfixedsize; j++)
567  {
571  int poly = m_TheLandscape->SupplyPolyRef(i, j);
572  if (poly != oldpoly)
573  {
574  oldpoly = poly;
576  if (ClassifyHabitat(tole) == torh_Forage) add = 1; else add = 0;
577  }
578  total += add;
579  }
580  }
581  double warrenarea = m_warrenfixedsize * m_warrenfixedsize;
585  return (double) total/warrenarea;
586 }
587 
589 {
594  ofstream ofile(cfg_warrenlocationsfile.value());
595  if ( !ofile.is_open() )
596  {
597  g_msg->Warn("Rabbit_Population_Manager::SaveWarrenLocations() Cannot open file: ", cfg_warrenlocationsfile.value());
598  exit( 1 );
599  }
600  int sz = (int) TheArray[rob_Warren].size();
601  ofile << sz << endl;
602  for (int i=0; i< sz; i++)
603  {
604  Rabbit_Warren* awarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i]);
605  ofile << awarren->Supply_m_Location_x() - m_warrenfixedsizediv2 << '\t' << awarren->Supply_m_Location_y() - m_warrenfixedsizediv2 << '\t' << awarren->GetSoilType() << endl;
606  }
607  ofile.close();
608 }
609 
611 {
616  ifstream ifile(cfg_warrenlocationsfile.value());
617  if ( !ifile.is_open() )
618  {
619  g_msg->Warn("Rabbit_Population_Manager::LoadWarrenLocations() Cannot open file: ", cfg_warrenlocationsfile.value());
620  exit( 1 );
621  }
622  int sz;
623  ifile >> sz;
624  for (int i=0; i< sz; i++)
625  {
626  int x,y,s;
627  ifile >> x >> y >> s;
628  struct_Rabbit sR;
629  sR.m_NPM = this;
630  sR.m_L = m_TheLandscape;
631  sR.m_x = x;
632  sR.m_y = y;
633  sR.m_soil = s;
634  CreateObjects(rob_Warren,NULL,&sR,1);
635  }
636  ifile.close();
637 }
638 
639 
641 {
646  int sz = (int) TheArray[rob_Warren].size();
647  for (int i=0; i< sz; i++)
648  {
649  int closest = -1;
650  int dist = SimH;
651  int mDist = SimH;
652  int ourX = TheArray[rob_Warren][i]->Supply_m_Location_x();
653  int ourY = TheArray[rob_Warren][i]->Supply_m_Location_y();
654  for (int j=0; j< sz; j++)
655  {
656  if (i!=j) // Don't add ourselves
657  {
658  int theirX = TheArray[rob_Warren][j]->Supply_m_Location_x();
659  int theirY = TheArray[rob_Warren][j]->Supply_m_Location_y();
660  dist = (int) sqrt( (double)(((theirX-ourX)*(theirX-ourX)) + ((theirY-ourY)*(theirY - ourY))) );
661  if (dist < cfg_maxWarrenNetworkDist.value())
662  {
663  // Add to the network for this warren
665  LWNE.m_aWarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][j]);
666  LWNE.m_dist = dist;
667  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->AddNetworkConnection( LWNE );
668  }
669  if (dist < mDist)
670  {
671  mDist = dist;
672  closest = j;
673  }
674  }
675  }
676  if (dist > cfg_maxWarrenNetworkDist.value())
677  {
678  // Add the closest warren since there are no others
680  LWNE.m_aWarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][closest]);
681  LWNE.m_dist = dist;
682  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->AddNetworkConnection( LWNE );
683  }
684  }
685  for (int i=0; i< sz; i++)
686  {
687  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->NetworkEvaluation();
688  }
689 }
690 
691 
693 {
703  int results[10];
704  int dist;
705  TAnimal* ptrs[10];
706  for (int r = 0; r < 10; r++) {
707  results[ r ] = SimH*SimW;
708  ptrs[ r ] = NULL;
709  }
710  int sz = (int) TheArray[rob_Warren].size();
711  for (int i=0; i< sz; i++)
712  {
713  int X = TheArray[rob_Warren][i]->Supply_m_Location_x();
714  int Y = TheArray[rob_Warren][i]->Supply_m_Location_y();
715  dist = (int)sqrt( ((double( X - a_x )*double( X - a_x )) + (double( Y - a_y )*double( Y - a_y ))) );
716  for (int r=0; r<10; r++)
717  {
718  if (dist<=results[r])
719  {
720  for (int t=r+1; t<10; t++)
721  {
722  results[t]=results[t-1];
723  ptrs[t]=ptrs[t-1];
724  }
725  results[r]=dist;
726  ptrs[r]=TheArray[rob_Warren][i];
727  break;
728  }
729  }
730  }
731  Rabbit_Warren* rw = dynamic_cast<Rabbit_Warren*>(ptrs[ a_rank ]);
732  return rw;
733 }
734 
736 {
737  /*
738  * 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.
739  * When the temperature in the future drops down again then the breeding season stops
740  */
741  if (--m_reproswitchbuffer > 0) return;
742 
744  {
746  {
747  m_reproswitchbuffer = 120;
748  m_rabbitBreedingSeason = true;
749 #ifdef __RABBITBREEDINGSEASONCHECK
750  cout << g_date->GetYearNumber() << " " << g_date->DayInYear() << " " << m_TheLandscape->SupplyTempPeriod( g_date->Date()+60, 60 ) << " - " << "Started" << endl;
751 #endif
752  }
753  }
754  else
755  {
757  {
758  m_reproswitchbuffer = 90;
759  m_rabbitBreedingSeason = false;
760 #ifdef __RABBITBREEDINGSEASONCHECK
761  cout << g_date->GetYearNumber() << " " << g_date->DayInYear() << " " << m_TheLandscape->SupplyTempPeriod( g_date->Date()+30, 90 ) << " - " << "Stopped" << endl;
762 #endif
763  }
764  }
765 }
766 //---------------------------------------------------------------------------
767 
769 {
770  m_PesticideDeaths[a_ob]++;
771 }
772 //---------------------------------------------------------------------------
773 
779  ofstream warrenrecord( "WarrenOccupancyRecord.txt", ios::app );
780  double occupancy = 0;
781  double var_occupancy = 0;
782  double sumsqr = 0.0;
783  double totalrabbits = 0;
784  double burrows = 0;
785  double disease = 0;
786  int warrensoccupied = 0;
787  int kits = 0;
788  int juvs = 0;
789  int ads = 0;
790  int breedingfemales = 0;
791  double breedingfemalesAv = 0;
792  int oneyroldfemales = 0;
793  int nonbreedingfemales = 0;
794  int litters = 0;
795  double lrc = 0;
796  double n = (double)TheArray[ rob_Warren ].size();
797  for (unsigned i = 0; i < TheArray[ rob_Warren ].size(); i++) {
798  Rabbit_Warren* warren = dynamic_cast<Rabbit_Warren*>(TheArray[ rob_Warren ][ i ]);
799  double occ = warren->GetCarryingCapacityRatio();
800  occupancy += occ;
801  sumsqr += occ * occ;
802  totalrabbits += warren->GetPopulationSize();
803  if (warren->GetPopulationSize()>0) warrensoccupied++;
804  burrows += warren->GetCarryingCapacity();
805  disease += warren->GetDiseaseConstant();
806  kits += warren->GetRabbitProductionRecord( rob_Young );
807  juvs += warren->GetRabbitProductionRecord( rob_Juvenile );
808  ads += warren->GetRabbitProductionRecord( rob_Male );
809  ads += warren->GetRabbitProductionRecord( rob_Female );
810  warren->UpdateThisYearsBreeders();
811  breedingfemales += warren->GetThisYearsBreeders();
812  breedingfemalesAv += warren->GetThisYearsBreedersAv();
813  oneyroldfemales += warren->GetThisYears1yrOldFemales();
814  nonbreedingfemales += warren->GetThisYearsNonBreeders();
815  litters += warren->GetLittersThisYear();
816  lrc += warren->GetLitterReabsortionConst();
818  }
819  double littersperfemale = 0;
820  double CV_occ = 0;
821  if ((occupancy > 0) && (ads > 0)) {
822  var_occupancy = (sumsqr - (occupancy*occupancy) / n) / (n - 1);
823  if (var_occupancy < 0) var_occupancy = 0.0; // Rounding errors cause this
824  occupancy /= n;
825  burrows /= n;
826  disease /= n;
827  totalrabbits /= n;
828  kits /= (int)n;
829  juvs /= (int)n;
830  ads /= (int)n;
831  CV_occ = sqrt( var_occupancy ) / occupancy;
832  if (breedingfemales > 0) littersperfemale = litters / double( breedingfemales );
833  }
834  else {
835  var_occupancy = 0;
836  occupancy = 0;
837  burrows = 0;
838  disease = 0;
839  totalrabbits = 0;
840  kits = 0;
841  juvs = 0;
842  ads = 0;
843  CV_occ = 0;
844  }
845  lrc /= n;
846  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;
847  for (int r = (int)rob_Young; r < rob_Warren; r++) warrenrecord << '\t' << TheArray[ r ].size();
848  warrenrecord << '\t' << breedingfemales << '\t' << breedingfemalesAv << '\t' << oneyroldfemales << '\t' << nonbreedingfemales << '\t' << littersperfemale << '\t' << lrc << '\t' << litters << endl;
849 }
850 //---------------------------------------------------------------------------
851 
853 {
858  for (int r = (int)rob_Young; r < (int)rob_foobar; r++)
859  {
861  }
862  m_PesticideDeathOFile << endl;
863 }
864 //---------------------------------------------------------------------------
865 
867 {
868  m_PesticideDeathOFile.open("RabbitPesticideDeathRecord.txt", ios::out);
869 }
870 //---------------------------------------------------------------------------
871 
873 {
874  m_WarrenOccupancyFile.open("WarrenOccupancyRecord.txt", ios::out);
875  m_WarrenOccupancyFile << "Year" << '\t' << "Day" << '\t' << "No. Warrens" << '\t' << "No.Occ.Warrens" << '\t' << "Mean Burrows" << '\t' << "Mean Rabbits" << '\t' << "Mean Disease"
876  << '\t' << "Mean Occupancy" << '\t' << "CV Occupancy" << '\t' << "Mean Kits" << '\t' << "Mean Juvs" << '\t' << "Mean Ads" << '\t' << "TotalYoung" << '\t' << "TotalJuvs"
877  << '\t' << "TotalMales" << '\t' << "TotalFemales" << '\t' << "BreedingFemales" << '\t' << "BreedingDensityAv" << '\t' << "1yr old females" << '\t' << "NonBreedingFems.>1yr"
878  << '\t' << "Littersperfemale" << '\t' << "lrc" << '\t' << "litters" << endl;
879 }
880 //---------------------------------------------------------------------------
881 
883 {
884  m_PesticideDeathOFile.close();
885 }
886 //---------------------------------------------------------------------------
887 
889 {
894  m_ReproOutputFile << '\t' << a_female->GetAge() << '\t' << a_female->GetTotalOffspring() << '\t' << a_female->GetTotalLitters() << endl;
895 }
896 //---------------------------------------------------------------------------
897 
899 {
900  m_ReproOutputFile.open( "RabbitLifetimeReproRecord.txt", ios::out );
901  m_ReproOutputFile << "Year" << '\t' << "Day" << '\t';
902  m_ReproOutputFile << '\t' << "Age" << '\t' << "Offpring" << '\t' << "Litters" << endl;
903 }
904 //---------------------------------------------------------------------------
905 
907 {
908  m_ReproOutputFile.close();
909 }
910 //---------------------------------------------------------------------------
911 
913 {
918  APoint pt = a_rabbit->GetBornLocation();
919  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;
920 }
921 //---------------------------------------------------------------------------
922 
924 {
925  m_NatalDispersalFile.open("RabbitNatalDispersalRecord.txt", ios::out);
926  m_NatalDispersalFile << "Year" << '\t' << "Day" << '\t';
927  m_NatalDispersalFile << "Born_X" << '\t' << "Born_Y" << '\t' << "New_X" << '\t' << "New_Y" << '\t' << "Rabbit_Type" << endl;
928 }
929 //---------------------------------------------------------------------------
930 
932 {
933  m_NatalDispersalFile.close();
934 }
935 //---------------------------------------------------------------------------
936 
938 {
939  m_WarrenOccupancyFile.close();
940 }
941 //---------------------------------------------------------------------------
942 
944  double Year, Day, NoWarrens, NoOccWarrens, MeanBurrows, MeanRabbits, MeanDisease, MeanOccupancy, CVOccupancy, MeanKits, MeanJuvs, MeanAds, TotalYoung, TotalJuvs, TotalMales,
945  TotalFemales, BreedingFemales, yroldfemales, NonBreedingFems;
946  vector<double> totalfemales;
947  vector<double> totalbrfemalesdensity;
948  vector<double> nonbreedingdensity;
949  vector<double> yrolddensity;
950  vector<double> breedingdensity;
951  vector<double> yearlingpct;
952  vector<double> kitsperfemale;
953 
954  double meantotalbrpop;
955  double maxbreedingpop = -1;
956  double minbreedingpop = 100000;
957  double maxyroldspct = -1;
958  double minyroldspct = 100000;
959  double correlation;
960  double correlation_b;
961  double littersperfemale;
962  double lrc;
963  double BreedingDensityAv;
964  double litters;
965 
966 
967  ifstream WarrenOccupancyFile( "WarrenOccupancyRecord.txt", ios::in );
968  // Read the header line
969  char st[ 2000 ];
970  WarrenOccupancyFile.getline( st, 2000 );
971  while (!WarrenOccupancyFile.eof()) {
972  WarrenOccupancyFile >> Year >> Day >> NoWarrens >> NoOccWarrens >> MeanBurrows >> MeanRabbits >> MeanDisease
973  >> MeanOccupancy >> CVOccupancy >> MeanKits >> MeanJuvs >> MeanAds >> TotalYoung >> TotalJuvs
974  >> TotalMales >> TotalFemales >> BreedingFemales >> BreedingDensityAv >> yroldfemales >> NonBreedingFems >> littersperfemale >> lrc >> litters;
975  // Here we create the actual data that we need
976  // We want:
977  // - correlation between total breeding pop and 1yr olds
978  // - mean of total breeding pop
979  // - mean of 1yr olds
980  // - range max-min of total breeding pop
981  // - range max-min of 1yr olds
982  if ((yroldfemales + BreedingFemales + NonBreedingFems) > 0) {
983  yearlingpct.push_back( yroldfemales / (yroldfemales + BreedingFemales + NonBreedingFems) );
984  totalbrfemalesdensity.push_back( (yroldfemales + BreedingFemales + NonBreedingFems) / 2.0 );
985  totalfemales.push_back( (BreedingFemales + NonBreedingFems) / 2.0 );
986  breedingdensity.push_back( BreedingFemales / 2.0 );
987  nonbreedingdensity.push_back( NonBreedingFems / 2.0 );
988  yrolddensity.push_back( yroldfemales / 2.0 );
989  kitsperfemale.push_back( littersperfemale );
990  }
991  else {
992  // All dead so save the results
993  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
994  ofile << 0
995  << '\t' << 0
996  << '\t' << 0
997  << '\t' << 0
998  << '\t' << 0
999  << '\t' << 0
1000  << '\t' << 0 << endl;
1001  ofile.close();
1002  return;
1003  }
1004  }
1005  WarrenOccupancyFile.close();
1006  // Now we have all the useful data we can create the stats for this analysis
1007  //
1008  // Get the ranges skipping the first 10 years
1009  int sz = static_cast<int>(yearlingpct.size());
1010  double sumx = 0;
1011  double sumx2 = 0;
1012  double sumy = 0;
1013  double sumy2 = 0;
1014  double sumxy = 0;
1015  double sumx_b = 0;
1016  double sumx2_b = 0;
1017  double sumy_b = 0;
1018  double sumy2_b = 0;
1019  double sumxy_b = 0;
1020  double n = sz - 1 - 10;
1021  // Do the correlation for yearlingpct and total female density
1022  for (int i = 10; i < sz - 1; i++) {
1023  if (totalbrfemalesdensity[ i ]>maxbreedingpop)maxbreedingpop = totalbrfemalesdensity[ i ];
1024  if (totalbrfemalesdensity[ i ] < minbreedingpop)minbreedingpop = totalbrfemalesdensity[ i ];
1025  if (yearlingpct[ i ] > maxyroldspct) maxyroldspct = yearlingpct[ i ];
1026  if (yearlingpct[ i ] < minyroldspct) minyroldspct = yearlingpct[ i ];
1027  sumx += totalbrfemalesdensity[ i ];
1028  sumx2 += totalbrfemalesdensity[ i ] * totalbrfemalesdensity[ i ];
1029  sumy += yearlingpct[ i ];
1030  sumy2 += yearlingpct[ i ] * yearlingpct[ i ];
1031  sumxy += totalbrfemalesdensity[ i ] * yearlingpct[ i ];
1032  }
1033  meantotalbrpop = sumx / n;
1034  double intermediate = (n*sumxy) - (sumx*sumy);
1035  correlation = intermediate / sqrt( ((n*sumx2) - (sumx*sumx))*((n*sumy2) - (sumy*sumy)) );
1036  //
1037  n = n - 1;
1038  for (int i = 10; i < sz - 2; i++) {
1039  // Here we need the numbers from the year before
1040  sumx_b += totalfemales[ i ];
1041  sumx2_b += totalfemales[ i ] * totalfemales[ i ];
1042  sumy_b += kitsperfemale[ i+1 ];
1043  sumy2_b += kitsperfemale[ i+1 ] * kitsperfemale[ i+1 ];
1044  sumxy_b += totalfemales[ i ] * kitsperfemale[ i+1 ];
1045  }
1046  intermediate = (n*sumxy_b) - (sumx_b*sumy_b);
1047  correlation_b = intermediate / sqrt( ((n*sumx2_b) - (sumx_b*sumx_b))*((n*sumy2_b) - (sumy_b*sumy_b)) );
1048  // Now save the results
1049  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1050  ofile << meantotalbrpop
1051  << '\t' << maxbreedingpop
1052  << '\t' << minbreedingpop
1053  << '\t' << maxyroldspct
1054  << '\t' << minyroldspct
1055  << '\t' << correlation
1056  << '\t' << correlation_b << endl;
1057  ofile.close();
1058 }
1059 //---------------------------------------------------------------------------
1060 
1062  /*
1063  % Success 0.66
1064  Average litters( of reproducers ) 4.39
1065  Av.Total Offspring 21.13
1066  Mean Repro Age 348.26
1067  Max Repro Age 2069.00
1068  */
1069  int Year, Day, Age, Offspring, Litter;
1070  double NoSuccessfulReproducers = 0;
1071  double NoOffspring = 0;
1072  double TotalAdults = 0;
1073  double ZeroLitters = 0;
1074  double TotalLitters = 0;
1075  double AvNoYoungLitter = 0;
1076  double AvLittersPerFemale = 0;
1077  double AvTotalOffspring = 0;
1078  double pctSuccess = 0;
1079  double MeanReproAge = 0;
1080  double SumReproAge = 0;
1081  double MaxReproAge = 0;
1082  double sumunderage = 0;
1083  double sumunderageoffspring = 0;
1084 
1085  ifstream ReproFile( "RabbitLifetimeReproRecord.txt", ios::in );
1086  // Read the header line
1087  char st[ 2000 ];
1088  ReproFile.getline( st, 2000 );
1089  ReproFile >> Year >> Day >> Age >> Offspring >> Litter;
1090  while (!ReproFile.eof()) {
1091  if (Year > 2000) {
1092  if (Age >= 304) {
1093  TotalAdults++;
1094  SumReproAge += Age - 304;
1095  if (Litter > 0) {
1096  TotalLitters += Litter;
1097  NoSuccessfulReproducers++;
1098  if (MaxReproAge < Age - 304) MaxReproAge = Age - 304;
1099  }
1100  else ZeroLitters++;
1101  NoOffspring += Offspring;
1102  }
1103  else if (Litter > 0) {
1104  sumunderage++;
1105  sumunderageoffspring += Offspring;
1106  }
1107  }
1108  ReproFile >> Year >> Day >> Age >> Offspring >> Litter;
1109  }
1110  if (TotalLitters > 0) AvNoYoungLitter = NoOffspring / TotalLitters;
1111  if (TotalAdults > 0) {
1112  MeanReproAge = SumReproAge / TotalAdults;
1113  pctSuccess = NoSuccessfulReproducers / TotalAdults;
1114  AvLittersPerFemale = TotalLitters / NoSuccessfulReproducers;
1115  }
1116  AvTotalOffspring = AvLittersPerFemale * AvNoYoungLitter;
1117  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1118  ofile << NoSuccessfulReproducers
1119  << '\t' << TotalLitters
1120  << '\t' << NoOffspring
1121  << '\t' << pctSuccess
1122  << '\t' << AvTotalOffspring
1123  << '\t' << AvNoYoungLitter
1124  << '\t' << AvLittersPerFemale
1125  << '\t' << MeanReproAge
1126  << '\t' << MaxReproAge
1127  << '\t' << sumunderage
1128  << '\t' << sumunderageoffspring << '\t';
1129  ofile.close();
1130 }
1131 //---------------------------------------------------------------------------
1132 
1134  int year, day, bornx, borny, newx, newy, sex;
1135  int sedmales = 0;
1136  int sedfemales = 0;
1137  int dispmales = 0;
1138  int dispfemales = 0;
1139  double malenataldisp = 0;
1140  double femalenataldisp = 0;
1141  ifstream DispFile( "RabbitNatalDispersalRecord.txt", ios::in );
1142  // Read the header line
1143  char st[ 2000 ];
1144  DispFile.getline( st, 2000 );
1145  DispFile >> year >> day >> bornx >> borny >> newx >> newy >> sex;
1146  while (!DispFile.eof()) {
1147  if (year > 2000) {
1148  if ((bornx != newx) || (borny != newy)) {
1149  if (sex == 2) dispmales++; else dispfemales++;
1150  }
1151  else if (sex == 2) sedmales++; else sedfemales++;
1152  }
1153  DispFile >> year >> day >> bornx >> borny >> newx >> newy >> sex;
1154  }
1155  if ((dispmales + sedmales)>0) malenataldisp = dispmales / double( dispmales + sedmales );
1156  if ((dispfemales + sedfemales)>0) femalenataldisp = dispfemales / double( dispfemales + sedfemales );
1157  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1158  ofile << malenataldisp << '\t' << femalenataldisp << '\t';
1159  ofile.close();
1160 }
1161 //---------------------------------------------------------------------------
1162 
1164  m_AOR_Probe->DoProbe(rob_Female);
1165 }
1166 //-----------------------------------------------------------------------------
1167 
1168 // ***************************************************************************
1169 // ************* END RABBIT POPULATION MANAGER CODE **************************
1170 // ***************************************************************************
Rabbit_Juvenile
The rabbit juvenile class. All special juvenile behaviour is described here.
Definition: Rabbit.h:347
Rabbit_Population_Manager::LoadWarrenLocations
void LoadWarrenLocations(void)
Load warren locations.
Definition: Rabbit_Population_Manager.cpp:610
RabbitObjectTypes
RabbitObjectTypes
Definition: Rabbit.h:68
tole_HedgeBank
Definition: tole_declaration.h:68
tole_UrbanNoVeg
Definition: tole_declaration.h:78
tole_Saltwater
Definition: tole_declaration.h:66
tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
CfgStr::value
const char * value(void)
Definition: configurator.h:152
cfg_RipleysOutput_used
CfgBool cfg_RipleysOutput_used
tole_Building
Definition: tole_declaration.h:62
Landscape::SupplyTemp
double SupplyTemp(void)
Definition: landscape.h:1386
Rabbit_Warren::UpdateThisYearsBreeders
void UpdateThisYearsBreeders()
Calculates and stores the number of breeders and non-breeders.
Definition: Rabbit.cpp:1821
Rabbit_Population_Manager::PesticideDeathRecordOutputClose
void PesticideDeathRecordOutputClose()
Closes the pesticide death output file.
Definition: Rabbit_Population_Manager.cpp:882
cfg_rabbitmaxkits
CfgFloat cfg_rabbitmaxkits
The maximum number of kits in a litter.
struct_Rabbit::m_y
int m_y
y-coord
Definition: Rabbit_Population_Manager.h:64
tole_Freshwater
Definition: tole_declaration.h:64
cfg_rabbit_use_fixed_soiltype
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?
Landscape::SupplyElementType
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
tole_Parkland
Definition: tole_declaration.h:77
tole_StoneWall
Definition: tole_declaration.h:56
tole_RiversidePlants
Definition: tole_declaration.h:49
tole_FishFarm
Definition: tole_declaration.h:102
Rabbit_Warren::GetThisYearsNonBreeders
int GetThisYearsNonBreeders()
Returns the number of females not breeding this year but older than 1 year.
Definition: Rabbit.h:674
Rabbit_Population_Manager::PesticideDeathRecord
void PesticideDeathRecord(RabbitObjectTypes ob_type)
Records pesticide poisoning incidents.
Definition: Rabbit_Population_Manager.cpp:768
Population_Manager::TheArray
vector< TListOfAnimals > TheArray
Definition: populationmanager.h:534
LocalWarrenNewtorkEntry::m_dist
int m_dist
Definition: Rabbit.h:143
tole_Garden
Definition: tole_declaration.h:58
Rabbit_Population_Manager::DoLast
virtual void DoLast()
Things to do after the EndStep.
Definition: Rabbit_Population_Manager.cpp:360
tole_Churchyard
Definition: tole_declaration.h:86
cfg_rabbit_pesticidedegradationrate
CfgFloat cfg_rabbit_pesticidedegradationrate
Holds 1-proportion of decay of body burden of pesticide per day. Default of 0.0 will remove all body ...
Rabbit_Population_Manager::FindClosestWarren
Rabbit_Warren * FindClosestWarren(int a_x, int a_y, int a_rank)
Finds the closest warren as the crow flies.
Definition: Rabbit_Population_Manager.cpp:692
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: calendar.h:68
tole_RoadsideSlope
Definition: tole_declaration.h:83
Rabbit_Population_Manager::~Rabbit_Population_Manager
virtual ~Rabbit_Population_Manager(void)
Rabbit_Population_Manager Destructor.
Definition: Rabbit_Population_Manager.cpp:225
tole_MixedForest
Definition: tole_declaration.h:53
cfg_rabbitminbreedingtemp
static CfgFloat cfg_rabbitminbreedingtemp("RABBIT_MINBREEDINGTEMP", CFG_CUSTOM, 300.0)
Input variable. The minimum 60 day average temperature for rabbit breeding.
Rabbit_Base::GetBornLocation
APoint GetBornLocation()
Get location of birth.
Definition: Rabbit.h:258
Rabbit_Population_Manager::m_forageday
bool m_forageday
Flag to record whether today is a possible forage day.
Definition: Rabbit_Population_Manager.h:149
Rabbit_Female
The rabbit female class. All special female behaviour is described here.
Definition: Rabbit.h:443
cfg_maxWarrenNetworkDist
static CfgInt cfg_maxWarrenNetworkDist("RABBIT_MAXWARRENNETWORKDIST", CFG_CUSTOM, 1500)
Input variable. The maximum distance between directly connected warrens.
cfg_AOROutput_used
CfgBool cfg_AOROutput_used
tole_Copse
Definition: tole_declaration.h:82
cfg_rabbitminkits
CfgFloat cfg_rabbitminkits
The minimum number of kits in a litter.
CfgStr
String configurator entry class.
Definition: configurator.h:144
tole_UnknownGrass
Definition: tole_declaration.h:91
Rabbit_Warren::GetSoilType
int GetSoilType(void)
Gets the warren soil type.
Definition: Rabbit.h:632
cfg_rabbitminimumforagetemp
static CfgFloat cfg_rabbitminimumforagetemp("RABBIT_MINFORAGETEMP", CFG_CUSTOM, -0.83)
Input variable. The minimum forage temperature for rabbits.
tole_BareRock
Definition: tole_declaration.h:75
tole_Saltmarsh
Definition: tole_declaration.h:88
Rabbit_Population_Manager::TheAOROutputProbe
void TheAOROutputProbe()
Definition: Rabbit_Population_Manager.cpp:1163
Rabbit_Population_Manager::ReproOutputRecordOutputOpen
void ReproOutputRecordOutputOpen()
Opens the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:898
tole_Railway
Definition: tole_declaration.h:39
Rabbit_Population_Manager::PreProcessWarrenLocations
void PreProcessWarrenLocations()
This pre-scans the landscape and determines all potential warren locations on start-up.
Definition: Rabbit_Population_Manager.cpp:378
Rabbit_Warren::GetRabbitProductionRecord
int GetRabbitProductionRecord(RabbitObjectTypes YoungType)
Get data about production of rabbits throughout year.
Definition: Rabbit.h:584
g_land_width
int g_land_width
Definition: Rabbit_Population_Manager.cpp:114
Rabbit_Population_Manager::WarrenOccupancyRecordOutput
void WarrenOccupancyRecordOutput()
Print warren occupancy record to file.
Definition: Rabbit_Population_Manager.cpp:774
Rabbit_Population_Manager::CheckForRabbitBreedingConditions
void CheckForRabbitBreedingConditions(void)
Determines whether it is breeding season.
Definition: Rabbit_Population_Manager.cpp:735
Population_Manager::OpenTheRipleysOutputProbe
bool OpenTheRipleysOutputProbe(string a_NWordFilename)
Definition: PopulationManager.cpp:757
Landscape::SupplySoilTypeR
int SupplySoilTypeR(int a_x, int a_y)
Returns the soil type in rabbit warren reference numbers.
Definition: landscape.h:464
tole_RoadsideVerge
Definition: tole_declaration.h:38
tole_Pylon
Definition: tole_declaration.h:96
Rabbit_Population_Manager::m_NatalDispersalFile
ofstream m_NatalDispersalFile
For recording the natal dispersal of adults from birth to death.
Definition: Rabbit_Population_Manager.h:143
cfg_RabbitUseReproOutput
CfgBool cfg_RabbitUseReproOutput("RABBIT_USEREPROOUTPUT", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
tole_WoodlandMargin
Definition: tole_declaration.h:98
Population_Manager::m_SimulationName
char m_SimulationName[255]
Definition: populationmanager.h:513
Rabbit_Population_Manager::m_warrenfixedsizediv2
int m_warrenfixedsizediv2
Half max warren size in m - for speed
Definition: Rabbit_Population_Manager.h:131
rob_Male
Definition: Rabbit.h:72
tole_WindTurbine
Definition: tole_declaration.h:97
tole_ActivePit
Definition: tole_declaration.h:63
Rabbit_Warren::GetThisYears1yrOldFemales
int GetThisYears1yrOldFemales()
Returns the number of 1yr old females.
Definition: Rabbit.h:666
Rabbit_Population_Manager::CreateLocalWarrenNetworkLists
void CreateLocalWarrenNetworkLists(void)
Forms the local warren network list for this warren.
Definition: Rabbit_Population_Manager.cpp:640
TAnimal::Supply_m_Location_x
int Supply_m_Location_x()
Definition: populationmanager.h:213
LocalWarrenNewtorkEntry::m_aWarren
Rabbit_Warren * m_aWarren
Definition: Rabbit.h:142
struct_Rabbit
Used for creation of a new Rabbit object.
Definition: Rabbit_Population_Manager.h:58
Rabbit_Population_Manager::NatalDispersalRecordOutput
void NatalDispersalRecordOutput(Rabbit_Base *a_rabbit)
Records the natal dispersal.
Definition: Rabbit_Population_Manager.cpp:912
Rabbit_Population_Manager::m_rabbitBreedingSeason
bool m_rabbitBreedingSeason
The breeding season flag.
Definition: Rabbit_Population_Manager.h:133
cfg_minForageDigestability
CfgFloat cfg_minForageDigestability
Input variable. Input variable. The minimum digestability desirable for forage vegetation.
Rabbit_Population_Manager::WarrenOccupancyRecordOutputOpen
void WarrenOccupancyRecordOutputOpen()
Opens the warren occupancy output file.
Definition: Rabbit_Population_Manager.cpp:872
tole_MownGrass
Definition: tole_declaration.h:74
Rabbit_Population_Manager::m_ReproOutputFile
ofstream m_ReproOutputFile
For recording the lifetime reproductive success.
Definition: Rabbit_Population_Manager.h:145
tole_YoungForest
Definition: tole_declaration.h:55
Population_Manager::SimW
int SimW
Definition: populationmanager.h:511
tole_Stream
Definition: tole_declaration.h:89
Rabbit_Warren::m_maxForageHeight
static double m_maxForageHeight
The maximum vegetation height assumed for forage potential.
Definition: Rabbit.h:541
cfg_warrenoccupancyrecordday
static CfgInt cfg_warrenoccupancyrecordday("RABBIT_WARRENOCCUPANCYRECORDDAY", CFG_CUSTOM, 60)
Output control - the day in year for recording warren and population data.
tole_ConiferousForest
Definition: tole_declaration.h:54
g_msg
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:41
cfg_maxForageHeight
CfgFloat cfg_maxForageHeight
Input variable. The maximum height desirable for forage vegetation.
cfg_RabbitUseNatalDispersalRecordAge
CfgInt cfg_RabbitUseNatalDispersalRecordAge("RABBIT_USENATALDISPERSALRECORDAGE", CFG_CUSTOM, 30 *6)
Flag to denote using lifetime repro output file or not.
Rabbit_Base::m_pesticidedegradationrate
static double m_pesticidedegradationrate
State variable used to hold the daily degredation rate of the pesticide in the body.
Definition: Rabbit.h:174
cfg_rabbitmaxforagerainfall
static CfgFloat cfg_rabbitmaxforagerainfall("RABBIT_MAXFORAGERAINFALL", CFG_CUSTOM, 3.6)
Input variable. The maximum rainfall before rabbits are assumed not to forage.
tole_LargeRoad
Definition: tole_declaration.h:61
Rabbit_Warren::GetCarryingCapacity
int GetCarryingCapacity()
Returns the carrying capacity in burrows.
Definition: Rabbit.h:578
struct_Rabbit::m_age
int m_age
The rabbit age.
Definition: Rabbit_Population_Manager.h:74
Population_Manager::m_AOR_Probe
AOR_Probe * m_AOR_Probe
Definition: populationmanager.h:526
Landscape
The landscape class containing all environmental and topographical data.
Definition: landscape.h:112
Rabbit_Warren::GetThisYearsBreedersAv
double GetThisYearsBreedersAv()
Returns the number of females breeding this year.
Definition: Rabbit.h:658
Rabbit_Population_Manager::ClassifyHabitat
TTypesOfRabbitHabitat ClassifyHabitat(TTypesOfLandscapeElement a_tole)
Classify a landscape element type according to the rabbit habitat classification.
Definition: Rabbit_Population_Manager.cpp:457
struct_Rabbit::m_NPM
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
Definition: Rabbit_Population_Manager.h:72
rob_Young
Definition: Rabbit.h:70
Rabbit_Population_Manager::NatalDispersalRecordOutputClose
void NatalDispersalRecordOutputClose()
Closes the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:931
Rabbit_Base::m_dispersalmortperm
static double m_dispersalmortperm
The extra dispersal mortality per m travelled.
Definition: Rabbit.h:172
Rabbit_Population_Manager::m_RabbitGrowth
double m_RabbitGrowth[3650]
Holds daily growth potential of rabbits for each day
Definition: Rabbit_Population_Manager.h:137
tole_Marsh
Definition: tole_declaration.h:41
TTypesOfRabbitHabitat
TTypesOfRabbitHabitat
A classification of rabbit habitat types. All landscape elements will be classified into one of the c...
Definition: Rabbit.h:101
rob_foobar
Definition: Rabbit.h:75
Rabbit_Population_Manager::CreateObjects
void CreateObjects(RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
Method for creating a new individual Rabbit.
Definition: Rabbit_Population_Manager.cpp:250
tole_OrchardBand
Definition: tole_declaration.h:73
Rabbit_Female::GetTotalLitters
int GetTotalLitters()
Definition: Rabbit.h:465
tole_Pond
Definition: tole_declaration.h:101
Rabbit_Population_Manager::WarrenOutputAnalysis
void WarrenOutputAnalysis()
Does analysis on the warren output file and saves the results to RabbitPOMSummary....
Definition: Rabbit_Population_Manager.cpp:943
Calendar::Date
long Date(void)
Definition: calendar.h:57
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
Rabbit_Population_Manager::SaveWarrenLocations
void SaveWarrenLocations(void)
Save warren locations.
Definition: Rabbit_Population_Manager.cpp:588
CfgBool
Bool configurator entry class.
Definition: configurator.h:127
tole_PermPasture
Definition: tole_declaration.h:47
struct_Rabbit::m_L
Landscape * m_L
Landscape pointer.
Definition: Rabbit_Population_Manager.h:70
struct_Rabbit::m_x2
int m_x2
x-coord of birth
Definition: Rabbit_Population_Manager.h:66
Rabbit_Population_Manager::WarrenLegalPos
bool WarrenLegalPos(int &a_x, int a_y)
Tests the warrens list to see if this position is legal.
Definition: Rabbit_Population_Manager.cpp:431
Rabbit_Female::GetTotalOffspring
int GetTotalOffspring()
Definition: Rabbit.h:464
TAnimal
The base class for all ALMaSS animal classes.
Definition: populationmanager.h:205
cfg_rabbitdiseasedensitydependencedelay
CfgInt cfg_rabbitdiseasedensitydependencedelay("RABBITDISEASEDENDEPPERIOD", CFG_CUSTOM, 90)
Input variable. The period between recalculation of rabbit disease probability.
cfg_dispersalmortperm
CfgFloat cfg_dispersalmortperm
Input variable. The additional mortality rate with distance for between warren dispersal.
tole_PermanentSetaside
Definition: tole_declaration.h:46
rob_Warren
Definition: Rabbit.h:74
Rabbit_Warren::GetDiseaseConstant
double GetDiseaseConstant(void)
Returns the warrens current disease constant.
Definition: Rabbit.h:580
tole_UrbanPark
Definition: tole_declaration.h:79
struct_Rabbit::m_Warren
Rabbit_Warren * m_Warren
A pointer to the current warren.
Definition: Rabbit_Population_Manager.h:80
Rabbit_Population_Manager::m_warrenfixedsize
int m_warrenfixedsize
Holds an input variable for max warren size in m
Definition: Rabbit_Population_Manager.h:129
tole_Track
Definition: tole_declaration.h:59
Rabbit_Warren::m_minForageDigestability
static double m_minForageDigestability
The minimum vegetation digestability allowed for foraging.
Definition: Rabbit.h:543
cfg_warrenlocationsfile
static CfgStr cfg_warrenlocationsfile("RABBIT_WARRENLOCATIONSFILE", CFG_CUSTOM, "RabbitWarrenLocations.txt")
Input variable. The warren locations file.
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
Population_Manager
Base class for all population managers.
Definition: populationmanager.h:424
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Definition: landscape.h:1596
cfg_rabbitdailygrowthparam3
static CfgFloat cfg_rabbitdailygrowthparam3("RABBIT_DAILYGROWTHPARAM_THREE", CFG_CUSTOM, 0.0)
Input variable. Parameter three of the rabbit growth curve.
cfg_rabbit_fix_soiltype
static CfgInt cfg_rabbit_fix_soiltype("RABBIT_FIX_SOIL_TYPE", CFG_CUSTOM, 0)
Input variable. The soil type applied to all warrens.
Rabbit_Warren::GetCarryingCapacityRatio
double GetCarryingCapacityRatio()
Checks whether all possible burrows are filled with rabbits. This is updated daily by Rabbit_Warren::...
Definition: Rabbit.h:576
Rabbit_Female::SetMinKits
void SetMinKits(double a_num)
Definition: Rabbit.h:462
Rabbit_Population_Manager::DoFirst
virtual void DoFirst()
Things to do before anything else at the start of a timestep
Definition: Rabbit_Population_Manager.cpp:312
Rabbit_Population_Manager::Rabbit_Population_Manager
Rabbit_Population_Manager(Landscape *L)
Rabbit_Population_Manager Constructor.
Definition: Rabbit_Population_Manager.cpp:120
struct_Rabbit::m_weightage
int m_weightage
The rabbit age in terms of weight.
Definition: Rabbit_Population_Manager.h:76
Landscape::SupplyYearNumber
int SupplyYearNumber(void)
Definition: landscape.h:1616
tole_NaturalGrassWet
Definition: tole_declaration.h:87
Rabbit_Population_Manager::NatalDispersalRecordOutputOpen
void NatalDispersalRecordOutputOpen()
Opens the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:923
Rabbit_Warren::GetPopulationSize
int GetPopulationSize()
Gets the total warren population of rabbits.
Definition: Rabbit.h:572
tole_Orchard
Definition: tole_declaration.h:71
tole_MetalledPath
Definition: tole_declaration.h:84
Rabbit_Population_Manager::PesticideDeathRecordOutput
void PesticideDeathRecordOutput()
Print pesticide death record to file.
Definition: Rabbit_Population_Manager.cpp:852
cfg_rabbitdailygrowthparam1
static CfgFloat cfg_rabbitdailygrowthparam1("RABBIT_DAILYGROWTHPARAM_ONE", CFG_CUSTOM, 1127.616084)
Input variable. Parameter one of the rabbit growth curve.
tole_SandDune
Definition: tole_declaration.h:81
CfgFloat::value
double value(void)
Definition: configurator.h:118
tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
torh_Forage
Definition: Rabbit.h:103
Rabbit_Population_Manager::AssessPctForage
double AssessPctForage(int a_x, int a_y)
Assesses the percentage of forage for a location assuming max warren size.
Definition: Rabbit_Population_Manager.cpp:552
Rabbit_Warren::GetThisYearsBreeders
int GetThisYearsBreeders()
Returns the number of females breeding this year.
Definition: Rabbit.h:654
Rabbit_Base::GetRabbitType
RabbitObjectTypes GetRabbitType(void)
Get rabbit type.
Definition: Rabbit.h:218
tole_River
Definition: tole_declaration.h:65
Rabbit_Population_Manager::LifetimeReproAnalysis
void LifetimeReproAnalysis()
Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary....
Definition: Rabbit_Population_Manager.cpp:1061
struct_Rabbit::m_soil
int m_soil
The current warren soil type.
Definition: Rabbit_Population_Manager.h:82
tole_Scrub
Definition: tole_declaration.h:42
CFG_CUSTOM
Definition: configurator.h:60
tole_PermPastureTussocky
Definition: tole_declaration.h:45
Landscape::SupplyRain
double SupplyRain(void)
Definition: landscape.h:1365
Population_Manager::m_TheLandscape
Landscape * m_TheLandscape
Definition: populationmanager.h:515
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
tole_Field
Definition: tole_declaration.h:43
tole_PermPastureTussockyWet
Definition: tole_declaration.h:100
tole_FieldBoundary
Definition: tole_declaration.h:40
Rabbit_Population_Manager::ReproOutputRecordOutput
void ReproOutputRecordOutput(Rabbit_Female *a_female)
Print reproductive record to file.
Definition: Rabbit_Population_Manager.cpp:888
tole_PermPastureLowYield
Definition: tole_declaration.h:44
Rabbit_Warren::GetLitterReabsortionConst
double GetLitterReabsortionConst(void)
Returns litter reabsorption chance.
Definition: Rabbit.h:650
Population_Manager::SimH
int SimH
Definition: populationmanager.h:511
torh_Other
Definition: Rabbit.h:106
CfgInt
Integer configurator entry class.
Definition: configurator.h:87
tole_RiversideTrees
Definition: tole_declaration.h:51
Population_Manager::m_ListNameLength
unsigned m_ListNameLength
Definition: populationmanager.h:538
Rabbit_Population_Manager::m_PesticideDeathOFile
ofstream m_PesticideDeathOFile
The pesticide death output file.
Definition: Rabbit_Population_Manager.h:147
Rabbit_Female::SetMaxKits
void SetMaxKits(double a_num)
Definition: Rabbit.h:463
cfg_RabbitUseNatalDispersalRecord
CfgBool cfg_RabbitUseNatalDispersalRecord("RABBIT_USENATALDISPERSALRECORD", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
Rabbit_Population_Manager::m_PesticideDeaths
int m_PesticideDeaths[rob_foobar]
Holds the number of rabbits killed each day by pesticides.
Definition: Rabbit_Population_Manager.h:139
LocalWarrenNewtorkEntry
An entry in the local warren network - a helper list of accessibly local warren locations.
Definition: Rabbit.h:140
TTypesOfLandscapeElement
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
tole_IndividualTree
Definition: tole_declaration.h:93
rob_Female
Definition: Rabbit.h:73
TAnimal::Supply_m_Location_y
int Supply_m_Location_y()
Definition: populationmanager.h:216
Rabbit_Population_Manager::WarrenOccupancyRecordOutputClose
void WarrenOccupancyRecordOutputClose()
Closes the warren occupancy output file.
Definition: Rabbit_Population_Manager.cpp:937
CfgFloat
Double configurator entry class.
Definition: configurator.h:106
tole_PitDisused
Definition: tole_declaration.h:50
Rabbit_Warren
A class to describe the rabbits warren system.
Definition: Rabbit.h:518
tole_Wasteland
Definition: tole_declaration.h:92
Rabbit_Warren::ResetAllRabbitProductionRecord
void ResetAllRabbitProductionRecord(void)
Reset data about production of rabbits throughout year.
Definition: Rabbit.h:588
torh_TemporaryForage
Definition: Rabbit.h:104
tole_HeritageSite
Definition: tole_declaration.h:90
CfgInt::value
int value(void)
Definition: configurator.h:98
tole_PlantNursery
Definition: tole_declaration.h:95
cfg_warrenreadlocations
static CfgBool cfg_warrenreadlocations("RABBIT_WARRENREADLOCATIONS", CFG_CUSTOM, true)
Input variable. Should warren locations be calculated or read from a file?
cfg_rabbitdailygrowthparam2
static CfgFloat cfg_rabbitdailygrowthparam2("RABBIT_DAILYGROWTHPARAM_TWO", CFG_CUSTOM, -0.013143202)
Input variable. Parameter two of the rabbit growth curve.
Rabbit_Male
The rabbit male class. All special male behaviour is described here.
Definition: Rabbit.h:422
Rabbit_Population_Manager::PesticideDeathRecordOutputOpen
void PesticideDeathRecordOutputOpen()
Opens pesticide death output file.
Definition: Rabbit_Population_Manager.cpp:866
Rabbit_Population_Manager::NatalDispersalAnalysis
void NatalDispersalAnalysis()
Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary....
Definition: Rabbit_Population_Manager.cpp:1133
Calendar::DayInYear
int DayInYear(void)
Definition: calendar.h:58
rob_Juvenile
Definition: Rabbit.h:71
tole_Carpark
Definition: tole_declaration.h:85
Rabbit_Population_Manager::ReproOutputRecordOutputClose
void ReproOutputRecordOutputClose()
Closes the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:906
Landscape::SupplyYear
int SupplyYear(void)
Definition: landscape.h:1611
g_date
class Calendar * g_date
Definition: calendar.cpp:38
Landscape::SupplyTempPeriod
double SupplyTempPeriod(long a_date, int a_period)
Definition: landscape.h:1410
tole_DeciduousForest
Definition: tole_declaration.h:52
tole_Hedges
Definition: tole_declaration.h:37
cfg_rabbitdensitydependencedelay
CfgInt cfg_rabbitdensitydependencedelay("RABBIT_DENDEPPERIOD", CFG_CUSTOM, 53)
Input variable. The period between recalculation of rabbit disease probability.
tole_Vildtager
Definition: tole_declaration.h:99
Population_Manager::m_ListNames
const char * m_ListNames[32]
Definition: populationmanager.h:537
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
struct_Rabbit::m_y2
int m_y2
y-coord of birth
Definition: Rabbit_Population_Manager.h:68
CfgBool::value
bool value(void)
Definition: configurator.h:135
tole_AmenityGrass
Definition: tole_declaration.h:76
cfg_RabbitStartNos
static CfgInt cfg_RabbitStartNos("RABBIT_STARTNOS", CFG_CUSTOM, 25000)
The starting number of rabbits.
Rabbit_Warren::GetLittersThisYear
int GetLittersThisYear()
Returns the number litters produced in the last 12 months.
Definition: Rabbit.h:670
tole_NaturalGrassDry
Definition: tole_declaration.h:48
tole_BeetleBank
Definition: tole_declaration.h:69
Landscape::SupplyPolyRef
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
torh_Cover
Definition: Rabbit.h:105
Rabbit_Population_Manager::AssignStaticVariables
void AssignStaticVariables()
Assigns any static variables needing config variable assignment.
Definition: Rabbit_Population_Manager.cpp:203
cfg_warrenfixedsize
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...
tole_Coast
Definition: tole_declaration.h:67
tole_BuiltUpWithParkland
Definition: tole_declaration.h:80
tole_SmallRoad
Definition: tole_declaration.h:60
Rabbit_Base
Definition: Rabbit.h:166
Rabbit_Young
The rabbit young class. All special young behaviour is described here.
Definition: Rabbit.h:319
Rabbit_Base::GetAge
int GetAge(void)
Get age method.
Definition: Rabbit.h:222
tole_Fence
Definition: tole_declaration.h:57
struct_Rabbit::m_x
int m_x
x-coord
Definition: Rabbit_Population_Manager.h:62
Rabbit_Population_Manager::m_reproswitchbuffer
int m_reproswitchbuffer
Prevents continuous breeding season switching.
Definition: Rabbit_Population_Manager.h:135
Rabbit_Population_Manager::m_WarrenOccupancyFile
ofstream m_WarrenOccupancyFile
The warren occupancy output file.
Definition: Rabbit_Population_Manager.h:141
tole_Heath
Definition: tole_declaration.h:70