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_Population_Manager Class Reference

The class to handle all subpopulation-based ainimal population related matters in the whole landscape. More...

#include <SubPopulation_Population_Manager.h>

Inheritance diagram for SubPopulation_Population_Manager:
Population_Manager_Base Aphid_Population_Manager

Public Member Functions

 SubPopulation_Population_Manager (Landscape *L, string DevReproFile="", int a_sub_w=10, int a_sub_h=10, int a_num_life_stage=5, int a_max_long_dist=1000, int a_peak_long_dist=100, float a_scale_wind_speed=1.1, float a_max_wind_speed=16, int a_wind_direc_num=8, int a_wind_speed_step_size=2, int a_max_alive_day=300)
 
virtual ~SubPopulation_Population_Manager (void)
 SubPopulation_Manager Destructor. More...
 
double supplyAllPopulationGivenStage (int index)
 Supply the population size at the given life stage for the who landscape. More...
 
double supplyTotalPopulationInCell (int x_indx, int y_indx)
 Supply whole population size at the given cell. More...
 
int supplyCellNumX ()
 Supply number of subpopulation in x coordinate. More...
 
int supplyCellNumY ()
 Supply number of subpopulation in y coordinate. More...
 
double supplyCellWidth ()
 Supply the width of a subpopulation cell. More...
 
double supplyCellHeight ()
 Supply the height of a subpopulation cell. More...
 
double supplySizeSubpopulationCell ()
 Supply the size of aphid subpopulation cell. More...
 
bool openSubpopulationBaseProbeFile ()
 Open the storing file. More...
 
virtual void subpopuBaseOutputProbe ()
 Below are the functions for saving result. More...
 
double getTotalSubpopulationInCell (int x_indx, int y_indx)
 Supply the total subpopulation size in the given cell. More...
 
double getSubpopulationInCellLifeStage (int x_indx, int y_indx, int a_life_stage)
 Supply the subpopulation size at the given life stage in the given cell. More...
 
double getSuitabilityInCell (int x_indx, int y_indx)
 Supply the suitability in the given cell. More...
 
SubPopulationsupplySubPopulationPointer (int indx, int indy)
 Supply the pointer of the subpopulation object in the given cell. More...
 
int supplyLifeStageNum ()
 Supply the number of life stage. More...
 
int supplyMaxColNum ()
 Supply the maximum number of column in the development array. More...
 
int supplyNextLifeStage (int life_circle_index, int life_stage_index)
 Supply the next life stage index for a given life stage and a given life path. More...
 
std::vector< int > supplyOldEnoughIndex (int life_stage_index)
 
int supplyNewestIndex (int life_stage_index)
 
virtual unsigned GetLiveArraySize (int a_listindex)
 Must be re-implemented in descendent classes. Gets the number of 'live' objects. More...
 
void readDevReproFile (string inputfile)
 Function to read the development time and lifestage. More...
 
void relocatePopulation (void)
 Relocate the population in each cell based on the suitability and movement ability. More...
 
virtual void DoLast ()
 
virtual void DoFirst ()
 
virtual void calLongMovementMask (void)
 Function to calculate the movement mask. More...
 
void doDevelopment ()
 Function to make the development for all the subpopulation object. More...
 
void addNewDay ()
 Add new day to the newest and oldest array. More...
 
virtual int calNextStage (int current_stage, double density=1)
 Return the next life stage for the given life stage. More...
 
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. More...
 
virtual void updateDevelopmentSeason ()
 The function to update the development season. More...
 
void updateWholePopulationArray (int a_listindex, double number)
 The function to update the whole population array in the whole landscape. More...
 
void updateWholePopulationArray (blitz::Array< double, 1 > a_array)
 
void setFirstFlagLifeStage (int life_stage, bool pvalue)
 The function to set the flag indicating whether a given lifestage is the first time of existing. More...
 
bool supplyFirstFlagLifeStage (int life_stage)
 The function to supply the flag of first for the given life stage. More...
 
void setOldIndex (int life_stage, int p_value)
 The function to set the oldest index for the given life stage. More...
 
void doFlying (int ind, int index_x, int index_y)
 The function to fly the winged adults. More...
 
void doLocalMovement (int index_x, int index_y, double proportion)
 The function for local movement. More...
 
bool isWinterHostTole (TTypesOfLandscapeElement a_ele)
 Test whether it is a winter host tole. More...
 
bool isSummerHostTole (TTypesOfLandscapeElement a_ele)
 Test whether it is a summer host tole. More...
 
bool isWinterHostTov (TTypesOfVegetation a_ele)
 Test whether it is a winter host tov. More...
 
bool isSummerHostTov (TTypesOfVegetation a_ele)
 Test whether it is a summer host tov. More...
 
virtual unsigned supplyDevelopmentSeason ()
 The function to supply the development season. More...
 
virtual void updateMortalityArray (void)
 This function is used to update the daily mortality rate for all the ages. In this base class, it only depends on the temperature. The lowest and highest temperature that will make the species die. The optimal temperature will make the mortality rate to be 0. More...
 
double supplyMortality (int a_life_stage, int a_age)
 The function to supply the mortality rate for the given life stage and the age. More...
 
blitz::Array< double, 2 > supplyMortalityWholeArray (void)
 The function to supply the whole base mortality rate array. More...
 
blitz::Array< double, 1 > supplyMortalityStageArray (int a_life_stage)
 The function to supply the 1D base morality rate array for the given life stage. More...
 
double calLandingCurve (double a_dis, double a_peak, double a_furthest)
 The function to calculate the landing curve along the wind direction. More...
 
virtual void initialisePopulation ()
 The function to initialise the population when starting the simulation which requires rewritten in the derived class. More...
 
SubPopulationCreateObjects (TAnimal *pvo, struct_SubPopulation *data, int number)
 
int supplyAgeInDay (int lifestage_index, int column_index)
 The function to return the age in days given an element in the subpopulation table. More...
 
double supplyAgeInDayDegree (int lifestage_index, int column_index)
 
virtual void SupplyLocXY (unsigned index_x, unsigned index_y, int &x, int &y)
 A stub for identifying an individual at a location. More...
 
std::vector< int > supplyVecFlyingLifeStages ()
 Supply the vector of life stages for flying. More...
 
int supplyNumFlyingLifeStages ()
 Supply the number of life stages that can fly. More...
 
std::vector< int > supplyVecLocMoveLifeStages ()
 Supply the vector of life stages that can do local movement. More...
 
int supplyNumLocMovLifeStages ()
 Supply the number of life stages thah can do local movement. More...
 
virtual unsigned GetPopulationSize (int a_listindex)
 Must be re-implemented in descendent classes. More...
 
virtual bool isEnoughNextLifeStage (int a_life_stage)
 The funcition to check whether it is read for the next life stage. More...
 
std::vector< int > supplyWinterTolePeriod (TTypesOfLandscapeElement a_tole)
 The function to supply the available period vector for the given winter tole host. More...
 
std::vector< int > supplySummerTolePeriod (TTypesOfLandscapeElement a_tole)
 The function to supply the available period vector for the given summer tole host. More...
 
virtual void doParasitoidDevelopment ()
 The function for parasitoid calculation, it does nothing in this base class. More...
 
virtual void doSpecicesLastThing ()
 The special last thing for the drived species. More...
 
void updateWholePopulation ()
 Update whole population info. More...
 
virtual void SetNoProbesAndSpeciesSpecificFunctions (int a_pn)
 Sets up probe and species specifics. More...
 
virtual void readHosts (string a_file_name)
 The fuction to read the host lists for aphid. More...
 
virtual void writeCalibrationFiles (void)
 Write probe files for calibration. More...
 
bool supplySummerHostOn (void)
 
bool supplyWinterHostOn (void)
 
- Public Member Functions inherited from Population_Manager_Base
 Population_Manager_Base (Landscape *L)
 The Population_Manager_Base constructor. More...
 
virtual void Catastrophe (int)
 Must be re-implemented in descendent classes. More...
 
int SupplySimW () const
 Returns landscape width in m. More...
 
int SupplySimH () const
 Returns landscape height in m. More...
 
int SupplySimWH () const
 Returns half the landscape width in m. More...
 
int SupplySimHH () const
 Returns half the landscape height in m. More...
 
virtual int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 A stub to build specfic probes and functions. More...
 
virtual char * SpeciesSpecificReporting (int, int)
 A stub to build specfic reporting. More...
 
int SupplyListNameLength () const
 
const char * SupplyListName (int a_i) const
 Get a list name from the list. More...
 
virtual TAnimalFindClosest (int, int, unsigned)
 A stub for identifying an individual at a location. More...
 
std::string SupplySimulationName ()
 
virtual void OpenTheAOROutputProbe (const string &a_string)
 An empty method that needs to be here because the population manager lists might contain sub-population models which will skip Population_Manager functionality. More...
 
void SetStepCounterInADay (int a_counter)
 Set step counter in a day. More...
 
int GetStepCounterInADay (void)
 Return the sep counter in a day. More...
 
virtual double GetAphidDensity (int, int)
 Return the aphid density, it is only used when aphid simulations are running. More...
 
virtual TAnimalSupplyAnimalPtr (unsigned int a_index, unsigned int a_animal)
 Return the animal pointer for the give life stage and number. More...
 

Protected Member Functions

virtual void Run (int NoTSteps)
 
- Protected Member Functions inherited from Population_Manager_Base
 ~Population_Manager_Base ()=default
 

Protected Attributes

blitz::Array< double, 2 > m_development_degree_day
 The array to store the average max and std development time for each life stage, max and std time for reproducing. More...
 
int m_num_x_range
 The number of subpopulation in x range. More...
 
int m_num_y_range
 The number of subpopulation in y range. More...
 
int m_num_life_stage
 The number of life stages for the animal. More...
 
bool m_mul_hosts_flag
 Flag to show whether it has both winter and summer host. More...
 
int m_sub_w
 Variable to record the width of the subpopulation cell. More...
 
int m_sub_h
 Variable to record the height of the subpopulation cell. More...
 
blitz::Array< double, 2 > m_cell_popu_density
 Array for weighted population density in each subpopulation cell. More...
 
blitz::Array< double, 2 > m_cell_suitability
 Array for suitable value in each subpopulation cell. More...
 
blitz::Array< SubPopulation *, 2 > m_the_subpopulation_array
 Vector to store the all the pointers for the subpopulation object. More...
 
blitz::Array< double, 4 > m_short_move_mask
 Short distance movement mask. More...
 
blitz::Array< double, 4 > m_long_move_mask
 Long distance movement mask. More...
 
int m_max_long_distance
 The longest distance that the specieces can fly for long distance dispersal. More...
 
int m_peak_long_distance
 The distance for the peak amount of landing. More...
 
float m_scale_wind_speed
 The scale for wind. More...
 
float m_max_flying_wind_speed
 The larget wind speed for winged adults to fly. More...
 
int m_wind_speed_step_size
 The sampling step size for wind speed. More...
 
int m_wind_direction_num
 The number of wind directions. More...
 
int m_wind_speed_num
 The number of wind speed samples. More...
 
blitz::Array< int, 1 > m_wind_speed_lookup_table
 The look up table for wind speed index in the flying mask. More...
 
double m_max_short_distance
 The longest distance that the specieces can move for short distance dispersal. More...
 
int m_long_move_mask_x_num
 Variable to record the dimension of the long distance movement mask. - x. More...
 
int m_long_move_mask_y_num
 Variable to record the dimension of the long distance movement mask. - y. More...
 
int m_long_move_mask_x_num_half
 Variable to record the dimension of the short distance movement mask. - x. More...
 
int m_long_move_mask_y_num_half
 
blitz::Array< int, 1 > m_long_move_mask_x_num_half_array
 Array to store the number of cells for longest flying at different windspeed. More...
 
blitz::Array< int, 1 > m_long_move_mask_y_num_half_array
 
int m_short_move_mask_x_num
 
int m_short_move_mask_y_num
 Variable to record the dimension of the short distance movement mask. - y. More...
 
blitz::Array< double, 2 > m_accumu_degree_days
 Array for accumulated degree days for each life circle. More...
 
blitz::Array< int, 2 > m_index_new_old
 Array for index of the newest and oldest life stages. More...
 
int m_max_alive_days
 The longest alive day among all the life stages. More...
 
blitz::Array< double, 1 > m_lowest_temp_dev
 Lowest development temperatures for each life stage. This is the last step in each day. More...
 
blitz::Array< double, 2 > m_life_circle_path
 The life circle array. It could have more than one life circle paths. More...
 
bool m_hibernated_hatch_flag
 Flag variable to indicate hibernated eggs are ready to hatch. More...
 
blitz::Array< bool, 1 > m_first_flag_life_stage
 Array to track whether it is the first existence for a life stage. More...
 
blitz::Array< double, 1 > m_current_flying_array
 Temporal array for the flying subpopulation. More...
 
blitz::Array< double, 1 > m_current_landing_array
 Temporal array for the landing subpopulation. More...
 
std::vector< TTypesOfLandscapeElementm_winter_hosts_tole
 The vector to hold winter host landscape type. More...
 
std::vector< std::vector< int > > m_winter_hosts_tole_period
 The vector to store the exsiting period for winter host tole. More...
 
std::map< int, int > m_winter_hosts_tole_period_map
 The map to store the index for the winter host period. More...
 
std::vector< TTypesOfVegetationm_winter_hosts_tov
 The vector to hold winter host vegetation type. More...
 
std::vector< TTypesOfLandscapeElementm_summer_hosts_tole
 The vector to hold summer host landscape type. More...
 
std::vector< std::vector< int > > m_summer_hosts_tole_period
 The vector to store the exsiting period for summer host tole. More...
 
std::map< int, int > m_summer_hosts_tole_period_map
 The map to store the index for the summer host period. More...
 
std::vector< TTypesOfVegetationm_summer_hosts_tov
 The vector to hold sumber host vegetation type. More...
 
blitz::Array< double, 2 > m_current_mortality_array
 This a lookup table for the age and temperature dependent mortality rate. This is the same for the whole landscape for each day. Further cell specific related calculate should be done in the SubPopulation class. More...
 
blitz::Array< double, 2 > m_wind_direction_array
 The array to hold the wind directions. More...
 
blitz::Array< blitz::Array< double, 2 >, 2 > m_landing_masks
 The array to store the landing masks. The vector is indexed by the wind speed index first and the second index is the wind direction. Each element is a 2-D dimensional blitz array. More...
 
