ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
Population_Manager Class Reference

Base class for all population managers for agent based models. More...

#include <PopulationManager.h>

Inheritance diagram for Population_Manager:
Population_Manager_Base Beetle_Population_Manager None_Population_Manager Osmia_Population_Manager OsmiaParasitoid_Population_Manager Skylark_Population_Manager Spider_Population_Manager THare_Population_Manager TPredator_Population_Manager Vole_Population_Manager

Public Member Functions

 Population_Manager (Landscape *a_l_ptr, int a_numberLifeStages=12)
 
virtual ~Population_Manager (void)
 
void SetNoProbesAndSpeciesSpecificFunctions (int a_pn) override
 Sets up probe and species specifics. More...
 
void OpenTheAOROutputProbe (const string &a_AORFilename) override
 Opens the AOR output file. More...
 
unsigned GetLiveArraySize (int a_listindex) override
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
unsigned GetPopulationSize (int a_listindex) override
 Gets the number of species objects by default it is the same as LiveArray, however it could be different. This function should be used/overriden when we are interested in the number of the objects for presentation and not in inner maintenance of the PopulationManager and or TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time) override
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize () const
 
void Run (int NoTSteps) override
 
virtual unsigned Probe (int ListIndex, Probe_Data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
virtual TAnimalSupplyAnimalPtr (unsigned int a_index, unsigned int a_animal)
 Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More...
 
virtual unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex) const
 
void PushIndividual (const unsigned a_listindex, TAnimal *a_individual_ptr)
 
const char * SupplyStateNames (int i) const
 
unsigned SupplyStateNamesLength () const
 
virtual void DisplayLocations ()
 
TAnimalFindIndividual (unsigned Type, TAnimal *a_me)
 
virtual TAnimalFindClosest (int x, int y, unsigned Type, TAnimal *a_me)
 
omp_nest_lock_t * GetGuardMapElement (unsigned a_x_index, unsigned a_y_index)
 Return the guard map cell. More...
 
void SetGuardMapElement (unsigned a_x_index, unsigned a_y_index)
 Set the given guard map cell. More...
 
void UnsetGuardMapElement (unsigned a_x_index, unsigned a_y_index)
 Unset the given guard map cell. More...
 
void UpdateGuardMap (int a_x, int a_y, int &a_index_x, int &a_index_y)
 Get the index of the guard map for the given location. More...
 
bool OpenTheRipleysOutputProbe ()
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheAOROutputProbe ()
 
virtual void TheRipleysOutputProbe (ofstream *a_prb)
 Special output functionality. More...
 
virtual void TheReallyBigOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe () const
 
virtual void CloseTheRipleysOutputProbe ()
 
virtual void CloseTheReallyBigOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 
void Debug_Shuffle (unsigned int Type)
 
virtual void RunStepMethods ()
 
- 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...
 
int SupplyListNameLength () const
 
const char * SupplyListName (int a_i) const
 Get a list name from the list. More...
 
virtual void SupplyLocXY (unsigned, unsigned, int &, int &)
 A stub for identifying an individual at a location. More...
 
virtual TAnimalFindClosest (int, int, unsigned)
 A stub for identifying an individual at a location. More...
 
std::string SupplySimulationName ()
 
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...
 

Public Attributes

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

Protected Member Functions

virtual bool StepFinished ()
 Methods to run the simulations. More...
 
virtual void DoFirst ()
 
virtual void DoBefore ()
 
virtual void DoAfter ()
 
virtual void DoLast ()
 
virtual void DoSpecialBetweenLifeStages (int a_life_stage)
 
virtual void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
virtual void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
virtual unsigned PartitionLiveDead (unsigned Type)
 
virtual void Shuffle_or_Sort (unsigned Type)
 
virtual void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 
- Protected Member Functions inherited from Population_Manager_Base
 ~Population_Manager_Base ()=default
 

Protected Attributes

vector< unsigned > m_LiveArraySize
 
int m_NoProbes = 0
 
std::vector< std::vector< omp_nest_lock_t * > > m_MapGuard
 This is used to make sure animals will not behaviour at the same area - multi threads. More...
 
int m_guard_cell_height_num
 
int m_guard_cell_width_num
 
int m_guard_cell_size
 
bool m_is_paralleled
 This is used to indicate whether the species is paralleled. More...
 
const char * StateNames [100] {}
 
int m_StepSize {}
 
vector< vector< forward_list< TAnimal * > * > > TheSubArrays
 Hold all the animal pointers. More...
 
vector< vector< int > > TheSubArraysSizes
 Hold all the animal sizes in each thread. More...
 
vector< int > m_LifeStageOrderVec
 The vector to store the life stage order for looping specie life stages. More...
 
vector< forward_list< TAnimal * >::iterator > TheSubArraysIterators
 the iterator from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the derived class. More...
 
vector< int > TheSubArrayPreviousIndex
 the animal index number from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the derived class. More...
 
vector< int > TheSubArrayThreadIndex
 the thread index number from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the derived class. More...
 
unsigned StateNamesLength
 
FILE * TestFile {}
 
FILE * TestFile2 {}
 
vector< unsigned > BeforeStepActions
 Holds the season list of possible before step actions. More...
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type {TOP_NoSpecies}
 
ofstream * AOROutputPrb {}
 
ofstream * RipleysOutputPrb {}
 
ofstream * RipleysOutputPrb1 {}
 
ofstream * RipleysOutputPrb2 {}
 
ofstream * RipleysOutputPrb3 {}
 
ofstream * RipleysOutputPrb4 {}
 
ofstream * RipleysOutputPrb5 {}
 
ofstream * RipleysOutputPrb6 {}
 
ofstream * RipleysOutputPrb7 {}
 
ofstream * RipleysOutputPrb8 {}
 
ofstream * RipleysOutputPrb9 {}
 
ofstream * RipleysOutputPrb10 {}
 
ofstream * RipleysOutputPrb11 {}
 
ofstream * RipleysOutputPrb12 {}
 
ofstream * ReallyBigOutputPrb {}
 
AOR_Probem_AOR_Probe {}
 A pointer to the AOR probe. More...
 
long int lamdagrid [2][257][257] {}
 
- 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...
 

Detailed Description

Base class for all population managers for agent based models.

The core of the handling of animal populations. All time-step code and most input/output is handled by this class and its descendents. This class effectively implements a state machine to facilitate simulation of animal behaviours and handle potential issues with concurrency. The PopulationManager class is never instantiated but must be used by deriving a descendent class.

Constructor & Destructor Documentation

◆ Population_Manager()

Population_Manager::Population_Manager ( Landscape a_l_ptr,
int  a_numberLifeStages = 12 
)

Constructor for the Population_Manager class

200  : Population_Manager_Base(a_l_ptr) {
201  // create N empty arrays
202  TheSubArraysIterators.resize(a_numberLifeStages);
203  TheSubArrayPreviousIndex.resize(a_numberLifeStages);
204  TheSubArrayThreadIndex.resize(a_numberLifeStages);
205  TheSubArrays.resize(a_numberLifeStages);
206  TheSubArraysSizes.resize(a_numberLifeStages);
207  m_LifeStageOrderVec.resize(a_numberLifeStages);
208  for (int i = 0; i < a_numberLifeStages; i++)
209  {
210  TheSubArrayPreviousIndex[i] = -1;
211  TheSubArrayThreadIndex[i] = -1;
212  TheSubArrays[i].resize(g_thread_count);
214  for (int j = 0; j < g_thread_count; j++){
215  TheSubArrays[i][j] = new forward_list<TAnimal*>;
216  TheSubArraysSizes[i][j] = 0;
217  }
218  m_LifeStageOrderVec[i] = i;
219  }
220 
221  BeforeStepActions.resize(a_numberLifeStages);
222  for (int i = 0; i < a_numberLifeStages; i++)
223  {
224  // Set default BeforeStepActions
225  BeforeStepActions[i] = 0;
226  m_ListNames[i] = "Unknown";
227  m_LiveArraySize.push_back(0);
228  }
229  // modify this if they need to in descendent classes
230  StateNamesLength = 0; // initialise this variable.
231 #ifdef __LAMBDA_RECORD
232  ofstream fout("LambdaGridOuput.txt", ios_base::out); // open for writing
233  fout.close();
234  LamdaClear();
235 #endif
237  // Ensure the GUI pointer is NULL in case we are not in GUI mode
238  m_SeasonNumber = 0; // Ensure that we start in season number 0. Season number is incremented at day in year 183
239 
240  //initialise map guard thing
244 
245 
247  for(int j = 0; j < m_guard_cell_height_num; j++){
249  for(int k = 0; k < m_guard_cell_width_num; k++){
250  m_MapGuard[j][k] = new omp_nest_lock_t;
251  omp_init_nest_lock(m_MapGuard[j][k]);
252  }
253  }
254 
255  m_is_paralleled = false; //by default it is not paralleled
256 }

References BeforeStepActions, cfg_MapGuardCellSize, cfg_RipleysOutputMonthly_used, g_thread_count, LamdaClear(), m_guard_cell_height_num, m_guard_cell_size, m_guard_cell_width_num, m_is_paralleled, m_LifeStageOrderVec, Population_Manager_Base::m_ListNames, m_LiveArraySize, m_MapGuard, m_SeasonNumber, OpenTheMonthlyRipleysOutputProbe(), Population_Manager_Base::SimH, Population_Manager_Base::SimW, StateNamesLength, TheSubArrayPreviousIndex, TheSubArrays, TheSubArraysIterators, TheSubArraysSizes, TheSubArrayThreadIndex, CfgInt::value(), and CfgBool::value().

◆ ~Population_Manager()

Population_Manager::~Population_Manager ( void  )
virtual

Destructor for the Population_Manager class

262  {
263  // clean-up // no need to delete members of the array
267  if (cfg_AorOutput_used.value()) delete m_AOR_Probe;
268  for (int i = 0; i < TheSubArrays.size(); i++)
269  {
270  for (int j = 0; j < TheSubArrays[i].size(); j++){
271  for (auto it = TheSubArrays[i][j]->begin(); it != TheSubArrays[i][j]->end(); ++it){
272  if(*it != nullptr)
273  delete *it;
274  }
275  if(TheSubArrays[i][j] != nullptr)
276  delete TheSubArrays[i][j];
277  }
278  }
279 
280 
281  for(int j = 0; j < m_guard_cell_height_num; j++){
282  for(int k = 0; k < m_guard_cell_width_num; k++){
283  omp_destroy_nest_lock(m_MapGuard[j][k]);
284  delete m_MapGuard[j][k];
285  }
286  }
287 }

References cfg_AorOutput_used, cfg_CfgRipleysOutputUsed, cfg_ReallyBigOutputUsed, cfg_RipleysOutputMonthly_used, CloseTheMonthlyRipleysOutputProbe(), CloseTheReallyBigOutputProbe(), CloseTheRipleysOutputProbe(), m_AOR_Probe, m_guard_cell_height_num, m_guard_cell_width_num, m_MapGuard, TheSubArrays, and CfgBool::value().

Member Function Documentation

◆ BeginningOfMonth()

bool Population_Manager::BeginningOfMonth ( )

Is it the first day of the month?

1282  {
1283  if (m_TheLandscape->SupplyDayInMonth() == cfg_DayInMonth.value()) return true;
1284  return false;
1285 }

References cfg_DayInMonth, Population_Manager_Base::m_TheLandscape, Landscape::SupplyDayInMonth(), and CfgInt::value().

Referenced by ImpactProbeReport(), and ProbeReport().

◆ BreedingPairsOutput()

virtual void Population_Manager::BreedingPairsOutput ( int  )
inlinevirtual

Reimplemented in Skylark_Population_Manager.

905  {
906  }

Referenced by SpeciesSpecificReporting().

◆ BreedingSuccessProbeOutput()

virtual void Population_Manager::BreedingSuccessProbeOutput ( double  ,
int  ,
int  ,
int  ,
int  ,
int  ,
int  ,
int   
)
inlinevirtual

Reimplemented in Skylark_Population_Manager.

910  {
911  }

Referenced by SpeciesSpecificReporting().

◆ Catastrophe()

void Population_Manager::Catastrophe ( void  )
protectedvirtual

This method MUST be overidden in descendent classes if this functionality is does not match with the animals requirements

Reimplemented in Beetle_Population_Manager, THare_Population_Manager, Skylark_Population_Manager, Vole_Population_Manager, Spider_Population_Manager, Oedothorax_Population_Manager, and Erigone_Population_Manager.

1289  {
1294 }

◆ CloseTheMonthlyRipleysOutputProbe()

void Population_Manager::CloseTheMonthlyRipleysOutputProbe ( ) const

