Goose Management Model ODdox  1.02
GoosePinkFooted_All.cpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2013, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
35 #include <iostream>
36 #include <fstream>
37 #include <list>
38 #include <vector>
39 #include <string>
40 #include "../BatchALMaSS/ALMaSS_Setup.h"
41 #include "../Landscape/ls.h"
42 #include "../BatchALMaSS/PopulationManager.h"
43 #include "GooseMemoryMap.h"
44 #include "Goose_Base.h"
45 #include "../BatchALMaSS/CurveClasses.h"
46 #include "../Hunters/Hunters_all.h"
48 #include "GoosePinkFooted_All.h"
49 #include "../BatchALMaSS/BoostRandomGenerators.h"
50 
52 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> > g_rand_uni;
54 extern MapErrorMsg *g_msg;
55 
56 using namespace std;
57 
64 
65 //*******************************************************************************************************
66 //**********************************Goose_Pinkfoot_Base**************************************************
67 //*******************************************************************************************************
68 
69 Goose_Pinkfoot_Base::Goose_Pinkfoot_Base(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) : Goose_Base(p_L, p_NPM, a_weight, a_sex, a_roost)
70 {
71  Init(p_NPM, a_weight, a_sex, a_roost);
72 }
73 
74 void Goose_Pinkfoot_Base::Init(Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
75  Goose_Base::Init(p_NPM, a_weight, a_sex, a_roost);
80  m_myspecies = gs_Pinkfoot;
81  double daylightprop = m_OurLandscape->SupplyDaylightProp();
82  double nighttimeprop = m_OurLandscape->SupplyNightProp();
83  double multiplier = cfg_goose_daytime_BMR_multiplier.value() * daylightprop + cfg_goose_nighttime_BMR_multiplier.value() * nighttimeprop;
86 }
87 
88 void Goose_Pinkfoot_Base::ReInit(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
89  Goose_Base::ReInit(p_L, p_NPM, a_weight, a_sex, a_roost);
90  Init(p_NPM, a_weight, a_sex, a_roost);
91 }
92 //-------------------------------------------------------------------------------------------------------
93 
95 {
96  ;
97 }
98 //-------------------------------------------------------------------------------------------------------
99 
101 {
105  if (m_myForageIndex != -1)
106  {
108  }
109  m_myForageIndex = -1;
115  {
116  ChangeRoost();
117  }
118  FlyTo(m_MyRoost.m_x, m_MyRoost.m_y);
119  return togs_Roost;
120 }
121 //--------------------------------------------------------------------------------------------------------
122 
124 {
129  APoint pt;
130  if (m_MyRoost.m_x == m_Location_x && m_MyRoost.m_y == m_Location_y)
131  {
132  pt.m_x = (int)((g_rand_uni() * m_GooseForageDistX2[gs_Pinkfoot]) - m_GooseForageDist[gs_Pinkfoot] + m_MyRoost.m_x);
133  pt.m_y = (int)((g_rand_uni() * m_GooseForageDistX2[gs_Pinkfoot]) - m_GooseForageDist[gs_Pinkfoot] + m_MyRoost.m_y);
134  }
135  else {
136  pt.m_x = (int)((g_rand_uni() * m_GooseFieldForageDistX2[gs_Pinkfoot]) - m_GooseFieldForageDist[gs_Pinkfoot] + m_Location_x);
137  pt.m_y = (int)((g_rand_uni() * m_GooseFieldForageDistX2[gs_Pinkfoot]) - m_GooseFieldForageDist[gs_Pinkfoot] + m_Location_y);
138  }
139 
140  m_OurLandscape->CorrectCoordsPointNoWrap(pt);
146  return pt;
147 }
148 //--------------------------------------------------------------------------------------------------------
149 
150 //*******************************************************************************************************
151 //********************************* Goose_Pinkfoot_FamilyGroup ******************************************
152 //*******************************************************************************************************
153 Goose_Pinkfoot_FamilyGroup::Goose_Pinkfoot_FamilyGroup(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost) : Goose_Pinkfoot_Base(p_L, p_NPM, a_weight, a_sex, a_roost)
154 {
155  Init(p_NPM, a_weight, a_sex, a_groupsize, a_roost);
156 }
157 //-------------------------------------------------------------------------------------------------------
158 
159 void Goose_Pinkfoot_FamilyGroup::Init(Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
160 {
161  Goose_Pinkfoot_Base::Init(p_NPM, a_weight, a_sex, a_roost);
165  m_groupsize = a_groupsize;
167 }
168 //-------------------------------------------------------------------------------------------------------
169 
170 void Goose_Pinkfoot_FamilyGroup::ReInit(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, int a_grpsize, APoint a_roost)
171 {
172  Goose_Pinkfoot_Base::ReInit(p_L, p_NPM, a_weight, a_sex, a_roost);
173  Init(p_NPM, a_weight, a_sex, a_grpsize, a_roost);
174 }
175 
176 //-------------------------------------------------------------------------------------------------------
177 
179 {
180  ;
181 }
182 //-------------------------------------------------------------------------------------------------------
183 
185 {
186  if (m_StepDone || m_CurrentStateNo == -1) return;
187  switch (CurrentGState)
188  {
189  case togs_InitialState: // Initial state always starts by setting the behaviour to togs_Roost
191  break;
194  m_StepDone = true;
195  break;
196  case togs_Forage:
198  m_StepDone = true;
199  break;
200  case togs_ToRoost:
202  m_StepDone = true;
203  break;
204  case togs_Roost:
206  m_StepDone = true;
207  break;
208  case togs_Emigrate:
210  break;
211  case togs_Die:
212  st_Dying(); // No return value - no behaviour after this
213  //m_StepDone = true; done in st_Dying
214  break;
215  default:
216  m_OurLandscape->Warn("Goose_Pinkfoot_FamilyGroup::Step()","unknown state - default");
217  exit(1);
218  }
219 }
220 //-------------------------------------------------------------------------------------------------------
221 
223 {
230  if (m_myForageIndex != -1)
231  {
233  }
234  if (--m_groupsize < 1)
235  {
236  delete m_MyMemory; // this is reinitisalised in the object pool.
237  TAnimal::KillThis();
238  }
239 }
240 //-------------------------------------------------------------------------------------------------------
241 //*******************************************************************************************************
242 
243 //*******************************************************************************************************
244 //**********************************Goose_Pinkfoot_NonBreeder**************************************************
245 //*******************************************************************************************************
246 
247 Goose_Pinkfoot_NonBreeder::Goose_Pinkfoot_NonBreeder(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) : Goose_Pinkfoot_Base(p_L, p_NPM, a_weight, a_sex, a_roost)
248 {
249  Init(p_NPM, a_weight, a_sex, a_roost);
250 }
251 //-------------------------------------------------------------------------------------------------------
252 
253 void Goose_Pinkfoot_NonBreeder::Init(Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
254  Goose_Pinkfoot_Base::Init(p_NPM, a_weight, a_sex, a_roost);
258  m_groupsize = 1;
260 }
261 //-------------------------------------------------------------------------------------------------------
262 
263 void Goose_Pinkfoot_NonBreeder::ReInit(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
264  Goose_Pinkfoot_Base::ReInit(p_L, p_NPM, a_weight, a_sex, a_roost);
265  Init(p_NPM, a_weight, a_sex, a_roost);
266 }
267 //-------------------------------------------------------------------------------------------------------
268 
270 {
271  ;
272 }
273 //-------------------------------------------------------------------------------------------------------
274 
276 {
277  if (m_StepDone || m_CurrentStateNo == -1) return;
278  switch (CurrentGState)
279  {
280  case togs_InitialState: // Initial state always starts by setting the behaviour to togs_Roost
282  break;
285  m_StepDone = true;
286  break;
287  case togs_Forage:
289  m_StepDone = true;
290  break;
291  case togs_ToRoost:
293  m_StepDone = true;
294  break;
295  case togs_Roost:
297  m_StepDone = true;
298  break;
299  case togs_Emigrate:
301  break;
302  case togs_Die:
303  st_Dying(); // No return value - no behaviour after this
304  m_StepDone = true;
305  break;
306  default:
307  m_OurLandscape->Warn("Goose_Pinkfoot_FamilyGroup::Step()","unknown state - default");
308  exit(1);
309  }
310 }
311 //-------------------------------------------------------------------------------------------------------
312 //*******************************************************************************************************
313 
314 
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
A random number generator (0-1)
GoosePinkFooted_All.h
PinkFootedGoose_All.h This is the header file for the pink footed goose classes
Goose_Pinkfoot_Base::ReInit
void ReInit(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
ReInit for object pool.
Definition: GoosePinkFooted_All.cpp:88
togs_Roost
Definition: Goose_Base.h:80
Goose_Base::st_Roost
TTypeOfGoose_BaseState st_Roost()
Roosting until next forage or next morning.
Definition: Goose_Base.cpp:550
Goose_Pinkfoot_NonBreeder::Goose_Pinkfoot_NonBreeder
Goose_Pinkfoot_NonBreeder(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint roost)
Goose_Pinkfoot_NonBreeder constructor.
Definition: GoosePinkFooted_All.cpp:247
Goose_Base::m_myForageIndex
int m_myForageIndex
Temporary storage for a forage location index - this is a speed optimisation.
Definition: Goose_Base.h:291
Goose_Pinkfoot_Base::ChooseHopLoc
virtual APoint ChooseHopLoc()
Pick a hop location point within a_dist meters - must be overridden by descendent classes.
Definition: GoosePinkFooted_All.cpp:123
Goose_Base::m_DEB
double m_DEB
The daily energy budget excluding flying (kJ)
Definition: Goose_Base.h:191
Goose_Pinkfoot_Base::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Intitialise object.
Definition: GoosePinkFooted_All.cpp:74
Goose_Base::m_groupsize
int m_groupsize
The size of the group this bird represents.
Definition: Goose_Base.h:171
Goose_Pinkfoot_FamilyGroup::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
Intitialise object.
Definition: GoosePinkFooted_All.cpp:159
togs_Die
Definition: Goose_Base.h:81
Goose_Pinkfoot_Base::st_ToRoost
virtual TTypeOfGoose_BaseState st_ToRoost()
Return to roost and assess whether to forage again that day.
Definition: GoosePinkFooted_All.cpp:100
togs_ToRoost
Definition: Goose_Base.h:79
Goose_Pinkfoot_FamilyGroup::Step
virtual void Step(void)
The Goose_Pinkfoot_FamilyGroup Step.
Definition: GoosePinkFooted_All.cpp:184
Goose_Base::m_GooseFieldForageDist
static double m_GooseFieldForageDist[gs_foobar]
The maximum distance travelled from roost to forage sites for each species of goose (m)
Definition: Goose_Base.h:247
Goose_Base::st_ChooseForageLocation
TTypeOfGoose_BaseState st_ChooseForageLocation(void)
Selects a forage location based on past memory, or initiates an exploration.
Definition: Goose_Base.cpp:258
Goose_Base::ReInit
void ReInit(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
ReInit for object pool.
Definition: Goose_Base.cpp:168
togs_ChooseForageLocation
Definition: Goose_Base.h:77
Goose_Pinkfoot_Base::~Goose_Pinkfoot_Base
virtual ~Goose_Pinkfoot_Base()
Goose_Pinkfoot_Base destructor.
Definition: GoosePinkFooted_All.cpp:94
Goose_Base::m_GooseMaxAppetiteScaler
static double m_GooseMaxAppetiteScaler
Scaler to determine the max kJ possible to eat per day based on non-energy reserve weight.
Definition: Goose_Base.h:259
Goose_Base::m_GooseForageDistX2
static double m_GooseForageDistX2[gs_foobar]
Double the maximum distance travelled from roost to forage sites for each species of goose (m) - this...
Definition: Goose_Base.h:243
Landscape
The landscape class containing all environmental and topographical data.
Definition: landscape.h:112
g_msg
MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
Goose_Base::m_myspecies
GooseSpecies m_myspecies
Holds goose species.
Definition: Goose_Base.h:159
Goose_Pinkfoot_Base::ChangeRoost
virtual void ChangeRoost()
Find the closest roost.
Definition: GoosePinkFooted_All.h:65
MapErrorMsg
Definition: maperrormsg.h:43
Goose_Base::m_DailyMaxAppetite
double m_DailyMaxAppetite
The daily max kJ possible to get as intake.
Definition: Goose_Base.h:195
Goose_Base::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Intitialise object.
Definition: Goose_Base.cpp:111
Goose_Base::CurrentGState
TTypeOfGoose_BaseState CurrentGState
Variable to record current behavioural state.
Definition: Goose_Base.h:147
Goose_Base::st_Dying
void st_Dying(void)
Behavioural state dying.
Definition: Goose_Base.cpp:251
Goose_Population_Manager::GetThermalCosts
double GetThermalCosts(GooseSpecies a_goose)
Get daily thermal costs const.
Definition: Goose_Population_Manager.h:556
Goose_Base::m_GooseForageDist
static double m_GooseForageDist[gs_foobar]
The maximum distance travelled from roost to forage sites for each species of goose (m)
Definition: Goose_Base.h:239
gst_PinkfootNonBreeder
Definition: Goose_Base.h:61
Goose_Base::m_MyMemory
GooseMemoryMap * m_MyMemory
The Goose Memory.
Definition: Goose_Base.h:299
Goose_Population_Manager
The class to handle all goose population related matters.
Definition: Goose_Population_Manager.h:392
Goose_Base::On_Migrate
void On_Migrate(TTypeOfLeaveReason a_leavereason)
The goose is told to leave the simulation area (poss due to bad weather)
Definition: Goose_Base.cpp:722
tolr_migration
Definition: Goose_Base.h:104
GooseMemoryMap.h
Header file for the Goose Memory Map and associated classes.
togs_InitialState
Definition: Goose_Base.h:76
cfg_goose_roostchangechance
CfgFloat cfg_goose_roostchangechance
Chance of changing roost.
Goose_Pinkfoot_Base::Goose_Pinkfoot_Base
Goose_Pinkfoot_Base(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Goose_Pinkfoot_Base constructor.
Definition: GoosePinkFooted_All.cpp:69
CfgFloat::value
double value(void)
Definition: configurator.h:118
Goose_Pinkfoot_NonBreeder::Step
virtual void Step(void)
The Goose_Pinkfoot_NonBreeder Step.
Definition: GoosePinkFooted_All.cpp:275
Goose_Pinkfoot_NonBreeder::~Goose_Pinkfoot_NonBreeder
virtual ~Goose_Pinkfoot_NonBreeder()
Goose_Pinkfoot_NonBreeder destructor.
Definition: GoosePinkFooted_All.cpp:269
Goose_Base::FlyTo
void FlyTo(int a_x, int a_y)
The goose flys to the location specified by a_x, a_y.
Definition: Goose_Base.cpp:409
Goose_Base::m_BMR
double m_BMR
The daily BMR.
Definition: Goose_Base.h:187
Goose_Base::EvaluateForageToHopLoc
void EvaluateForageToHopLoc(APoint a_HopLoc)
Do a forage evaluation from current location to a_HopLoc.
Definition: Goose_Base.cpp:593
gst_PinkfootFamilyGroup
Definition: Goose_Base.h:60
Goose_Base.h
Goose_Base.h This is the header file for the goose base class
Goose_Base
A class to describe the goose base.
Definition: Goose_Base.h:131
Goose_Base::st_Forage
TTypeOfGoose_BaseState st_Forage()
Behavioural forage.
Definition: Goose_Base.cpp:433
CfgFloat
Double configurator entry class.
Definition: configurator.h:106
Goose_Base::m_myGooseSpeciesType
GooseSpeciesType m_myGooseSpeciesType
Holds the goose species type.
Definition: Goose_Base.h:163
Goose_Base::m_OurPopulationManager
Goose_Population_Manager * m_OurPopulationManager
This is a time saving pointer to the correct population manager object.
Definition: Goose_Base.h:151
Goose_Base::m_GooseFieldForageDistX2
static double m_GooseFieldForageDistX2[gs_foobar]
Double the maximum distance travelled from roost to forage sites for each species of goose (m) - this...
Definition: Goose_Base.h:251
Goose_Pinkfoot_FamilyGroup::~Goose_Pinkfoot_FamilyGroup
virtual ~Goose_Pinkfoot_FamilyGroup()
Goose_Pinkfoot_FamilyGroup destructor.
Definition: GoosePinkFooted_All.cpp:178
TTypeOfGoose_BaseState
TTypeOfGoose_BaseState
Definition: Goose_Base.h:74
Goose_Population_Manager::RemoveGeeseFromForageLocation
void RemoveGeeseFromForageLocation(GooseSpeciesType a_type, int a_index, int a_number)
Removes a goose or geese to the forage location - requires an index.
Definition: Goose_Population_Manager.cpp:1812
Goose_Pinkfoot_FamilyGroup::KillThis
virtual void KillThis(void)
The Goose_Pinkfoot_FamilyGroup KillThis must be overridden for families.
Definition: GoosePinkFooted_All.cpp:222
togs_Emigrate
Definition: Goose_Base.h:82
cfg_goose_daytime_BMR_multiplier
CfgFloat cfg_goose_daytime_BMR_multiplier
To calculate daily energy budget. This is the multiple of BMR spent during daytime.
Goose_Pinkfoot_Base
A class to describe the Pinkfoot base.
Definition: GoosePinkFooted_All.h:46
Goose_Pinkfoot_FamilyGroup::ReInit
void ReInit(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
ReInit for object pool.
Definition: GoosePinkFooted_All.cpp:170
Goose_Pinkfoot_FamilyGroup::Goose_Pinkfoot_FamilyGroup
Goose_Pinkfoot_FamilyGroup(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
Goose_Pinkfoot_FamilyGroup constructor.
Definition: GoosePinkFooted_All.cpp:153
Goose_Pinkfoot_NonBreeder::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Intitialise object.
Definition: GoosePinkFooted_All.cpp:253
Goose_Base::m_MyRoost
APoint m_MyRoost
The current roost location.
Definition: Goose_Base.h:167
cfg_goose_nighttime_BMR_multiplier
CfgFloat cfg_goose_nighttime_BMR_multiplier
To calculate daily energy budget. This is the multiple of BMR spent during nighttime.
Goose_Pinkfoot_NonBreeder::ReInit
void ReInit(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
ReInit for object pool.
Definition: GoosePinkFooted_All.cpp:263
togs_Forage
Definition: Goose_Base.h:78
Goose_Population_Manager.h
Goose_Population_Manager.h This is the header file for the goose population manager class