std::vector< int > m_flying_life_stage_array
 The vector to store the life stages that can fly. More...
 
std::vector< int > m_landing_life_stage_array
 The vector to store the life stage when a flying one lands, it could be different from the flying one, e.g., they drop theri wings. More...
 
std::vector< int > m_local_moving_life_stage_array
 The vector to store the life stags that can move locally. More...
 
std::ofstream m_subpopulation_base_prb_file
 The file for the storing the data. More...
 
std::vector< std::vector< SubPopulation * > > m_vec_subpopulation_pointers_polygon
 The vector used to store the pointers of all the subpopulation objects in each polygon. More...
 
bool m_summer_host_on
 The flag to enable summer host. More...
 
bool m_winter_host_on
 The flag to enalble winter host. More...
 
- Protected Attributes inherited from Population_Manager_Base
int SimH
 stores the simulation height More...
 
int SimW
 stores the simulation width More...
 
int SimHH
 stores the simulation height halved More...
 
int SimWH
 stores the simulation width halved More...
 
string m_SimulationName
 stores the simulation name More...
 
Landscapem_TheLandscape
 holds an internal pointer to the landscape More...
 
int m_ListNameLength {}
 the number of life-stages simulated in the population manager More...
 
const char * m_ListNames [32] {}
 A list of life-stage names. More...
 
std::string m_AORProbeFileName {"AOR_Probe.txt"}
 name of the AOR Probe file More...
 
std::string m_ProbeFileName {"Probe.res"}
 name of the Probe file More...
 
int m_step_counter_in_a_day
 Step counter in a day, this is used for the animals with finer step size other than one day. More...
 

Private Attributes

blitz::Array< double, 1 > m_total_num_each_stage
 Array to hold the total number of alive animals under different life stages in the whole landscape. More...
 
double m_size_cell
 The size of each subpopulation cell. More...
 
std::vector< std::vector< int > > m_index_next_life_stage
 The array to store the index for the ones go to the next life stage or die. -1 means nothing. More...
 
blitz::Array< double, 1 > m_lowest_temperature_die
 The lowest temperature that will cause the species die. More...
 
blitz::Array< double, 1 > m_highest_temperature_die
 The highest temperature that will cause the species die. More...
 
blitz::Array< double, 1 > m_optimal_temperature
 The optimal development temperature for the species. (Mortality rate = 0). More...
 

Friends

class Subpopulation
 

Additional Inherited Members

- Public Attributes inherited from Population_Manager_Base
Probe_DataTheProbe [100] = {nullptr}
 Holds a list of pointers to standard output probes. More...
 

Detailed Description

The class to handle all subpopulation-based ainimal population related matters in the whole landscape.

Constructor & Destructor Documentation

◆ SubPopulation_Population_Manager()

SubPopulation_Population_Manager::SubPopulation_Population_Manager ( Landscape L,
string  DevReproFile = "",
int  a_sub_w = 10,
int  a_sub_h = 10,
int  a_num_life_stage = 5,
int  a_max_long_dist = 1000,
int  a_peak_long_dist = 100,
float  a_scale_wind_speed = 1.1,
float  a_max_wind_speed = 16,
int  a_wind_direc_num = 8,
int  a_wind_speed_step_size = 2,
int  a_max_alive_day = 300 
)
62 {
63  //set the number of life stages
64  m_num_life_stage = a_num_life_stage;
66 
67  //set the number of longest life time in calendar days
68  m_max_alive_days = a_max_alive_day;
69 
70  //set the width and height of the grid
71  m_sub_w = a_sub_w;
72  m_sub_h = a_sub_h;
73 
74  //create the array to store the base development temperature for each life stage
76  //create the vector to store the indix for the old enough ones for next life stage or death
78  /*
79  for (int i=0; i<m_num_life_stage; i++){
80  m_index_next_life_stage.at(i).push_back(-1);
81  }
82  */
84 
85  //flying related parameters
86  //create the movement masks
91  m_max_long_distance = a_max_long_dist;
92  m_peak_long_distance = a_peak_long_dist;
93  m_scale_wind_speed = a_scale_wind_speed;
94  m_max_flying_wind_speed = a_max_wind_speed;
95  //the default wind direction number is 8
96  m_wind_direction_num = a_wind_direc_num;
97  m_wind_speed_step_size = a_wind_speed_step_size;
98  //get the sampling nubmers for the wind speed with the given the step size
100 
101  //resize the landing mask array
103 
104  //initialise the lookup table for puting the given wind speed to a range for the sake of speed. Each range is like [) with a 1m/s resolution.
106 
107  for(int i = 0; i<=ceil(m_max_flying_wind_speed); i++){
109  //cout<<m_wind_speed_lookup_table<<endl;
110  }
111 
112  //initialise the wind direction array
114  double temp_degree = 2*M_PI/m_wind_direction_num;
115  for (int i=0; i<m_wind_direction_num; i++){
116  m_wind_direction_array(i,0) = cos(temp_degree*i);
117  m_wind_direction_array(i,1) = sin(temp_degree*i);
118  }
119 
120  cout<<m_wind_direction_array<<endl;
121 
122  //convert the longest distance to the number of cells
123  //we need to make it with the largest distance multiplied by the incremental factor
126  for (int i=0; i<m_wind_speed_num;i++){
127  m_long_move_mask_x_num_half_array(i) = m_max_long_distance*pow(a_scale_wind_speed, i)/m_sub_w;
128  m_long_move_mask_y_num_half_array(i) = m_max_long_distance*pow(a_scale_wind_speed, i)/m_sub_h;
129  }
130 
131  //initialise the landing mask arrays
132  for (int i=0; i<m_wind_speed_num;i++)
133  for (int j=0; j<m_wind_direction_num; j++){
135  m_landing_masks(i, j) = 0.0;
136  cout<<m_landing_masks(i,j).shape()<<endl;
137  }
138 
139 
140  double temp_longest_factored = m_max_long_distance*pow(a_scale_wind_speed, m_wind_speed_num-1);
141  m_long_move_mask_x_num_half = temp_longest_factored/m_sub_w;
143  m_long_move_mask_y_num_half = temp_longest_factored/m_sub_h;
146  m_long_move_mask = 0.0;
148 
149  //hard coded
153  m_short_move_mask = 0.0;
154  if(DevReproFile==""){
155  readDevReproFile("Subpopulation/subpopulation_default_info.txt");
156  }
157  else{
158  readDevReproFile(DevReproFile);
159  }
160 
161  // Initialize the default population size to zero
164 
165  //set the number of cells
169 
170  //Initialize the weighted population density array with zero
172  m_cell_popu_density = 0.0;
173 
174  //Initialize the suitability for each cell with zero
176  m_cell_suitability = 0.0;
177 
178  //Initialize the pointer array for the subpopulation objects
181 
184 
185  //check if we need to open the base storing file
188  }
189 
190  m_hibernated_hatch_flag = false;
191 
192  //initialize the mortality related arrays
201 
202  //create the arrays for calculation of degree days
204  m_accumu_degree_days = 0.0;
205  m_index_new_old.resize(m_num_life_stage, 2); //the first is the newest index and the second is the oldest index
206  m_index_new_old = 0; //They start from zero from the beginning.
207 
208  //do the initialisation
209  if(DevReproFile=="") initialisePopulation();
210 }

References calLongMovementMask(), cfg_Subpopu_Base_Output_Used, initialisePopulation(), m_accumu_degree_days, m_cell_popu_density, m_cell_suitability, m_current_flying_array, m_current_landing_array, m_current_mortality_array, m_first_flag_life_stage, m_hibernated_hatch_flag, m_highest_temperature_die, m_index_new_old, m_index_next_life_stage, m_landing_masks, Population_Manager_Base::m_ListNameLength, m_long_move_mask, m_long_move_mask_x_num, m_long_move_mask_x_num_half, m_long_move_mask_x_num_half_array, m_long_move_mask_y_num, m_long_move_mask_y_num_half, m_long_move_mask_y_num_half_array, m_lowest_temp_dev, m_lowest_temperature_die, m_max_alive_days, m_max_flying_wind_speed, m_max_long_distance, m_num_life_stage, m_num_x_range, m_num_y_range, m_optimal_temperature, m_peak_long_distance, M_PI, m_scale_wind_speed, m_short_move_mask, m_short_move_mask_x_num, m_short_move_mask_y_num, m_size_cell, m_sub_h, m_sub_w, m_the_subpopulation_array, Population_Manager_Base::m_TheLandscape, m_total_num_each_stage, m_vec_subpopulation_pointers_polygon, m_wind_direction_array, m_wind_direction_num, m_wind_speed_lookup_table, m_wind_speed_num, m_wind_speed_step_size, openSubpopulationBaseProbeFile(), readDevReproFile(), Population_Manager_Base::SimH, Population_Manager_Base::SimW, Landscape::SupplyNumberOfPolygons(), and CfgBool::value().

◆ ~SubPopulation_Population_Manager()

SubPopulation_Population_Manager::~SubPopulation_Population_Manager ( void  )
virtual

SubPopulation_Manager Destructor.

212  {
213  for (int i=0; i<m_num_y_range; i++){
214  for (int j=0; j<m_num_x_range; j++){
215  if (m_the_subpopulation_array(i,j) != NULL){
216  delete m_the_subpopulation_array(i,j);
217  }
218  }
219  }
220 
223  //delete m_subpopulation_base_prb_file;
224  }
225 }

References cfg_Subpopu_Base_Output_Used, m_num_x_range, m_num_y_range, m_subpopulation_base_prb_file, m_the_subpopulation_array, and CfgBool::value().

Member Function Documentation

◆ addNewDay()

void SubPopulation_Population_Manager::addNewDay ( )

Add new day to the newest and oldest array.

628  {
629  m_index_new_old(blitz::Range::all(),0)+=1;
630  //Set it to zero when they reaches the end
631  for (int i=0; i < m_num_life_stage; i++){
632  if (m_index_new_old(i,0) >= m_max_alive_days){
633  m_index_new_old(i,0) = 0;
634  }
635  }
636 }

References m_index_new_old, m_max_alive_days, and m_num_life_stage.

Referenced by DoLast().

◆ calLandingCurve()

double SubPopulation_Population_Manager::calLandingCurve ( double  a_dis,
double  a_peak,
double  a_furthest 
)

The function to calculate the landing curve along the wind direction.

896  {
897  if(a_dis<=a_peak && a_dis>0){
898  return -1*a_dis*a_dis + 2*a_peak*a_dis;
899  }
900  if(a_dis>a_peak && a_dis <= a_furthest){
901  return a_peak*a_peak*pow(a_furthest-a_dis, 2)/pow(a_furthest-a_peak, 2);
902  }
903  return 0.0;
904 }

Referenced by calLongMovementMask().

◆ calLongMovementMask()

void SubPopulation_Population_Manager::calLongMovementMask ( void  )
virtual

Function to calculate the movement mask.

488  {
489 
490  //fstream tempoutputfilet("result.txt", ios::app); //debug code
491  for (int i=0; i<m_wind_speed_num; i++){
494  //we calculate the base mask without the consideration of the wind direction first
495  double temp_mask_value = calLandingCurve(sqrt(pow(x*m_sub_w,2)+pow(y*m_sub_h,2)), m_peak_long_distance*pow(m_scale_wind_speed, i), m_max_long_distance*pow(m_scale_wind_speed, i));
496  //apply the wind direction
497  for(int j=0; j<m_wind_direction_num; j++){
498  //calculate the cosine value between the direction of the cell and the wind direction
499  double temp_cos = -1;
500  if(x!=0 || y!=0)
502  if (temp_cos>0.000001){
503  m_long_move_mask(i, j, m_long_move_mask_y_num_half+y, m_long_move_mask_x_num_half+x) = temp_mask_value* temp_cos;
504  m_landing_masks(i, j)(m_long_move_mask_y_num_half_array(i)-y, m_long_move_mask_x_num_half_array(i)+x) = temp_mask_value * temp_cos;
505  }
506  else{
509  }
510 
511  //if (i==4 && j==0) tempoutputfilet<<temp_cos<<"/t"<<temp_mask_value<<endl; //debug code
512  }
513  }
514  }
515  }
516 
517  //normalise the masks
518  //fstream tempoutputfile("landing_mask.txt", ios::app);
519 
520  for (int i=0; i<m_wind_speed_num; i++){
521  for (int j=0; j<m_wind_direction_num; j++){
522  //cout<<m_landing_masks<<endl;
523  m_landing_masks(i, j) /= sum(m_landing_masks(i,j));
524  double min_value = 0.1/double(m_landing_masks(i,j).shape()(0)*m_landing_masks(i,j).shape()(1));
525  for (int k=0; k<m_landing_masks(i,j).shape()(0);k++){
526  for (int l=0; l<m_landing_masks(i,j).shape()(1);l++){
527  if(m_landing_masks(i, j)(k,l)<=min_value){
528  m_landing_masks(i, j)(k,l) = 0;
529  }
530  }
531  }
532  m_landing_masks(i, j) /= sum(m_landing_masks(i,j));
533  //tempoutputfile<<m_landing_masks(i,j)<<endl;
534  //cout<<i<<j<<sum(m_landing_masks(i,j))<<endl;
535  //cout<<m_landing_masks(i,j)<<endl;
536  }
537  }
538  //tempoutputfile.close();
539 
540  /* not used
541  blitz::Array<double, 1> mean_vector_temp (2);
542  mean_vector_temp = 0;
543  blitz::Array<double, 2> covariance_temp (2, 2);
544  covariance_temp = 1,0,0,1;
545 
546  //We first calculate the long distance movement masks.
547 
548  //Get the center of the mask.
549  double center_x = (m_long_move_mask_x_num-1)/2;
550  double center_y = (m_long_move_mask_y_num-1)/2;
551 
552  //Temporary location array
553  blitz::Array<double, 2> temp_local_array(m_long_move_mask_x_num, m_long_move_mask_y_num);
554  blitz::firstIndex i;
555  blitz::secondIndex j;
556  //temp_local_array(i, blitz::Range::all())=j;
557  blitz::thirdIndex k;
558  blitz::fourthIndex l;
559 
560  m_long_move_mask_y_num = 0;
561  */
562  //m_long_move_mask(blitz::Range::all(), blitz::Range::all(), 0, 0) = 1.0;
563  //std::cout << m_long_move_mask << std::endl;
564 }