close the monthly probes

1029  {
1030  RipleysOutputPrb1->close();
1031  RipleysOutputPrb2->close();
1032  RipleysOutputPrb3->close();
1033  RipleysOutputPrb4->close();
1034  RipleysOutputPrb5->close();
1035  RipleysOutputPrb6->close();
1036  RipleysOutputPrb7->close();
1037  RipleysOutputPrb8->close();
1038  RipleysOutputPrb9->close();
1039  RipleysOutputPrb10->close();
1040  RipleysOutputPrb11->close();
1041  RipleysOutputPrb12->close();
1042 }

References RipleysOutputPrb1, RipleysOutputPrb10, RipleysOutputPrb11, RipleysOutputPrb12, RipleysOutputPrb2, RipleysOutputPrb3, RipleysOutputPrb4, RipleysOutputPrb5, RipleysOutputPrb6, RipleysOutputPrb7, RipleysOutputPrb8, and RipleysOutputPrb9.

Referenced by ~Population_Manager().

◆ CloseTheReallyBigOutputProbe()

void Population_Manager::CloseTheReallyBigOutputProbe ( )
virtual

close the probe

Reimplemented in TPredator_Population_Manager.

1048  {
1049  if (ReallyBigOutputPrb != nullptr) ReallyBigOutputPrb->close();
1050  ReallyBigOutputPrb = nullptr;
1051 }

References ReallyBigOutputPrb.

Referenced by ~Population_Manager().

◆ CloseTheRipleysOutputProbe()

void Population_Manager::CloseTheRipleysOutputProbe ( )
virtual

close the probe

1020  {
1022  RipleysOutputPrb = nullptr;
1023 }

References cfg_RipleysOutputMonthly_used, RipleysOutputPrb, and CfgBool::value().

Referenced by ~Population_Manager().

◆ Debug_Shuffle()

void Population_Manager::Debug_Shuffle ( unsigned int  Type)

◆ DisplayLocations()

void Population_Manager::DisplayLocations ( )
virtual

Used to update the graphics when control is not returned to the ALMaSS_GUI between timesteps.

661  {
665 }

◆ DoAfter()

void Population_Manager::DoAfter ( )
protectedvirtual

Can be used in descendent classes

Reimplemented in Osmia_Population_Manager, and TPredator_Population_Manager.

648  {
649  //TODO: Add your source code here
650 }

Referenced by RunStepMethods().

◆ DoBefore()

void Population_Manager::DoBefore ( )
protectedvirtual

Can be used in descendent classes

Reimplemented in Beetle_Population_Manager, Osmia_Population_Manager, and TPredator_Population_Manager.

341  {
342 }

Referenced by RunStepMethods().

◆ DoFirst()

◆ DoLast()

void Population_Manager::DoLast ( )
protectedvirtual

Collects some data to describe the number of animals in each state at the end of the day

Reimplemented in Beetle_Population_Manager, THare_Population_Manager, PoecilusCupreus_Population_Manager, Osmia_Population_Manager, and TPredator_Population_Manager.

656  {
657  //TODO: Add your source code here
658 }

Referenced by THare_Population_Manager::DoLast(), and RunStepMethods().

◆ DoSpecialBetweenLifeStages()

virtual void Population_Manager::DoSpecialBetweenLifeStages ( int  a_life_stage)
inlineprotectedvirtual

Reimplemented in Ladybird_Population_Manager.

829 {;}

Referenced by RunStepMethods().

◆ FarmAnimalCensus()

unsigned int Population_Manager::FarmAnimalCensus ( unsigned int  a_farm,
unsigned int  a_typeofanimal 
)
1448  {
1449  unsigned int No = 0;
1450  int temp_thread_num = omp_get_max_threads();
1451  for(int i=0; i<temp_thread_num; i++){
1452  for(auto it = TheSubArrays[a_typeofanimal][i]->begin(); it != TheSubArrays[a_typeofanimal][i]->end(); ++it){
1453  if((*it)->GetCurrentStateNo() < 0){
1454  continue;
1455  }
1456  if (a_farm == (*it)->SupplyFarmOwnerRef()) No++;
1457  }
1458  }
1459  return No;
1460 }

References TheSubArrays.

◆ FindClosest()

TAnimal * Population_Manager::FindClosest ( int  x,
int  y,
unsigned  Type,
TAnimal a_me 
)
virtual

Finds the closest individual to an x,y point that is not a_me

1102  {
1103 
1104  int distance = 100000000;
1105  TAnimal* TA = nullptr;
1106  int temp_thread_num = omp_get_max_threads();
1107  for(int j=0; j<temp_thread_num; j++){
1108  for(auto it = TheSubArrays[Type][j]->begin(); it != TheSubArrays[Type][j]->end(); ++it){
1109  int dx = (*it)->Supply_m_Location_x();
1110  int dy = (*it)->Supply_m_Location_y();
1111  dx = dx - x;
1112  dx *= dx;
1113  dy = dy - y;
1114  dy *= dy;
1115  int d = dx + dy;
1116  if (d < distance)
1117  {
1118  if ((*it) != a_me)
1119  {
1120  if ((*it)->GetCurrentStateNo() != -1)
1121  {
1122  TA = (*it);
1123  distance = d;
1124  }
1125  }
1126  }
1127  }
1128  }
1129  return TA;
1130 }

References TheSubArrays.

◆ FindIndividual()

TAnimal * Population_Manager::FindIndividual ( unsigned  Type,
TAnimal a_me 
)

Gets a random live individual returned as TAnimal*

Gets a random individual that is not a_me

1078  {
1079  int i = static_cast<int>(GetLiveArraySize(Type) * g_rand_uni_fnc());
1080  int temp_thread_num = omp_get_max_threads();
1081 
1082  int temp_animal_num = 0;
1083  for(int j=0; j<temp_thread_num; j++){
1084  for(auto it = TheSubArrays[Type][j]->begin(); it != TheSubArrays[Type][j]->end(); ++it){
1085  if(temp_animal_num >= i){
1086  if((*it) != a_me){
1087  return (*it);
1088  }
1089  }
1090  if(temp_animal_num == i){
1091  return nullptr;
1092  }
1093  temp_animal_num++;
1094  }
1095  }
1096  return nullptr;
1097 }

References g_rand_uni_fnc(), GetLiveArraySize(), and TheSubArrays.

◆ FledgelingProbeOutput()

virtual void Population_Manager::FledgelingProbeOutput ( int  ,
int   
)
inlinevirtual

Reimplemented in Skylark_Population_Manager.

914  {
915  }

Referenced by SpeciesSpecificReporting().

◆ GeneticsResultsOutput()

virtual void Population_Manager::GeneticsResultsOutput ( FILE *  ,
unsigned   
)
inlinevirtual

Reimplemented in Vole_Population_Manager.

918  {
919  }

◆ GetGuardMapElement()

omp_nest_lock_t* Population_Manager::GetGuardMapElement ( unsigned  a_x_index,
unsigned  a_y_index 
)
inline

Return the guard map cell.

751  {
752  return m_MapGuard[a_y_index][a_x_index];
753  }

References m_MapGuard.

◆ GetLiveArraySize()

unsigned Population_Manager::GetLiveArraySize ( int  a_listindex)
inlineoverridevirtual

Gets the number of 'live' objects for a list index in the TheArray.

Reimplemented from Population_Manager_Base.

657 { return m_LiveArraySize[a_listindex]; }

References m_LiveArraySize.

Referenced by Skylark_Population_Manager::BreedingPairsOutput(), Erigone_Population_Manager::Catastrophe(), Oedothorax_Population_Manager::Catastrophe(), Vole_Population_Manager::Catastrophe(), Skylark_Population_Manager::Catastrophe(), THare_Population_Manager::Catastrophe(), Beetle_Population_Manager::Catastrophe(), Beetle_Population_Manager::Catastrophe2(), Osmia_Population_Manager::DoBefore(), Erigone_Population_Manager::DoFirst(), Oedothorax_Population_Manager::DoFirst(), Vole_Population_Manager::DoFirst(), THare_Population_Manager::DoFirst(), AOR_Probe_Goose::DoProbe(), AOR_Probe::DoProbeInHaitatType(), THare_Population_Manager::ExtraPopMort(), FindIndividual(), Vole_Population_Manager::FindOutsideRadiusMale(), Vole_Population_Manager::FindRandomMale(), Vole_Population_Manager::GeneticsOutputFile(), Vole_Population_Manager::GeneticsResultsOutput(), GetPopulationSize(), Beetle_Population_Manager::GetPopulationSize(), THare_Population_Manager::Hunting(), THare_Population_Manager::HuntingDifferentiatedBeetleBankArea(), THare_Population_Manager::HuntingGrid(), Vole_Population_Manager::ImpactedProbe(), Vole_Population_Manager::LandscapeQuadrantOutputProbe(), THare_Population_Manager::MRROutputs(), THare_Population_Manager::POMOutputs(), Probe(), Beetle_Population_Manager::Probe(), Skylark_Population_Manager::ProbePOM(), Skylark_Population_Manager::ReHouse(), Vole_Population_Manager::ResistanceOutput(), Vole_Population_Manager::SendMessage(), Vole_Population_Manager::TheAgeSexLocationProbe(), Skylark_Population_Manager::TheBreedingFemalesProbe(), Skylark_Population_Manager::TheBreedingSuccessProbe(), Skylark_Population_Manager::TheFledgelingProbe(), Vole_Population_Manager::TheReallyBigOutputProbe(), Beetle_Population_Manager::TheReallyBigOutputProbe(), Erigone_Population_Manager::TheRipleysOutputProbe(), Oedothorax_Population_Manager::TheRipleysOutputProbe(), Vole_Population_Manager::TheRipleysOutputProbe(), Skylark_Population_Manager::TheRipleysOutputProbe(), THare_Population_Manager::TheRipleysOutputProbe(), Beetle_Population_Manager::TheRipleysOutputProbe(), and Vole_Population_Manager::TheSexRatiosProbe().

◆ GetPopulationSize()

unsigned Population_Manager::GetPopulationSize ( int  a_listindex)
inlineoverridevirtual

Gets the number of species objects by default it is the same as LiveArray, however it could be different. This function should be used/overriden when we are interested in the number of the objects for presentation and not in inner maintenance of the PopulationManager and or TheArray.

Reimplemented from Population_Manager_Base.

Reimplemented in Beetle_Population_Manager.

663 { return GetLiveArraySize(a_listindex); }

References GetLiveArraySize().

◆ GetPopulationType()

TTypesOfPopulation Population_Manager::GetPopulationType ( )
inline
853 { return m_population_type; }

References m_population_type.

◆ GetSeasonNumber()

int Population_Manager::GetSeasonNumber ( )
inline

Get the season number.

855 { return m_SeasonNumber; }

References m_SeasonNumber.

◆ ImpactedProbe()

void Population_Manager::ImpactedProbe ( )
virtual

Special pesticide related probe. Overidden in descendent classes

Reimplemented in Vole_Population_Manager.

785  {
786 }

Referenced by ImpactProbeReport().

◆ ImpactProbeReport()

void Population_Manager::ImpactProbeReport ( int  a_Time)

Special probe

1513  {
1514  for (int ProbeNo = 0; ProbeNo < 1; ProbeNo++)
1515  {
1516  // See if we need to record/update this one
1517  // if time/months/years ==0 or every time
1518  if (TheProbe[ProbeNo]->m_ReportInterval == 3 || (TheProbe[ProbeNo]->m_ReportInterval == 2 && BeginningOfMonth())
1519  || (TheProbe[ProbeNo]->m_ReportInterval == 1 && a_Time % 365 == 0)) { ImpactedProbe(); }
1520  }
1521 }

References BeginningOfMonth(), ImpactedProbe(), and Population_Manager_Base::TheProbe.

Referenced by SpeciesSpecificReporting().

◆ IncLiveArraySize()

◆ LamdaBirth() [1/2]

void Population_Manager::LamdaBirth ( int  x,
int  y 
)
inline
883 { lamdagrid[0][x / __lgridsize][y / __lgridsize]++; }

References lamdagrid.

Referenced by Beetle_Egg_List::St_Hatch().

◆ LamdaBirth() [2/2]

void Population_Manager::LamdaBirth ( int  x,
int  y,
int  z 
)
inline
884 { lamdagrid[0][x / __lgridsize][y / __lgridsize] += z; }

References lamdagrid.

◆ LamdaClear()

void Population_Manager::LamdaClear ( )
inline
885  {
886  for (int i = 0; i < 257; i++)
887  {
888  for (int j = 0; j < 257; j++)
889  {
890  lamdagrid[0][i][j] = 0;
891  lamdagrid[1][i][j] = 0;
892  }
893  }
894  }

