Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SubPopulation.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2021, Xiaodong Duan, Aarhus University
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 */
32 //---------------------------------------------------------------------------
33 #ifndef SubPopulationAnimalH
34 #define SubPopulationAnimalH
35 //---------------------------------------------------------------------------
36 
37 //---------------------------------------------------------------------------
38 class SubPopulation;
40 //------------------------------------------------------------------------------
41 
49 } ;
50 
51 
56 class SubPopulation : public TAnimal
57 {
58 private:
62  unsigned m_SpeciesID;
64  blitz::Array<double, 2> temp_mortality_array;
65 
66 
67 protected:
69  int m_index_x;
71  int m_index_y;
75  double *m_popu_density;
77  double *m_suitability;
81  blitz::Array<double, 1> m_population_each_life_stage;
83  blitz::Array<double, 2> m_animal_num_array;
85  blitz::Array<double, 2> m_temp_animal_num_array;
86 
88  blitz::Array<double, 1> m_temp_droping_wings_array;
90  blitz::Array<double, 1> m_died_number_each_life_stage;
92  blitz::Array<double, 2> m_flying_array;
94  blitz::Array<double, 2> m_local_moving_array;
111 
112 public:
114  SubPopulation(int p_x, int p_y, Landscape* p_L, SubPopulation_Population_Manager* p_NPM, bool a_empty_flag, int a_index_x, int a_index_y, double* p_suitability=NULL, double* p_weight_density=NULL, int number=-1, int a_SpeciesID=999, TTypesOfLandscapeElement p_winter_landscape_host=tole_Foobar, TTypesOfLandscapeElement p_summer_landscape_host=tole_Foobar, bool p_farm_flag=false);
115  virtual ~SubPopulation()=default;
117  unsigned getSpeciesID() { return m_SpeciesID; }
119  void setSpeciesID(unsigned a_spID) { m_SpeciesID = a_spID; }
121  double getNumforOneLifeStage(int source_type);
125  void addAnimalNumGivenStageColumn(int source_type, int a_column, double a_num);
127  void addAnimalNumGivenStage(int source_type, blitz::Array<double, 1>* a_animal_num_array);
129  void removeAnimalNumGivenStage(int source_type);
131  double removeAnimalPortionGivenStageColumn(int source_type, int a_column, double a_prop);
133  void addAnimalFromAnotherCell(int source_type, int a_column, double a_num);
135  blitz::Array<double, 1> getArrayForOneLifeStage(int life_stage);
137  virtual void calPopuDensity(void);
139  virtual void calSuitability(void);
140  virtual void Step();
141  virtual void doDevelopment();
142  virtual void doMovement();
143  virtual void doReproduction();
145  virtual void doDropingWings() {};
146  virtual void doMortality();
148  virtual double calCellRelatedMortalityWeight() {return 0.0;};
150  blitz::Array<double, 1> getFlyingArray( int ind) {return m_flying_array(ind, blitz::Range::all());}
152  double getFlyingNum(int ind) {return sum(m_flying_array(ind, blitz::Range::all()));}
154  void setWinterHostPeriod(int start_month, int end_month) {m_winter_landscape_host_period.at(0) = start_month; m_winter_landscape_host_period.at(1)=end_month;}
156  void setSummerHostPeriod(int start_month, int end_month) {m_summer_landscape_host_period.at(0) = start_month; m_summer_landscape_host_period.at(1)=end_month;}
158  virtual double calBioticMortalityRate(int a_life_stage) {return 0.0;}
160  virtual void setParasitoidNum(double a_num) {;}
162  virtual void setParasitoidEggNum(double a_num) {;}
164  virtual void giveBirthParasitoidEgg(double a_egg_num) {;}
166  virtual void killByParasitoid(){;}
168  virtual void hatchParasitoidEggs(){;}
174  void setFlyLocalMovFlag(bool a_flag) {m_landing_local_move_flag = a_flag;}
178  bool isFarm() {return m_farm_flag;}
179  virtual void BeginStep(){;}
180 };
181 
182 #endif
SubPopulation::removeAnimalNumGivenStage
void removeAnimalNumGivenStage(int source_type)
Function to remove one life stage completely.
Definition: SubPopulation.cpp:142
SubPopulation::m_SpeciesID
unsigned m_SpeciesID
A unique ID number for this species.
Definition: SubPopulation.h:62
SubPopulation_Population_Manager
The class to handle all subpopulation-based ainimal population related matters in the whole landscape...
Definition: SubPopulation_Population_Manager.h:77
SubPopulation::m_popu_density
double * m_popu_density
Variable to store the weighted population density pointer.
Definition: SubPopulation.h:75
Landscape::SupplyGreenBiomass
double SupplyGreenBiomass(int a_polyref)
Returns the green biomass of the vegetation using the polygon reference number a_polyref.
Definition: Landscape.h:1612
SubPopulation::m_winter_landscape_host
TTypesOfLandscapeElement m_winter_landscape_host
The flag to show whether it is a winter landscape type host.
Definition: SubPopulation.h:96
SubPopulation::m_landing_local_move_flag
bool m_landing_local_move_flag
landing_enable_local_movement_flag
Definition: SubPopulation.h:110
SubPopulation::SubPopulation
SubPopulation(int p_x, int p_y, Landscape *p_L, SubPopulation_Population_Manager *p_NPM, bool a_empty_flag, int a_index_x, int a_index_y, double *p_suitability=NULL, double *p_weight_density=NULL, int number=-1, int a_SpeciesID=999, TTypesOfLandscapeElement p_winter_landscape_host=tole_Foobar, TTypesOfLandscapeElement p_summer_landscape_host=tole_Foobar, bool p_farm_flag=false)
Subpopulation constructor.
Definition: SubPopulation.cpp:49
Landscape::SupplyVegType
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Returns the vegetation type of the polygon using the polygon reference number a_polyref or coordinate...
Definition: Landscape.h:1925
Landscape::SupplyElementType
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Returns the landscape type of the polygon using the polygon reference number a_polyref or coordinates...
Definition: Landscape.h:1732
SubPopulation::addAnimalNumGivenStageColumn
void addAnimalNumGivenStageColumn(int source_type, int a_column, double a_num)
Add animal number for the given life stage at specific column (age) in the animal number array.
Definition: SubPopulation.cpp:100
SubPopulation::Step
virtual void Step()
Step behaviour - must be implemented in descendent classes.
Definition: SubPopulation.cpp:153
tole_Foobar
Definition: LandscapeFarmingEnums.h:183
SubPopulation::calBioticMortalityRate
virtual double calBioticMortalityRate(int a_life_stage)
The function to calculate the biotic mortalit rate.
Definition: SubPopulation.h:158
SubPopulation_Object
SubPopulation_Object
Definition: SubPopulation.h:42
SubPopulation::doReproduction
virtual void doReproduction()
Definition: SubPopulation.cpp:294
SubPopulation::getSpeciesID
unsigned getSpeciesID()
A typical interface function - this one returns the SpeciesID number as an unsigned integer.
Definition: SubPopulation.h:117
SubPopulation::doDevelopment
virtual void doDevelopment()
Definition: SubPopulation.cpp:172
SubPopulation::m_died_number_each_life_stage
blitz::Array< double, 1 > m_died_number_each_life_stage
Array used for mortality.
Definition: SubPopulation.h:90
SubPopulation::m_parasitoid_egg_num
double m_parasitoid_egg_num
The variable to recourd the number of parasitoid egg.
Definition: SubPopulation.h:108
SubPopulation::setSpeciesID
void setSpeciesID(unsigned a_spID)
A typical interface function - this one returns the SpeciesID number as an unsigned integer.
Definition: SubPopulation.h:119
SubPopulation::killByParasitoid
virtual void killByParasitoid()
The function to kill subpopulation by parasitoid.
Definition: SubPopulation.h:166
SubPopulation::setParasitoidEggNum
virtual void setParasitoidEggNum(double a_num)
The function to set the parasitoid egg number.
Definition: SubPopulation.h:162
SubPopulation::m_empty_cell
bool m_empty_cell
Flag to show whether it is an empty subpopulation cell.
Definition: SubPopulation.h:60
SubPopulation::getArrayForOneLifeStage
blitz::Array< double, 1 > getArrayForOneLifeStage(int life_stage)
Get the numbers of the given life stage at different ages.
Definition: SubPopulation.cpp:209
SubPopulation::m_OurPopulationManager
SubPopulation_Population_Manager * m_OurPopulationManager
This is a time saving pointer to the correct population manager object.
Definition: SubPopulation.h:73
SubPopulation_Population_Manager::supplyFirstFlagLifeStage
bool supplyFirstFlagLifeStage(int life_stage)
The function to supply the flag of first for the given life stage.
Definition: SubPopulation_Population_Manager.h:276
SubPopulation::~SubPopulation
virtual ~SubPopulation()=default
tos_Adult_no_wing
Definition: SubPopulation.h:47
tos_Egg
Definition: SubPopulation.h:43
tos_Pupa
Definition: SubPopulation.h:45
SubPopulation_Population_Manager::supplyNumFlyingLifeStages
int supplyNumFlyingLifeStages()
Supply the number of life stages that can fly.
Definition: SubPopulation_Population_Manager.h:319
SubPopulation_Population_Manager::supplyNumLocMovLifeStages
int supplyNumLocMovLifeStages()
Supply the number of life stages thah can do local movement.
Definition: SubPopulation_Population_Manager.h:323
SubPopulation_Population_Manager::isSummerHostTole
bool isSummerHostTole(TTypesOfLandscapeElement a_ele)
Test whether it is a summer host tole.
Definition: SubPopulation_Population_Manager.cpp:810
SubPopulation::getFlyingNum
double getFlyingNum(int ind)
Supply the number of winged ones that want to fly away,.
Definition: SubPopulation.h:152
SubPopulation::doDropingWings
virtual void doDropingWings()
For some specices, they drop the wings at some situation.
Definition: SubPopulation.h:145
SubPopulation::getFlyingArray
blitz::Array< double, 1 > getFlyingArray(int ind)
Supply the flying array for flying.
Definition: SubPopulation.h:150
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
SubPopulation_Population_Manager::supplySizeSubpopulationCell
double supplySizeSubpopulationCell()
Supply the size of aphid subpopulation cell.
Definition: SubPopulation_Population_Manager.h:228
SubPopulation::getPrasitoidEggNum
double getPrasitoidEggNum()
Definition: SubPopulation.h:171
TTypesOfLandscapeElement
TTypesOfLandscapeElement
Values that represent the types of landscape polygon that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:57
Landscape
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
SubPopulation::temp_mortality_array
blitz::Array< double, 2 > temp_mortality_array
The array used for mortality calculation.
Definition: SubPopulation.h:64
SubPopulation::calCellRelatedMortalityWeight
virtual double calCellRelatedMortalityWeight()
This function is used to calculate the cell realted weight to multiply with the temperature and age b...
Definition: SubPopulation.h:148
SubPopulation::m_local_moving_array
blitz::Array< double, 2 > m_local_moving_array
Array used to store the number of adults willing for local movement.
Definition: SubPopulation.h:94
SubPopulation::m_summer_landscape_host_period
std::vector< int > m_summer_landscape_host_period
The starting and ending month for the summer landscape host.
Definition: SubPopulation.h:102
SubPopulation::setParasitoidNum
virtual void setParasitoidNum(double a_num)
The function to set the parasitoid number.
Definition: SubPopulation.h:160
SubPopulation::m_index_y
int m_index_y
Variable to store the index of y in the population manager.
Definition: SubPopulation.h:71
MapErrorMsg
Definition: MapErrorMsg.h:43
TAnimal::m_Location_y
int m_Location_y
The objects ALMaSS y coordinate.
Definition: PopulationManager.h:366
SubPopulation_Population_Manager::calNextStage
virtual int calNextStage(int current_stage, double density=1)
Return the next life stage for the given life stage.
Definition: SubPopulation_Population_Manager.cpp:659
TAnimal::m_OurLandscape
static Landscape * m_OurLandscape
A pointer to the landscape object shared with all TAnimal objects.
Definition: PopulationManager.h:342
SubPopulation::getTotalSubpopulation
double getTotalSubpopulation(void)
Return totalpopulation in the cell.
Definition: SubPopulation.h:123
TAnimal
The base class for all ALMaSS animal classes. Includes all the functionality required to be handled b...
Definition: PopulationManager.h:200
SubPopulation::addAnimalNumGivenStage
void addAnimalNumGivenStage(int source_type, blitz::Array< double, 1 > *a_animal_num_array)
Add animal number for the given life stage.
Definition: SubPopulation.cpp:121
tos_Adult
Definition: SubPopulation.h:46
SubPopulation::setFlyLocalMovFlag
void setFlyLocalMovFlag(bool a_flag)
The function to set the flag to enable local movement triged by landing activity.
Definition: SubPopulation.h:174
SubPopulation::m_temp_droping_wings_array
blitz::Array< double, 1 > m_temp_droping_wings_array
Array used for droping wings.
Definition: SubPopulation.h:88
SubPopulation::isFarm
bool isFarm()
The function to return whether it is part of farm.
Definition: SubPopulation.h:178
SubPopulation::m_summer_landscape_host
TTypesOfLandscapeElement m_summer_landscape_host
The flag to show whether it is a summer landscape type host.
Definition: SubPopulation.h:98
SubPopulation::m_suitability
double * m_suitability
Variable to store the suitability pointer.
Definition: SubPopulation.h:77
SubPopulation::getNumforOneLifeStage
double getNumforOneLifeStage(int source_type)
Return the number of animals in a specific life stage in the cell.
Definition: SubPopulation.cpp:95
SubPopulation_Population_Manager::supplyLifeStageNum
int supplyLifeStageNum()
Supply the number of life stage.
Definition: SubPopulation_Population_Manager.h:242
SubPopulation::setSummerHostPeriod
void setSummerHostPeriod(int start_month, int end_month)
Set the available period for summer landscape host.
Definition: SubPopulation.h:156
SubPopulation::m_winter_landscape_host_period
std::vector< int > m_winter_landscape_host_period
The staring and ending month for the winter landscape host.
Definition: SubPopulation.h:100
SubPopulation_Population_Manager::supplyMaxColNum
int supplyMaxColNum()
Supply the maximum number of column in the development array.
Definition: SubPopulation_Population_Manager.h:244
SubPopulation::m_animal_num_array
blitz::Array< double, 2 > m_animal_num_array
Variables to record numbers of the animals at different life stages and age in canlander days.
Definition: SubPopulation.h:83
SubPopulation::BeginStep
virtual void BeginStep()
BeingStep behaviour - must be implemented in descendent classes.
Definition: SubPopulation.h:179
SubPopulation::getPrasitoidNum
double getPrasitoidNum()
The function to supply the parasitoid number.
Definition: SubPopulation.h:170
SubPopulation_Population_Manager::supplyOldEnoughIndex
std::vector< int > supplyOldEnoughIndex(int life_stage_index)
Definition: SubPopulation_Population_Manager.h:247
tos_Larva
Definition: SubPopulation.h:44
SubPopulation::m_parasitoid_num
double m_parasitoid_num
The variable to record the number of parasitoid.
Definition: SubPopulation.h:106
SubPopulation::addAnimalFromAnotherCell
void addAnimalFromAnotherCell(int source_type, int a_column, double a_num)
Add the number of animal at the given source and column that moved from another grid.
Definition: SubPopulation.cpp:337
SubPopulation_Population_Manager::supplyMortalityWholeArray
blitz::Array< double, 2 > supplyMortalityWholeArray(void)
The function to supply the whole base mortality rate array.
Definition: SubPopulation_Population_Manager.h:298
SubPopulation::supplySuitability
int supplySuitability()
Definition: SubPopulation.h:172
SubPopulation::giveBirthParasitoidEgg
virtual void giveBirthParasitoidEgg(double a_egg_num)
The function to give birth of parasitiod eggs.
Definition: SubPopulation.h:164
SubPopulation::calPopuDensity
virtual void calPopuDensity(void)
Function to calculate the weighted population density for the cell.
Definition: SubPopulation.cpp:350
SubPopulation::removeAnimalPortionGivenStageColumn
double removeAnimalPortionGivenStageColumn(int source_type, int a_column, double a_prop)
Remove propotion of animals for the given species and age.
Definition: SubPopulation.cpp:326
SubPopulation::hatchParasitoidEggs
virtual void hatchParasitoidEggs()
The function to hatch parasitoid eggs.
Definition: SubPopulation.h:168
SubPopulation::m_farm_flag
bool m_farm_flag
The flag to show whether it is part of farm.
Definition: SubPopulation.h:104
SubPopulation::isNewlyLanded
bool isNewlyLanded()
Supply whether it is newly landed grid.
Definition: SubPopulation.h:176
SubPopulation_Population_Manager::setFirstFlagLifeStage
void setFirstFlagLifeStage(int life_stage, bool pvalue)
The function to set the flag indicating whether a given lifestage is the first time of existing.
Definition: SubPopulation_Population_Manager.h:274
SubPopulation
The class for base animal using subpopulation method.
Definition: SubPopulation.h:56
SubPopulation::m_whole_population_in_cell
double m_whole_population_in_cell
Variable to track the whole population in the current cell.
Definition: SubPopulation.h:79
SubPopulation::setWinterHostPeriod
void setWinterHostPeriod(int start_month, int end_month)
Set the available period for winter landscape host.
Definition: SubPopulation.h:154
SubPopulation::m_index_x
int m_index_x
Variable to store the index of x in the population manager.
Definition: SubPopulation.h:69
TAnimal::m_Location_x
int m_Location_x
The objects ALMaSS x coordinate.
Definition: PopulationManager.h:362
count
Definition: SubPopulation.h:48
SubPopulation_Population_Manager::calOffspringStage
virtual int calOffspringStage(int current_stage, double *offspring_num=NULL, double a_age=1, double a_density=-1, double a_growth_stage=0, double *a_propotion=NULL, bool winter_host_flag=false)
Calculate the offspring life stage.
Definition: SubPopulation_Population_Manager.cpp:1117
SubPopulation::doMovement
virtual void doMovement()
Definition: SubPopulation.cpp:312
SubPopulation_Population_Manager::setOldIndex
void setOldIndex(int life_stage, int p_value)
The function to set the oldest index for the given life stage.
Definition: SubPopulation_Population_Manager.cpp:701
SubPopulation::m_flying_array
blitz::Array< double, 2 > m_flying_array
Array used to store the number of winged adults willing to fly away.
Definition: SubPopulation.h:92
SubPopulation::calSuitability
virtual void calSuitability(void)
Function to calculate the suitability for the cell.
Definition: SubPopulation.cpp:343
SubPopulation::m_temp_animal_num_array
blitz::Array< double, 2 > m_temp_animal_num_array
Tempraral variables for manipulting the animal number array.
Definition: SubPopulation.h:85
SubPopulation_Population_Manager::isSummerHostTov
bool isSummerHostTov(TTypesOfVegetation a_ele)
Test whether it is a summer host tov.
Definition: SubPopulation_Population_Manager.cpp:830
SubPopulation::m_population_each_life_stage
blitz::Array< double, 1 > m_population_each_life_stage
Array to hold the population number for each life stage.
Definition: SubPopulation.h:81
SubPopulation_Population_Manager::supplyNewestIndex
int supplyNewestIndex(int life_stage_index)
Definition: SubPopulation_Population_Manager.h:248
SubPopulation_Population_Manager::supplyVecFlyingLifeStages
std::vector< int > supplyVecFlyingLifeStages()
Supply the vector of life stages for flying.
Definition: SubPopulation_Population_Manager.h:317
SubPopulation::doMortality
virtual void doMortality()
Definition: SubPopulation.cpp:213