References calLandingCurve(), m_landing_masks, m_long_move_mask, m_long_move_mask_x_num_half, m_long_move_mask_x_num_half_array, m_long_move_mask_y_num_half, m_long_move_mask_y_num_half_array, m_max_long_distance, m_peak_long_distance, m_scale_wind_speed, m_sub_h, m_sub_w, m_wind_direction_array, m_wind_direction_num, and m_wind_speed_num.

Referenced by SubPopulation_Population_Manager().

◆ calNextStage()

int SubPopulation_Population_Manager::calNextStage ( int  current_stage,
double  density = 1 
)
virtual

Return the next life stage for the given life stage.

Return the next life stage based on the density

Reimplemented in Aphid_Population_Manager.

659  {
660  int next_stage;
661 
662  //if(current_stage == 2) //to adult, randomly choose female or male
663  //{
664  // next_stage = g_rand_uni()>0.5 ? current_stage+1 :current_stage+2;
665  //}
666  //else
667  if (current_stage == 3 || current_stage == 4) // already adult, die next
668  {
669  next_stage = -1;
670  }
671  else if(current_stage<2)// otherwise next life stage
672  {
673  next_stage = current_stage+1;
674  }
675  else{
676  if(density>=0){
677  if(density<cfg_Subpopu_Density_Threshold.value()){
678  next_stage = 4;
679  }
680  else{
681  next_stage = 3; //too crowded, winged ones
682  }
683  }
684  else{
685  next_stage=-1;
686  }
687  }
688  return next_stage;
689 }

References cfg_Subpopu_Density_Threshold, and CfgFloat::value().

Referenced by SubPopulation::doDevelopment().

◆ calOffspringStage()

int SubPopulation_Population_Manager::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 
)
virtual

Calculate the offspring life stage.

Reimplemented in Aphid_Population_Manager.

1117  {
1118  if(current_stage == 3 || current_stage == 4){
1119  *offspring_num = 1;
1120  return 0;
1121  }
1122  *offspring_num = 0;
1123  return -1;
1124 }

Referenced by Aphid::doReproduction(), and SubPopulation::doReproduction().

◆ CreateObjects()

SubPopulation * SubPopulation_Population_Manager::CreateObjects ( TAnimal pvo,
struct_SubPopulation data,
int  number 
)
976  {
977  SubPopulation* new_Sub;
978  new_Sub = new SubPopulation(data->x, data->y, data->L, data->NPM, data->empty_flag, data->index_x, data->index_y, data->starting_suitability, data->starting_popu_density, number);
979  // always 0 since it is a subpopulation model
980 
981  //the simulation starts from Jan, we only have some eggs from the beginning.
982  if(number > 0){
983  //updateWholePopulationArray(toa_Egg, number);
984  new_Sub -> addAnimalNumGivenStageColumn(tos_Egg, 0, number);
985  }
986  return new_Sub;
987 }

References struct_SubPopulation::empty_flag, struct_SubPopulation::index_x, struct_SubPopulation::index_y, struct_SubPopulation::L, struct_SubPopulation::NPM, struct_SubPopulation::starting_popu_density, struct_SubPopulation::starting_suitability, tos_Egg, struct_SubPopulation::x, and struct_SubPopulation::y.

Referenced by initialisePopulation().

◆ doDevelopment()

void SubPopulation_Population_Manager::doDevelopment ( )

Function to make the development for all the subpopulation object.

566  {
567  double current_temp = g_landscape_p->SupplyTemp();
568  double current_degree_days = 0;
569  //std::cout<<m_index_next_life_stage<<endl;
570  //m_index_next_life_stage = -1;
571 
572  //update hibernate flag
575  for (int i=0; i < m_num_life_stage; i++){
576  //clear the data from yesterday
577  m_index_next_life_stage.at(i).clear();
578  //First, calculate the degree days for today
579  //THe degree days can only be accumulated when the curent temperature is higher than the lowest development temperature
580  //for over winter eggs, no need to accumulate degree days
581  if (i==0 && m_development_degree_day(0, i) < 0) {
583  m_index_next_life_stage.at(i).push_back(0); //for the overwintering eggs, they always stay at zero.
584  }
585  continue;
586  }
587 
588  else{
589  if (current_temp > m_lowest_temp_dev(i)){
590  current_degree_days = current_temp - m_lowest_temp_dev(i);
591  //decide which ones should be added
592  if(m_index_new_old(i,0)<m_index_new_old(i,1)){
593  m_accumu_degree_days(i, blitz::Range(0, m_index_new_old(i, 0))) += current_degree_days;
594  m_accumu_degree_days(i, blitz::Range(m_index_new_old(i,1), blitz::toEnd)) += current_degree_days;
595  }
596  else if(m_index_new_old(i, 0)==m_index_new_old(i, 1)){
597  m_accumu_degree_days(i, m_index_new_old(i, 1)) += current_degree_days;
598  }
599  else{
600  m_accumu_degree_days(i, blitz::Range(m_index_new_old(i, 1), m_index_new_old(i, 0))) += current_degree_days;
601  }
602  //check whether they need to go to next life stage or die
603  while(isEnoughNextLifeStage(i)){
604  m_index_next_life_stage.at(i).push_back(m_index_new_old(i, 1));
605  //set it to zero
606  m_accumu_degree_days(i, m_index_new_old(i, 1)) = 0.0;
607  m_index_new_old(i, 1) += 1;
608  //when it reaches the end, set it to zero
609  if (m_index_new_old(i,1) >= m_max_alive_days){
610  m_index_new_old(i,1) = 0;
611  }
612  }
613  }
614  }
615  }
616  //std::cout << current_temp <<endl;
617  //std::cout << m_index_new_old <<endl;
618  //for (int temp_next:m_index_next_life_stage.at(5))
619  // std::cout << temp_next <<endl;
620  //std::cout << m_accumu_degree_days<<endl;
621  //std::cout << m_current_mortality_array << endl;
622 }

References g_landscape_p, isEnoughNextLifeStage(), m_accumu_degree_days, m_development_degree_day, m_hibernated_hatch_flag, m_index_new_old, m_index_next_life_stage, m_lowest_temp_dev, m_max_alive_days, m_num_life_stage, Population_Manager_Base::m_TheLandscape, Landscape::SupplyMonth(), and Landscape::SupplyTemp().

Referenced by DoLast().

◆ DoFirst()

void SubPopulation_Population_Manager::DoFirst ( void  )
virtual
691  {
695  double current_wind_speed = g_landscape_p->SupplyWind();
696  if (current_wind_speed<m_max_flying_wind_speed){
697  relocatePopulation(); //let the species move when it is not too windy
698  }
699 }

References doParasitoidDevelopment(), g_landscape_p, m_max_flying_wind_speed, relocatePopulation(), Landscape::SupplyWind(), updateDevelopmentSeason(), and updateMortalityArray().

Referenced by Run().

◆ doFlying()

void SubPopulation_Population_Manager::doFlying ( int  ind,
int  index_x,
int  index_y 
)

The function to fly the winged adults.

708  {
709 
710  int life_stage = m_flying_life_stage_array.at(ind);
711  int landing_life_stage = m_landing_life_stage_array.at(ind);
712 
713  m_current_flying_array = m_the_subpopulation_array(index_y, index_x)->getFlyingArray(ind);
714 
715  //get the wind direction and speed
716  int current_wind_direction = g_landscape_p->SupplyWindDirection();
717  double current_wind_speed = g_landscape_p->SupplyWind();
718  int current_wind_speed_index = m_wind_speed_lookup_table(int(current_wind_speed));
719  //double flying_total_num = m_the_subpopulation_array(index_y,index_x)->getNumforOneLifeStage(life_stage);
720  double flying_total_num = sum(m_current_flying_array);
721  if(flying_total_num>0){
722  double landed_num = 0;
723  int temp_index_mask_x = -1;
724  int temp_index_mask_y = -1;
725 
726  double temp_not_landed_num = 0; //land the number samller than 1 to the peak cell
727  int temp_peak_x = -1;
728  int temp_peak_y = 0;
729  double temp_peak = -9999999;
730  for (int x = index_x-m_long_move_mask_x_num_half_array(current_wind_speed_index); x<=index_x+m_long_move_mask_x_num_half_array(current_wind_speed_index);x++){
731  //out of range for x
732  temp_index_mask_x++;
733  if(x<0 || x>=m_num_x_range){
734  continue;
735  }
736  temp_index_mask_y = -1;
737  for (int y = index_y-m_long_move_mask_y_num_half_array(current_wind_speed_index); y<=index_y+m_long_move_mask_y_num_half_array(current_wind_speed_index);y++){
738  //out of range for y
739  landed_num = 0;
740  temp_index_mask_y++;
741  if (y<0 || y>=m_num_y_range){
742  continue;
743  }
744 
745  //landing them
746  if(m_the_subpopulation_array(y,x) !=NULL){
747  if(m_landing_masks(current_wind_speed_index, current_wind_direction)(temp_index_mask_y,temp_index_mask_x)>0.00001 && m_cell_suitability(y, x) ==1){
748  if (m_landing_masks(current_wind_speed_index, current_wind_direction)(temp_index_mask_y,temp_index_mask_x)>temp_peak){
749  temp_peak = m_landing_masks(current_wind_speed_index, current_wind_direction)(temp_index_mask_y,temp_index_mask_x);
750  temp_peak_x = x;
751  temp_peak_y = y;
752  }
753  //m_current_landing_array=m_landing_masks(current_wind_speed_index, current_wind_direction)(temp_index_mask_x,temp_index_mask_y)*m_current_flying_array;
754  landed_num = m_landing_masks(current_wind_speed_index, current_wind_direction)(temp_index_mask_y, temp_index_mask_x)*flying_total_num;
755  if(landed_num>=1){
756  //int temp_landing_age = m_index_new_old(landing_life_stage, 0) - 1;
757  //if (temp_landing_age < 0) temp_landing_age = m_max_alive_days - 1;
758  int temp_landing_age = m_index_new_old(landing_life_stage, 0);
759 
760 
761  //enable local movement
762  if(m_the_subpopulation_array(y,x)->getTotalSubpopulation()<=0){
763  m_the_subpopulation_array(y,x)->setFlyLocalMovFlag(true);
764  }
765  m_the_subpopulation_array(y,x)->addAnimalNumGivenStageColumn(landing_life_stage, temp_landing_age, landed_num);
766  }
767  else if(landed_num >0 && landed_num <1){
768  temp_not_landed_num += landed_num;
769  }
770  }
771  }
772  }
773  }
774 
775  //land the no landing ones to the peak place
776  if (temp_not_landed_num >=1 && temp_peak_x >=0 && m_the_subpopulation_array(temp_peak_y,temp_peak_x)->isFarm()&& m_cell_suitability(temp_peak_y, temp_peak_x) ==1){
777  //cout<<"I am landed: "<<landing_life_stage<<endl;
778  //int temp_landing_age = m_index_new_old(landing_life_stage, 0) - 1;
779  //if (temp_landing_age < 0) temp_landing_age = m_max_alive_days - 1;
780  int temp_landing_age = m_index_new_old(landing_life_stage, 0);
781 
782  if(m_the_subpopulation_array(temp_peak_y,temp_peak_x)->getTotalSubpopulation()<=0){
783  m_the_subpopulation_array(temp_peak_y,temp_peak_x)->setFlyLocalMovFlag(true);
784  }
785  m_the_subpopulation_array(temp_peak_y,temp_peak_x)->addAnimalNumGivenStageColumn(landing_life_stage, temp_landing_age, temp_not_landed_num);
786  }
787  m_the_subpopulation_array(index_y, index_x)->removeAnimalNumGivenStage(life_stage);
788  //m_current_flying_array *= -1;
789  //m_current_flying_array = ceil(m_current_flying_array);
790  //m_the_subpopulation_array(index_y, index_x)->addAnimalNumGivenStageColumn(life_stage,m_index_new_old(life_stage, 1), m_current_flying_array(i)); //land them in the old one
791  //for (int i = 0; i<m_max_alive_days;){
792  // if(m_current_flying_array(i)>0){
793  // double removed_number = -1*m_current_flying_array(i);
794  // m_the_subpopulation_array(index_y, index_x)->addAnimalNumGivenStageColumn(life_stage, i, removed_number);
795  // }
796  //}
797  }
798 }

References g_landscape_p, m_cell_suitability, m_current_flying_array, m_flying_life_stage_array, m_index_new_old, m_landing_life_stage_array, m_landing_masks, m_long_move_mask_x_num_half_array, m_long_move_mask_y_num_half_array, m_num_x_range, m_num_y_range, m_the_subpopulation_array, m_wind_speed_lookup_table, Landscape::SupplyWind(), and Landscape::SupplyWindDirection().

Referenced by relocatePopulation().

◆ DoLast()

void SubPopulation_Population_Manager::DoLast ( )
virtual
478  {
479  doDevelopment();
481  addNewDay();
483  //store results if it is needed
486  }
487 }

References addNewDay(), doDevelopment(), doSpecicesLastThing(), m_subpopulation_base_prb_file, subpopuBaseOutputProbe(), and updateWholePopulation().

Referenced by Run().

◆ doLocalMovement()

void SubPopulation_Population_Manager::doLocalMovement ( int  index_x,
int  index_y,
double  proportion 
)

The function for local movement.

844  {
845  for( int s = 0; s<m_local_moving_life_stage_array.size(); s++){
846  if (m_the_subpopulation_array(index_y, index_x)->getNumforOneLifeStage(m_local_moving_life_stage_array.at(s)) && m_the_subpopulation_array(index_y, index_x)->isNewlyLanded()){
847  bool temp_successed_flag = false;
848  for (int i = index_x-1; i<=index_x+1; i++){
849  if(i<0 || i>=m_num_x_range){
850  continue;
851  }
852  for (int j = index_y-1; j<=index_y+1; j++){
853  if(j<0 || j>=m_num_y_range){
854  continue;
855  }
856  if(m_the_subpopulation_array(j, i)->getTotalSubpopulation()<=0 && m_cell_suitability(j, i)>0){
857  //move half to the neighbor
858  //cout<<"I am moving to a neighbor: "<<endl;
859  for (int k=0; k<m_max_alive_days; k++){
860 
861  double mov_num = m_the_subpopulation_array(index_y, index_x)->removeAnimalPortionGivenStageColumn(s, k, proportion);
862  if (mov_num > 0){
863  m_the_subpopulation_array(j,i)->addAnimalFromAnotherCell(s, k, mov_num);
864  }
865  }
866  temp_successed_flag = true;
867  m_the_subpopulation_array(index_y, index_x)->setFlyLocalMovFlag(false);
868  break;
869  }
870 
871  }
872  if(temp_successed_flag) break;
873  }
874  }
875  }
876 
877 }