References lamdagrid.

Referenced by Beetle_Population_Manager::DoFirst(), and Population_Manager().

◆ LamdaDeath()

void Population_Manager::LamdaDeath ( int  x,
int  y 
)
inline
879  {
880  // inlined for speed
881  lamdagrid[1][x / __lgridsize][y / __lgridsize]++;
882  }

References lamdagrid.

Referenced by Beetle_Base::StDie().

◆ LamdaDumpOutput()

void Population_Manager::LamdaDumpOutput ( )

Special probe

771  {
772  ofstream fout("LambdaGridOuput.txt", ios_base::app); // open for writing
773  for (int i = 0; i < 257; i++)
774  {
775  for (int j = 0; j < 257; j++) { fout << lamdagrid[0][i][j] << "\t" << lamdagrid[1][i][j] << endl; }
776  }
777  //fout << "NEXT" << endl;
778  fout.close();
779 }

References lamdagrid.

Referenced by Beetle_Population_Manager::DoFirst().

◆ LOG()

void Population_Manager::LOG ( const char *  fname)

Debug function used to log whatever is needed - this is just a place to write whatever is needed at the time - so contents vary

304  {
305  FILE* PFile = fopen(fname, "w");
306  if (PFile)
307  {
308  m_TheLandscape->Warn("PopulationManager::LOG - Could not open file ", fname);
309  exit(0);
310  }
311  AnimalPosition AP;
312  for (unsigned listindex = 0; listindex < TheSubArrays.size(); listindex++)
313  {
314 #ifndef __BCB__
315  fprintf(PFile, "%s :\n", m_ListNames[listindex]);
316 #else
317  fprintf( PFile, "%s :\n", m_ListNames[ listindex ].c_str() );
318 #endif
319  for (unsigned j = 0; j < m_LiveArraySize[listindex]; j++)
320  {
321  AP = SupplyAnimalPtr(listindex, j)->SupplyPosition();
322  fprintf(PFile, "%i %i %i\n", j, AP.m_x, AP.m_y);
323  }
324  }
325  fclose(PFile);
326 }

References Population_Manager_Base::m_ListNames, m_LiveArraySize, Population_Manager_Base::m_TheLandscape, AnimalPosition::m_x, AnimalPosition::m_y, SupplyAnimalPtr(), TAnimal::SupplyPosition(), TheSubArrays, and Landscape::Warn().

◆ OpenTheAOROutputProbe()

void Population_Manager::OpenTheAOROutputProbe ( const string &  a_AORFilename)
overridevirtual

Opens the AOR output file.

Reimplemented from Population_Manager_Base.

Reimplemented in Beetle_Population_Manager.

295  {
296  m_AORProbeFileName = a_AORFilename;
297  m_AOR_Probe = new AOR_Probe(this, m_TheLandscape, a_AORFilename);
298 }

References m_AOR_Probe, Population_Manager_Base::m_AORProbeFileName, and Population_Manager_Base::m_TheLandscape.

◆ OpenTheBreedingPairsProbe()

virtual bool Population_Manager::OpenTheBreedingPairsProbe ( )
inlinevirtual

Reimplemented in Skylark_Population_Manager.

903 { return false; }

◆ OpenTheBreedingSuccessProbe()

virtual bool Population_Manager::OpenTheBreedingSuccessProbe ( )
inlinevirtual

Reimplemented in Skylark_Population_Manager.

904 { return false; }

◆ OpenTheFledgelingProbe()

virtual bool Population_Manager::OpenTheFledgelingProbe ( )
inlinevirtual

Reimplemented in Skylark_Population_Manager.

902 { return false; }

◆ OpenTheMonthlyRipleysOutputProbe()

bool Population_Manager::OpenTheMonthlyRipleysOutputProbe ( )

open 12 ripley output probes, one for each month

912  {
913  RipleysOutputPrb1 = new ofstream("RipleyOutput_Jan.txt");
914  if (!RipleysOutputPrb1)
915  {
916  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
918  exit(1);
919  }
920  RipleysOutputPrb2 = new ofstream("RipleyOutput_Feb.txt");
921  if (!RipleysOutputPrb2)
922  {
923  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
925  exit(1);
926  }
927  RipleysOutputPrb3 = new ofstream("RipleyOutput_Mar.txt");
928  if (!RipleysOutputPrb3)
929  {
930  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
932  exit(1);
933  }
934  RipleysOutputPrb4 = new ofstream("RipleyOutput_Apr.txt");
935  if (!RipleysOutputPrb4)
936  {
937  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
939  exit(1);
940  }
941  RipleysOutputPrb5 = new ofstream("RipleyOutput_May.txt");
942  if (!RipleysOutputPrb5)
943  {
944  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
946  exit(1);
947  }
948  RipleysOutputPrb6 = new ofstream("RipleyOutput_Jun.txt");
949  if (!RipleysOutputPrb6)
950  {
951  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
953  exit(1);
954  }
955  RipleysOutputPrb7 = new ofstream("RipleyOutput_Jul.txt");
956  if (!RipleysOutputPrb7)
957  {
958  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
960  exit(1);
961  }
962  RipleysOutputPrb8 = new ofstream("RipleyOutput_Aug.txt");
963  if (!RipleysOutputPrb8)
964  {
965  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
967  exit(1);
968  }
969  RipleysOutputPrb9 = new ofstream("RipleyOutput_Sep.txt");
970  if (!RipleysOutputPrb9)
971  {
972  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
974  exit(1);
975  }
976  RipleysOutputPrb10 = new ofstream("RipleyOutput_Oct.txt");
977  if (!RipleysOutputPrb10)
978  {
979  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
981  exit(1);
982  }
983  RipleysOutputPrb11 = new ofstream("RipleyOutput_Nov.txt");
984  if (!RipleysOutputPrb11)
985  {
986  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
988  exit(1);
989  }
990  RipleysOutputPrb12 = new ofstream("RipleyOutput_Dec.txt");
991  if (!RipleysOutputPrb12)
992  {
993  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
995  exit(1);
996  }
997  return true;
998 }

References cfg_RipleysOutput_filename, g_msg, RipleysOutputPrb1, RipleysOutputPrb10, RipleysOutputPrb11, RipleysOutputPrb12, RipleysOutputPrb2, RipleysOutputPrb3, RipleysOutputPrb4, RipleysOutputPrb5, RipleysOutputPrb6, RipleysOutputPrb7, RipleysOutputPrb8, RipleysOutputPrb9, CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Population_Manager().

◆ OpenTheReallyBigProbe()

bool Population_Manager::OpenTheReallyBigProbe ( )

open the probe

1005  {
1007  if (!ReallyBigOutputPrb)
1008  {
1009  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
1011  exit(1);
1012  }
1013  return true;
1014 }

References cfg_ReallyBigOutput_filename, g_msg, ReallyBigOutputPrb, CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Beetle_Population_Manager::Beetle_Population_Manager(), Erigone_Population_Manager::Init(), Oedothorax_Population_Manager::Init(), Vole_Population_Manager::Init(), Skylark_Population_Manager::Init(), and THare_Population_Manager::Init().

◆ OpenTheRipleysOutputProbe()

bool Population_Manager::OpenTheRipleysOutputProbe ( )

open the Ripley probe

