Goose Management Model ODdox  1.02
GooseGreylag_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 "../Landscape/ls.h"
41 #include "../BatchALMaSS/PopulationManager.h"
42 #include "GooseMemoryMap.h"
43 #include "Goose_Base.h"
44 #include "../BatchALMaSS/CurveClasses.h"
45 #include "../Hunters/Hunters_all.h"
47 #include "GooseGreylag_All.h"
48 #include "../BatchALMaSS/BoostRandomGenerators.h"
49 
51 extern boost::variate_generator<base_generator_type &, boost::uniform_real<>> g_rand_uni;
53 extern MapErrorMsg *g_msg;
54 
55 using namespace std;
56 
63 
64 //*******************************************************************************************************
65 //**********************************Goose_Greylag_Base**************************************************
66 //*******************************************************************************************************
67 
68 Goose_Greylag_Base::Goose_Greylag_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)
69 {
70  Init(p_NPM, a_weight, a_sex, a_roost);
71 }
72 void Goose_Greylag_Base::ReInit(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
73  Goose_Base::ReInit(p_L, p_NPM, a_weight, a_sex, a_roost);
74  Init(p_NPM, a_weight, a_sex, a_roost);
75 }
76 
77 void Goose_Greylag_Base::Init(Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
78  Goose_Base::Init(p_NPM, a_weight, a_sex, a_roost);
83  m_myspecies = gs_Greylag;
84  double daylightprop = m_OurLandscape->SupplyDaylightProp();
85  double nighttimeprop = m_OurLandscape->SupplyNightProp();
86  double multiplier = cfg_goose_daytime_BMR_multiplier.value() * daylightprop + cfg_goose_nighttime_BMR_multiplier.value() * nighttimeprop;
89 }
90 //-------------------------------------------------------------------------------------------------------
91 
93 {
94  ;
95 }
96 //-------------------------------------------------------------------------------------------------------
97 
99 {
103  if (m_myForageIndex != -1)
104  {
106  }
107  m_myForageIndex = -1;
113  {
114  ChangeRoost();
115  }
116  FlyTo(m_MyRoost.m_x, m_MyRoost.m_y);
117  return togs_Roost;
118 }
119 //--------------------------------------------------------------------------------------------------------
120 
122 {
127  APoint pt;
128  pt.m_x = (int)((g_rand_uni() * m_GooseForageDistX2[gs_Greylag]) - m_GooseForageDist[gs_Greylag] + m_MyRoost.m_x);
129  pt.m_y = (int)((g_rand_uni() * m_GooseForageDistX2[gs_Greylag]) - m_GooseForageDist[gs_Greylag] + m_MyRoost.m_y);
130  m_OurLandscape->CorrectCoordsPointNoWrap(pt);
133  return pt;
134 }
135 //--------------------------------------------------------------------------------------------------------
136 
137 //*******************************************************************************************************
138 //**********************************Goose_Greylag_FamilyGroup*********************************************
139 //*******************************************************************************************************
140 void Goose_Greylag_FamilyGroup::Init(Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
141 {
142  Goose_Greylag_Base::Init(p_NPM, a_weight, a_sex, a_roost);
146  m_groupsize = a_groupsize;
148 }
150  int a_groupsize, APoint a_roost) : Goose_Greylag_Base(p_L, p_NPM, a_weight, a_sex, a_roost)
151 {
152  Init(p_NPM, a_weight, a_sex, a_groupsize, a_roost);
153 }
154 void Goose_Greylag_FamilyGroup::ReInit(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
155 {
156  Goose_Greylag_Base::ReInit(p_L, p_NPM, a_weight, a_sex, a_roost);
157  Init(p_NPM, a_weight, a_sex, a_groupsize, a_roost);
158 }
159 //-------------------------------------------------------------------------------------------------------
160 
162 {
163  ;
164 }
165 //-------------------------------------------------------------------------------------------------------
166 
168 {
169  if (m_StepDone || m_CurrentStateNo == -1) return;
170  switch (CurrentGState)
171  {
172  case togs_InitialState: // Initial state always starts by setting the behaviour to togs_Roost
174  break;
177  m_StepDone = true;
178  break;
179  case togs_Forage:
181  m_StepDone = true;
182  break;
183  case togs_ToRoost:
185  m_StepDone = true;
186  break;
187  case togs_Roost:
189  m_StepDone = true;
190  break;
191  case togs_Emigrate:
193  break;
194  case togs_Die:
195  st_Dying(); // No return value - no behaviour after this
196  m_StepDone = true;
197  break;
198  default:
199  m_OurLandscape->Warn("Goose_Greylag_FamilyGroup::Step()","unknown state - default");
200  exit(1);
201  }
202 }
203 //-------------------------------------------------------------------------------------------------------
204 
206 {
213  if (m_myForageIndex != -1)
214  {
216  }
217  if (--m_groupsize < 1)
218  {
219  delete m_MyMemory; // this is reinitisalised in the object pool.
220  TAnimal::KillThis();
221  }
222 
223 }
224 //-------------------------------------------------------------------------------------------------------
225 //*******************************************************************************************************
226 
227 //*******************************************************************************************************
228 //**********************************Goose_Greylag_NonBreeder**************************************************
229 //*******************************************************************************************************
230 
231 Goose_Greylag_NonBreeder::Goose_Greylag_NonBreeder(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) : Goose_Greylag_Base(p_L, p_NPM, a_weight, a_sex, a_roost)
232 {
233  Init(p_NPM, a_weight, a_sex, a_roost);
234 }
235 //-------------------------------------------------------------------------------------------------------
236 
237 void Goose_Greylag_NonBreeder::Init(Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
238  Goose_Greylag_Base::Init(p_NPM, a_weight, a_sex, a_roost);
242  m_groupsize = 1;
244 }
245 //-------------------------------------------------------------------------------------------------------
246 
247 void Goose_Greylag_NonBreeder::ReInit(Landscape* p_L, Goose_Population_Manager* p_NPM, double a_weight, bool a_sex, APoint a_roost) {
248  Goose_Greylag_Base::ReInit(p_L, p_NPM, a_weight, a_sex, a_roost);
249  Init(p_NPM, a_weight, a_sex, a_roost);
250 }
251 //-------------------------------------------------------------------------------------------------------
252 
254 {
255  ;
256 }
257 //-------------------------------------------------------------------------------------------------------
258 
260 {
261  if (m_StepDone || m_CurrentStateNo == -1) return;
262  switch (CurrentGState)
263  {
264  case togs_InitialState: // Initial state always starts by setting the behaviour to togs_Roost
266  break;
269  m_StepDone = true;
270  break;
271  case togs_Forage:
273  m_StepDone = true;
274  break;
275  case togs_ToRoost:
277  m_StepDone = true;
278  break;
279  case togs_Roost:
281  m_StepDone = true;
282  break;
283  case togs_Emigrate:
285  break;
286  case togs_Die:
287  st_Dying(); // No return value - no behaviour after this
288  m_StepDone=true;
289  break;
290  default:
291  m_OurLandscape->Warn("Goose_Greylag_NonBreeder::Step()","unknown state - default");
292  exit(1);
293  }
294 }
295 //-------------------------------------------------------------------------------------------------------
296 //*******************************************************************************************************
297 
298 
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_Greylag_NonBreeder::Goose_Greylag_NonBreeder
Goose_Greylag_NonBreeder(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Goose_Greylag_NonBreeder constructor.
Definition: GooseGreylag_All.cpp:231
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_Base::m_DEB
double m_DEB
The daily energy budget excluding flying (kJ)
Definition: Goose_Base.h:191
Goose_Greylag_NonBreeder::Step
virtual void Step(void)
The Goose_Greylag_NonBreeder Step.
Definition: GooseGreylag_All.cpp:259
Goose_Base::m_groupsize
int m_groupsize
The size of the group this bird represents.
Definition: Goose_Base.h:171
Goose_Greylag_Base::Goose_Greylag_Base
Goose_Greylag_Base(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Goose_Greylag_Base constructor.
Definition: GooseGreylag_All.cpp:68
Goose_Greylag_Base::ChooseHopLoc
virtual APoint ChooseHopLoc()
Pick a hop location point within a_dist meters - must be overridden by descendent classes.
Definition: GooseGreylag_All.cpp:121
togs_Die
Definition: Goose_Base.h:81
Goose_Greylag_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: GooseGreylag_All.cpp:154
togs_ToRoost
Definition: Goose_Base.h:79
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
GooseGreylag_All.h
GreylagGoose_All.h This is the header file for the greylag goose classes
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
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
A random number generator (0-1)
togs_ChooseForageLocation
Definition: Goose_Base.h:77
Goose_Greylag_Base::~Goose_Greylag_Base
virtual ~Goose_Greylag_Base()
Goose_Greylag_Base destructor.
Definition: GooseGreylag_All.cpp:92
Goose_Greylag_FamilyGroup::KillThis
virtual void KillThis(void)
The FamilyGroup KillThis must be overridden for families.
Definition: GooseGreylag_All.cpp:205
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
Goose_Base::m_myspecies
GooseSpecies m_myspecies
Holds goose species.
Definition: Goose_Base.h:159
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.
MapErrorMsg
Definition: maperrormsg.h:43
gst_GreylagNonBreeder
Definition: Goose_Base.h:65
Goose_Greylag_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: GooseGreylag_All.cpp:247
Goose_Greylag_Base::ChangeRoost
virtual void ChangeRoost()
Find the closest roost.
Definition: GooseGreylag_All.h:65
Goose_Greylag_Base::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Intitialise object.
Definition: GooseGreylag_All.cpp:77
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_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_Greylag_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: GooseGreylag_All.cpp:72
Goose_Greylag_Base
A class to describe the Greylag base.
Definition: GooseGreylag_All.h:46
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
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
Goose_Greylag_FamilyGroup::Goose_Greylag_FamilyGroup
Goose_Greylag_FamilyGroup(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
Goose_Greylag_FamilyGroup constructor.
Definition: GooseGreylag_All.cpp:149
Goose_Greylag_FamilyGroup::~Goose_Greylag_FamilyGroup
virtual ~Goose_Greylag_FamilyGroup()
Goose_Greylag_FamilyGroup destructor.
Definition: GooseGreylag_All.cpp:161
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_Greylag_Base::st_ToRoost
TTypeOfGoose_BaseState st_ToRoost()
Return to roost and assess whether to forage again that day.
Definition: GooseGreylag_All.cpp:98
CfgFloat::value
double value(void)
Definition: configurator.h:118
Goose_Greylag_FamilyGroup::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, int a_groupsize, APoint a_roost)
Intitialise object.
Definition: GooseGreylag_All.cpp:140
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
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_Greylag_NonBreeder::Init
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Intitialise object.
Definition: GooseGreylag_All.cpp:237
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
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
togs_Emigrate
Definition: Goose_Base.h:82
gst_GreylagFamilyGroup
Definition: Goose_Base.h:64
Goose_Base::m_MyRoost
APoint m_MyRoost
The current roost location.
Definition: Goose_Base.h:167
Goose_Greylag_NonBreeder::~Goose_Greylag_NonBreeder
virtual ~Goose_Greylag_NonBreeder()
Goose_Greylag_NonBreeder destructor.
Definition: GooseGreylag_All.cpp:253
g_msg
MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
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
Goose_Greylag_FamilyGroup::Step
virtual void Step(void)
The Goose_Greylag_FamilyGroup Step.
Definition: GooseGreylag_All.cpp:167