References m_cell_suitability, m_local_moving_life_stage_array, m_max_alive_days, m_num_x_range, m_num_y_range, and m_the_subpopulation_array.

◆ doParasitoidDevelopment()

virtual void SubPopulation_Population_Manager::doParasitoidDevelopment ( )
inlinevirtual

The function for parasitoid calculation, it does nothing in this base class.

336 {;};

Referenced by DoFirst().

◆ doSpecicesLastThing()

virtual void SubPopulation_Population_Manager::doSpecicesLastThing ( )
inlinevirtual

The special last thing for the drived species.

338 {;}

Referenced by DoLast().

◆ GetLiveArraySize()

unsigned SubPopulation_Population_Manager::GetLiveArraySize ( int  a_listindex)
virtual

Must be re-implemented in descendent classes. Gets the number of 'live' objects.

Reimplemented from Population_Manager_Base.

410  {
411  return unsigned(supplyAllPopulationGivenStage(a_listindex));
412 }

References supplyAllPopulationGivenStage().

◆ GetPopulationSize()

virtual unsigned SubPopulation_Population_Manager::GetPopulationSize ( int  a_listindex)
inlinevirtual

Must be re-implemented in descendent classes.

Reimplemented from Population_Manager_Base.

324  {
325  return supplyAllPopulationGivenStage(a_listindex);
326  }

References supplyAllPopulationGivenStage().

◆ getSubpopulationInCellLifeStage()

double SubPopulation_Population_Manager::getSubpopulationInCellLifeStage ( int  x_indx,
int  y_indx,
int  a_life_stage 
)

Supply the subpopulation size at the given life stage in the given cell.

331  {
332  if(m_the_subpopulation_array(y_indx, x_indx)==NULL){
333  return 0;
334  }
335  return m_the_subpopulation_array(y_indx, x_indx)->getNumforOneLifeStage(a_life_stage);
336 }

References m_the_subpopulation_array.

◆ getSuitabilityInCell()

double SubPopulation_Population_Manager::getSuitabilityInCell ( int  x_indx,
int  y_indx 
)
inline

Supply the suitability in the given cell.

238 {return m_cell_suitability(y_indx, x_indx);}

References m_cell_suitability.

Referenced by Aphid::doMovement().

◆ getTotalSubpopulationInCell()

double SubPopulation_Population_Manager::getTotalSubpopulationInCell ( int  x_indx,
int  y_indx 
)

Supply the total subpopulation size in the given cell.

324  {
325  if(m_the_subpopulation_array(y_indx, x_indx)==NULL){
326  return 0;
327  }
328  return m_the_subpopulation_array(y_indx, x_indx)->getTotalSubpopulation();
329 }

References m_the_subpopulation_array.

Referenced by Aphid::doMovement().

◆ initialisePopulation()

void SubPopulation_Population_Manager::initialisePopulation ( )
virtual

The function to initialise the population when starting the simulation which requires rewritten in the derived class.

Reimplemented in Aphid_Population_Manager.

906  {
907  //this is one a general subpopulation species
908  m_ListNames[0]="Egg";
909  m_ListNames[1]="Larva";
910  m_ListNames[2]="Pupa";
911  m_ListNames[3]="Adult";
912  m_ListNames[4]="Adult wingless";
913  m_SimulationName = "General Subpopulation Simulation";
914 
915  //suppose we only have one type of host
916  //m_summer_hosts_tole.push_back(tole_Field);
917  //m_mul_hosts_flag = false; //no host changes
918  readHosts("Subpopulation/subpopulation_default_host.txt");
919 
920  //This needs to be changed in the decent class
921  m_flying_life_stage_array.push_back(3);
922  m_landing_life_stage_array.push_back(4); //by default, they don't drop theri wings
923  m_local_moving_life_stage_array.push_back(3);
924 
925  //we add 1000 eggs to the grid when it is a suitable one
926  int index_cell_i = 0;
927  int index_cell_j = 0;
929  sp = new struct_SubPopulation;
930  sp->NPM = this;
931  sp->L = g_landscape_p;
932  //creat the aphid in each cell
933  for (int i=0; i<SimW; i=i+m_sub_w) //x, but coloumn number
934  {
935  index_cell_j = 0;
936  for(int j=0; j<SimH; j=j+m_sub_h) //y, but row number
937  {
938  sp->x = i+m_sub_w/2.0; //use the center of the cell as the location;
939  sp->y = j+m_sub_h/2.0;;
940  sp->w = m_sub_w;
941  sp->h = m_sub_h;
942  sp->NPM = this;
943  sp->empty_flag = false;
944  sp->index_x = index_cell_i;
945  sp->index_y = index_cell_j;
946  TTypesOfLandscapeElement current_landtype = g_landscape_p->SupplyElementType(i, j);
947  sp->starting_popu_density = &(m_cell_popu_density(index_cell_j, index_cell_i));
948  sp->starting_suitability = &(m_cell_suitability(index_cell_j, index_cell_i));
949 
950  double current_biomass = g_landscape_p->SupplyVegBiomass(i, j);
951 
952  //for the default subpopulation species, we only have one host
953  bool current_winter_host_flag = isSummerHostTole(current_landtype);
954  if(current_winter_host_flag>0){
955  //sp->starting_suitability = 1;
956  m_the_subpopulation_array(index_cell_j, index_cell_i) = CreateObjects(NULL, sp, 1000);
957  m_cell_suitability(index_cell_j, index_cell_i) = 1;
958  }
959  else{
960  sp->empty_flag = true;
961  //sp->starting_suitability = 0;
962  m_the_subpopulation_array(index_cell_j, index_cell_i) = CreateObjects(NULL, sp, 0);
963  m_cell_suitability(index_cell_j, index_cell_i) = 0;
964  }
965  index_cell_j++;
966 
967  //add the pointer to its belonging polygon
968  int temp_poly_id = m_TheLandscape->SupplyPolyRefIndex(sp->x, sp->y);
969  m_vec_subpopulation_pointers_polygon.at(temp_poly_id).push_back(m_the_subpopulation_array(index_cell_j, index_cell_i));
970  }
971  index_cell_i++;
972  }
973  delete sp;
974 }

References CreateObjects(), struct_SubPopulation::empty_flag, g_landscape_p, struct_SubPopulation::h, struct_SubPopulation::index_x, struct_SubPopulation::index_y, isSummerHostTole(), struct_SubPopulation::L, m_cell_popu_density, m_cell_suitability, m_flying_life_stage_array, m_landing_life_stage_array, Population_Manager_Base::m_ListNames, m_local_moving_life_stage_array, Population_Manager_Base::m_SimulationName, m_sub_h, m_sub_w, m_the_subpopulation_array, Population_Manager_Base::m_TheLandscape, m_vec_subpopulation_pointers_polygon, struct_SubPopulation::NPM, readHosts(), Population_Manager_Base::SimH, Population_Manager_Base::SimW, struct_SubPopulation::starting_popu_density, struct_SubPopulation::starting_suitability, Landscape::SupplyElementType(), Landscape::SupplyPolyRefIndex(), Landscape::SupplyVegBiomass(), struct_SubPopulation::w, struct_SubPopulation::x, and struct_SubPopulation::y.

Referenced by SubPopulation_Population_Manager().

◆ isEnoughNextLifeStage()

bool SubPopulation_Population_Manager::isEnoughNextLifeStage ( int  a_life_stage)
virtual

The funcition to check whether it is read for the next life stage.

Reimplemented in Aphid_Population_Manager.

624  {
625  return m_accumu_degree_days(a_life_stage, m_index_new_old(a_life_stage,1))>=m_development_degree_day(0, a_life_stage);
626 }

References m_accumu_degree_days, m_development_degree_day, and m_index_new_old.

Referenced by doDevelopment().

◆ isSummerHostTole()

bool SubPopulation_Population_Manager::isSummerHostTole ( TTypesOfLandscapeElement  a_ele)

Test whether it is a summer host tole.

810  {
811  if (std::count(m_summer_hosts_tole.begin(), m_summer_hosts_tole.end(), a_ele)){
812  return true;
813  }
814 
815  else {
816  return false;
817  }
818 }

References count, and m_summer_hosts_tole.

Referenced by SubPopulation::calSuitability(), initialisePopulation(), and Aphid_Population_Manager::initialiseSimWithEggs().

◆ isSummerHostTov()

bool SubPopulation_Population_Manager::isSummerHostTov ( TTypesOfVegetation  a_ele)

Test whether it is a summer host tov.

830  {
831  if (std::count(m_summer_hosts_tov.begin(), m_summer_hosts_tov.end(), a_ele)){
832  return true;
833  }
834 
835  else {
836  return false;
837  }
838 }

References count, and m_summer_hosts_tov.

Referenced by SubPopulation::calSuitability().

◆ isWinterHostTole()

bool SubPopulation_Population_Manager::isWinterHostTole ( TTypesOfLandscapeElement  a_ele)

Test whether it is a winter host tole.

800  {
801  if (std::count(m_winter_hosts_tole.begin(), m_winter_hosts_tole.end(), a_ele)){
802  return true;
803  }
804 
805  else {
806  return false;
807  }
808 }

References count, and m_winter_hosts_tole.

Referenced by Aphid_Population_Manager::initialiseSimWithEggs().

◆ isWinterHostTov()

bool SubPopulation_Population_Manager::isWinterHostTov ( TTypesOfVegetation  a_ele)

Test whether it is a winter host tov.

820  {
821  if (std::count(m_winter_hosts_tov.begin(), m_winter_hosts_tov.end(), a_ele)){
822  return true;
823  }
824 
825  else {
826  return false;
827  }
828 }

References count, and m_winter_hosts_tov.

◆ openSubpopulationBaseProbeFile()

bool SubPopulation_Population_Manager::openSubpopulationBaseProbeFile ( )

Open the storing file.

394  {
397  g_msg->Warn( WARN_FILE, "SubPopulationPopulation_Manager::openSubpopulationBaseProbeFile(): ""Unable to open probe file",cfg_Subpopu_Base_Output_Filename.value() );
398  exit( 1 );
399  }
400 
401  #ifdef SubpopulationSpatialResult
405  #endif
406 
407  return true;
408 }

References cfg_Subpopu_Base_Output_Filename, g_msg, m_num_life_stage, m_num_x_range, m_num_y_range, m_subpopulation_base_prb_file, CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Aphid_Population_Manager::Aphid_Population_Manager(), and SubPopulation_Population_Manager().

◆ readDevReproFile()

void SubPopulation_Population_Manager::readDevReproFile ( string  inputfile)

Function to read the development time and lifestage.

414  {
415  ifstream ist(inputfile, ios::in);
416  int row_num;
417  ist >> row_num;
418  ist >> m_num_life_stage;
420 
421  //load the name for life stages
422  for(int j=0; j<m_num_life_stage;j++){
423  string temp_name;
424  ist >> temp_name;
425  }
426 
427  //m_max_alive_days = -1;
428 
429  //load the development and reproducing degree days
430  for (int i=0; i<row_num-1; i++){
431  for(int j=0; j<m_num_life_stage;j++){
432  int temp_int;
433  ist >> temp_int;
434  m_development_degree_day(i,j)=temp_int;
435  //cout<<m_activities_priorities(i,j);
436  //if(i==0){
437  // if (m_max_alive_days < temp_int){
438  // m_max_alive_days = temp_int;
439  // }
440  //}
441  }
442  }
443 
444  //load the lowest development temperature
445  for (int j=0; j<m_num_life_stage; j++){
446  double temp_dou;
447  ist >> temp_dou;
448  m_lowest_temp_dev(j) = temp_dou;
449  }
450 }

References m_development_degree_day, m_lowest_temp_dev, and m_num_life_stage.

Referenced by SubPopulation_Population_Manager().

◆ readHosts()

void SubPopulation_Population_Manager::readHosts ( string  a_file_name)
virtual

The fuction to read the host lists for aphid.

1006  {
1007 
1008  //reset all the vectors
1009  m_winter_hosts_tole.clear();
1012  m_winter_hosts_tov.clear();
1013  m_summer_hosts_tole.clear();
1016  m_summer_hosts_tov.clear();
1017 
1018  ifstream ist(a_file_name, ios::in);
1019  string one_line;
1020  int host_id;
1021  int month_id;
1022 
1023  //get the host switch flag
1024  getline(ist, one_line);
1025  istringstream iss(one_line);
1026  int summer_winter;
1027  iss >> summer_winter;
1028  if (summer_winter==1) {
1029  m_mul_hosts_flag=false;
1030  m_summer_host_on=true;
1031  m_winter_host_on=false;
1032  }//only summer hosts are uses since the species does not switch hosts
1033 
1034  if (summer_winter==2) {
1035  m_mul_hosts_flag=true;
1036  m_winter_host_on=true;
1037  m_summer_host_on=false;
1038  }//start with winter host since the simulation starts from jan.
1039 
1040  //get the summer host tole
1041  getline(ist, one_line);
1042  iss = istringstream(one_line);
1043  int temp_index = -1;
1044  while(iss>>host_id){
1045  temp_index += 1;
1046  if(host_id>=0){
1047  m_summer_hosts_tole.push_back(TTypesOfLandscapeElement(host_id));
1048  m_summer_hosts_tole_period_map.insert({TTypesOfLandscapeElement(host_id), temp_index});
1049  }
1050  }
1051 
1052  //get the summer host tole period
1053  getline(ist, one_line);
1054  iss = istringstream(one_line);
1055  while(iss>>month_id){
1056  if(host_id<0){
1057  break;
1058  }
1059  else{
1060  std::vector<int> temp(2, 1);
1061  temp.at(0) = month_id;
1062  iss>>month_id;
1063  temp.at(1) = month_id;
1064  m_summer_hosts_tole_period.push_back(temp);
1065  }
1066  }
1067 
1068  //get the summer host tov
1069  getline(ist, one_line);
1070  iss = istringstream(one_line);
1071  string veg_str;
1072  while(iss>>veg_str){
1073  if(veg_str!="NONE"){
1074  m_summer_hosts_tov.push_back(g_farmmanager->TranslateVegCodes(veg_str));
1075  }
1076  }
1077 
1078  //get the winter host tole
1079  getline(ist, one_line);
1080  iss = istringstream(one_line);
1081  temp_index = -1;
1082  while(iss>>host_id){
1083  temp_index += 1;
1084  if(host_id>=0){
1085  m_winter_hosts_tole.push_back(TTypesOfLandscapeElement(host_id));
1086  m_winter_hosts_tole_period_map.insert({TTypesOfLandscapeElement(host_id), temp_index});
1087  }
1088  }
1089 
1090  //get the winter host tole period
1091  getline(ist, one_line);
1092  iss = istringstream(one_line);
1093  while(iss>>month_id){
1094  if(host_id<0){
1095  break;
1096  }
1097  else{
1098  std::vector<int> temp(2, 1);
1099  temp.at(0) = month_id;
1100  iss>>month_id;
1101  temp.at(1) = month_id;
1102  m_winter_hosts_tole_period.push_back(temp);
1103  }
1104  }
1105 
1106  //get the winter host tov
1107  getline(ist, one_line);
1108  iss = istringstream(one_line);
1109  while(iss>>veg_str){
1110  if(veg_str!="NONE"){
1111  m_winter_hosts_tov.push_back(g_farmmanager->TranslateVegCodes(veg_str));
1112  }
1113  }
1114 
1115 }

