Goose Management Model ODdox
1.02
|
Go to the documentation of this file.
39 #include "../Landscape/ls.h"
40 #include "../BatchALMaSS/PopulationManager.h"
41 #include "../GooseManagement/GooseMemoryMap.h"
42 #include "../GooseManagement/Goose_Base.h"
43 #include "../BatchALMaSS/CurveClasses.h"
44 #include "../Hunters/Hunters_all.h"
45 #include "../GooseManagement/Goose_Population_Manager.h"
46 #include "../BatchALMaSS/BoostRandomGenerators.h"
49 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> >
g_rand_uni;
51 extern boost::variate_generator<base_generator_type&, boost::uniform_int<> >
g_rand_uni2;
113 m_OurPopulationManager = p_NPM;
120 m_DailyMaxAppetite = 0.0;
121 m_DailyMaxAppetiteHitTime = 0;
123 int today = m_OurLandscape->SupplyDayInYear();
125 m_energyReserve = m_weight * 0.22;
127 m_weightTotal = m_weight + m_energyReserve;
131 m_BodyConditionCounter = 0;
132 m_TheBodyCondition = 0.0;
133 for (
unsigned i = 0; i < 5; i++)
135 double condition = m_weightTotal / m_weight;
136 SetBodyCondition(condition, i);
137 AddBodyCondition(m_BodyCondition[i]);
139 m_LeaveRoostTime = 0;
140 m_myForageIndex = -1;
145 m_Location_x = a_roost.m_x;
146 m_Location_y = a_roost.m_y;
147 m_MyRoost.m_x = a_roost.m_x;
148 m_MyRoost.m_y = a_roost.m_y;
153 m_myspecies = gs_foobar;
157 Set_Indivmingooseforagerate(0.0);
159 m_FlightDistance = 0;
160 m_forageLocCount = 0;
165 Init(p_NPM, a_weight, a_sex, a_roost);
169 TAnimal::ReinitialiseObject(0, 0, p_L);
171 Init(p_NPM, a_weight, a_sex, a_roost);
233 double daylightprop = m_OurLandscape->SupplyDaylightProp();
234 double nighttimeprop = m_OurLandscape->SupplyNightProp();
237 double minforagerate = (
m_DEB / (1440 * daylightprop));
246 m_OurLandscape->Warn(
"Goose_Base::Step()",
"attempt to instantiate and use the base class!");
253 m_CurrentStateNo = -1;
262 int today = m_OurLandscape->SupplyDayInYear();
264 int daylength = m_OurLandscape->SupplyDaylength();
289 #ifdef __FOLLOW_FIELD
292 if (forageindex > -1) {
299 if (leader != NULL) {
319 aThought.
m_x = m_OurLandscape->SupplyCentroidX( poly );
320 aThought.
m_y = m_OurLandscape->SupplyCentroidY( poly );
329 g_msg->
Warn(
"TTypeOfGoose_BaseState Goose_Base::st_ChooseForageLocation() : No geese at foraging location when following",
"" );
357 m_Location_x = aThought.
m_x;
358 m_Location_y = aThought.
m_y;
359 int polyref = m_OurLandscape->SupplyPolyRef(m_Location_x, m_Location_y);
360 double grazing = m_OurLandscape->GetActualGooseGrazingForage(polyref,
m_myspecies);
361 double grain = m_OurLandscape->SupplyBirdSeedForage(polyref);
362 double maize = m_OurLandscape->SupplyBirdMaizeForage(polyref);
363 bool instubble = m_OurLandscape->SupplyInStubble(polyref);
366 bool iscereal = m_OurLandscape->SupplyIsCereal2(lastsowncrop);
383 myforagerate =
GetMaxForageRate( grain_intake, maize_intake, grazing, interferenceComp, iscereal, veg, instubble, lastsowncrop);
405 FlyTo(a_pt.m_x,a_pt.m_y);
419 if ((m_Location_x == a_x) && (m_Location_y == a_y))
return;
457 int daylength = m_OurLandscape->SupplyDaylength();
482 double grazing = m_OurLandscape->GetActualGooseGrazingForage(polyref,
m_myspecies);
483 double grain = m_OurLandscape->SupplyBirdSeedForage(polyref);
484 double maize = m_OurLandscape->SupplyBirdMaizeForage(polyref);
485 bool instubble = m_OurLandscape->SupplyInStubble(polyref);
488 bool iscereal = m_OurLandscape->SupplyIsCereal2(lastsowncrop);
502 myforagerate =
GetMaxForageRate( grain_intake, maize_intake, grazing, interferenceComp, iscereal, veg, instubble, lastsowncrop);
530 double forage = myforagerate * 10;
580 for (
int i = 0; i < 1; i++)
595 double dx = a_HopLoc.m_x - m_Location_x;
596 double dy = a_HopLoc.m_y - m_Location_y;
598 double tx = m_Location_x;
599 double ty = m_Location_y;
601 double ddx = (dx/dist)*100;
602 double ddy = (dy/dist)*100;
603 int lastpoly = m_OurLandscape->SupplyPolyRef(m_Location_x, m_Location_y);
604 for (
int d=0; d<dist/100; d++)
608 if (m_OurLandscape->SupplyPolyRef((
int)tx, (
int)ty) != lastpoly)
610 lastpoly = m_OurLandscape->SupplyPolyRef((
int)tx, (
int)ty);
611 int openness = (int)m_OurLandscape->SupplyOpenness(lastpoly);
615 double grain = m_OurLandscape->SupplyBirdSeedForage(lastpoly);
616 double maize = m_OurLandscape->SupplyBirdMaizeForage(lastpoly);
624 aThought.
m_x = m_OurLandscape->SupplyCentroidX(lastpoly);
625 aThought.
m_y = m_OurLandscape->SupplyCentroidY(lastpoly);
646 if (m_CurrentStateNo == -1)
return;
651 aThought.
m_x = m_OurLandscape->SupplyCentroidX(a_polyid);
652 aThought.
m_y = m_OurLandscape->SupplyCentroidY(a_polyid);
679 if (m_CurrentStateNo == -1)
return;
684 aThought.
m_x = m_OurLandscape->SupplyCentroidX(a_polyid);
685 aThought.
m_y = m_OurLandscape->SupplyCentroidY(a_polyid);
740 int foraging_time = -1;
741 int day_length = m_OurLandscape->SupplyDaylength();
742 int roost_leave_time = (int)a_RoostLeaveTime;
743 if (roost_leave_time < 0) {
744 roost_leave_time = 0;
747 if (a_EndForagingTime == 1440)
749 foraging_time = day_length - roost_leave_time;
753 foraging_time = a_EndForagingTime - roost_leave_time;
755 if (foraging_time == -1)
757 m_OurLandscape->Warn(
"Goose_Base::CalcForagingTime()",
"error in foraging time calculation");
760 return foraging_time;
CfgFloat cfg_goose_nighttime_BMR_multiplier
To calculate daily energy budget. This is the multiple of BMR spent during nighttime.
bool m_LeavingRoost
Flag to indicate that we are coming from the roost. Used to control code for "following".
double GetMaxIntakeRate(double a_grain, double a_maize, double a_grass)
Returns the max intake rate of the three different types of intake.
double m_energyToday
The bird's daily energy account (kJ)
int m_FlightNumber
Counter for the number of flights per day.
double GetFlightCost()
Get the flight costs per m per g.
double GetGrazing(int gs)
Returns the current forage rate kJ/min assuming no other geese affect this.
TTypeOfGoose_BaseState st_Roost()
Roosting until next forage or next morning.
int m_myForageIndex
Temporary storage for a forage location index - this is a speed optimisation.
int GetForageLocIndex(GooseSpecies a_species, int a_x, int a_y)
Get a forage location for my species (picked randomly among the active locations)
double m_DEB
The daily energy budget excluding flying (kJ)
static double m_GooseLeavingThreshold
The trigger for leaving as a 5 day average of body condition.
int GetDayTime()
Get the time of day (in minutes). For the goose model, sunrise is defined as m_daytime == 0....
int m_groupsize
The size of the group this bird represents.
bool MemDel(int a_polyid)
Delete a memory location.
double m_LeaveRoostTime
Controls the time when the goose will leave the roost.
a data structure to hold goose memory location attributes
double m_score
A score used to assess the location.
double m_grazing
the grazing resource at the location as intake rate kJ/min
void AddGeeseToForageLocation(GooseSpeciesType a_type, int a_index, int a_number)
Adds a goose or geese to the forage location - requires an index.
int GetForagingTime(int a_EndForagingTime, double a_RoostLeaveTime)
Returns the time spent foraging.
void RecordWeight(double a_weight, GooseSpecies a_species)
Record the weight.
static double m_GooseFieldForageDist[gs_foobar]
The maximum distance travelled from roost to forage sites for each species of goose (m)
static double m_GooseFattoKJConversion
Conversion rate fat to kJ.
double m_BodyCondition[5]
A variable describing current body condition over the past 5 days.
TTypeOfGoose_BaseState st_ChooseForageLocation(void)
Selects a forage location based on past memory, or initiates an exploration.
static double m_GooseMaxEnergyReserveProportion
Max proportion of weight that can be energy reserve.
virtual void Step(void)
The Step is the second 'part' of the timestep that an animal can behave in. It is called continuously...
double GetMaizeDensity(void)
Returns the current maize forage density (kJ/m2)
CfgInt cfg_goose_RoostLeaveDistSD
The standard deviation for the normal distribution which determines roost leave time.
bool ChangeSetFoodRes(int a_polyid, double a_grain, double a_maize, double a_grazing)
Set food at a memory location.
int GetIsDaylight()
Is it daylight hours? Daylight starts at m_daytime == 0.
void SubtractBodyCondition(double a_condition)
Alters body conditon by subtraction of a double value.
CfgFloat cfg_goose_snow_scaler
The decrease in intake rate resulting from snow.
void ReInit(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
ReInit for object pool.
void RecordDailyEnergyBudget(int a_deb, GooseSpecies a_species)
Record the daily energy budget.
static double m_SnowDepth
The current snow depth. Held here for speed optimization.
double GetMaizeFeedingRate(double a_maizedensity, GooseSpecies a_species)
Get the forage rate when feeding on maize.
void RecordLeaveReason(TTypeOfLeaveReason a_leavereason, GooseSpeciesType a_speciestype)
Record the reason for leaving.
int GetPolygonref()
Get the landscape element ( LE ) reference number used by the Landscape class to identify this locati...
double AdjustIntakeRateToSnowDepth(double a_intakerate)
When there is snow, the intake rate is decreased by 10 % per cm of snow.
double GetGrainDensity(void)
Returns the current forage density (grain/m2)
bool ChangeAddThreat(int a_polyid, double a_threat)
Add to threat at a memory location.
void Set_Indivmingooseforagerate(double a_cost)
Set the mimimum tolerated forage rate for the individual goose.
void Set_mingooseforagerate(double a_cost, GooseSpecies a_species)
Set the mimimum tolerated forage rate for all geese.
int m_DailyMaxAppetiteHitTime
The time of day when m_DailyMaxAppetite was hit.
int m_myMemPolyID
Temporary storage for a memory location polygon id.
ALMaSS_MathFuncs constructor.
double CalcScore(int a_dist, double a_foodresource, double a_threat)
Inline function to calulate overall score for a distance, resource and threat.
Variate_gen * m_variate_generator
Function to be able to draw randomly from predefined distributions.
static double m_GooseMaxAppetiteScaler
Scaler to determine the max kJ possible to eat per day based on non-energy reserve weight.
Goose_Base * GetLeader(APoint a_homeloc, GooseSpecies a_species)
Asks for a pointer to a goose that can be followed.
static double m_GooseForageDistX2[gs_foobar]
Double the maximum distance travelled from roost to forage sites for each species of goose (m) - this...
The landscape class containing all environmental and topographical data.
void SetBodyCondition(double a_condition, unsigned a_index)
Sets the current body condition.
TTypeOfMaxIntakeSource m_maxintakesource
The intake source which gave the maximum intake.
void RecordForagingTime(int a_time, GooseSpecies a_species)
Record the time spent foraging.
GooseSpecies m_myspecies
Holds goose species.
int m_FlightDistance
Storage for the total distance flown per day.
CfgFloat cfg_goose_BMRconstant2
The cost of BMR per kg goose - constant 2.
void RecordIndForageLoc(double a_count, int a_groupsize, GooseSpecies a_species)
Record a forage location count.
double m_foodresource
The max food intake rate (kJ/min) at the location.
double GetFeedingRate(double a_graindensity, GooseSpecies a_species)
Get the forage rate based on the grain density.
double GetGooseMinForageRate(GooseSpecies a_species)
Returns the minimum forage rate for the species.
ALMaSS_MathFuncs g_AlmassMathFuncs
This variable provides access the to the internal ALMaSS math functions.
int ForageLocationInUse(int a_polyref)
Tests if a forage location is currently in use, if so returns the index to it.
double m_DailyMaxAppetite
The daily max kJ possible to get as intake.
void Init(Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Intitialise object.
CfgFloat cfg_goose_MinForageRateDecayRate
The decay rate for the minimum forage rate.
GooseMemoryLocation GetBestFeedingScore()
Find the current best feeding location.
static double m_GooseKJtoFatConversion
Conversion rate kJ to fat.
TTypeOfGoose_BaseState CurrentGState
Variable to record current behavioural state.
int m_forageLocCount
The number of forage locations visited today.
std::vector< GooseActiveForageLocation > m_GooseForageLocations
Is a list of active goose forage locations where we have geese.
void st_Dying(void)
Behavioural state dying.
double GetThermalCosts(GooseSpecies a_goose)
Get daily thermal costs const.
static double m_GooseForageDist[gs_foobar]
The maximum distance travelled from roost to forage sites for each species of goose (m)
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
GooseActiveForageLocation * GetForageLocation(unsigned int a_index)
Returns a pointer to the forage location indexed by index.
void RecordFlightDistance(int a_distance, GooseSpecies a_species)
Record the flight distance.
boost::variate_generator< base_generator_type &, boost::uniform_int<> > g_rand_uni2
A random number generator (0-9999)
GooseMemoryMap * m_MyMemory
The Goose Memory.
The class to handle all goose population related matters.
void On_Migrate(TTypeOfLeaveReason a_leavereason)
The goose is told to leave the simulation area (poss due to bad weather)
double GetMaxForageRate(double a_grain, double a_maize, double a_grass, double a_interferenceComp, bool a_iscereal, TTypesOfVegetation a_veg, bool a_stubble, TTypesOfVegetation a_prevcrop)
Returns the max forage rate of the three different types of forage The max rate is adjusted according...
int GetBirdsAtForageLoc(int a_index, GooseSpeciesType a_type)
Returns the number of birds at a forage location - given by a poly ref.
double ScaleForageToGroupsize(double a_forage)
Scales forage to groupsize.
CfgInt cfg_goose_RoostLeaveDistMean
The mean for the normal distribution which determines roost leave time.
double m_maize
the maize resource at the location as intake rate kJ/min
CfgInt cfg_goose_AfterDarkTime
The number of minutes that geese will be foraging after sunset.
A class to hold an active goose foraging location and the number of birds of different types there.
void Set_GooseLeavingRoost(bool a_leaving)
Set the flag to indicate if we are coming from the roost.
int NewForageLocation(GooseSpeciesType a_type, int a_number, int a_polyref)
Creates a new forage location and adds a goose or geese to the forage location. Returns an index to t...
static int m_followinglikelyhood[(int) gst_foobar]
An attribute used to determine the chance of following or exploring when foraging.
CfgFloat cfg_goose_daytime_BMR_multiplier
To calculate daily energy budget. This is the multiple of BMR spent during daytime Default is based o...
CfgFloat cfg_goose_BMRconstant1
The cost of BMR per kg goose - constant 1.
TMaxIntakeSource m_MaxIntakeSource
Holds information about the food source which gave max intake rate.
void FlyTo(int a_x, int a_y)
The goose flys to the location specified by a_x, a_y.
double m_BMR
The daily BMR.
void EvaluateForageToHopLoc(APoint a_HopLoc)
Do a forage evaluation from current location to a_HopLoc.
double GetForageGooseDensity(int a_index)
Returns the total goose density for a forage location.
unsigned m_BodyConditionCounter
A counter for the daily body condition.
void DecayAllMemory()
Decay all memory.
void RecordDailyEnergyBalance(int a_balance, GooseSpecies a_species)
Record the daily energy balance.
CfgFloat cfg_goose_InitialEnergyReserveProportion
The initial proportion of weight that can be stored as energy reserves.
void On_Bang(int a_polyid)
The goose is scared by a bang at location.
double m_Indivmingooseforagerate
The minimum tolerable forage rate in kJ/minute for the individual.
virtual TTypeOfGoose_BaseState st_ToRoost()
Return to roost and assess whether to forage again that day.
static double m_GooseMinForageOpenness
The minimum openness value a goose will tolerate for forage.
int GetForageLocIndex()
Gets for the forage location index.
Integer configurator entry class.
A class to describe the goose base.
double m_TheBodyCondition
A variable describing current body condition averaged over 5 days.
virtual APoint ChooseHopLoc()
Pick a hop location point within a_dist meters - must be overridden by descendent classes.
void Explore()
Behavioural exploration of the area to find forage.
virtual ~Goose_Base()
Goose_Base destructor.
MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
int CalcDistPythagorasApprox(int a_x, int a_y, int a_x1, int a_y1)
Calculate distance using the Pythagoras approximation.
double m_threat
the threat-level memory strength
bool IsKnownArea(int a_polyid)
Check if this location is known.
TTypeOfGoose_BaseState st_Forage()
Behavioural forage.
Double configurator entry class.
GooseSpeciesType m_myGooseSpeciesType
Holds the goose species type.
int m_polygonid
the unique polygon identification
Goose_Population_Manager * m_OurPopulationManager
This is a time saving pointer to the correct population manager object.
static double m_GooseFieldForageDistX2[gs_foobar]
Double the maximum distance travelled from roost to forage sites for each species of goose (m) - this...
void AddBodyCondition(double a_condition)
Alters body conditon by addition of a double value.
virtual void KillThis()
The bird is dead of some external cause.
void RecordState()
Record the state.
static double m_mingooseforagerate[gs_foobar]
The minimum tolerable forage rate in kJ/minute for the species.
void MemAdd(GooseMemoryLocation a_gml)
Add a new memory location.
void RemoveGeeseFromForageLocation(GooseSpeciesType a_type, int a_index, int a_number)
Removes a goose or geese to the forage location - requires an index.
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
A random number generator (0-1)
void RemoveMaxForageKj(double a_forage, TTypeOfMaxIntakeSource a_maxintakesource, int m_myForageIndex)
Removes the forage eaten from the field.
double m_weightTotal
The weight of the bird in g including fat reserve.
CfgInt cfg_goose_pf_springmigdatestart
Input: Date for onset of spring migration.
int CalcDistPythagoras(int a_x, int a_y, int a_x1, int a_y1)
Calculate distance using Pythagoras.
virtual void StartDay(void)
Do any 'housekeeping' associated with the start of day.
CfgInt cfg_goose_pf_springmigdateend
Input: Date for end of spring migration.
APoint m_MyRoost
The current roost location.
double GetForageRateDensity(double a_foragedensity)
Get the forage intake rate for a forage density.
double m_grain
the grain resource at the location as intake rate kJ/min
double m_energyReserve
The bird's energy reserves in grams.
double m_weight
The weight of the bird in gram excluding fat reserve.
Goose_Base(Landscape *p_L, Goose_Population_Manager *p_NPM, double a_weight, bool a_sex, APoint a_roost)
Goose_Base constructor.
static double m_flightcost
The cost of flight per g per m in kJ.
The class describing both local and seasonal goose memories and cognition.