897  {
899  if (!RipleysOutputPrb)
900  {
901  g_msg->Warn(WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
903  exit(1);
904  }
905  return true;
906 }

References cfg_RipleysOutput_filename, g_msg, RipleysOutputPrb, CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Beetle_Population_Manager::Beetle_Population_Manager(), Erigone_Population_Manager::Init(), Oedothorax_Population_Manager::Init(), Vole_Population_Manager::Init(), Skylark_Population_Manager::Init(), and THare_Population_Manager::Init().

◆ PartitionLiveDead()

unsigned Population_Manager::PartitionLiveDead ( unsigned  Type)
protectedvirtual

Delete the animals in the array

1181  {
1182  m_LiveArraySize[Type] = 0;
1183  for (int j=0; j < TheSubArrays[Type].size(); j++){
1184  //new ones were created, add them to the array
1185  TheSubArraysSizes[Type][j] = 0;
1186  auto prev_it = TheSubArrays[Type][j]->before_begin();
1187  for (auto it = TheSubArrays[Type][j]->begin(); it != TheSubArrays[Type][j]->end();){
1188  //still alive
1189  if((*it)->GetCurrentStateNo()>=0){
1190  m_LiveArraySize[Type]++;
1191  TheSubArraysSizes[Type][j] += 1;
1192  prev_it = it;
1193  ++it; //only increment if not deleted
1194  }
1195  else{
1196  delete *it;
1197  it = TheSubArrays[Type][j]->erase_after(prev_it);
1198  }
1199  }
1200  }
1201 
1202  //let's check if there is thread without any live animals, then we move some to that thread from another thread
1203  for(int i=0; i<TheSubArrays[Type].size(); i++){
1204  if(TheSubArraysSizes[Type][i]==0){
1205  //find another thread with more than one animal
1206  for(int j=0; j<TheSubArrays[Type].size(); j++){
1207  if(TheSubArraysSizes[Type][j]>1){
1208  int temp_moved_size = TheSubArraysSizes[Type][j]/2;
1209  for(int k=0; k<=temp_moved_size; k++){
1210  TheSubArrays[Type][i]->push_front(TheSubArrays[Type][j]->front());
1211  TheSubArrays[Type][j]->pop_front();
1212  TheSubArraysSizes[Type][i] += 1;
1213  TheSubArraysSizes[Type][j] -= 1;
1214  }
1215  break;
1216  }
1217  }
1218  }
1219  }
1220  return m_LiveArraySize[Type];
1221 }

References m_LiveArraySize, TheSubArrays, and TheSubArraysSizes.

Referenced by Ladybird_Population_Manager::DoFirst(), and Run().

◆ Probe()

unsigned Population_Manager::Probe ( int  ListIndex,
Probe_Data p_TheProbe 
)
virtual

Default data probe. Rarely used in actuality but always available

Reimplemented in Beetle_Population_Manager.

792  {
793  // Counts through the list and goes through each area to see if the animal
794  // is standing there and if the farm, veg or element conditions are met
795  AnimalPosition Sp;
796  long NumberSk = 0;
797  // Four possibilities
798  // either NoVegTypes or NoElementTypes or NoFarmTypes is >0 or all==0
799  int temp_thread_num = omp_get_max_threads();
800  if (p_TheProbe->m_NoFarms != 0)
801  {
802  for (int thread_id=0; thread_id<temp_thread_num; thread_id++){
803  for(auto it = TheSubArrays[ListIndex][thread_id]->begin(); it != TheSubArrays[ListIndex][thread_id]->end(); ++it){
804  if((*it)->GetCurrentStateNo() < 0){
805  continue;
806  }
807  Sp = (*it)->SupplyPosition();
808  unsigned Farm = (*it)->SupplyFarmOwnerRef();
809  for (int i = 0; i < p_TheProbe->m_NoAreas; i++)
810  {
811  if ((p_TheProbe->m_FullLandscapeProbe) || (Sp.m_x >= p_TheProbe->m_Rect[i].m_x1 && Sp.m_y >= p_TheProbe->m_Rect[i].m_y1 && Sp.
812  m_x <= p_TheProbe->m_Rect[i].m_x2 && Sp.m_y <= p_TheProbe->m_Rect[i].m_y2))
813  for (int k = 0; k < p_TheProbe->m_NoFarms; k++)
814  {
815  if (p_TheProbe->m_RefFarms[k] == Farm) NumberSk++; // it is in the square so increment number
816  }
817  }
818  }
819  }
820  }
821  else if (p_TheProbe->m_NoEleTypes != 0)
822  {
823  for (int thread_id=0; thread_id<temp_thread_num; thread_id++){
824  for(auto it = TheSubArrays[ListIndex][thread_id]->begin(); it != TheSubArrays[ListIndex][thread_id]->end(); ++it){
825  if((*it)->GetCurrentStateNo() < 0){
826  continue;
827  }
828  for (unsigned i = 0; i < p_TheProbe->m_NoAreas; i++)
829  {
830  if ((p_TheProbe->m_FullLandscapeProbe) || (Sp.m_x >= p_TheProbe->m_Rect[i].m_x1 && Sp.m_y >= p_TheProbe->m_Rect[i].m_y1 && Sp.
831  m_x <= p_TheProbe->m_Rect[i].m_x2 && Sp.m_y <= p_TheProbe->m_Rect[i].m_y2))
832  for (unsigned k = 0; k < p_TheProbe->m_NoEleTypes; k++)
833  {
834  if (p_TheProbe->m_RefEle[k] == Sp.m_EleType) NumberSk++;
835  // it is in the square so increment number
836  }
837  }
838  }
839  }
840  }
841  else
842  {
843  if (p_TheProbe->m_NoVegTypes != 0)
844  {
845  for (int thread_id=0; thread_id<temp_thread_num; thread_id++){
846  for(auto it = TheSubArrays[ListIndex][thread_id]->begin(); it != TheSubArrays[ListIndex][thread_id]->end(); ++it){
847  if((*it)->GetCurrentStateNo() < 0){
848  continue;
849  }
850  Sp = (*it)->SupplyPosition();
851  for (unsigned i = 0; i < p_TheProbe->m_NoAreas; i++)
852  {
853  if ((p_TheProbe->m_FullLandscapeProbe) || (Sp.m_x >= p_TheProbe->m_Rect[i].m_x1 && Sp.m_y >= p_TheProbe->m_Rect[i].m_y1 && Sp.
854  m_x <= p_TheProbe->m_Rect[i].m_x2 && Sp.m_y <= p_TheProbe->m_Rect[i].m_y2))
855  {
856  for (unsigned k = 0; k < p_TheProbe->m_NoVegTypes; k++)
857  {
858  if (p_TheProbe->m_RefVeg[k] == Sp.m_VegType) NumberSk++;
859  // it is in the square so increment number
860  }
861  }
862  }
863  }
864  }
865  }
866  else // both must be zero
867  {
868  unsigned sz = static_cast<long>(GetLiveArraySize(ListIndex));
869 
870  // It is worth checking whether we have a total dump of all individuals
871  // if so don't bother with asking each where it is
872  if (p_TheProbe->m_FullLandscapeProbe) return sz;
873  // Asking for a subset - need to test them all
874  for (int thread_id=0; thread_id<temp_thread_num; thread_id++){
875  for(auto it = TheSubArrays[ListIndex][thread_id]->begin(); it != TheSubArrays[ListIndex][thread_id]->end(); ++it){
876  if((*it)->GetCurrentStateNo() < 0){
877  continue;
878  }
879  Sp = (*it)->SupplyPosition();
880  for (unsigned i = 0; i < p_TheProbe->m_NoAreas; i++)
881  {
882  if (Sp.m_x >= p_TheProbe->m_Rect[i].m_x1 && Sp.m_y >= p_TheProbe->m_Rect[i].m_y1 && Sp.m_x <=
883  p_TheProbe->m_Rect[i].m_x2 && Sp.m_y <= p_TheProbe->m_Rect[i].m_y2) NumberSk++;
884  // it is in the square so increment number
885  }
886  }
887  }
888  }
889  }
890  return NumberSk;
891 }

References GetLiveArraySize(), AnimalPosition::m_EleType, Probe_Data::m_FullLandscapeProbe, Probe_Data::m_NoAreas, Probe_Data::m_NoEleTypes, Probe_Data::m_NoFarms, Probe_Data::m_NoVegTypes, Probe_Data::m_Rect, Probe_Data::m_RefEle, Probe_Data::m_RefFarms, Probe_Data::m_RefVeg, AnimalPosition::m_VegType, AnimalPosition::m_x, rectangle::m_x1, rectangle::m_x2, AnimalPosition::m_y, rectangle::m_y1, rectangle::m_y2, and TheSubArrays.

Referenced by ProbeReport(), and ProbeReportTimed().

◆ ProbeReport()

char * Population_Manager::ProbeReport ( int  a_time)
1463  {
1464  char str[100]; // 100 out to be enough!!
1465  strcpy(g_Str, "");
1466  for (int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++)
1467  {
1468  int No = 0;
1469  // See if we need to record/update this one
1470  // if time/months/years ==0 or every time
1471  if (TheProbe[ProbeNo]->m_ReportInterval == 3 || (TheProbe[ProbeNo]->m_ReportInterval == 2 && BeginningOfMonth())
1472  || (TheProbe[ProbeNo]->m_ReportInterval == 1 && Time % 365 == 0))
1473  {
1474  // Goes through each area and sends a value to OutputForm
1475  unsigned Index = SupplyListIndexSize();
1476  for (unsigned listindex = 0; listindex < Index; listindex++)
1477  {
1478  if (TheProbe[ProbeNo]->m_TargetTypes[listindex]) No += static_cast<int>(Probe(
1479  listindex, TheProbe[ProbeNo]));
1480  }
1481  TheProbe[ProbeNo]->FileOutput(No, Time, ProbeNo);
1482  sprintf(str, " %d ", No);
1483  strcat(g_Str, str);
1484  }
1485  }
1486  return g_Str;
1487 }

References BeginningOfMonth(), Probe_Data::FileOutput(), g_Str, m_NoProbes, Probe(), SupplyListIndexSize(), and Population_Manager_Base::TheProbe.

Referenced by SpeciesSpecificReporting().

◆ ProbeReportTimed()

char * Population_Manager::ProbeReportTimed ( int  a_time)
1490  {
1491  char str[100]; // 100 ought to be enough!!
1492  strcpy(g_Str, "");
1493  for (int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++)
1494  {
1495  int No = 0;
1496  unsigned Index = SupplyListIndexSize();
1497  for (unsigned listindex = 0; listindex < Index; listindex++)
1498  {
1499  if (TheProbe[ProbeNo]->m_TargetTypes[listindex]) No += static_cast<int>(
1500  Probe(listindex, TheProbe[ProbeNo]));
1501  }
1502  TheProbe[ProbeNo]->FileOutput(No, Time, ProbeNo);
1503  sprintf(str, " %d ", No);
1504  strcat(g_Str, str);
1505  }
1506  return g_Str;
1507 }

References Probe_Data::FileOutput(), g_Str, m_NoProbes, Probe(), SupplyListIndexSize(), and Population_Manager_Base::TheProbe.

◆ PushIndividual()

void Population_Manager::PushIndividual ( const unsigned  a_listindex,
TAnimal a_individual_ptr 
)

◆ Run()

void Population_Manager::Run ( int  NoTSteps)
overridevirtual

This is the main scheduling method for the population manager.
Note the structure of Shuffle_or_Sort(), DoFirst(), BeginStep, DoBefore(), Step looping until all are finished, DoAfter(), EndStep, DoLast().

Can do multiple time-steps here inside one landscape time-step (a day). This is used in the roe deer model to provide 10 minute behavioural time-steps.

It is necessary to remove any dead animals before the timestep starts. It is possible that animals are killed after their population manager Run method has been executed. This is the case with geese and hunters. Checking death first prevents this becomming a problem.

Reimplemented from Population_Manager_Base.

Reimplemented in TPredator_Population_Manager.

350  {
354  for (int t_steps = 0; t_steps < NoTSteps; t_steps++)
355  {
356  const unsigned size1 = SupplyListIndexSize();
361  for (unsigned listindex = 0; listindex < size1; listindex++)
362  {
363  // Must check each object in the list for m_CurrentStateNo==-1
364  m_LiveArraySize[listindex] = PartitionLiveDead(listindex);
365  }
366 
367 
368  // begin step actions ...
369  // set all stepdone to false.... is this really necessary??
370  for (int listindex = 0; listindex < size1; listindex++)
371  {
372  #pragma omp parallel
373  {
374  int thread_id = omp_get_thread_num();
375  for(auto it = TheSubArrays[listindex][thread_id]->begin(); it != TheSubArrays[listindex][thread_id]->end(); ++it){
376  (*it)->SetStepDone(false);
377  }
378  }
379  }
380  //Only do this when single thread is used
381  if(omp_get_max_threads()<=1){
382  for (unsigned listindex = 0; listindex < size1; listindex++)
383  {
384  // Call the Shuffle/Sort procedures
385  if(m_LiveArraySize[listindex] > 1)
386  Shuffle_or_Sort(listindex);
387  }
388  }
389 
390  //Rest the fast read support variables for supply animal ptr
391  for (unsigned listindex = 0; listindex < size1; listindex++)
392  {
393  TheSubArrayPreviousIndex[listindex] = 0;
394  TheSubArrayThreadIndex[listindex] = 0;
395  TheSubArraysIterators[listindex] = TheSubArrays[listindex][0]->begin();
396 
397  //let's find the first non-empty subarray
398  for (int j = 0; j < TheSubArraysSizes[listindex].size(); j++){
399  if(TheSubArraysSizes[listindex][j] > 0){
400  TheSubArrayThreadIndex[listindex] = j;
401  TheSubArraysIterators[listindex] = TheSubArrays[listindex][j]->begin();
402  break;
403  }
404  }
405  }
406 
407  const int day = m_TheLandscape->SupplyDayInYear();
408  const int year = m_TheLandscape->SupplyYearNumber();
409  // Need to check if Ripleys Statistic needs to be saved
411  {
412  const int Year = m_TheLandscape->SupplyYearNumber();
413  if (Year >= cfg_RipleysOutputFirstYear.value())
414  {
415  if (Year % cfg_RipleysOutput_interval.value() == 0)
416  {
417  if (cfg_RipleysOutput_day.value() == day)
418  {
419  TheRipleysOutputProbe(RipleysOutputPrb); // Do the Ripley Probe
420  }
421  }
422  }
423  }
424  // Need to check if AOR output needs to be saved
426  {
427  if (year >= cfg_AorOutputFirstYear.value())
428  {
429  if (year % cfg_AorOutput_interval.value() == 0)
430  {
431  if (cfg_AorOutput_day.value() == day)
432  {
433  // Do the AOR Probe
435  }
436  }
437  }
438  }
439  // Need to check if Monthly Ripleys Statistic needs to be saved
441  {
442  if (m_TheLandscape->SupplyDayInMonth() == 1)
443  {
444  if (year >= cfg_RipleysOutputFirstYear.value())
445  {
446  if (year % cfg_RipleysOutput_interval.value() == 0)
447  {
448  int month = m_TheLandscape->SupplyMonth();
449  // Do the Ripley Probe
450  switch (month)
451  {
452  case 1:
454  break;
455  case 2:
457  break;
458  case 3:
460  break;
461  case 4:
463  break;
464  case 5:
466  break;
467  case 6:
469  break;
470  case 7:
472  break;
473  case 8:
475  break;
476  case 9:
478  break;
479  case 10:
481  break;
482  case 11:
484  break;
485  case 12:
487  break;
488  default:
489  g_msg->Warn("Population_Manager::Run ", "Wrong month");
490  exit(-1);
491  }
492  }
493  }
494  }
495  }
496  // Need to check if Really Big Probe needs to be saved
498  {
499  if (year >= cfg_ReallyBigOutputFirstYear.value())
500  {
501  if (year % cfg_ReallyBigOutput_interval.value() == 0)
502  {
506  {
507  // Do the Ripley Probe
509  }
510  }
511  }
512  }
513  // Set the static variables for TAnimal (speed optimisation)
516  RunStepMethods();
517  } // End of time step loop
518 }

References cfg_AorOutput_day, cfg_AorOutput_interval, cfg_AorOutput_used, cfg_AorOutputFirstYear, cfg_CfgRipleysOutputUsed, cfg_ReallyBigOutput_day1, cfg_ReallyBigOutput_day2, cfg_ReallyBigOutput_day3, cfg_ReallyBigOutput_day4, cfg_ReallyBigOutput_interval, cfg_ReallyBigOutputFirstYear, cfg_ReallyBigOutputUsed, cfg_RipleysOutput_day, cfg_RipleysOutput_interval, cfg_RipleysOutputFirstYear, cfg_RipleysOutputMonthly_used, g_msg, m_LiveArraySize, Population_Manager_Base::m_TheLandscape, PartitionLiveDead(), RipleysOutputPrb, RipleysOutputPrb1, RipleysOutputPrb10, RipleysOutputPrb11, RipleysOutputPrb12, RipleysOutputPrb2, RipleysOutputPrb3, RipleysOutputPrb4, RipleysOutputPrb5, RipleysOutputPrb6, RipleysOutputPrb7, RipleysOutputPrb8, RipleysOutputPrb9, RunStepMethods(), TAnimal::SetDayInYear(), TAnimal::SetTempToday(), Shuffle_or_Sort(), Landscape::SupplyDayInMonth(), Landscape::SupplyDayInYear(), SupplyListIndexSize(), Landscape::SupplyMonth(), Landscape::SupplyTemp(), Landscape::SupplyYearNumber(), TheAOROutputProbe(), TheReallyBigOutputProbe(), TheRipleysOutputProbe(), TheSubArrayPreviousIndex, TheSubArrays, TheSubArraysIterators, TheSubArraysSizes, TheSubArrayThreadIndex, CfgInt::value(), CfgBool::value(), and MapErrorMsg::Warn().

◆ RunStepMethods()

void Population_Manager::RunStepMethods ( )
virtual
521  {
522  //int size2;
523  //const int size1 = SupplyListIndexSize();
524  DoFirst();
525  // call the begin-step-method of all objects
526  //for (int listindex = 0; listindex < size1; listindex++)
527  for (auto& listindex : m_LifeStageOrderVec)
528  {
529  //size2 = GetLiveArraySize(listindex);
530  #pragma omp parallel
531  {
532  int thread_id = omp_get_thread_num();
533  for(auto it = TheSubArrays[listindex][thread_id]->begin(); it != TheSubArrays[listindex][thread_id]->end(); ++it){
534  int loc_x_cell = 0;
535  int loc_y_cell = 0;
536  if(m_is_paralleled) //only set the guard map if multiple threads are used
537  {
538  int loc_x = (*it)->Supply_m_Location_x();
539  int loc_y = (*it)->Supply_m_Location_y();
540  int loc_x_cell = loc_x / m_guard_cell_size;
541  int loc_y_cell = loc_y / m_guard_cell_size;
542  (*it)->SetGuardMapIndex(loc_x_cell, loc_y_cell);
543  omp_set_nest_lock(m_MapGuard[loc_y_cell][loc_x_cell]);
544  }
545  (*it)->BeginStep();
546  if(m_is_paralleled){
547  loc_x_cell = (*it)->SupplyGuardCellX();
548  loc_y_cell = (*it)->SupplyGuardCellY();
549  omp_unset_nest_lock(m_MapGuard[loc_y_cell][loc_x_cell]);
550  }
551  }
552  }
553  }
554  DoBefore();
555 
556  // call the step-method of all objects
557  do
558  {
559  for (auto& listindex : m_LifeStageOrderVec)
560  {
561  //size2 = GetLiveArraySize(listindex);
562  //cout<<"Parallel starts..."<<endl;
563  #pragma omp parallel
564  {
565  int thread_id = omp_get_thread_num();
566  //cout<<" thread_id: "<<thread_id<<endl;
567  //cout<<"listindex: "<<listindex<<" thread_id: "<<thread_id<<" j: "<<j<<endl;
568  for(auto it = TheSubArrays[listindex][thread_id]->begin(); it != TheSubArrays[listindex][thread_id]->end(); ++it){
569  int loc_x_cell = 0;
570  int loc_y_cell = 0;
571  if(m_is_paralleled){ //only set the guard map if multiple threads are used
572  //let's check the guard map
573  int loc_x = (*it)->Supply_m_Location_x();
574  int loc_y = (*it)->Supply_m_Location_y();
575  loc_x_cell = loc_x / m_guard_cell_size;
576  loc_y_cell = loc_y / m_guard_cell_size;
577  (*it)->SetGuardMapIndex(loc_x_cell, loc_y_cell);
578  omp_set_nest_lock(m_MapGuard[loc_y_cell][loc_x_cell]);
579  }
580  (*it)->Step();
581 
582  //only update the position if multiple threads are used
583  if(m_is_paralleled){
584  loc_x_cell = (*it)->SupplyGuardCellX();
585  loc_y_cell = (*it)->SupplyGuardCellY();
586  omp_unset_nest_lock(m_MapGuard[loc_y_cell][loc_x_cell]);
587  }
588  }
589  }
590  DoSpecialBetweenLifeStages(listindex);
591  //cout<<"Parallel ends!!!"<<endl;
592  } // for listindex
593  }
594  while (!StepFinished());
595  DoAfter();
596  // call the end-step-method of all objects
597  for (auto& listindex : m_LifeStageOrderVec)
598  {
599  //size2 = GetLiveArraySize(listindex);
600  #pragma omp parallel
601  {
602  int thread_id = omp_get_thread_num();
603  for(auto it = TheSubArrays[listindex][thread_id]->begin(); it != TheSubArrays[listindex][thread_id]->end(); ++it){
604  int loc_x_cell = 0;
605  int loc_y_cell = 0;
606  if(m_is_paralleled){ //only set the guard map if multiple threads are used
607  int loc_x = (*it)->Supply_m_Location_x();
608  int loc_y = (*it)->Supply_m_Location_y();
609  loc_x_cell = loc_x / m_guard_cell_size;
610  loc_y_cell = loc_y / m_guard_cell_size;
611  (*it)->SetGuardMapIndex(loc_x_cell, loc_y_cell);
612  omp_set_nest_lock(m_MapGuard[loc_y_cell][loc_x_cell]);
613  }
614  (*it)->EndStep();
615  if(m_is_paralleled){
616  loc_x_cell = (*it)->SupplyGuardCellX();
617  loc_y_cell = (*it)->SupplyGuardCellY();
618  omp_unset_nest_lock(m_MapGuard[loc_y_cell][loc_x_cell]);
619  }
620  }
621  }
622  }
623  // ----------------
624  // end of this step actions
625  // For each animal list
626 
627  DoLast();
628 }

References DoAfter(), DoBefore(), DoFirst(), DoLast(), DoSpecialBetweenLifeStages(), m_guard_cell_size, m_is_paralleled, m_LifeStageOrderVec, m_MapGuard, StepFinished(), and TheSubArrays.

Referenced by Run().

◆ SetGuardMapElement()

void Population_Manager::SetGuardMapElement ( unsigned  a_x_index,
unsigned  a_y_index 
)
inline

Set the given guard map cell.

757  {
758  omp_set_nest_lock(m_MapGuard[a_y_index][a_x_index]);
759  }

References m_MapGuard.

Referenced by Beetle_Egg_List::DailyMortality(), Beetle_Egg_List::ExtremeTempMortality(), and Beetle_Egg_List::St_Hatch().

◆ SetNoProbesAndSpeciesSpecificFunctions()

void Population_Manager::SetNoProbesAndSpeciesSpecificFunctions ( int  a_pn)
overridevirtual

Sets up probe and species specifics.

Reimplemented from Population_Manager_Base.

289  {
290  // This function relies on the fact that g_Species has been set already
291  m_NoProbes = a_pn;
293 }

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

◆ Shuffle()

void Population_Manager::Shuffle ( unsigned  Type)
protectedvirtual

Run once through the list swapping randomly chosen elements

1229  {
1230  int temp_thread_num = omp_get_max_threads();
1231  for(int i=0; i<temp_thread_num; i++){
1232  auto it = TheSubArrays[Type][i]->begin();
1233  auto prev_it = TheSubArrays[Type][i]->begin();
1234  it++; //start from the second element
1235  TAnimal* temp;
1236  for(; it != TheSubArrays[Type][i]->end(); ++it){
1237  if(g_rand_uni_fnc() < 0.5){
1238  //swap the elements
1239  temp = *it;
1240  *it = *prev_it;
1241  *prev_it = temp;
1242  }
1243  prev_it = it;
1244  }
1245  //TheSubArrays[Type][i]->sort([](TAnimal* a, TAnimal*b) { return g_rand_uni_fnc()>=0.5; } );
1246  }
1247 }

References g_rand_uni_fnc(), and TheSubArrays.

Referenced by Vole_Population_Manager::DoFirst(), and Shuffle_or_Sort().

◆ Shuffle_or_Sort()

void Population_Manager::Shuffle_or_Sort ( unsigned  Type)
protectedvirtual

This method is used to determine whether the array of animals should be shuffled or sorted.
To do nothing ensure that the BeforeStepActions[] is set appropriately // 0 = Shuffle, 1 = SortX, 2 = SortY, 3 = sortXIndex, 4 = do nothing

1255  {
1256  switch (BeforeStepActions[Type])
1257  {
1258  case 0:
1259  Shuffle(Type);
1260  break;
1261  case 1:
1262  SortX(Type);
1263  break;
1264  case 2:
1265  SortY(Type);
1266  break;
1267  case 3: // Do nothing
1268  break;
1269  case 4:
1270  if (g_rand_uni_fnc() < static_cast<double>(1. / 500)) Shuffle(Type);
1271  break;
1272  default:
1273  m_TheLandscape->Warn("Population_Manager::Shuffle_or_Sort", "- BeforeStepAction Unknown");
1274  exit(1);
1275  }
1276 }

References BeforeStepActions, g_rand_uni_fnc(), Population_Manager_Base::m_TheLandscape, Shuffle(), SortX(), SortY(), and Landscape::Warn().

Referenced by Run().

◆ SortState()

void Population_Manager::SortState ( unsigned  Type)
protected

Sort TheSubArrays w.r.t. the current state attribute

1159  {
1160  int temp_thread_num = omp_get_max_threads();
1161  for(int i=0; i<temp_thread_num; i++){
1162  TheSubArrays[Type][i]->sort([](TAnimal* A1, TAnimal*A2) { return A1->WhatState() < A2->WhatState(); } );
1163  }
1164 }

References TheSubArrays, and TAnimal::WhatState().

◆ SortStateR()

void Population_Manager::SortStateR ( unsigned  Type)
protected

Sort TheSubArrays w.r.t. the current state attribute in reverse order

1171  {
1172  int temp_thread_num = omp_get_max_threads();
1173  for(int i=0; i<temp_thread_num; i++){
1174  TheSubArrays[Type][i]->sort([](TAnimal* A1, TAnimal*A2) { return A1->GetCurrentStateNo() > A2->GetCurrentStateNo(); } );
1175  }
1176 }

References TALMaSSObject::GetCurrentStateNo(), and TheSubArrays.

◆ SortX()

void Population_Manager::SortX ( unsigned  Type)
protectedvirtual

Sort TheSubArrays w.r.t. the m_Location_x attribute

1135  {
1136  int temp_thread_num = omp_get_max_threads();
1137  for(int i=0; i<temp_thread_num; i++){
1138  TheSubArrays[Type][i]->sort([](TAnimal* A1, TAnimal*A2) { return A1->Supply_m_Location_x() < A2->Supply_m_Location_x(); } );
1139  }
1140 }

References TAnimal::Supply_m_Location_x(), and TheSubArrays.

Referenced by Shuffle_or_Sort().

◆ SortXIndex()

void Population_Manager::SortXIndex ( unsigned  Type)
protected

◆ SortY()

void Population_Manager::SortY ( unsigned  Type)
protectedvirtual

Sort TheSubArrays w.r.t. the m_Location_y attribute

1147  {
1148  int temp_thread_num = omp_get_max_threads();
1149  for(int i=0; i<temp_thread_num; i++){
1150  TheSubArrays[Type][i]->sort([](TAnimal* A1, TAnimal*A2) { return A1->Supply_m_Location_y() < A2->Supply_m_Location_y(); } );
1151  }
1152 }

References TAnimal::Supply_m_Location_y(), and TheSubArrays.

Referenced by Shuffle_or_Sort().

◆ SpeciesSpecificReporting()

char * Population_Manager::SpeciesSpecificReporting ( int  a_species,
int  a_time 
)
overridevirtual

This method handles species specific outputs. This is one place to do it. More commonly this is done in descendent classes

Reimplemented from Population_Manager_Base.

1300  {
1301  strcpy(g_Str, "");
1302  if (a_species == -1) { return g_Str; }
1303  // Vole Model
1304  if (a_species == 1)
1305  {
1306  /*
1307  // The next lines are obselete code from genetic simulations
1308  float MeanNoAlleles;
1309  float MeanHO;
1310  float MeanHE;
1311  unsigned size;
1312 
1313  if ( m_time % ( 365 * 24 * 60 ) == 0 ) // End of year
1314  {
1315 
1316  // empty the GenStruc data
1317  for ( int ProbeNo = 0; ProbeNo < ( int )m_NoProbes; ProbeNo++ ) {
1318  fprintf( m_GeneticsFile, "%d ", m_time );
1319  int TotalSize = 0;
1320  m_AManager->AlFreq->Flush();
1321  for ( unsigned listindex = 0; listindex <= 1; listindex++ ) {
1322  size = 0;
1323  m_AManager->TheGeneticProbe( listindex, ProbeNo, size );
1324  TotalSize += size;
1325  }
1326  if ( TotalSize > 0 ) {
1327  m_AManager->AlFreq->CalcAF();
1328  m_AManager->AlFreq->CalcNoAlleles();
1329  m_AManager->AlFreq->CalcHE();
1330  m_AManager->AlFreq->CalcHO( TotalSize );
1331  }
1332  // Get the means
1333  // For N alleles
1334  int NA = 0;
1335  float NHO = 0;
1336  float NHE = 0;
1337  for ( int l = 0; l < 16; l++ ) {
1338  NA += m_AManager->AlFreq->SupplyNoAlleles( l );
1339  }
1340  MeanNoAlleles = ( float )NA / 16.0;
1341  for ( int l = 0; l < 16; l++ ) {
1342  NHO += m_AManager->AlFreq->SupplyHO( l );
1343  }
1344  MeanHO = NHO / 16.0;
1345  for ( int l = 0; l < 16; l++ ) {
1346  NHE += m_AManager->AlFreq->SupplyHE( l );
1347  }
1348  MeanHE = NHE / 16.0;
1349 
1350  // Do some output
1351  // Output is to two files, the genetics file and the AllelerequencyFile
1352  fprintf( m_GeneticsFile, "%2.2f ", MeanNoAlleles );
1353  fprintf( m_GeneticsFile, "%1.3f ", MeanHO );
1354  fprintf( m_GeneticsFile, "%1.3f ", MeanHE );
1355  for ( int l = 0; l < 16; l++ ) {
1356  fprintf( m_GeneticsFile, "%04i ", m_AManager->AlFreq->SupplyNoAlleles( l ) );
1357  }
1358  for ( int l = 0; l < 16; l++ ) {
1359  fprintf( m_GeneticsFile, "%1.3f ", m_AManager->AlFreq->SupplyHO( l ) );
1360  }
1361  for ( int l = 0; l < 16; l++ ) {
1362  fprintf( m_GeneticsFile, "%1.3f ", m_AManager->AlFreq->SupplyHE( l ) );
1363  }
1364  fprintf( m_GeneticsFile, "\n" );
1365  fprintf( m_AlleleFreqsFile, "%d ", m_time );
1366  for ( int l = 0; l < 16; l++ ) {
1367  for ( int al = 0; al < 4; al++ ) {
1368  fprintf( m_AlleleFreqsFile, "%1.3f ", m_AManager->AlFreq->SupplyAF( l, al ) );
1369  }
1370  }
1371  fprintf( m_AlleleFreqsFile, "\n" );
1372  }
1373  // make sure progress reaches the disk
1374  fflush( m_GeneticsFile );
1375  fflush( m_AlleleFreqsFile );
1376  }
1377 
1378  if ( cfg_UseEasyPop.value()) {
1379  int targettime=a_time % ( 365 * 100 );
1380  if ( ( targettime == 59 ) ||(targettime == 181)||(targettime ==304)||(targettime ==59+365)||(targettime ==181+365)||(targettime ==304+365)) {
1381  for ( unsigned listindex = 0; listindex <= 1; listindex++ ) {
1382  GeneticsResultsOutput( m_EasyPopRes, listindex);
1383  }
1384  fflush( m_EasyPopRes );
1385  }
1386  }
1387  */
1388  /* Three times a year reporting
1389  if ( m_time % 365 == 60 ) ProbeReportNow( m_time );
1390  if ( m_time % 365 == 152 ) ProbeReportNow( m_time );
1391  if ( m_time % 365 == 273 ) ProbeReportNow( m_time ); */
1392  ProbeReport(a_time);
1393 #ifdef __SpecificPesticideEffectsVinclozolinLike__
1394  ImpactProbeReport( a_time );
1395 #endif
1396 #ifdef __WithinOrchardPesticideSim__
1397  ImpactProbeReport( a_time );
1398 #endif
1399  }
1400  // Skylark Model
1401  else if (a_species == 0)
1402  {
1403  int No;
1404  int a_day = a_time % 365;
1405  if (a_time % 365 == 364)
1406  {
1407  //Write the Breeding Attempts Probe
1408  int BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales, BreedingAttempts;
1409  No = TheBreedingSuccessProbe(BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales,
1410  BreedingAttempts);
1411  float bs = 0;
1412  if (BreedingFemales > 0)
1413  {
1414  bs = No / static_cast<float>(BreedingFemales);
1415  //bs = successful breeding attempt per attempting to breed female
1416  }
1417  BreedingSuccessProbeOutput(bs, BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales, a_time,
1418  BreedingAttempts);
1419  }
1420  if (a_day == 152)
1421  {
1422  // Need to fill in the landscape from 1st June, it will change before
1423  // the count of fledgelings is needed
1425  }
1426  if (a_day == 197)
1427  {
1428  for (int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++)
1429  {
1430  No = TheFledgelingProbe();
1431  // Do some output
1432  FledgelingProbeOutput(No, a_time);
1433  }
1434  }
1435 #ifdef __SKPOM
1436  // This is clunky but for purposes of validation we want probes throughout the year
1437  // First get the breeding pairs data.
1438  BreedingPairsOutput(a_day);
1439 #else
1440  ProbeReport(a_time);
1441 #endif
1442  }
1443  else return ProbeReport(a_time);
1444  return g_Str;
1445 }

References BreedingPairsOutput(), BreedingSuccessProbeOutput(), Landscape::FillVegAreaData(), FledgelingProbeOutput(), g_Str, ImpactProbeReport(), m_NoProbes, Population_Manager_Base::m_TheLandscape, ProbeReport(), TheBreedingSuccessProbe(), and TheFledgelingProbe().

◆ StepFinished()

bool Population_Manager::StepFinished ( void  )
protectedvirtual

Methods to run the simulations.

Returns true if and only if all objects have finished the current step

Reimplemented in TPredator_Population_Manager.

632  {
633  for (int listindex = 0; listindex < TheSubArrays.size(); listindex++)
634  {
635  for (int j=0; j < TheSubArrays[listindex].size(); j++){
636  for (auto it = TheSubArrays[listindex][j]->begin(); it != TheSubArrays[listindex][j]->end(); ++it){
637  if (!(*it)->GetStepDone()) return false;
638  }
639  }
640  }
641  return true;
642 }

References TheSubArrays.

Referenced by RunStepMethods().

◆ SupplyAnimalPtr()

virtual TAnimal* Population_Manager::SupplyAnimalPtr ( unsigned int  a_index,
unsigned int  a_animal 
)
inlinevirtual

Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK.

Reimplemented from Population_Manager_Base.

678  {
679  //reset
680  if(a_animal == 0 || a_animal < TheSubArrayPreviousIndex[a_index]){
681  //let's find the first non-empty subarray
682  TheSubArrayPreviousIndex[a_index] = 0;
683  TheSubArrayThreadIndex[a_index] = 0;
684  TheSubArraysIterators[a_index] = TheSubArrays[a_index][0]->begin();
685  for (int j = 0; j < TheSubArraysSizes[a_index].size(); j++){
686  if(TheSubArraysSizes[a_index][j] > 0){
687  TheSubArrayThreadIndex[a_index] = j;
688  TheSubArraysIterators[a_index] = TheSubArrays[a_index][j]->begin();
689  break;
690  }
691  }
692  if(a_animal == 0)
693  return *(TheSubArraysIterators[a_index]);
694  }
695 
696  if(a_animal == TheSubArrayPreviousIndex[a_index]){
697  return *(TheSubArraysIterators[a_index]);
698  }
699 
700  //start the search from right after the previous position
701  int temp_animal_num = TheSubArrayPreviousIndex[a_index];
702  int temp_thread_num = TheSubArrayThreadIndex[a_index];
703 
704  TheSubArraysIterators[a_index]++;
705  while(temp_animal_num < a_animal){
706  for (auto it = TheSubArraysIterators[a_index]; it != TheSubArrays[a_index][temp_thread_num]->end(); ++it)
707  {
708  temp_animal_num++;
709  if(temp_animal_num == a_animal){
710  TheSubArrayPreviousIndex[a_index] = temp_animal_num;
711  TheSubArrayThreadIndex[a_index] = temp_thread_num;
712  TheSubArraysIterators[a_index] = it;
713  return *it;
714  }
715  }
716  //we need to move to the next thread subarray and search from the beginning
717  temp_thread_num++;
718  TheSubArraysIterators[a_index] = TheSubArrays[a_index][temp_thread_num]->begin();
719  }
720 
721  //if reach here means error happens,quite
722  exit(1);
723  }

References TheSubArrayPreviousIndex, TheSubArrays, TheSubArraysIterators, TheSubArraysSizes, and TheSubArrayThreadIndex.

Referenced by Skylark_Population_Manager::BreedingPairsOutput(), Erigone_Population_Manager::Catastrophe(), Oedothorax_Population_Manager::Catastrophe(), Vole_Population_Manager::Catastrophe(), Skylark_Population_Manager::Catastrophe(), THare_Population_Manager::Catastrophe(), Beetle_Population_Manager::Catastrophe(), Beetle_Population_Manager::Catastrophe2(), Osmia_Population_Manager::DoBefore(), Erigone_Population_Manager::DoFirst(), Oedothorax_Population_Manager::DoFirst(), Vole_Population_Manager::DoFirst(), Bembidion_Population_Manager::DoFirst(), THare_Population_Manager::DoFirst(), AOR_Probe_Goose::DoProbe(), AOR_Probe::DoProbeInHaitatType(), THare_Population_Manager::ExtraPopMort(), Vole_Population_Manager::FindOutsideRadiusMale(), Vole_Population_Manager::FindRandomMale(), Vole_Population_Manager::GeneticsOutputFile(), Vole_Population_Manager::GeneticsResultsOutput(), Vole_Population_Manager::GetVoleAllele(), THare_Population_Manager::Hunting(), THare_Population_Manager::HuntingDifferentiatedBeetleBankArea(), THare_Population_Manager::HuntingGrid(), Vole_Population_Manager::ImpactedProbe(), TPredator_Population_Manager::InOtherTerritory(), LOG(), THare_Population_Manager::MRROutputs(), Osmia_Population_Manager::Osmia_Population_Manager(), THare_Population_Manager::POMOutputs(), TPredator_Population_Manager::PredSampleFile(), Beetle_Population_Manager::Probe(), Skylark_Population_Manager::ProbePOM(), Skylark_Population_Manager::ReHouse(), Vole_Population_Manager::ResistanceOutput(), TPredator_Population_Manager::Run(), Vole_Population_Manager::SendMessage(), TPredator_Population_Manager::StepFinished(), Skylark_Population_Manager::TheBreedingFemalesProbe(), Skylark_Population_Manager::TheBreedingSuccessProbe(), Skylark_Population_Manager::TheFledgelingProbe(), Vole_Population_Manager::TheReallyBigOutputProbe(), Beetle_Population_Manager::TheReallyBigOutputProbe(), Erigone_Population_Manager::TheRipleysOutputProbe(), Oedothorax_Population_Manager::TheRipleysOutputProbe(), Skylark_Population_Manager::TheRipleysOutputProbe(), THare_Population_Manager::TheRipleysOutputProbe(), Beetle_Population_Manager::TheRipleysOutputProbe(), and Vole_Population_Manager::TheSexRatiosProbe().

◆ SupplyCovPosx()

virtual int Population_Manager::SupplyCovPosx ( int  )
inlinevirtual
900 { return 0; }

◆ SupplyCovPosy()

virtual int Population_Manager::SupplyCovPosy ( int  )
inlinevirtual
901 { return 0; }

◆ SupplyListIndexSize()

virtual unsigned Population_Manager::SupplyListIndexSize ( )
inlinevirtual

◆ SupplyListSize()

unsigned Population_Manager::SupplyListSize ( unsigned  listindex) const
inline

◆ SupplyPegPosx()

virtual int Population_Manager::SupplyPegPosx ( int  )
inlinevirtual
898 { return 0; }

◆ SupplyPegPosy()

virtual int Population_Manager::SupplyPegPosy ( int  )
inlinevirtual
899 { return 0; }

◆ SupplyStateNames()

const char* Population_Manager::SupplyStateNames ( int  i) const
inline
738 { return StateNames[i]; }

References StateNames.

Referenced by Skylark_Female::Step(), and Skylark_Male::Step().

◆ SupplyStateNamesLength()

unsigned Population_Manager::SupplyStateNamesLength ( ) const
inline
739 { return StateNamesLength; }

References StateNamesLength.

◆ SupplyStepSize()

int Population_Manager::SupplyStepSize ( ) const
inline
673 { return m_StepSize; }

References m_StepSize.

◆ TheAOROutputProbe()

void Population_Manager::TheAOROutputProbe ( )
virtual

◆ TheBreedingFemalesProbe()

virtual int Population_Manager::TheBreedingFemalesProbe ( int  )
inlinevirtual

Reimplemented in Skylark_Population_Manager.

907 { return 0; }

◆ TheBreedingSuccessProbe()

virtual int Population_Manager::TheBreedingSuccessProbe ( int &  ,
int &  ,
int &  ,
int &  ,
int &  ,
int &   
)
inlinevirtual

Reimplemented in Skylark_Population_Manager.

913  { return 0; }

Referenced by SpeciesSpecificReporting().

◆ TheFledgelingProbe()

virtual int Population_Manager::TheFledgelingProbe ( )
inlinevirtual

Reimplemented in Skylark_Population_Manager.

908 { return 0; }

Referenced by SpeciesSpecificReporting().

◆ TheGeneticProbe()

virtual void Population_Manager::TheGeneticProbe ( unsigned  ,
int  ,
unsigned &   
)
inlinevirtual
916  {
917  }

◆ TheReallyBigOutputProbe()

void Population_Manager::TheReallyBigOutputProbe ( )
virtual

This method must be overridden in descendent classes

Reimplemented in Beetle_Population_Manager, and Vole_Population_Manager.

1056  {
1057 }

Referenced by Run().

◆ TheRipleysOutputProbe()

void Population_Manager::TheRipleysOutputProbe ( ofstream *  a_prb)
virtual

Special output functionality.

This method must be overridden in descendent classes

Reimplemented in Beetle_Population_Manager, and Vole_Population_Manager.

1061  {
1062 }

Referenced by Run().

◆ UnsetGuardMapElement()

void Population_Manager::UnsetGuardMapElement ( unsigned  a_x_index,
unsigned  a_y_index 
)
inline

Unset the given guard map cell.

763  {
764  omp_unset_nest_lock(m_MapGuard[a_y_index][a_x_index]);
765  }

References m_MapGuard.

Referenced by Beetle_Egg_List::DailyMortality(), Beetle_Egg_List::ExtremeTempMortality(), and Beetle_Egg_List::St_Hatch().

◆ UpdateGuardMap()

void Population_Manager::UpdateGuardMap ( int  a_x,
int  a_y,
int &  a_index_x,
int &  a_index_y 
)
inline

Get the index of the guard map for the given location.

769  {
770  int temp_index_x = a_x / m_guard_cell_size;
771  int temp_index_y = a_y / m_guard_cell_size;
772 
773  //a new cell, we need to reset the guard
774  if(a_index_x != temp_index_x || a_index_y != temp_index_y){
775  omp_unset_nest_lock(m_MapGuard[a_index_y][a_index_x]);
776  omp_set_nest_lock(m_MapGuard[temp_index_y][temp_index_x]);
777  a_index_x = temp_index_x;
778  a_index_y = temp_index_y;
779  }
780 
781  }

References m_guard_cell_size, and m_MapGuard.

Referenced by Spider_Juvenile::BalloonTo(), Beetle_Base::Beetle_1M_Move(), Vole_JuvenileMale::Dispersal(), Vole_Male::Dispersal(), Vole_JuvenileFemale::Dispersal(), Vole_Base::Escape(), Osmia_Female::FindNestLocation(), Ladybird_Adult::FindTarget(), Ladybird_Adult::LongRangeFind(), Vole_Base::MoveTo(), Beetle_Adult::MoveToNoList(), Beetle_Adult::MoveToWithPlacesList(), THare::Run(), THare::Running(), TPredator::st_Dispersal(), Osmia_Female::st_Dispersal(), Hare_Juvenile::st_Dispersal(), Vole_Male::st_Eval_n_Explore(), TPredator::st_Movement(), Vole_Female::st_Special_Explore(), Beetle_Adult::TryToReproduce(), and Spider_Juvenile::WalkTo().

Member Data Documentation

◆ AOROutputPrb

ofstream* Population_Manager::AOROutputPrb {}
protected

◆ BeforeStepActions

◆ lamdagrid

long int Population_Manager::lamdagrid[2][257][257] {}
protected

◆ m_AOR_Probe

◆ m_guard_cell_height_num

int Population_Manager::m_guard_cell_height_num
protected

◆ m_guard_cell_size

◆ m_guard_cell_width_num

int Population_Manager::m_guard_cell_width_num
protected

◆ m_is_paralleled

◆ m_LifeStageOrderVec

vector<int> Population_Manager::m_LifeStageOrderVec
protected

The vector to store the life stage order for looping specie life stages.

Referenced by Ladybird_Population_Manager::Ladybird_Population_Manager(), Population_Manager(), and RunStepMethods().

◆ m_LiveArraySize

◆ m_MapGuard

std::vector<std::vector<omp_nest_lock_t*> > Population_Manager::m_MapGuard
protected

◆ m_NoProbes

◆ m_population_type

◆ m_SeasonNumber

int Population_Manager::m_SeasonNumber
protected

Holds the season number. Used when running goose and hunter sims.

Referenced by GetSeasonNumber(), and Population_Manager().

◆ m_StepSize

int Population_Manager::m_StepSize {}
protected

◆ ProbesSet

bool Population_Manager::ProbesSet {}

◆ ReallyBigOutputPrb

◆ RipleysOutputPrb

ofstream* Population_Manager::RipleysOutputPrb {}
protected

◆ RipleysOutputPrb1

ofstream* Population_Manager::RipleysOutputPrb1 {}
protected

◆ RipleysOutputPrb10

ofstream* Population_Manager::RipleysOutputPrb10 {}
protected

◆ RipleysOutputPrb11

ofstream* Population_Manager::RipleysOutputPrb11 {}
protected

◆ RipleysOutputPrb12

ofstream* Population_Manager::RipleysOutputPrb12 {}
protected

◆ RipleysOutputPrb2

ofstream* Population_Manager::RipleysOutputPrb2 {}
protected

◆ RipleysOutputPrb3

ofstream* Population_Manager::RipleysOutputPrb3 {}
protected

◆ RipleysOutputPrb4

ofstream* Population_Manager::RipleysOutputPrb4 {}
protected

◆ RipleysOutputPrb5

ofstream* Population_Manager::RipleysOutputPrb5 {}
protected

◆ RipleysOutputPrb6

ofstream* Population_Manager::RipleysOutputPrb6 {}
protected

◆ RipleysOutputPrb7

ofstream* Population_Manager::RipleysOutputPrb7 {}
protected

◆ RipleysOutputPrb8

ofstream* Population_Manager::RipleysOutputPrb8 {}
protected

◆ RipleysOutputPrb9

ofstream* Population_Manager::RipleysOutputPrb9 {}
protected

◆ StateNames

◆ StateNamesLength

unsigned Population_Manager::StateNamesLength
protected

◆ TestFile

FILE* Population_Manager::TestFile {}
protected

◆ TestFile2

FILE* Population_Manager::TestFile2 {}
protected

◆ TheSubArrayPreviousIndex

vector<int> Population_Manager::TheSubArrayPreviousIndex
protected

the animal index number from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the derived class.

Referenced by Population_Manager(), Run(), and SupplyAnimalPtr().

◆ TheSubArrays

◆ TheSubArraysIterators

vector<forward_list<TAnimal*>::iterator> Population_Manager::TheSubArraysIterators
protected

the iterator from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the derived class.

Referenced by Population_Manager(), Run(), and SupplyAnimalPtr().

◆ TheSubArraysSizes

vector<vector<int> > Population_Manager::TheSubArraysSizes
protected

◆ TheSubArrayThreadIndex

vector<int> Population_Manager::TheSubArrayThreadIndex
protected

the thread index number from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the derived class.

Referenced by Population_Manager(), Run(), and SupplyAnimalPtr().


The documentation for this class was generated from the following files:
TAnimal::Supply_m_Location_x
int Supply_m_Location_x() const
Returns the ALMaSS x-coordinate.
Definition: PopulationManager.h:239
cfg_RipleysOutput_interval
CfgInt cfg_RipleysOutput_interval("G_RIPLEYSOUTPUT_INTERVAL", CFG_CUSTOM, 1)
WARN_FILE
Definition: MapErrorMsg.h:37
g_rand_uni_fnc
double g_rand_uni_fnc()
Definition: ALMaSS_Random.cpp:56
TAnimal::SupplyPosition
AnimalPosition SupplyPosition() const
Returns the objects location and habitat type and veg type.
Definition: PopulationManager.cpp:1533
Population_Manager::SupplyAnimalPtr
virtual TAnimal * SupplyAnimalPtr(unsigned int a_index, unsigned int a_animal)
Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK.
Definition: PopulationManager.h:678
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
Population_Manager::DoLast
virtual void DoLast()
Definition: PopulationManager.cpp:656
Population_Manager::m_MapGuard
std::vector< std::vector< omp_nest_lock_t * > > m_MapGuard
This is used to make sure animals will not behaviour at the same area - multi threads.
Definition: PopulationManager.h:790
TAnimal::SetTempToday
static void SetTempToday(double a_value)
Sets the temperature today attribute.
Definition: PopulationManager.h:337
Population_Manager::TheSubArraysSizes
vector< vector< int > > TheSubArraysSizes
Hold all the animal sizes in each thread.
Definition: PopulationManager.h:806
Population_Manager::m_guard_cell_width_num
int m_guard_cell_width_num
Definition: PopulationManager.h:792
Population_Manager::Shuffle_or_Sort
virtual void Shuffle_or_Sort(unsigned Type)
Definition: PopulationManager.cpp:1255
Probe_Data::m_FullLandscapeProbe
bool m_FullLandscapeProbe
Definition: PopulationManager.h:429
Population_Manager::StateNamesLength
unsigned StateNamesLength
Definition: PopulationManager.h:815
Population_Manager::m_population_type
TTypesOfPopulation m_population_type
Definition: PopulationManager.h:858
CfgStr::value
char * value() const
Definition: Configurator.h:182
Population_Manager::BeforeStepActions
vector< unsigned > BeforeStepActions
Holds the season list of possible before step actions.
Definition: PopulationManager.h:819
cfg_ReallyBigOutput_day1
CfgInt cfg_ReallyBigOutput_day1("G_REALLYBIGOUTPUT_DAY_ONE", CFG_CUSTOM, 1)
cfg_MapGuardCellSize
CfgInt cfg_MapGuardCellSize("MAP_GUARD_CELL_SIZE", CFG_CUSTOM, 20)
The size to create the map guard.
Population_Manager_Base::Population_Manager_Base
Population_Manager_Base(Landscape *L)
The Population_Manager_Base constructor.
Definition: PopulationManager.cpp:182
Population_Manager_Base::m_ListNames
const char * m_ListNames[32]
A list of life-stage names.
Definition: PopulationManager.h:628
Population_Manager::RipleysOutputPrb4
ofstream * RipleysOutputPrb4
Definition: PopulationManager.h:864
cfg_RipleysOutputFirstYear
CfgInt cfg_RipleysOutputFirstYear("G_RIPLEYSOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
Population_Manager::BreedingSuccessProbeOutput
virtual void BreedingSuccessProbeOutput(double, int, int, int, int, int, int, int)
Definition: PopulationManager.h:909
Population_Manager::RipleysOutputPrb6
ofstream * RipleysOutputPrb6
Definition: PopulationManager.h:866
Population_Manager::CloseTheRipleysOutputProbe
virtual void CloseTheRipleysOutputProbe()
Definition: PopulationManager.cpp:1020
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
Population_Manager::m_StepSize
int m_StepSize
Definition: PopulationManager.h:802
AnimalPosition::m_x
unsigned m_x
Definition: PopulationManager.h:173
Population_Manager::RipleysOutputPrb
ofstream * RipleysOutputPrb
Definition: PopulationManager.h:860
rectangle::m_y1
unsigned m_y1
Definition: PopulationManager.h:117
Landscape::FillVegAreaData
void FillVegAreaData()
Runs through all polygons and records the area of each vegetation type.
Definition: Landscape.cpp:5712
Population_Manager::m_LifeStageOrderVec
vector< int > m_LifeStageOrderVec
The vector to store the life stage order for looping specie life stages.
Definition: PopulationManager.h:808
Population_Manager::TheSubArraysIterators
vector< forward_list< TAnimal * >::iterator > TheSubArraysIterators
the iterator from last time called for SupplyAnimalPtr(), this for fast loop all the animals in the d...
Definition: PopulationManager.h:810
Population_Manager::RipleysOutputPrb3
ofstream * RipleysOutputPrb3
Definition: PopulationManager.h:863
Population_Manager::RunStepMethods
virtual void RunStepMethods()
Definition: PopulationManager.cpp:521
Population_Manager::ImpactProbeReport
void ImpactProbeReport(int a_Time)
Definition: PopulationManager.cpp:1513
rectangle::m_x2
unsigned m_x2
Definition: PopulationManager.h:118
Population_Manager::CloseTheMonthlyRipleysOutputProbe
void CloseTheMonthlyRipleysOutputProbe() const
Definition: PopulationManager.cpp:1029
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
Population_Manager::TheRipleysOutputProbe
virtual void TheRipleysOutputProbe(ofstream *a_prb)
Special output functionality.
Definition: PopulationManager.cpp:1061
cfg_DayInMonth
static CfgInt cfg_DayInMonth("PRB_DAYINMONTH", CFG_CUSTOM, 1)
Probe_Data::m_RefVeg
TTypesOfVegetation m_RefVeg[25]
Definition: PopulationManager.h:437
Population_Manager::Probe
virtual unsigned Probe(int ListIndex, Probe_Data *p_TheProbe)
Definition: PopulationManager.cpp:792
Population_Manager::m_AOR_Probe
AOR_Probe * m_AOR_Probe
A pointer to the AOR probe.
Definition: PopulationManager.h:875
Population_Manager::LamdaClear
void LamdaClear()
Definition: PopulationManager.h:885
Population_Manager::TheSubArrayThreadIndex
vector< int > TheSubArrayThreadIndex
the thread index number from last time called for SupplyAnimalPtr(), this for fast loop all the anima...
Definition: PopulationManager.h:814
Population_Manager_Base::SimH
int SimH
stores the simulation height
Definition: PopulationManager.h:614
cfg_ReallyBigOutput_interval
CfgInt cfg_ReallyBigOutput_interval("G_REALLYBIGOUTPUT_INTERVAL", CFG_CUSTOM, 1)
Population_Manager::RipleysOutputPrb11
ofstream * RipleysOutputPrb11
Definition: PopulationManager.h:871
Population_Manager::RipleysOutputPrb1
ofstream * RipleysOutputPrb1
Definition: PopulationManager.h:861
g_Species
TTypesOfPopulation g_Species
Definition: PopulationManager.cpp:101
cfg_ReallyBigOutput_day2
CfgInt cfg_ReallyBigOutput_day2("G_REALLYBIGOUTPUT_DAY_TWO", CFG_CUSTOM, 91)
Landscape::SupplyDayInMonth
int SupplyDayInMonth(void)
Passes a request on to the associated Calendar class function, returns m_day_in_month
Definition: Landscape.h:2277
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
TAnimal::SetDayInYear
static void SetDayInYear(int a_value)
Sets the day in year attribute.
Definition: PopulationManager.h:329
Population_Manager::TheReallyBigOutputProbe
virtual void TheReallyBigOutputProbe()
Definition: PopulationManager.cpp:1056
Population_Manager::DoBefore
virtual void DoBefore()
Definition: PopulationManager.cpp:341
Population_Manager::RipleysOutputPrb9
ofstream * RipleysOutputPrb9
Definition: PopulationManager.h:869
cfg_ReallyBigOutput_day3
CfgInt cfg_ReallyBigOutput_day3("G_REALLYBIGOUTPUT_DAY_THREE", CFG_CUSTOM, 182)
TAnimal::Supply_m_Location_y
int Supply_m_Location_y() const
Returns the ALMaSS y-coordinate.
Definition: PopulationManager.h:243
TAnimal
The base class for all ALMaSS animal classes. Includes all the functionality required to be handled b...
Definition: PopulationManager.h:200
Population_Manager::m_SeasonNumber
int m_SeasonNumber
Holds the season number. Used when running goose and hunter sims.
Definition: PopulationManager.h:821
Probe_Data::m_NoEleTypes
unsigned m_NoEleTypes
Definition: PopulationManager.h:434
AnimalPosition
A class defining an animals position.
Definition: PopulationManager.h:169
AOR_Probe
Definition: AOR_Probe.h:4
Population_Manager_Base::m_AORProbeFileName
std::string m_AORProbeFileName
name of the AOR Probe file
Definition: PopulationManager.h:630
Population_Manager::ImpactedProbe
virtual void ImpactedProbe()
Definition: PopulationManager.cpp:785
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
cfg_RipleysOutputMonthly_used
CfgBool cfg_RipleysOutputMonthly_used("G_RIPLEYSOUTPUTMONTHLY_USED", CFG_CUSTOM, false)
Probe_Data::m_Rect
rectangle m_Rect[16]
Definition: PopulationManager.h:433
Population_Manager::RipleysOutputPrb5
ofstream * RipleysOutputPrb5
Definition: PopulationManager.h:865
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Passes a request on to the associated Calendar class function, the day in the year.
Definition: Landscape.h:2267
Population_Manager::lamdagrid
long int lamdagrid[2][257][257]
Definition: PopulationManager.h:877
Population_Manager::m_is_paralleled
bool m_is_paralleled
This is used to indicate whether the species is paralleled.
Definition: PopulationManager.h:796
rectangle::m_y2
unsigned m_y2
Definition: PopulationManager.h:119
Population_Manager::RipleysOutputPrb2
ofstream * RipleysOutputPrb2
Definition: PopulationManager.h:862
Landscape::SupplyYearNumber
int SupplyYearNumber(void)
Passes a request on to the associated Calendar class function, returns m_simulationyear
Definition: Landscape.h:2287
cfg_ReallyBigOutput_filename
static CfgStr cfg_ReallyBigOutput_filename("G_REALLYBIGOUTPUT_FILENAME", CFG_CUSTOM, "ReallyBigOutput.txt")
g_Str
char g_Str[255]
Definition: PopulationManager.cpp:99
Population_Manager::TheFledgelingProbe
virtual int TheFledgelingProbe()
Definition: PopulationManager.h:908
CfgInt::value
int value() const
Definition: Configurator.h:116
cfg_ReallyBigOutput_day4
CfgInt cfg_ReallyBigOutput_day4("G_REALLYBIGOUTPUT_DAY_FOUR", CFG_CUSTOM, 274)
cfg_AorOutput_used
CfgBool cfg_AorOutput_used("G_AOROUTPUT_USED", CFG_CUSTOM, false)
Probe_Data::m_NoVegTypes
unsigned m_NoVegTypes
Definition: PopulationManager.h:435
AnimalPosition::m_EleType
TTypesOfLandscapeElement m_EleType
Definition: PopulationManager.h:175
Population_Manager_Base::TheProbe
Probe_Data * TheProbe[100]
Holds a list of pointers to standard output probes.
Definition: PopulationManager.h:588
Population_Manager::RipleysOutputPrb12
ofstream * RipleysOutputPrb12
Definition: PopulationManager.h:872
AnimalPosition::m_y
unsigned m_y
Definition: PopulationManager.h:174
Population_Manager::DoFirst
virtual void DoFirst()
Definition: PopulationManager.cpp:333
Population_Manager_Base::SimW
int SimW
stores the simulation width
Definition: PopulationManager.h:616
TALMaSSObject::GetCurrentStateNo
int GetCurrentStateNo() const
Returns the current state number.
Definition: PopulationManager.h:137
Probe_Data::m_NoAreas
unsigned m_NoAreas
Definition: PopulationManager.h:432
Population_Manager::StateNames
const char * StateNames[100]
Definition: PopulationManager.h:801
Population_Manager::TheBreedingSuccessProbe
virtual int TheBreedingSuccessProbe(int &, int &, int &, int &, int &, int &)
Definition: PopulationManager.h:912
Probe_Data::m_RefFarms
unsigned m_RefFarms[25]
Definition: PopulationManager.h:439
cfg_RipleysOutput_filename
static CfgStr cfg_RipleysOutput_filename("G_RIPLEYSOUTPUT_FILENAME", CFG_CUSTOM, "RipleysOutput.txt")
Population_Manager::FledgelingProbeOutput
virtual void FledgelingProbeOutput(int, int)
Definition: PopulationManager.h:914
Population_Manager::ProbeReport
char * ProbeReport(int a_time)
Definition: PopulationManager.cpp:1463
cfg_RipleysOutput_day
CfgInt cfg_RipleysOutput_day("G_RIPLEYSOUTPUT_DAY", CFG_CUSTOM, 60)
Population_Manager::OpenTheMonthlyRipleysOutputProbe
bool OpenTheMonthlyRipleysOutputProbe()
Definition: PopulationManager.cpp:912
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
Population_Manager::GetLiveArraySize
unsigned GetLiveArraySize(int a_listindex) override
Gets the number of 'live' objects for a list index in the TheArray.
Definition: PopulationManager.h:657
Population_Manager::RipleysOutputPrb7
ofstream * RipleysOutputPrb7
Definition: PopulationManager.h:867
cfg_ReallyBigOutputFirstYear
CfgInt cfg_ReallyBigOutputFirstYear("G_REALLYBIGOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
Population_Manager::BreedingPairsOutput
virtual void BreedingPairsOutput(int)
Definition: PopulationManager.h:905
rectangle::m_x1
unsigned m_x1
Definition: PopulationManager.h:116
cfg_AorOutput_interval
CfgInt cfg_AorOutput_interval("G_AORSOUTPUT_INTERVAL", CFG_CUSTOM, 1)
Population_Manager::BeginningOfMonth
bool BeginningOfMonth()
Definition: PopulationManager.cpp:1282
Farm
The base class for all farm types.
Definition: Farm.h:755
Probe_Data::FileOutput
void FileOutput(int No, int time, int ProbeNo) const
Definition: PopulationManager.cpp:1626
Population_Manager::SortX
virtual void SortX(unsigned Type)
Definition: PopulationManager.cpp:1135
g_thread_count
int g_thread_count
Definition: PopulationManager.cpp:107
Population_Manager::PartitionLiveDead
virtual unsigned PartitionLiveDead(unsigned Type)
Definition: PopulationManager.cpp:1181
Population_Manager::SupplyListIndexSize
virtual unsigned SupplyListIndexSize()
Definition: PopulationManager.h:725
Population_Manager::m_NoProbes
int m_NoProbes
Definition: PopulationManager.h:787
Population_Manager::DoSpecialBetweenLifeStages
virtual void DoSpecialBetweenLifeStages(int a_life_stage)
Definition: PopulationManager.h:829
Population_Manager::TheSubArrayPreviousIndex
vector< int > TheSubArrayPreviousIndex
the animal index number from last time called for SupplyAnimalPtr(), this for fast loop all the anima...
Definition: PopulationManager.h:812
Probe_Data::m_NoFarms
unsigned m_NoFarms
Definition: PopulationManager.h:436
Population_Manager::m_guard_cell_size
int m_guard_cell_size
Definition: PopulationManager.h:793
Population_Manager::RipleysOutputPrb8
ofstream * RipleysOutputPrb8
Definition: PopulationManager.h:868
cfg_CfgRipleysOutputUsed
CfgBool cfg_CfgRipleysOutputUsed("G_RIPLEYSOUTPUT_USED", CFG_CUSTOM, false)
Population_Manager::StepFinished
virtual bool StepFinished()
Methods to run the simulations.
Definition: PopulationManager.cpp:632
Population_Manager::CloseTheReallyBigOutputProbe
virtual void CloseTheReallyBigOutputProbe()
Definition: PopulationManager.cpp:1048
Population_Manager::Shuffle
virtual void Shuffle(unsigned Type)
Definition: PopulationManager.cpp:1229
cfg_ReallyBigOutputUsed
CfgBool cfg_ReallyBigOutputUsed("G_REALLYBIGOUTPUT_USED", CFG_CUSTOM, false)
Population_Manager::ReallyBigOutputPrb
ofstream * ReallyBigOutputPrb
Definition: PopulationManager.h:873
Population_Manager::TheSubArrays
vector< vector< forward_list< TAnimal * > * > > TheSubArrays
Hold all the animal pointers.
Definition: PopulationManager.h:804
Probe_Data::m_RefEle
TTypesOfLandscapeElement m_RefEle[25]
Definition: PopulationManager.h:438
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Wrapper for the g_msg Warn function.
Definition: Landscape.h:2250
Population_Manager::m_guard_cell_height_num
int m_guard_cell_height_num
Definition: PopulationManager.h:791
Population_Manager::TheAOROutputProbe
virtual void TheAOROutputProbe()
Definition: PopulationManager.cpp:1067
TAnimal::WhatState
virtual int WhatState()
Returns the objects current state number.
Definition: PopulationManager.h:301
Population_Manager::SortY
virtual void SortY(unsigned Type)
Definition: PopulationManager.cpp:1147
cfg_AorOutput_day
CfgInt cfg_AorOutput_day("G_AOROUTPUT_DAY", CFG_CUSTOM, 60)
cfg_AorOutputFirstYear
CfgInt cfg_AorOutputFirstYear("G_AOROUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
Population_Manager::m_LiveArraySize
vector< unsigned > m_LiveArraySize
Definition: PopulationManager.h:786
Population_Manager::RipleysOutputPrb10
ofstream * RipleysOutputPrb10
Definition: PopulationManager.h:870
Population_Manager::DoAfter
virtual void DoAfter()
Definition: PopulationManager.cpp:648
AnimalPosition::m_VegType
TTypesOfVegetation m_VegType
Definition: PopulationManager.h:176