References g_farmmanager, m_mul_hosts_flag, m_summer_host_on, m_summer_hosts_tole, m_summer_hosts_tole_period, m_summer_hosts_tole_period_map, m_summer_hosts_tov, m_winter_host_on, m_winter_hosts_tole, m_winter_hosts_tole_period, m_winter_hosts_tole_period_map, m_winter_hosts_tov, and FarmManager::TranslateVegCodes().

Referenced by Aphid_Population_Manager::initialisePopulation(), and initialisePopulation().

◆ relocatePopulation()

void SubPopulation_Population_Manager::relocatePopulation ( void  )

Relocate the population in each cell based on the suitability and movement ability.

452  {
453 
454  //local movement
455  /*
456  for(int ind_y=0; ind_y < m_num_y_range; ind_y++){
457  for(int ind_x=0; ind_x <m_num_x_range; ind_x++){
458  if(m_the_subpopulation_array(ind_y, ind_x) != NULL){
459  doLocalMovement(ind_x, ind_y, 0.5);
460  }
461  }
462  }*/
463 
464  //let winged aphihds to fly
465  for(int ind_y=0; ind_y < m_num_y_range; ind_y++){
466  for(int ind_x=0; ind_x <m_num_x_range; ind_x++){
467  if(m_the_subpopulation_array(ind_y, ind_x) != NULL){
468  for(int i=0; i<m_flying_life_stage_array.size(); i++){
469  //if(m_the_subpopulation_array(ind_y, ind_x)->getFlyingNum(i)>0){
470  doFlying(i, ind_x, ind_y);
471  //}
472  }
473  }
474  }
475  }
476 }

References doFlying(), m_flying_life_stage_array, m_num_x_range, m_num_y_range, and m_the_subpopulation_array.

Referenced by DoFirst().

◆ Run()

void SubPopulation_Population_Manager::Run ( int  NoTSteps)
protectedvirtual

This is the main scheduling method for the population manager using subpopulation model.

Reimplemented from Population_Manager_Base.

256  {
257 
258  for ( int TSteps = 0; TSteps < NoTSteps; TSteps++ )
259  {
260  cout<<"Day "<<m_TheLandscape->SupplyDayInYear() << endl;
261  #ifdef APHID_DEBUG
262  m_num_killed_by_parasitoid=0;
263  m_num_parasitoid=0;
264  m_num_parasitoid_egg=0;
265  m_num_new_parasitoid_egg_daily=0;
266  #endif
267  DoFirst();
268  for (int i = 0; i < m_num_y_range; i++){
269  //parallel_for(m_num_x_range[&](int start, int end){
270  for (int j = 0; j < m_num_x_range; j++){
271  if(m_the_subpopulation_array(i,j)!=NULL){
272  m_the_subpopulation_array(i,j)->BeginStep();
273  }
274  }
275  }
276  // call the step-method of all objects
277  for (int i = 0; i < m_num_y_range; i++){
278  //parallel_for(m_num_x_range[&](int start, int end){
279  for (int j = 0; j < m_num_x_range; j++){
280  if(m_the_subpopulation_array(i,j)!=NULL){
281  SubPopulation* temp_pointer = m_the_subpopulation_array(i,j);
282  m_the_subpopulation_array(i,j)->Step();
283  }
284  else {
285  std::cout<<"NULL"<<endl;
286  }
287  }
288  }
289  DoLast();
290 
291  #ifdef __APHID_CALIBRATION
293  #endif
294 
295  #ifdef APHID_BIOMASS_DEBUG
296  ofstream bio_file;
297  bio_file.open("biomass.txt", ios::app );
298 
299  for (int i = 0; i<2200; i++){
301  //bio_file<<g_landscape_p->SupplyVegPhase(i)<<"\t"<<g_landscape_p->SupplyVegBiomass(i)<<"\t"<<g_landscape_p->SupplyGreenBiomass(i)<<"\t";
302  bio_file<<g_landscape_p->SupplyVegBiomass(i)<<"\t"<<g_landscape_p->SupplyGreenBiomass(i)<<"\n";
303  break;
304  }
305  }
306 
307 
308  for (int i = 0; i<2600; i++){
310  //bio_file<<g_landscape_p->SupplyVegPhase(i)<<"\t"<<g_landscape_p->SupplyVegBiomass(i)<<"\t"<<g_landscape_p->SupplyGreenBiomass(i)<<"\n";
311  bio_file<<g_landscape_p->SupplyVegBiomass(i)<<"\t"<<g_landscape_p->SupplyGreenBiomass(i)<<"\n";
312  break;
313  }
314  }
315 
316 
317  bio_file.flush();
318  bio_file.close();
319  #endif
320 
321  } // End of time step loop
322 }

References DoFirst(), DoLast(), g_landscape_p, m_num_x_range, m_num_y_range, m_the_subpopulation_array, Population_Manager_Base::m_TheLandscape, Landscape::SupplyDayInYear(), Landscape::SupplyElementType(), Landscape::SupplyGreenBiomass(), Landscape::SupplyVegBiomass(), Landscape::SupplyVegType(), tole_PermPastureTussocky, tov_DKLegume_Beans, and writeCalibrationFiles().

◆ setFirstFlagLifeStage()

void SubPopulation_Population_Manager::setFirstFlagLifeStage ( int  life_stage,
bool  pvalue 
)
inline

The function to set the flag indicating whether a given lifestage is the first time of existing.

274 {m_first_flag_life_stage(life_stage) = pvalue;}

References m_first_flag_life_stage.

Referenced by SubPopulation::doDevelopment(), and Aphid::doReproduction().

◆ SetNoProbesAndSpeciesSpecificFunctions()

void SubPopulation_Population_Manager::SetNoProbesAndSpeciesSpecificFunctions ( int  a_pn)
virtual

Sets up probe and species specifics.

Reimplemented from Population_Manager_Base.

1001 {
1002  // This function relies on the fact that g_Species has been set already
1004 }

References g_Species, Population_Manager_Base::m_TheLandscape, and Landscape::SetSpeciesFunctions().

◆ setOldIndex()

void SubPopulation_Population_Manager::setOldIndex ( int  life_stage,
int  p_value 
)

The function to set the oldest index for the given life stage.

701  {
702  //1 is the old one
703  m_accumu_degree_days(life_stage, blitz::Range(m_index_new_old(life_stage, 1), p_value)) = 0;
704  m_index_new_old(life_stage,1) = p_value;
705 }

References m_accumu_degree_days, and m_index_new_old.

Referenced by SubPopulation::doDevelopment(), and Aphid::doReproduction().

◆ subpopuBaseOutputProbe()

void SubPopulation_Population_Manager::subpopuBaseOutputProbe ( )
virtual

Below are the functions for saving result.

349  {
350  for(int i=0; i<m_num_life_stage; i++){
352  }
354 
355  #ifdef APHID_DEBUG
356  m_subpopulation_base_prb_file<<g_landscape_p->SupplyTemp()<<"\t"<<m_num_killed_by_parasitoid<<"\t"<<
357  m_num_parasitoid<<"\t"<<m_num_parasitoid_egg<<"\t"<<m_num_new_parasitoid_egg_daily;;
358  #else
360  #endif
361 
362  #ifndef SubpopulationSpatialResult
364  #endif
365 
366  #ifdef SubpopulationSpatialResult
367  //the population in each grid
368  for (int index_y = 0; index_y < m_num_y_range; index_y++){
369  for (int index_x = 0; index_x < m_num_x_range; index_x++){
371  //for(int i=0; i<m_num_life_stage; i++){
372  //store the population at each life stage
373  // m_subpopulation_base_prb_file<<m_the_subpopulation_array(index_y, index_x)->getNumforOneLifeStage(i)<<"\t";
374  //}
375  double temp_counter = 0;
376  for (int i=5;i<9;i++){
377  if(m_the_subpopulation_array(index_y, index_x) != NULL){
378  temp_counter += m_the_subpopulation_array(index_y, index_x)->getNumforOneLifeStage(i);
379  }
380  }
381  m_subpopulation_base_prb_file<<temp_counter;
382 
383  // parasitoid number
384  //m_subpopulation_base_prb_file<<m_the_subpopulation_array(index_y, index_x)->getPrasitoidNum()<<"\t";
385  //m_subpopulation_base_prb_file<<m_the_subpopulation_array(index_y, index_x)->getPrasitoidEggNum();
386  }
387  }
389  #endif
390 
392 }

References g_landscape_p, m_num_life_stage, m_num_x_range, m_num_y_range, m_subpopulation_base_prb_file, m_the_subpopulation_array, m_total_num_each_stage, Landscape::SupplyDaylength(), and Landscape::SupplyTemp().

Referenced by DoLast().

◆ supplyAgeInDay()

int SubPopulation_Population_Manager::supplyAgeInDay ( int  lifestage_index,
int  column_index 
)

The function to return the age in days given an element in the subpopulation table.

990  {
991  int current_newest_index = supplyNewestIndex(lifestage_index);
992  if(current_newest_index>=column_index || (current_newest_index<column_index && column_index <= current_newest_index)){
993  return current_newest_index-column_index;
994  }
995  else{
996  return m_max_alive_days-column_index+current_newest_index;
997  }
998 }

References m_max_alive_days, and supplyNewestIndex().

Referenced by Aphid::doReproduction().

◆ supplyAgeInDayDegree()

double SubPopulation_Population_Manager::supplyAgeInDayDegree ( int  lifestage_index,
int  column_index 
)
inline
308 {return m_accumu_degree_days(lifestage_index, column_index);}

References m_accumu_degree_days.

Referenced by Aphid::doReproduction().

◆ supplyAllPopulationGivenStage()

double SubPopulation_Population_Manager::supplyAllPopulationGivenStage ( int  index)

Supply the population size at the given life stage for the who landscape.

342  {
343  if(index<m_num_life_stage){
344  return m_total_num_each_stage(index);
345  }
346  return 0;
347 }

References m_num_life_stage, and m_total_num_each_stage.

Referenced by GetLiveArraySize(), and GetPopulationSize().

◆ supplyCellHeight()

double SubPopulation_Population_Manager::supplyCellHeight ( )
inline

Supply the height of a subpopulation cell.

226 {return m_sub_h;}

References m_sub_h.

◆ supplyCellNumX()

int SubPopulation_Population_Manager::supplyCellNumX ( )
inline

Supply number of subpopulation in x coordinate.

220 {return m_num_x_range;}

References m_num_x_range.

Referenced by Aphid::doMovement().

◆ supplyCellNumY()

int SubPopulation_Population_Manager::supplyCellNumY ( )
inline

Supply number of subpopulation in y coordinate.

222 {return m_num_y_range;}

References m_num_y_range.

Referenced by Aphid::doMovement().

◆ supplyCellWidth()

double SubPopulation_Population_Manager::supplyCellWidth ( )
inline

Supply the width of a subpopulation cell.

224 {return m_sub_w;}

References m_sub_w.

◆ supplyDevelopmentSeason()

virtual unsigned SubPopulation_Population_Manager::supplyDevelopmentSeason ( )
inlinevirtual

The function to supply the development season.

Reimplemented in Aphid_Population_Manager.

292 {return 0;};

◆ supplyFirstFlagLifeStage()

bool SubPopulation_Population_Manager::supplyFirstFlagLifeStage ( int  life_stage)
inline

The function to supply the flag of first for the given life stage.

276 {return m_first_flag_life_stage(life_stage);}

References m_first_flag_life_stage.

Referenced by SubPopulation::doDevelopment(), and Aphid::doReproduction().

◆ supplyLifeStageNum()

int SubPopulation_Population_Manager::supplyLifeStageNum ( )
inline

◆ SupplyLocXY()

virtual void SubPopulation_Population_Manager::SupplyLocXY ( unsigned  ,
unsigned  ,
int &  ,
int &   
)
inlinevirtual

A stub for identifying an individual at a location.

Reimplemented from Population_Manager_Base.

310  {
311  int indx = index_x;
312  int indy = index_y;
313  x = m_the_subpopulation_array(indy, indx)->Supply_m_Location_x();
314  y = m_the_subpopulation_array(indy, indx)->Supply_m_Location_y();
315  }

References m_the_subpopulation_array.

◆ supplyMaxColNum()

int SubPopulation_Population_Manager::supplyMaxColNum ( )
inline

Supply the maximum number of column in the development array.

244 {return m_max_alive_days;}

References m_max_alive_days.

Referenced by SubPopulation::addAnimalNumGivenStage(), SubPopulation::doMortality(), Aphid::doReproduction(), and SubPopulation::SubPopulation().

◆ supplyMortality()

double SubPopulation_Population_Manager::supplyMortality ( int  a_life_stage,
int  a_age 
)
inline

The function to supply the mortality rate for the given life stage and the age.

296 {return m_current_mortality_array(a_life_stage, a_age);}

References m_current_mortality_array.

◆ supplyMortalityStageArray()

blitz::Array<double, 1> SubPopulation_Population_Manager::supplyMortalityStageArray ( int  a_life_stage)
inline

The function to supply the 1D base morality rate array for the given life stage.

300 {return m_current_mortality_array(a_life_stage, blitz::Range::all());}

References m_current_mortality_array.

◆ supplyMortalityWholeArray()

blitz::Array<double, 2> SubPopulation_Population_Manager::supplyMortalityWholeArray ( void  )
inline

The function to supply the whole base mortality rate array.

References m_current_mortality_array.

Referenced by SubPopulation::doMortality().

◆ supplyNewestIndex()

int SubPopulation_Population_Manager::supplyNewestIndex ( int  life_stage_index)
inline

◆ supplyNextLifeStage()

int SubPopulation_Population_Manager::supplyNextLifeStage ( int  life_circle_index,
int  life_stage_index 
)
inline

Supply the next life stage index for a given life stage and a given life path.

246 {return m_life_circle_path(life_circle_index, life_stage_index);}

References m_life_circle_path.

◆ supplyNumFlyingLifeStages()

int SubPopulation_Population_Manager::supplyNumFlyingLifeStages ( )
inline

Supply the number of life stages that can fly.

319 {return m_flying_life_stage_array.size();}

References m_flying_life_stage_array.

Referenced by SubPopulation::doMovement(), and SubPopulation::SubPopulation().

◆ supplyNumLocMovLifeStages()

int SubPopulation_Population_Manager::supplyNumLocMovLifeStages ( )
inline

Supply the number of life stages thah can do local movement.

323 {return m_local_moving_life_stage_array.size();}

References m_local_moving_life_stage_array.

Referenced by SubPopulation::SubPopulation().

◆ supplyOldEnoughIndex()

std::vector<int> SubPopulation_Population_Manager::supplyOldEnoughIndex ( int  life_stage_index)
inline
247 {return m_index_next_life_stage.at(life_stage_index);}

References m_index_next_life_stage.

Referenced by SubPopulation::doDevelopment().

◆ supplySizeSubpopulationCell()

double SubPopulation_Population_Manager::supplySizeSubpopulationCell ( )
inline

Supply the size of aphid subpopulation cell.

228 {return m_size_cell;}

References m_size_cell.

Referenced by Aphid::calPopuDensity(), and SubPopulation::calPopuDensity().

◆ supplySubPopulationPointer()

SubPopulation * SubPopulation_Population_Manager::supplySubPopulationPointer ( int  indx,
int  indy 
)

Supply the pointer of the subpopulation object in the given cell.

338  {
339  return m_the_subpopulation_array(indy, indx);
340 }

References m_the_subpopulation_array.

Referenced by Aphid::doMovement().

◆ supplySummerHostOn()

bool SubPopulation_Population_Manager::supplySummerHostOn ( void  )
inline
349 {return m_summer_host_on;}

References m_summer_host_on.

Referenced by Aphid::calSuitabilityShared().

◆ supplySummerTolePeriod()

std::vector<int> SubPopulation_Population_Manager::supplySummerTolePeriod ( TTypesOfLandscapeElement  a_tole)
inline

The function to supply the available period vector for the given summer tole host.

References m_summer_hosts_tole_period, and m_summer_hosts_tole_period_map.

◆ supplyTotalPopulationInCell()

double SubPopulation_Population_Manager::supplyTotalPopulationInCell ( int  x_indx,
int  y_indx 
)

Supply whole population size at the given cell.

◆ supplyVecFlyingLifeStages()

std::vector<int> SubPopulation_Population_Manager::supplyVecFlyingLifeStages ( )
inline

Supply the vector of life stages for flying.

317 {return m_flying_life_stage_array; };

References m_flying_life_stage_array.

Referenced by SubPopulation::doMovement().

◆ supplyVecLocMoveLifeStages()

std::vector<int> SubPopulation_Population_Manager::supplyVecLocMoveLifeStages ( )
inline

Supply the vector of life stages that can do local movement.

References m_local_moving_life_stage_array.

Referenced by Aphid::doMovement().

◆ supplyWinterHostOn()

bool SubPopulation_Population_Manager::supplyWinterHostOn ( void  )
inline

◆ supplyWinterTolePeriod()

std::vector<int> SubPopulation_Population_Manager::supplyWinterTolePeriod ( TTypesOfLandscapeElement  a_tole)
inline

The function to supply the available period vector for the given winter tole host.

References m_winter_hosts_tole_period, and m_winter_hosts_tole_period_map.

◆ updateDevelopmentSeason()

virtual void SubPopulation_Population_Manager::updateDevelopmentSeason ( )
inlinevirtual

The function to update the development season.

Reimplemented in Aphid_Population_Manager.

269 {};

Referenced by DoFirst().

◆ updateMortalityArray()

void SubPopulation_Population_Manager::updateMortalityArray ( void  )
virtual

This function is used to update the daily mortality rate for all the ages. In this base class, it only depends on the temperature. The lowest and highest temperature that will make the species die. The optimal temperature will make the mortality rate to be 0.

Reimplemented in Aphid_Population_Manager.

879  {
880  //get the current temperature
881  double current_temperature = g_landscape_p->SupplyTemp();
882  //egg will not die because of cold or hot
883  m_current_mortality_array(0,blitz::Range::all()) = 0.01;
884  //others will die because of too cold and too hot
885  for (int i=1; i<m_num_life_stage; i++){
886  if(current_temperature<m_lowest_temperature_die(i) || current_temperature>m_highest_temperature_die(i)){
887  m_current_mortality_array(i,blitz::Range::all()) = 1; //all die if it is too cold or too hot
888  }
889  else{
890  m_current_mortality_array(i,blitz::Range::all()) = 0.01;
891  }
892  }
894 }

References g_landscape_p, m_current_mortality_array, m_highest_temperature_die, m_lowest_temperature_die, m_num_life_stage, and Landscape::SupplyTemp().

Referenced by DoFirst().

◆ updateWholePopulation()

void SubPopulation_Population_Manager::updateWholePopulation ( )

Update whole population info.

240  {
241  for (int k=0; k<m_num_life_stage; k++){
242  m_total_num_each_stage(k) = 0;
243  for (int i = 0; i < m_num_y_range; i++){
244  for (int j = 0; j < m_num_x_range; j++){
245  if(m_the_subpopulation_array(i,j)!=NULL){
246  m_total_num_each_stage(k) += m_the_subpopulation_array(i,j)->getNumforOneLifeStage(k);
247  }
248  }
249  }
250  }
251 }

References m_num_life_stage, m_num_x_range, m_num_y_range, m_the_subpopulation_array, and m_total_num_each_stage.

Referenced by DoLast().

◆ updateWholePopulationArray() [1/2]

void SubPopulation_Population_Manager::updateWholePopulationArray ( blitz::Array< double, 1 >  a_array)
840  {
841  m_total_num_each_stage += a_array;
842 }

References m_total_num_each_stage.

◆ updateWholePopulationArray() [2/2]

void SubPopulation_Population_Manager::updateWholePopulationArray ( int  a_listindex,
double  number 
)

The function to update the whole population array in the whole landscape.

228 {
229  double temp_number = m_total_num_each_stage(a_listindex);
230  temp_number += number;
231  if (temp_number < 0){
232  m_total_num_each_stage(a_listindex)=0;
233  }
234  else
235  {
236  m_total_num_each_stage(a_listindex)= temp_number;
237  }
238 }

References m_total_num_each_stage.

◆ writeCalibrationFiles()

virtual void SubPopulation_Population_Manager::writeCalibrationFiles ( void  )
inlinevirtual

Write probe files for calibration.

Reimplemented in Aphid_Population_Manager.

347 {;};

Referenced by Run().

Friends And Related Function Documentation

◆ Subpopulation

friend class Subpopulation
friend

Member Data Documentation

◆ m_accumu_degree_days

◆ m_cell_popu_density

blitz::Array<double, 2> SubPopulation_Population_Manager::m_cell_popu_density
protected

Array for weighted population density in each subpopulation cell.

Referenced by initialisePopulation(), Aphid_Population_Manager::initialiseSimWithEggs(), and SubPopulation_Population_Manager().

◆ m_cell_suitability

blitz::Array<double, 2> SubPopulation_Population_Manager::m_cell_suitability
protected

◆ m_current_flying_array

blitz::Array<double, 1> SubPopulation_Population_Manager::m_current_flying_array
protected

Temporal array for the flying subpopulation.

Referenced by doFlying(), and SubPopulation_Population_Manager().

◆ m_current_landing_array

blitz::Array<double, 1> SubPopulation_Population_Manager::m_current_landing_array
protected

Temporal array for the landing subpopulation.

Referenced by SubPopulation_Population_Manager().

◆ m_current_mortality_array

blitz::Array<double, 2> SubPopulation_Population_Manager::m_current_mortality_array
protected

This a lookup table for the age and temperature dependent mortality rate. This is the same for the whole landscape for each day. Further cell specific related calculate should be done in the SubPopulation class.

Referenced by SubPopulation_Population_Manager(), supplyMortality(), supplyMortalityStageArray(), supplyMortalityWholeArray(), updateMortalityArray(), and Aphid_Population_Manager::updateMortalityArrayShared().

◆ m_development_degree_day

blitz::Array<double, 2> SubPopulation_Population_Manager::m_development_degree_day
protected

The array to store the average max and std development time for each life stage, max and std time for reproducing.

Referenced by doDevelopment(), isEnoughNextLifeStage(), and readDevReproFile().

◆ m_first_flag_life_stage

blitz::Array<bool, 1> SubPopulation_Population_Manager::m_first_flag_life_stage
protected

Array to track whether it is the first existence for a life stage.

Referenced by setFirstFlagLifeStage(), SubPopulation_Population_Manager(), and supplyFirstFlagLifeStage().

◆ m_flying_life_stage_array

std::vector<int> SubPopulation_Population_Manager::m_flying_life_stage_array
protected

◆ m_hibernated_hatch_flag

bool SubPopulation_Population_Manager::m_hibernated_hatch_flag
protected

Flag variable to indicate hibernated eggs are ready to hatch.

Referenced by doDevelopment(), and SubPopulation_Population_Manager().

◆ m_highest_temperature_die

blitz::Array<double, 1> SubPopulation_Population_Manager::m_highest_temperature_die
private

The highest temperature that will cause the species die.

Referenced by SubPopulation_Population_Manager(), and updateMortalityArray().

◆ m_index_new_old

blitz::Array<int, 2> SubPopulation_Population_Manager::m_index_new_old
protected

◆ m_index_next_life_stage

std::vector<std::vector<int> > SubPopulation_Population_Manager::m_index_next_life_stage
private

The array to store the index for the ones go to the next life stage or die. -1 means nothing.

Referenced by doDevelopment(), SubPopulation_Population_Manager(), and supplyOldEnoughIndex().

◆ m_landing_life_stage_array

std::vector<int> SubPopulation_Population_Manager::m_landing_life_stage_array
protected

The vector to store the life stage when a flying one lands, it could be different from the flying one, e.g., they drop theri wings.

Referenced by doFlying(), Aphid_Population_Manager::initialisePopulation(), and initialisePopulation().

◆ m_landing_masks

blitz::Array<blitz::Array<double, 2>, 2> SubPopulation_Population_Manager::m_landing_masks
protected

The array to store the landing masks. The vector is indexed by the wind speed index first and the second index is the wind direction. Each element is a 2-D dimensional blitz array.

Referenced by calLongMovementMask(), doFlying(), and SubPopulation_Population_Manager().

◆ m_life_circle_path

blitz::Array<double, 2> SubPopulation_Population_Manager::m_life_circle_path
protected

The life circle array. It could have more than one life circle paths.

Referenced by supplyNextLifeStage().

◆ m_local_moving_life_stage_array

std::vector<int> SubPopulation_Population_Manager::m_local_moving_life_stage_array
protected

◆ m_long_move_mask

blitz::Array<double, 4> SubPopulation_Population_Manager::m_long_move_mask
protected

Long distance movement mask.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_long_move_mask_x_num

int SubPopulation_Population_Manager::m_long_move_mask_x_num
protected

Variable to record the dimension of the long distance movement mask. - x.

Referenced by SubPopulation_Population_Manager().

◆ m_long_move_mask_x_num_half

int SubPopulation_Population_Manager::m_long_move_mask_x_num_half
protected

Variable to record the dimension of the short distance movement mask. - x.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_long_move_mask_x_num_half_array

blitz::Array<int,1> SubPopulation_Population_Manager::m_long_move_mask_x_num_half_array
protected

Array to store the number of cells for longest flying at different windspeed.

Referenced by calLongMovementMask(), doFlying(), and SubPopulation_Population_Manager().

◆ m_long_move_mask_y_num

int SubPopulation_Population_Manager::m_long_move_mask_y_num
protected

Variable to record the dimension of the long distance movement mask. - y.

Referenced by SubPopulation_Population_Manager().

◆ m_long_move_mask_y_num_half

int SubPopulation_Population_Manager::m_long_move_mask_y_num_half
protected

◆ m_long_move_mask_y_num_half_array

blitz::Array<int,1> SubPopulation_Population_Manager::m_long_move_mask_y_num_half_array
protected

◆ m_lowest_temp_dev

blitz::Array<double, 1> SubPopulation_Population_Manager::m_lowest_temp_dev
protected

Lowest development temperatures for each life stage. This is the last step in each day.

Referenced by doDevelopment(), Aphid_Population_Manager::initialisePopulation(), readDevReproFile(), and SubPopulation_Population_Manager().

◆ m_lowest_temperature_die

blitz::Array<double, 1> SubPopulation_Population_Manager::m_lowest_temperature_die
private

The lowest temperature that will cause the species die.

Referenced by SubPopulation_Population_Manager(), and updateMortalityArray().

◆ m_max_alive_days

int SubPopulation_Population_Manager::m_max_alive_days
protected

◆ m_max_flying_wind_speed

float SubPopulation_Population_Manager::m_max_flying_wind_speed
protected

The larget wind speed for winged adults to fly.

Referenced by DoFirst(), and SubPopulation_Population_Manager().

◆ m_max_long_distance

int SubPopulation_Population_Manager::m_max_long_distance
protected

The longest distance that the specieces can fly for long distance dispersal.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_max_short_distance

double SubPopulation_Population_Manager::m_max_short_distance
protected

The longest distance that the specieces can move for short distance dispersal.

◆ m_mul_hosts_flag

bool SubPopulation_Population_Manager::m_mul_hosts_flag
protected

Flag to show whether it has both winter and summer host.

Referenced by Aphid_Population_Manager::initialiseSimWithEggs(), readHosts(), and Aphid_Population_Manager::updateDevelopmentSeason().

◆ m_num_life_stage

◆ m_num_x_range

◆ m_num_y_range

◆ m_optimal_temperature

blitz::Array<double, 1> SubPopulation_Population_Manager::m_optimal_temperature
private

The optimal development temperature for the species. (Mortality rate = 0).

Referenced by SubPopulation_Population_Manager().

◆ m_peak_long_distance

int SubPopulation_Population_Manager::m_peak_long_distance
protected

The distance for the peak amount of landing.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_scale_wind_speed

float SubPopulation_Population_Manager::m_scale_wind_speed
protected

The scale for wind.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_short_move_mask

blitz::Array<double, 4> SubPopulation_Population_Manager::m_short_move_mask
protected

Short distance movement mask.

Referenced by SubPopulation_Population_Manager().

◆ m_short_move_mask_x_num

int SubPopulation_Population_Manager::m_short_move_mask_x_num
protected

◆ m_short_move_mask_y_num

int SubPopulation_Population_Manager::m_short_move_mask_y_num
protected

Variable to record the dimension of the short distance movement mask. - y.

Referenced by SubPopulation_Population_Manager().

◆ m_size_cell

double SubPopulation_Population_Manager::m_size_cell
private

The size of each subpopulation cell.

Referenced by SubPopulation_Population_Manager(), and supplySizeSubpopulationCell().

◆ m_sub_h

◆ m_sub_w

◆ m_subpopulation_base_prb_file

std::ofstream SubPopulation_Population_Manager::m_subpopulation_base_prb_file
protected

◆ m_summer_host_on

bool SubPopulation_Population_Manager::m_summer_host_on
protected

The flag to enable summer host.

Referenced by readHosts(), supplySummerHostOn(), and Aphid_Population_Manager::updateDevelopmentSeason().

◆ m_summer_hosts_tole

std::vector<TTypesOfLandscapeElement> SubPopulation_Population_Manager::m_summer_hosts_tole
protected

The vector to hold summer host landscape type.

Referenced by isSummerHostTole(), and readHosts().

◆ m_summer_hosts_tole_period

std::vector<std::vector<int> > SubPopulation_Population_Manager::m_summer_hosts_tole_period
protected

The vector to store the exsiting period for summer host tole.

Referenced by readHosts(), and supplySummerTolePeriod().

◆ m_summer_hosts_tole_period_map

std::map<int, int> SubPopulation_Population_Manager::m_summer_hosts_tole_period_map
protected

The map to store the index for the summer host period.

Referenced by readHosts(), and supplySummerTolePeriod().

◆ m_summer_hosts_tov

std::vector<TTypesOfVegetation> SubPopulation_Population_Manager::m_summer_hosts_tov
protected

The vector to hold sumber host vegetation type.

Referenced by isSummerHostTov(), and readHosts().

◆ m_the_subpopulation_array

◆ m_total_num_each_stage

blitz::Array<double, 1> SubPopulation_Population_Manager::m_total_num_each_stage
private

Array to hold the total number of alive animals under different life stages in the whole landscape.

Referenced by subpopuBaseOutputProbe(), SubPopulation_Population_Manager(), supplyAllPopulationGivenStage(), updateWholePopulation(), and updateWholePopulationArray().

◆ m_vec_subpopulation_pointers_polygon

std::vector<std::vector<SubPopulation*> > SubPopulation_Population_Manager::m_vec_subpopulation_pointers_polygon
protected

The vector used to store the pointers of all the subpopulation objects in each polygon.

Referenced by initialisePopulation(), Aphid_Population_Manager::initialiseSimWithEggs(), and SubPopulation_Population_Manager().

◆ m_wind_direction_array

blitz::Array<double, 2> SubPopulation_Population_Manager::m_wind_direction_array
protected

The array to hold the wind directions.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_wind_direction_num

int SubPopulation_Population_Manager::m_wind_direction_num
protected

The number of wind directions.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_wind_speed_lookup_table

blitz::Array<int,1> SubPopulation_Population_Manager::m_wind_speed_lookup_table
protected

The look up table for wind speed index in the flying mask.

Referenced by doFlying(), and SubPopulation_Population_Manager().

◆ m_wind_speed_num

int SubPopulation_Population_Manager::m_wind_speed_num
protected

The number of wind speed samples.

Referenced by calLongMovementMask(), and SubPopulation_Population_Manager().

◆ m_wind_speed_step_size

int SubPopulation_Population_Manager::m_wind_speed_step_size
protected

The sampling step size for wind speed.

Referenced by SubPopulation_Population_Manager().

◆ m_winter_host_on

bool SubPopulation_Population_Manager::m_winter_host_on
protected

◆ m_winter_hosts_tole

std::vector<TTypesOfLandscapeElement> SubPopulation_Population_Manager::m_winter_hosts_tole
protected

The vector to hold winter host landscape type.

Referenced by isWinterHostTole(), and readHosts().

◆ m_winter_hosts_tole_period

std::vector<std::vector<int> > SubPopulation_Population_Manager::m_winter_hosts_tole_period
protected

The vector to store the exsiting period for winter host tole.

Referenced by readHosts(), and supplyWinterTolePeriod().

◆ m_winter_hosts_tole_period_map

std::map<int, int> SubPopulation_Population_Manager::m_winter_hosts_tole_period_map
protected

The map to store the index for the winter host period.

Referenced by readHosts(), and supplyWinterTolePeriod().

◆ m_winter_hosts_tov

std::vector<TTypesOfVegetation> SubPopulation_Population_Manager::m_winter_hosts_tov
protected

The vector to hold winter host vegetation type.

Referenced by isWinterHostTov(), and readHosts().


The documentation for this class was generated from the following files:
SubPopulation_Population_Manager::m_long_move_mask_x_num_half
int m_long_move_mask_x_num_half
Variable to record the dimension of the short distance movement mask. - x.
Definition: SubPopulation_Population_Manager.h:143
cfg_Subpopu_Density_Threshold
CfgFloat cfg_Subpopu_Density_Threshold("SUBPOPU_DENSITY_THRESHOLD", CFG_CUSTOM, 1000)
SubPopulation_Population_Manager::supplyAllPopulationGivenStage
double supplyAllPopulationGivenStage(int index)
Supply the population size at the given life stage for the who landscape.
Definition: SubPopulation_Population_Manager.cpp:342
M_PI
#define M_PI
Definition: sunset.h:33
SubPopulation_Population_Manager::m_the_subpopulation_array
blitz::Array< SubPopulation *, 2 > m_the_subpopulation_array
Vector to store the all the pointers for the subpopulation object.
Definition: SubPopulation_Population_Manager.h:115
Landscape::SupplyNumberOfPolygons
unsigned int SupplyNumberOfPolygons(void)
Returns the number of polygons in the landscape.
Definition: Landscape.h:2127
WARN_FILE
Definition: MapErrorMsg.h:37
SubPopulation_Population_Manager::m_total_num_each_stage
blitz::Array< double, 1 > m_total_num_each_stage
Array to hold the total number of alive animals under different life stages in the whole landscape.
Definition: SubPopulation_Population_Manager.h:81
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_Population_Manager::m_max_alive_days
int m_max_alive_days
The longest alive day among all the life stages.
Definition: SubPopulation_Population_Manager.h:156
SubPopulation_Population_Manager::m_max_flying_wind_speed
float m_max_flying_wind_speed
The larget wind speed for winged adults to fly.
Definition: SubPopulation_Population_Manager.h:127
Landscape::SupplyTemp
double SupplyTemp(void)
Passes a request on to the associated Weather class function, the temperature for the current day.
Definition: Landscape.h:1993
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
g_landscape_p
Landscape * g_landscape_p
SubPopulation_Population_Manager::m_wind_direction_array
blitz::Array< double, 2 > m_wind_direction_array
The array to hold the wind directions.
Definition: SubPopulation_Population_Manager.h:188
struct_SubPopulation::x
int x
x-coord
Definition: SubPopulation_Population_Manager.h:50
SubPopulation_Population_Manager::m_flying_life_stage_array
std::vector< int > m_flying_life_stage_array
The vector to store the life stages that can fly.
Definition: SubPopulation_Population_Manager.h:194
SubPopulation_Population_Manager::addNewDay
void addNewDay()
Add new day to the newest and oldest array.
Definition: SubPopulation_Population_Manager.cpp:628
CfgStr::value
char * value() const
Definition: Configurator.h:182
Landscape::SupplyWind
double SupplyWind(void)
Passes a request on to the associated Weather class function, the wind speed for the current day.
Definition: Landscape.h:2061
SubPopulation_Population_Manager::writeCalibrationFiles
virtual void writeCalibrationFiles(void)
Write probe files for calibration.
Definition: SubPopulation_Population_Manager.h:347
Landscape::SupplyWindDirection
int SupplyWindDirection(void)
Passes a request on to the associated Weather class function, the wind direction in 4 directions for ...
Definition: Landscape.h:2067
SubPopulation_Population_Manager::m_long_move_mask_x_num_half_array
blitz::Array< int, 1 > m_long_move_mask_x_num_half_array
Array to store the number of cells for longest flying at different windspeed.
Definition: SubPopulation_Population_Manager.h:146
struct_SubPopulation::starting_popu_density
double * starting_popu_density
Starting weighted population density for the subpopulation.
Definition: SubPopulation_Population_Manager.h:68
Population_Manager_Base::Population_Manager_Base
Population_Manager_Base(Landscape *L)
The Population_Manager_Base constructor.
Definition: PopulationManager.cpp:182
SubPopulation_Population_Manager::m_current_landing_array
blitz::Array< double, 1 > m_current_landing_array
Temporal array for the landing subpopulation.
Definition: SubPopulation_Population_Manager.h:168
SubPopulation_Population_Manager::calLandingCurve
double calLandingCurve(double a_dis, double a_peak, double a_furthest)
The function to calculate the landing curve along the wind direction.
Definition: SubPopulation_Population_Manager.cpp:896
Population_Manager_Base::m_ListNames
const char * m_ListNames[32]
A list of life-stage names.
Definition: PopulationManager.h:628
SubPopulation_Population_Manager::m_wind_speed_lookup_table
blitz::Array< int, 1 > m_wind_speed_lookup_table
The look up table for wind speed index in the flying mask.
Definition: SubPopulation_Population_Manager.h:135
SubPopulation_Population_Manager::m_cell_suitability
blitz::Array< double, 2 > m_cell_suitability
Array for suitable value in each subpopulation cell.
Definition: SubPopulation_Population_Manager.h:113
SubPopulation_Population_Manager::m_num_life_stage
int m_num_life_stage
The number of life stages for the animal.
Definition: SubPopulation_Population_Manager.h:103
struct_SubPopulation::empty_flag
bool empty_flag
Indicator show whether it is an empty subpopulation.
Definition: SubPopulation_Population_Manager.h:64
SubPopulation_Population_Manager::readDevReproFile
void readDevReproFile(string inputfile)
Function to read the development time and lifestage.
Definition: SubPopulation_Population_Manager.cpp:414
SubPopulation_Population_Manager::m_lowest_temperature_die
blitz::Array< double, 1 > m_lowest_temperature_die
The lowest temperature that will cause the species die.
Definition: SubPopulation_Population_Manager.h:88
SubPopulation_Population_Manager::m_mul_hosts_flag
bool m_mul_hosts_flag
Flag to show whether it has both winter and summer host.
Definition: SubPopulation_Population_Manager.h:105
struct_SubPopulation::NPM
SubPopulation_Population_Manager * NPM
SubPopulation_Population_Manager pointer.
Definition: SubPopulation_Population_Manager.h:62
SubPopulation_Population_Manager::m_long_move_mask_x_num
int m_long_move_mask_x_num
Variable to record the dimension of the long distance movement mask. - x.
Definition: SubPopulation_Population_Manager.h:139
CfgFloat::value
double value() const
Definition: Configurator.h:142
struct_SubPopulation
Used for creation of a new struct_SubPopulation object.
Definition: SubPopulation_Population_Manager.h:46
SubPopulation_Population_Manager::m_summer_host_on
bool m_summer_host_on
The flag to enable summer host.
Definition: SubPopulation_Population_Manager.h:204
FarmManager::TranslateVegCodes
TTypesOfVegetation TranslateVegCodes(std::string &str)
Converts strings to tov_
Definition: Farm.cpp:2180
Landscape::SupplyMonth
int SupplyMonth(void)
Passes a request on to the associated Calendar class function, returns m_month + 1 (the calendar mont...
Definition: Landscape.h:2272
SubPopulation_Population_Manager::DoLast
virtual void DoLast()
Definition: SubPopulation_Population_Manager.cpp:478
SubPopulation_Population_Manager::m_cell_popu_density
blitz::Array< double, 2 > m_cell_popu_density
Array for weighted population density in each subpopulation cell.
Definition: SubPopulation_Population_Manager.h:111
SubPopulation_Population_Manager::m_peak_long_distance
int m_peak_long_distance
The distance for the peak amount of landing.
Definition: SubPopulation_Population_Manager.h:123
SubPopulation_Population_Manager::DoFirst
virtual void DoFirst()
Definition: SubPopulation_Population_Manager.cpp:691
SubPopulation_Population_Manager::isEnoughNextLifeStage
virtual bool isEnoughNextLifeStage(int a_life_stage)
The funcition to check whether it is read for the next life stage.
Definition: SubPopulation_Population_Manager.cpp:624
SubPopulation_Population_Manager::m_wind_direction_num
int m_wind_direction_num
The number of wind directions.
Definition: SubPopulation_Population_Manager.h:131
struct_SubPopulation::L
Landscape * L
Landscape pointer.
Definition: SubPopulation_Population_Manager.h:60
struct_SubPopulation::w
int w
area width
Definition: SubPopulation_Population_Manager.h:54
SubPopulation_Population_Manager::m_summer_hosts_tole_period_map
std::map< int, int > m_summer_hosts_tole_period_map
The map to store the index for the summer host period.
Definition: SubPopulation_Population_Manager.h:182
SubPopulation_Population_Manager::doSpecicesLastThing
virtual void doSpecicesLastThing()
The special last thing for the drived species.
Definition: SubPopulation_Population_Manager.h:338
Population_Manager_Base::m_ListNameLength
int m_ListNameLength
the number of life-stages simulated in the population manager
Definition: PopulationManager.h:626
SubPopulation_Population_Manager::CreateObjects
SubPopulation * CreateObjects(TAnimal *pvo, struct_SubPopulation *data, int number)
Definition: SubPopulation_Population_Manager.cpp:976
SubPopulation_Population_Manager::m_long_move_mask_y_num
int m_long_move_mask_y_num
Variable to record the dimension of the long distance movement mask. - y.
Definition: SubPopulation_Population_Manager.h:141
tos_Egg
Definition: SubPopulation.h:43
SubPopulation_Population_Manager::readHosts
virtual void readHosts(string a_file_name)
The fuction to read the host lists for aphid.
Definition: SubPopulation_Population_Manager.cpp:1006
SubPopulation_Population_Manager::isSummerHostTole
bool isSummerHostTole(TTypesOfLandscapeElement a_ele)
Test whether it is a summer host tole.
Definition: SubPopulation_Population_Manager.cpp:810
SubPopulation_Population_Manager::m_index_new_old
blitz::Array< int, 2 > m_index_new_old
Array for index of the newest and oldest life stages.
Definition: SubPopulation_Population_Manager.h:154
CfgBool::value
bool value() const
Definition: Configurator.h:164
Population_Manager_Base::m_TheLandscape
Landscape * m_TheLandscape
holds an internal pointer to the landscape
Definition: PopulationManager.h:624
SubPopulation_Population_Manager::calLongMovementMask
virtual void calLongMovementMask(void)
Function to calculate the movement mask.
Definition: SubPopulation_Population_Manager.cpp:488
SubPopulation_Population_Manager::m_max_long_distance
int m_max_long_distance
The longest distance that the specieces can fly for long distance dispersal.
Definition: SubPopulation_Population_Manager.h:121
SubPopulation_Population_Manager::m_winter_hosts_tole_period
std::vector< std::vector< int > > m_winter_hosts_tole_period
The vector to store the exsiting period for winter host tole.
Definition: SubPopulation_Population_Manager.h:172
SubPopulation_Population_Manager::doFlying
void doFlying(int ind, int index_x, int index_y)
The function to fly the winged adults.
Definition: SubPopulation_Population_Manager.cpp:708
SubPopulation_Population_Manager::m_winter_hosts_tole
std::vector< TTypesOfLandscapeElement > m_winter_hosts_tole
The vector to hold winter host landscape type.
Definition: SubPopulation_Population_Manager.h:170
TTypesOfLandscapeElement
TTypesOfLandscapeElement
Values that represent the types of landscape polygon that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:57
tov_DKLegume_Beans
Definition: LandscapeFarmingEnums.h:358
Population_Manager_Base::SimH
int SimH
stores the simulation height
Definition: PopulationManager.h:614
SubPopulation_Population_Manager::m_wind_speed_step_size
int m_wind_speed_step_size
The sampling step size for wind speed.
Definition: SubPopulation_Population_Manager.h:129
Landscape::SetSpeciesFunctions
void SetSpeciesFunctions(TTypesOfPopulation a_species)
This is the jumping off point for any landscape related species setup, it creates function pointers t...
Definition: Landscape.cpp:7821
SubPopulation_Population_Manager::m_winter_hosts_tov
std::vector< TTypesOfVegetation > m_winter_hosts_tov
The vector to hold winter host vegetation type.
Definition: SubPopulation_Population_Manager.h:176
SubPopulation_Population_Manager::updateDevelopmentSeason
virtual void updateDevelopmentSeason()
The function to update the development season.
Definition: SubPopulation_Population_Manager.h:269
struct_SubPopulation::index_y
int index_y
Definition: SubPopulation_Population_Manager.h:70
SubPopulation_Population_Manager::m_sub_h
int m_sub_h
Variable to record the height of the subpopulation cell.
Definition: SubPopulation_Population_Manager.h:109
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Passes a request on to the associated Calendar class function, the day in the year.
Definition: Landscape.h:2267
Landscape::SupplyVegBiomass
double SupplyVegBiomass(int a_polyref)
Returns the biomass of the vegetation using the polygon reference number a_polyref or based on the x,...
Definition: Landscape.h:1542
SubPopulation_Population_Manager::m_long_move_mask_y_num_half_array
blitz::Array< int, 1 > m_long_move_mask_y_num_half_array
Definition: SubPopulation_Population_Manager.h:147
tole_PermPastureTussocky
Definition: LandscapeFarmingEnums.h:67
SubPopulation_Population_Manager::m_summer_hosts_tov
std::vector< TTypesOfVegetation > m_summer_hosts_tov
The vector to hold sumber host vegetation type.
Definition: SubPopulation_Population_Manager.h:184
SubPopulation_Population_Manager::m_local_moving_life_stage_array
std::vector< int > m_local_moving_life_stage_array
The vector to store the life stags that can move locally.
Definition: SubPopulation_Population_Manager.h:198
SubPopulation_Population_Manager::m_summer_hosts_tole
std::vector< TTypesOfLandscapeElement > m_summer_hosts_tole
The vector to hold summer host landscape type.
Definition: SubPopulation_Population_Manager.h:178
SubPopulation_Population_Manager::m_vec_subpopulation_pointers_polygon
std::vector< std::vector< SubPopulation * > > m_vec_subpopulation_pointers_polygon
The vector used to store the pointers of all the subpopulation objects in each polygon.
Definition: SubPopulation_Population_Manager.h:202
SubPopulation_Population_Manager::m_summer_hosts_tole_period
std::vector< std::vector< int > > m_summer_hosts_tole_period
The vector to store the exsiting period for summer host tole.
Definition: SubPopulation_Population_Manager.h:180
SubPopulation_Population_Manager::m_index_next_life_stage
std::vector< std::vector< int > > m_index_next_life_stage
The array to store the index for the ones go to the next life stage or die. -1 means nothing.
Definition: SubPopulation_Population_Manager.h:86
SubPopulation_Population_Manager::m_life_circle_path
blitz::Array< double, 2 > m_life_circle_path
The life circle array. It could have more than one life circle paths.
Definition: SubPopulation_Population_Manager.h:160
Population_Manager_Base::SimW
int SimW
stores the simulation width
Definition: PopulationManager.h:616
SubPopulation_Population_Manager::m_long_move_mask
blitz::Array< double, 4 > m_long_move_mask
Long distance movement mask.
Definition: SubPopulation_Population_Manager.h:119
SubPopulation_Population_Manager::m_short_move_mask_y_num
int m_short_move_mask_y_num
Variable to record the dimension of the short distance movement mask. - y.
Definition: SubPopulation_Population_Manager.h:150
SubPopulation_Population_Manager::m_highest_temperature_die
blitz::Array< double, 1 > m_highest_temperature_die
The highest temperature that will cause the species die.
Definition: SubPopulation_Population_Manager.h:90
SubPopulation_Population_Manager::m_lowest_temp_dev
blitz::Array< double, 1 > m_lowest_temp_dev
Lowest development temperatures for each life stage. This is the last step in each day.
Definition: SubPopulation_Population_Manager.h:158
SubPopulation_Population_Manager::m_landing_life_stage_array
std::vector< int > m_landing_life_stage_array
The vector to store the life stage when a flying one lands, it could be different from the flying one...
Definition: SubPopulation_Population_Manager.h:196
struct_SubPopulation::h
int h
area height
Definition: SubPopulation_Population_Manager.h:56
SubPopulation_Population_Manager::updateWholePopulation
void updateWholePopulation()
Update whole population info.
Definition: SubPopulation_Population_Manager.cpp:240
SubPopulation_Population_Manager::subpopuBaseOutputProbe
virtual void subpopuBaseOutputProbe()
Below are the functions for saving result.
Definition: SubPopulation_Population_Manager.cpp:349
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
SubPopulation_Population_Manager::m_size_cell
double m_size_cell
The size of each subpopulation cell.
Definition: SubPopulation_Population_Manager.h:83
SubPopulation_Population_Manager::m_development_degree_day
blitz::Array< double, 2 > m_development_degree_day
The array to store the average max and std development time for each life stage, max and std time for...
Definition: SubPopulation_Population_Manager.h:97
SubPopulation_Population_Manager::m_current_mortality_array
blitz::Array< double, 2 > m_current_mortality_array
This a lookup table for the age and temperature dependent mortality rate. This is the same for the wh...
Definition: SubPopulation_Population_Manager.h:186
g_farmmanager
FarmManager * g_farmmanager
Definition: Farm.cpp:638
SubPopulation_Population_Manager::doDevelopment
void doDevelopment()
Function to make the development for all the subpopulation object.
Definition: SubPopulation_Population_Manager.cpp:566
SubPopulation_Population_Manager::openSubpopulationBaseProbeFile
bool openSubpopulationBaseProbeFile()
Open the storing file.
Definition: SubPopulation_Population_Manager.cpp:394
struct_SubPopulation::index_x
int index_x
Definition: SubPopulation_Population_Manager.h:69
Population_Manager_Base::m_SimulationName
string m_SimulationName
stores the simulation name
Definition: PopulationManager.h:622
SubPopulation_Population_Manager::initialisePopulation
virtual void initialisePopulation()
The function to initialise the population when starting the simulation which requires rewritten in th...
Definition: SubPopulation_Population_Manager.cpp:906
SubPopulation_Population_Manager::m_num_x_range
int m_num_x_range
The number of subpopulation in x range.
Definition: SubPopulation_Population_Manager.h:99
SubPopulation_Population_Manager::m_scale_wind_speed
float m_scale_wind_speed
The scale for wind.
Definition: SubPopulation_Population_Manager.h:125
SubPopulation_Population_Manager::m_subpopulation_base_prb_file
std::ofstream m_subpopulation_base_prb_file
The file for the storing the data.
Definition: SubPopulation_Population_Manager.h:200
SubPopulation_Population_Manager::m_first_flag_life_stage
blitz::Array< bool, 1 > m_first_flag_life_stage
Array to track whether it is the first existence for a life stage.
Definition: SubPopulation_Population_Manager.h:164
SubPopulation_Population_Manager::relocatePopulation
void relocatePopulation(void)
Relocate the population in each cell based on the suitability and movement ability.
Definition: SubPopulation_Population_Manager.cpp:452
SubPopulation_Population_Manager::m_landing_masks
blitz::Array< blitz::Array< double, 2 >, 2 > m_landing_masks
The array to store the landing masks. The vector is indexed by the wind speed index first and the sec...
Definition: SubPopulation_Population_Manager.h:191
SubPopulation_Population_Manager::m_hibernated_hatch_flag
bool m_hibernated_hatch_flag
Flag variable to indicate hibernated eggs are ready to hatch.
Definition: SubPopulation_Population_Manager.h:162
SubPopulation_Population_Manager::updateMortalityArray
virtual void updateMortalityArray(void)
This function is used to update the daily mortality rate for all the ages. In this base class,...
Definition: SubPopulation_Population_Manager.cpp:879
SubPopulation
The class for base animal using subpopulation method.
Definition: SubPopulation.h:56
SubPopulation_Population_Manager::m_current_flying_array
blitz::Array< double, 1 > m_current_flying_array
Temporal array for the flying subpopulation.
Definition: SubPopulation_Population_Manager.h:166
SubPopulation_Population_Manager::doParasitoidDevelopment
virtual void doParasitoidDevelopment()
The function for parasitoid calculation, it does nothing in this base class.
Definition: SubPopulation_Population_Manager.h:336
SubPopulation_Population_Manager::m_winter_hosts_tole_period_map
std::map< int, int > m_winter_hosts_tole_period_map
The map to store the index for the winter host period.
Definition: SubPopulation_Population_Manager.h:174
SubPopulation_Population_Manager::m_wind_speed_num
int m_wind_speed_num
The number of wind speed samples.
Definition: SubPopulation_Population_Manager.h:133
SubPopulation_Population_Manager::m_num_y_range
int m_num_y_range
The number of subpopulation in y range.
Definition: SubPopulation_Population_Manager.h:101
SubPopulation_Population_Manager::m_short_move_mask
blitz::Array< double, 4 > m_short_move_mask
Short distance movement mask.
Definition: SubPopulation_Population_Manager.h:117
Landscape::SupplyPolyRefIndex
int SupplyPolyRefIndex(int a_x, int a_y)
Get the index to the m_elems array for a polygon at location x,y.
Definition: Landscape.h:2172
SubPopulation_Population_Manager::m_long_move_mask_y_num_half
int m_long_move_mask_y_num_half
Definition: SubPopulation_Population_Manager.h:144
count
Definition: SubPopulation.h:48
struct_SubPopulation::starting_suitability
double * starting_suitability
Starting suitability for the subpopulation.
Definition: SubPopulation_Population_Manager.h:66
Landscape::SupplyDaylength
int SupplyDaylength(void)
Passes a request on to the associated Weather class function, the day length for the current day.
Definition: Landscape.h:2201
SubPopulation_Population_Manager::m_accumu_degree_days
blitz::Array< double, 2 > m_accumu_degree_days
Array for accumulated degree days for each life circle.
Definition: SubPopulation_Population_Manager.h:152
struct_SubPopulation::y
int y
y-coord
Definition: SubPopulation_Population_Manager.h:52
SubPopulation_Population_Manager::m_optimal_temperature
blitz::Array< double, 1 > m_optimal_temperature
The optimal development temperature for the species. (Mortality rate = 0).
Definition: SubPopulation_Population_Manager.h:92
SubPopulation_Population_Manager::m_short_move_mask_x_num
int m_short_move_mask_x_num
Definition: SubPopulation_Population_Manager.h:148
g_Species
TTypesOfPopulation g_Species
Definition: PopulationManager.cpp:101
cfg_Subpopu_Base_Output_Used
CfgBool cfg_Subpopu_Base_Output_Used("SUBPOPU_BASE_OUTPUT_USED", CFG_CUSTOM, true)
cfg_Subpopu_Base_Output_Filename
CfgStr cfg_Subpopu_Base_Output_Filename("SUBPOPU_BASE_OUTPUT_FILENAME", CFG_CUSTOM, "SubpopuBaseOutput.txt")
SubPopulation_Population_Manager::m_sub_w
int m_sub_w
Variable to record the width of the subpopulation cell.
Definition: SubPopulation_Population_Manager.h:107
SubPopulation_Population_Manager::supplyNewestIndex
int supplyNewestIndex(int life_stage_index)
Definition: SubPopulation_Population_Manager.h:248
SubPopulation_Population_Manager::m_winter_host_on
bool m_winter_host_on
The flag to enalble winter host.
Definition: SubPopulation_Population_Manager.h:206