ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Population_Manager Class Reference

Base class for all population managers. More...

#include <populationmanager.h>

Inheritance diagram for Population_Manager:
Rabbit_Population_Manager

Public Member Functions

 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual void Run (int NoTSteps)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
int SupplyListNameLength ()
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe ()
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual void TheReallyBigOutputProbe ()
 
virtual void TheNWordOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
void CloseTheRipleysOutputProbe ()
 
void CloseTheReallyBigOutputProbe ()
 
bool OpenTheCIPEGridOutputProbe ()
 
virtual void TheCIPEGridOutputProbe ()
 
void CloseTheCIPEGridOutputProbe ()
 
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)
 

Public Attributes

int IndexArrayX [5][10000]
 
probe_dataTheProbe [100]
 
int SimH
 
int SimW
 
unsigned SimHH
 
unsigned SimWH
 
char m_SimulationName [255]
 
bool ProbesSet
 
Landscapem_TheLandscape
 

Protected Member Functions

virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoFirst ()
 
virtual void DoBefore ()
 
virtual void DoAfter ()
 
virtual void DoAlmostLast ()
 
virtual void DoLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 
void NWordOutput ()
 The output section for the NWord probe.
. More...
 

Protected Attributes

vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [10]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [10]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * CIPEGridOutputPrb
 
FILE * CIPEGridOutputPrbB
 
FILE * ReallyBigOutputPrb
 
FILE * NWordOutputPrb
 
int * m_cgridcount
 
int * m_gridcount [4]
 
int m_cgridcountwidth
 
int m_gridcountwidth [4]
 
int m_cipegridsize
 
int m_gridcountsize [4]
 
long int lamdagrid [2][257][257]
 

Detailed Description

Base class for all population managers.

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.

Definition at line 401 of file populationmanager.h.

Constructor & Destructor Documentation

Population_Manager::Population_Manager ( Landscape L)

Constructor for the Population_Manager class

Definition at line 222 of file PopulationManager.cpp.

References cfg_CipeGridSize, cfg_RipleysOutputMonthly_used, Landscape::SupplySimAreaHeight(), CfgInt::value(), and CfgBool::value().

222  {
223  // Keep a pointer to the landscape this population is in
224  m_TheLandscape = L;
225  // create 10 empty arrays as default, excess can be removed in descendent classes
226  TListOfAnimals alist;
227  TheArray.insert( TheArray.end(), 10, alist );
228  // Set the simulation bounds
233  for (int i = 0; i < 10; i++) {
234  // Set default BeforeStepActions
235  BeforeStepActions[ i ] = 0;
236  m_ListNames[ i ] = "Unknown";
237  m_LiveArraySize.push_back( 0 );
238  }
239  // modify this if they need to in descendent classes
240  StateNamesLength = 0; // initialise this variable.
241  m_catastrophestartyear=-1; // Default is don't do this
242 #ifdef __LAMBDA_RECORD
243  ofstream fout("LambdaGridOuput.txt", ios_base::out); // open for writing
244  fout.close();
245  LamdaClear();
246 #endif
249  }
253  m_gridcountsize[0] = 50;
254  m_gridcountsize[1] = 100;
255  m_gridcountsize[2] = 200;
256  m_gridcountsize[3] = 500;
257  m_gridcountwidth[0] = SimW/50;
258  m_gridcountwidth[1] = SimW/100;
259  m_gridcountwidth[2] = SimW/200;
260  m_gridcountwidth[3] = SimW/500;
261  m_gridcount[0] = new int[ m_gridcountwidth[0] * m_gridcountwidth[0] ];
262  m_gridcount[1] = new int[ m_gridcountwidth[1] * m_gridcountwidth[1] ];
263  m_gridcount[2] = new int[ m_gridcountwidth[2] * m_gridcountwidth[2] ];
264  m_gridcount[3] = new int[ m_gridcountwidth[3] * m_gridcountwidth[3] ];
265  // Ensure the GUI pointer is NULL in case we are not in GUI mode
266 #ifdef __ALMASS_VISUAL
267  m_MainForm = NULL;
268 #endif
269  m_SeasonNumber = 0; // Ensure that we start in season number 0. Season number is incremented at day in year 183
270 }
CfgBool cfg_RipleysOutputMonthly_used("G_RIPLEYSOUTPUTMONTHLY_USED", CFG_CUSTOM, false)
unsigned BeforeStepActions[10]
vector< TListOfAnimals > TheArray
int SupplySimAreaWidth(void)
Definition: landscape.h:1558
bool value(void)
Definition: configurator.h:123
int m_SeasonNumber
Holds the season number. Used when running goose and hunter sims.
int SupplySimAreaHeight(void)
Definition: landscape.h:1563
vector< TAnimal * > TListOfAnimals
static CfgInt cfg_CipeGridSize("G_CIPEGRIDSIZE", CFG_CUSTOM, 500)
int value(void)
Definition: configurator.h:92
vector< unsigned > m_LiveArraySize
const char * m_ListNames[10]
Landscape * m_TheLandscape
Population_Manager::~Population_Manager ( void  )
virtual

Destructor for the Population_Manager class

Definition at line 276 of file PopulationManager.cpp.

References cfg_ReallyBigOutput_used, cfg_RipleysOutput_used, cfg_RipleysOutputMonthly_used, and CfgBool::value().

276  {
277  // clean-up
278  for ( unsigned i = 0; i < TheArray.size(); i++ ) {
279  // if objects in the list need to be deleted:
280  for ( unsigned j = 0; j < (unsigned) GetLiveArraySize(i); j++ ) {
281  delete TheArray[ i ] [ j ];
282  }
283  // empty the array
284  TheArray[ i ].clear();
285  // --
286  }
287  if ( cfg_RipleysOutput_used.value() ) {
289  fclose( NWordOutputPrb );
290  }
293  }
296  }
297  for (int d=0; d<4; d++) delete [] m_gridcount[d];
298  delete [] m_cgridcount;
299 }
CfgBool cfg_RipleysOutputMonthly_used("G_RIPLEYSOUTPUTMONTHLY_USED", CFG_CUSTOM, false)
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
CfgBool cfg_RipleysOutput_used("G_RIPLEYSOUTPUT_USED", CFG_CUSTOM, true)
void CloseTheMonthlyRipleysOutputProbe()
vector< TListOfAnimals > TheArray
bool value(void)
Definition: configurator.h:123
CfgBool cfg_ReallyBigOutput_used("G_REALLYBIGOUTPUT_USED", CFG_CUSTOM, false)

Member Function Documentation

bool Population_Manager::BeginningOfMonth ( )

Is it the first day of the month?

Definition at line 1172 of file PopulationManager.cpp.

References cfg_DayInMonth, and CfgInt::value().

1172  {
1173  if ( m_TheLandscape->SupplyDayInMonth() == cfg_DayInMonth.value() ) return true;
1174  return false;
1175 }
static CfgInt cfg_DayInMonth("PRB_DAYINMONTH", CFG_CUSTOM, 1)
int SupplyDayInMonth(void)
Definition: landscape.h:1532
int value(void)
Definition: configurator.h:92
Landscape * m_TheLandscape
virtual void Population_Manager::BreedingPairsOutput ( int  )
inlinevirtual

Definition at line 622 of file populationmanager.h.

622  {
623  }
virtual void Population_Manager::BreedingSuccessProbeOutput ( double  ,
int  ,
int  ,
int  ,
int  ,
int  ,
int  ,
int   
)
inlinevirtual

Definition at line 630 of file populationmanager.h.

630  {
631  }
virtual void Population_Manager::Catastrophe ( int  )
inlinevirtual

Definition at line 415 of file populationmanager.h.

415  {
416  }
void Population_Manager::Catastrophe ( )
protectedvirtual

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

Definition at line 1179 of file PopulationManager.cpp.

1179  {
1184  return;
1185 }
bool Population_Manager::CheckXY ( int  l,
int  i 
)

Debug method to test for out of bounds coordinates.

Definition at line 1588 of file PopulationManager.cpp.

1589 {
1590  if (TheArray[l][i]->Supply_m_Location_x() > 10000) return true;
1591  if (TheArray[l][i]->Supply_m_Location_y() > 10000) return true;
1592  if (TheArray[l][i]->Supply_m_Location_x() < 0) return true;
1593  if (TheArray[l][i]->Supply_m_Location_y() < 0) return true;
1594  return false;
1595 }
vector< TListOfAnimals > TheArray
void Population_Manager::CloseTheCIPEGridOutputProbe ( )

close the probe

Definition at line 790 of file PopulationManager.cpp.

790  {
791  if ( CIPEGridOutputPrb != NULL )
792  fclose( CIPEGridOutputPrb );
793  fclose( CIPEGridOutputPrbB );
794 }
void Population_Manager::CloseTheMonthlyRipleysOutputProbe ( )

close the monthly probes

Definition at line 961 of file PopulationManager.cpp.

961  {
962  fclose( RipleysOutputPrb1 );
963  fclose( RipleysOutputPrb2 );
964  fclose( RipleysOutputPrb3 );
965  fclose( RipleysOutputPrb4 );
966  fclose( RipleysOutputPrb5 );
967  fclose( RipleysOutputPrb6 );
968  fclose( RipleysOutputPrb7 );
969  fclose( RipleysOutputPrb8 );
970  fclose( RipleysOutputPrb9 );
971  fclose( RipleysOutputPrb10 );
972  fclose( RipleysOutputPrb11 );
973  fclose( RipleysOutputPrb12 );
974 }
void Population_Manager::CloseTheReallyBigOutputProbe ( )

close the probe

Definition at line 980 of file PopulationManager.cpp.

980  {
981  if ( ReallyBigOutputPrb != 0 )
982  fclose( ReallyBigOutputPrb );
984 }
void Population_Manager::CloseTheRipleysOutputProbe ( )

close the probe

Definition at line 950 of file PopulationManager.cpp.

References cfg_RipleysOutputMonthly_used, and CfgBool::value().

950  {
952  fclose( RipleysOutputPrb );
953  RipleysOutputPrb=NULL;
954 }
CfgBool cfg_RipleysOutputMonthly_used("G_RIPLEYSOUTPUTMONTHLY_USED", CFG_CUSTOM, false)
bool value(void)
Definition: configurator.h:123
void Population_Manager::DisplayLocations ( )
virtual

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

Definition at line 571 of file PopulationManager.cpp.

572 {
576 #ifdef __ALMASS_VISUAL
577  m_MainForm->UpdateGraphics();
578 #endif
579 }
void Population_Manager::DoAfter ( )
protectedvirtual

Can be used in descendent classes

Reimplemented in Rabbit_Population_Manager.

Definition at line 524 of file PopulationManager.cpp.

524  {
525  //TODO: Add your source code here
526 }
void Population_Manager::DoAlmostLast ( )
protectedvirtual

Can be used in descendent classes

Definition at line 533 of file PopulationManager.cpp.

533  {
534  //TODO: Add your source code here
535 }
void Population_Manager::DoBefore ( )
protectedvirtual

Can be used in descendent classes

Reimplemented in Rabbit_Population_Manager.

Definition at line 340 of file PopulationManager.cpp.

340  {
341 }
void Population_Manager::DoFirst ( )
protectedvirtual

Can be used in descendent classes

Reimplemented in Rabbit_Population_Manager.

Definition at line 332 of file PopulationManager.cpp.

332  {
333 }
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 Rabbit_Population_Manager.

Definition at line 541 of file PopulationManager.cpp.

541  {
542 
543 /*
544 #ifdef __UNIX__
545  for ( unsigned i = 0; i < 100; i++ ) {
546  StateList.n[ i ] = 0;
547  }
548 #else
549  // Zero results
550  for ( unsigned listindex = 0; listindex < m_ListNameLength; listindex++ ) {
551  for ( unsigned i = 0; i < 100; i++ ) {
552  Counts[ listindex ] [ i ] = 0;
553  }
554  }
555 #endif
556  // How many animals in each state?
557  for ( unsigned listindex = 0; listindex < TheArray.size(); listindex++ ) {
558  unsigned size = (unsigned) TheArray[ listindex ].size();
559  for ( unsigned j = 0; j < size; j++ ) {
560 #ifdef __UNIX__
561  StateList.n[ TheArray[ listindex ] [ j ]->WhatState() ] ++;
562 #else
563  Counts[ listindex ] [ TheArray[ listindex ] [ j ]->WhatState() ] ++;
564 #endif
565  }
566  }
567 */
568 }
void Population_Manager::EmptyTheArray ( )
protected

Removes all objects from the TheArray by deleting them and clearing TheArray.

Sort TheArray w.r.t. the m_Location_x attribute

Definition at line 1032 of file PopulationManager.cpp.

1033 {
1034  for ( unsigned i = 0; i < TheArray.size(); i++ )
1035  {
1036  // if objects in the list need to be deleted:
1037  for (unsigned j = 0; j < (unsigned) TheArray[i].size(); j++)
1038  {
1039  delete TheArray[ i ] [ j ];
1040  }
1041  // empty the array
1042  TheArray[ i ].clear();
1043  }
1044 }
vector< TListOfAnimals > TheArray
unsigned int Population_Manager::FarmAnimalCensus ( unsigned int  a_farm,
unsigned int  a_typeofanimal 
)

Definition at line 1331 of file PopulationManager.cpp.

1332 {
1333  unsigned int No = 0;
1334  unsigned sz = (unsigned)GetLiveArraySize( a_typeofanimal );
1335  for ( unsigned j = 0; j < sz; j++ )
1336  {
1337  if (a_farm == TheArray[ a_typeofanimal ] [ j ]->SupplyFarmOwnerRef()) No++;
1338  }
1339  return No;
1340 }
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
vector< TListOfAnimals > TheArray
TAnimal * Population_Manager::FindClosest ( int  x,
int  y,
unsigned  Type 
)

Finds the closest individual to an x,y point

Definition at line 1007 of file PopulationManager.cpp.

References TAnimal::Supply_m_Location_x().

1007  {
1008  int distance = 100000000;
1009  TAnimal * TA = NULL;
1010  int dx, dy, d;
1011  for (unsigned j = 0; j < (unsigned)GetLiveArraySize( Type ); j++) {
1012  dx = TheArray[ Type ] [ j ]->Supply_m_Location_x();
1013  dy = TheArray[ Type ] [ j ]->Supply_m_Location_y();
1014  dx = ( dx - x );
1015  dx *= dx;
1016  dy = ( dy - y );
1017 
1018  dy *= dy;
1019  d = dx + dy;
1020  if ( d < distance ) {
1021  distance = d;
1022  TA = TheArray[ Type ] [ j ];
1023  }
1024  }
1025  return TA;
1026 }
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
vector< TListOfAnimals > TheArray
The base class for all ALMaSS animal classes.
virtual void Population_Manager::FledgelingProbeOutput ( int  ,
int   
)
inlinevirtual

Definition at line 635 of file populationmanager.h.

635  {
636  }
virtual void Population_Manager::GeneticsResultsOutput ( FILE *  ,
unsigned   
)
inlinevirtual

Definition at line 639 of file populationmanager.h.

639  {
640  }
unsigned Population_Manager::GetLiveArraySize ( int  a_listindex)
inline

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

Definition at line 408 of file populationmanager.h.

Referenced by Rabbit_Warren::CalcDisease().

408  {
409  return m_LiveArraySize[a_listindex];
410  }
vector< unsigned > m_LiveArraySize
TTypesOfPopulation Population_Manager::GetPopulationType ( )
inline

Definition at line 549 of file populationmanager.h.

549 { return m_population_type; }
TTypesOfPopulation m_population_type
int Population_Manager::GetSeasonNumber ( )
inline

Get the season number.

Definition at line 551 of file populationmanager.h.

551 {return m_SeasonNumber;}
int m_SeasonNumber
Holds the season number. Used when running goose and hunter sims.
void Population_Manager::ImpactedProbe ( )
virtual

Special pesticide related probe. Overidden in descendent classes

Definition at line 683 of file PopulationManager.cpp.

683  {
684 
685 }
void Population_Manager::ImpactProbeReport ( int  a_Time)

Special probe

Definition at line 1391 of file PopulationManager.cpp.

1391  {
1392 
1393  for ( int ProbeNo = 0; ProbeNo < 1; ProbeNo++ ) {
1394  // See if we need to record/update this one
1395  // if time/months/years ==0 or every time
1396  if ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 3 )
1397  || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 2 ) && ( BeginningOfMonth() ) )
1398  || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 1 ) && ( a_Time % 365 == 0 ) ) ) {
1399  ImpactedProbe();
1400  }
1401  }
1402 }
probe_data * TheProbe[100]
virtual void ImpactedProbe()
void Population_Manager::IncLiveArraySize ( int  a_listindex)
inline

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

Definition at line 412 of file populationmanager.h.

412  {
413  m_LiveArraySize[a_listindex]++;
414  }
vector< unsigned > m_LiveArraySize
bool Population_Manager::IsLast ( unsigned  listindex)
inline

Definition at line 452 of file populationmanager.h.

452  {
453  if ( TheArray[ listindex ].size() > 1 ) return false; else
454  return true;
455  }
vector< TListOfAnimals > TheArray
void Population_Manager::LamdaBirth ( int  x,
int  y 
)
inline

Definition at line 584 of file populationmanager.h.

584  {
585  lamdagrid[0][x / __lgridsize][y / __lgridsize ]++;
586  }
long int lamdagrid[2][257][257]
void Population_Manager::LamdaBirth ( int  x,
int  y,
int  z 
)
inline

Definition at line 587 of file populationmanager.h.

587  {
588  lamdagrid[0][x / __lgridsize][y / __lgridsize ]+=z;
589  }
long int lamdagrid[2][257][257]
void Population_Manager::LamdaClear ( )
inline

Definition at line 590 of file populationmanager.h.

590  {
591  for (int i=0; i<257; i++ ) {
592  for (int j=0; j<257; j++) {
593  lamdagrid[0][i][j]=0;
594  lamdagrid[1][i][j]=0;
595  }
596  }
597  }
long int lamdagrid[2][257][257]
void Population_Manager::LamdaDeath ( int  x,
int  y 
)
inline

Definition at line 580 of file populationmanager.h.

580  {
581  // inlined for speed
582  lamdagrid[1][x / __lgridsize][y / __lgridsize ]++;
583  }
long int lamdagrid[2][257][257]
void Population_Manager::LamdaDumpOutput ( )

Special probe

Definition at line 668 of file PopulationManager.cpp.

668  {
669  ofstream fout("LambdaGridOuput.txt", ios_base::app); // open for writing
670  for (int i=0; i<257; i++ ) {
671  for (int j=0; j<257; j++) {
672  fout << lamdagrid[0][i][j] << "\t" << lamdagrid[1][i][j] << endl;
673  }
674  }
675  //fout << "NEXT" << endl;
676  fout.close();
677 }
long int lamdagrid[2][257][257]
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

Definition at line 306 of file PopulationManager.cpp.

References AnimalPosition::m_x, and AnimalPosition::m_y.

306  {
307  FILE * PFile = fopen(fname, "w" );
308  if (PFile) {
309  m_TheLandscape->Warn("PopulationManager::LOG - Could not open file ",fname);
310  exit(0);
311  }
312  AnimalPosition AP;
313  for ( unsigned listindex = 0; listindex < TheArray.size(); listindex++ ) {
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 < (unsigned) m_LiveArraySize[listindex]; j++ ) {
320  AP = TheArray[ listindex ] [ j ]->SupplyPosition();
321  fprintf( PFile, "%i %i %i\n", j, AP.m_x, AP.m_y );
322  }
323  }
324  fclose( PFile );
325 }
A class defining an animals position.
vector< TListOfAnimals > TheArray
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1505
vector< unsigned > m_LiveArraySize
const char * m_ListNames[10]
Landscape * m_TheLandscape
void Population_Manager::NWordOutput ( )
protected

The output section for the NWord probe.
.

A common output stub for the NWord output probe. Specialist counting for each species occurs as part of the CIPE grid probe, then this method deals with the final output.

Definition at line 804 of file PopulationManager.cpp.

804  {
807  int Counted[4];
808  int totalcells[4];
809  int OccupiedCells[4];
810  for (int cellwidth=0; cellwidth<4; cellwidth++) {
811  Counted[cellwidth] = 0;
812  totalcells[cellwidth] = m_gridcountwidth[cellwidth] * m_gridcountwidth[cellwidth];
813  OccupiedCells[cellwidth] = 0;
814  for (int i=0; i<m_gridcountwidth[cellwidth]; i++) {
815  for (int j=0; j<m_gridcountwidth[cellwidth]; j++) {
816  int res=m_gridcount[cellwidth][i+j*m_gridcountwidth[cellwidth]];
817  Counted[cellwidth] += res;
818  if (res>0) OccupiedCells[cellwidth]++;
819  }
820  }
821  }
822  fprintf(NWordOutputPrb,"%d\t%d\t%d\t", m_TheLandscape->SupplyYearNumber() ,(int)m_TheLandscape->SupplyDayInYear(), Counted[0] );
823  for (int c=0; c<4; c++) {
824  fprintf(NWordOutputPrb,"%d\t%d\t", totalcells[c], OccupiedCells[c]);
825  }
826  fprintf(NWordOutputPrb,"\n");
827  fflush(NWordOutputPrb);
828 }
int SupplyYearNumber(void)
Definition: landscape.h:1542
int SupplyDayInYear(void)
Definition: landscape.h:1522
Landscape * m_TheLandscape
virtual bool Population_Manager::OpenTheBreedingPairsProbe ( )
inlinevirtual

Definition at line 616 of file populationmanager.h.

616  {
617  return false;
618  }
virtual bool Population_Manager::OpenTheBreedingSuccessProbe ( )
inlinevirtual

Definition at line 619 of file populationmanager.h.

619  {
620  return false;
621  }
bool Population_Manager::OpenTheCIPEGridOutputProbe ( )

open the probe

Definition at line 769 of file PopulationManager.cpp.

References cfg_CIPEGridOutput_filename, cfg_CIPEGridOutput_filenameB, g_msg, CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

769  {
771  if ( !CIPEGridOutputPrb ) {
772  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheCIPEGridOutputProbe(): ""Unable to open probe file",
774  exit( 1 );
775  }
777  if ( !CIPEGridOutputPrbB ) {
778  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheCIPEGridOutputProbe(): ""Unable to open probe file",
780  exit( 1 );
781  }
782  return true;
783 }
const char * value(void)
Definition: configurator.h:139
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
CfgStr cfg_CIPEGridOutput_filename("G_CIPEGRIDOUTPUT_FILENAME", CFG_CUSTOM,"CIPEGridOutput.txt")
CfgStr cfg_CIPEGridOutput_filenameB("G_CIPEGRIDOUTPUT_FILENAME_B", CFG_CUSTOM,"CIPEGridOutputB.txt")
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
virtual bool Population_Manager::OpenTheFledgelingProbe ( )
inlinevirtual

Definition at line 613 of file populationmanager.h.

613  {
614  return false;
615  }
bool Population_Manager::OpenTheMonthlyRipleysOutputProbe ( )

open 12 ripley output probles, one for each month

Definition at line 854 of file PopulationManager.cpp.

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

854  {
855  RipleysOutputPrb1 = fopen("RipleyOutput_Jan.txt", "w" );
856  if ( !RipleysOutputPrb1 ) {
857  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
859  exit( 1 );
860  }
861  RipleysOutputPrb2 = fopen("RipleyOutput_Feb.txt", "w" );
862  if ( !RipleysOutputPrb2 ) {
863  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
865  exit( 1 );
866  }
867  RipleysOutputPrb3 = fopen("RipleyOutput_Mar.txt", "w" );
868  if ( !RipleysOutputPrb3 ) {
869  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
871  exit( 1 );
872  }
873  RipleysOutputPrb4 = fopen("RipleyOutput_Apr.txt", "w" );
874  if ( !RipleysOutputPrb4 ) {
875  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
877  exit( 1 );
878  }
879  RipleysOutputPrb5 = fopen("RipleyOutput_May.txt", "w" );
880  if ( !RipleysOutputPrb5 ) {
881  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
883  exit( 1 );
884  }
885  RipleysOutputPrb6 = fopen("RipleyOutput_Jun.txt", "w" );
886  if ( !RipleysOutputPrb6 ) {
887  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
889  exit( 1 );
890  }
891  RipleysOutputPrb7 = fopen("RipleyOutput_Jul.txt", "w" );
892  if ( !RipleysOutputPrb7 ) {
893  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
895  exit( 1 );
896  }
897  RipleysOutputPrb8 = fopen("RipleyOutput_Aug.txt", "w" );
898  if ( !RipleysOutputPrb8 ) {
899  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
901  exit( 1 );
902  }
903  RipleysOutputPrb9 = fopen("RipleyOutput_Sep.txt", "w" );
904  if ( !RipleysOutputPrb9 ) {
905  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
907  exit( 1 );
908  }
909  RipleysOutputPrb10 = fopen("RipleyOutput_Oct.txt", "w" );
910  if ( !RipleysOutputPrb10 ) {
911  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
913  exit( 1 );
914  }
915  RipleysOutputPrb11 = fopen("RipleyOutput_Nov.txt", "w" );
916  if ( !RipleysOutputPrb11 ) {
917  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
919  exit( 1 );
920  }
921  RipleysOutputPrb12 = fopen("RipleyOutput_Dec.txt", "w" );
922  if ( !RipleysOutputPrb12 ) {
923  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
925  exit( 1 );
926  }
927  return true;
928 }
const char * value(void)
Definition: configurator.h:139
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
static CfgStr cfg_RipleysOutput_filename("G_RIPLEYSOUTPUT_FILENAME", CFG_CUSTOM,"RipleysOutput.txt")
bool Population_Manager::OpenTheReallyBigProbe ( )

open the probe

Definition at line 935 of file PopulationManager.cpp.

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

935  {
937  if ( !ReallyBigOutputPrb ) {
938  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
940  exit( 1 );
941  }
942  return true;
943 }
const char * value(void)
Definition: configurator.h:139
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
static CfgStr cfg_ReallyBigOutput_filename("G_REALLYBIGOUTPUT_FILENAME", CFG_CUSTOM,"ReallyBigOutput.txt")
bool Population_Manager::OpenTheRipleysOutputProbe ( )

open the probe

Definition at line 834 of file PopulationManager.cpp.

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

Referenced by Rabbit_Population_Manager::Rabbit_Population_Manager().

834  {
836  if ( !RipleysOutputPrb ) {
837  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
839  exit( 1 );
840  }
841  NWordOutputPrb = fopen("NWordOutputPrb.txt", "w" );
842  if ( !NWordOutputPrb ) {
843  g_msg->Warn( WARN_FILE, "Population_Manager::OpenTheCIPEGridOutputProbe(): ""Unable to open NWord probe file", "" );
844  exit( 1 );
845  }
846  fprintf(NWordOutputPrb,"%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n","Year","Day","Total no.","Cells50","Occupied50","Cells100","Occupied100","Cells200","Occupied200","Cells400","Occupied400");
847  return true;
848 }
const char * value(void)
Definition: configurator.h:139
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
static CfgStr cfg_RipleysOutput_filename("G_RIPLEYSOUTPUT_FILENAME", CFG_CUSTOM,"RipleysOutput.txt")
unsigned Population_Manager::PartitionLiveDead ( unsigned  Type)
protected

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

Definition at line 1085 of file PopulationManager.cpp.

1085  {
1086  auto it = partition(TheArray[Type].begin(), TheArray[Type].begin() + m_LiveArraySize[Type], CompareStateAlive());
1087  // it now points at the first dead element
1088  // the number of live ones before it is it-TheArray[Type].begin(). This is the new vector size for live animals.
1089  return unsigned(it - TheArray[Type].begin());
1090 }
vector< TListOfAnimals > TheArray
Function to compare to TAnimal&#39;s m_CurrentStateNo to anything but -1.
vector< unsigned > m_LiveArraySize
float Population_Manager::Probe ( int  ListIndex,
probe_data p_TheProbe 
)
virtual

Default data probe. Rarely used in actuality but always available

Definition at line 691 of file PopulationManager.cpp.

References AnimalPosition::m_EleType, 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, and rectangle::m_y2.

691  {
692  // Counts through the list and goes through each area to see if the animal
693  // is standing there and if the farm, veg or element conditions are met
694  AnimalPosition Sp;
695  float NumberSk = 0;
696  // Four possibilites
697  // either NoVegTypes or NoElementTypes or NoFarmTypes is >0 or all==0
698  if ( p_TheProbe->m_NoFarms != 0 ) {
699  for (unsigned j = 0; j < (unsigned)GetLiveArraySize( ListIndex ); j++) {
700  Sp = TheArray[ ListIndex ] [ j ]->SupplyPosition();
701  unsigned Farm = TheArray[ ListIndex ] [ j ]->SupplyFarmOwnerRef();
702  for ( unsigned i = 0; i < p_TheProbe->m_NoAreas; i++ ) {
703  if ( ( Sp.m_x >= p_TheProbe->m_Rect[ i ].m_x1 ) && ( Sp.m_y >= p_TheProbe->m_Rect[ i ].m_y1 )
704  && ( Sp.m_x <= p_TheProbe->m_Rect[ i ].m_x2 ) && ( Sp.m_y <= p_TheProbe->m_Rect[ i ].m_y2 ) )
705  for ( unsigned k = 0; k < p_TheProbe->m_NoFarms; k++ ) {
706  if ( p_TheProbe->m_RefFarms[ k ] == Farm )
707  NumberSk++; // it is in the square so increment number
708  }
709 
710  }
711  }
712  } else if ( p_TheProbe->m_NoEleTypes != 0 ) {
713  for (unsigned j = 0; j < (unsigned)GetLiveArraySize( ListIndex ); j++) {
714  Sp = TheArray[ ListIndex ] [ j ]->SupplyPosition();
715  for ( unsigned i = 0; i < p_TheProbe->m_NoAreas; i++ ) {
716  if ( ( Sp.m_x >= p_TheProbe->m_Rect[ i ].m_x1 ) && ( Sp.m_y >= p_TheProbe->m_Rect[ i ].m_y1 )
717  && ( Sp.m_x <= p_TheProbe->m_Rect[ i ].m_x2 ) && ( Sp.m_y <= p_TheProbe->m_Rect[ i ].m_y2 ) )
718  for ( unsigned k = 0; k < p_TheProbe->m_NoEleTypes; k++ ) {
719  if ( p_TheProbe->m_RefEle[ k ] == Sp.m_EleType )
720  NumberSk++; // it is in the square so increment number
721  }
722  }
723  }
724  } else {
725  if ( p_TheProbe->m_NoVegTypes != 0 ) {
726  for (unsigned j = 0; j < (unsigned)GetLiveArraySize( ListIndex ); j++) {
727  Sp = TheArray[ ListIndex ] [ j ]->SupplyPosition();
728 
729  for ( unsigned i = 0; i < p_TheProbe->m_NoAreas; i++ ) {
730  if ( ( Sp.m_x >= p_TheProbe->m_Rect[ i ].m_x1 ) && ( Sp.m_y >= p_TheProbe->m_Rect[ i ].m_y1 )
731  && ( Sp.m_x <= p_TheProbe->m_Rect[ i ].m_x2 ) && ( Sp.m_y <= p_TheProbe->m_Rect[ i ].m_y2 ) ) {
732  for ( unsigned k = 0; k < p_TheProbe->m_NoVegTypes; k++ ) {
733  if ( p_TheProbe->m_RefVeg[ k ] == Sp.m_VegType )
734  NumberSk++; // it is in the square so increment number
735  }
736  }
737  }
738  }
739  } else // both must be zero
740  {
741  unsigned sz = (unsigned)GetLiveArraySize( ListIndex );
742  // It is worth checking whether we have a total dump of all individuals
743  // if so don't bother with asking each where it is
744  if (p_TheProbe->m_NoAreas==1) {
745  if ((p_TheProbe->m_Rect[0].m_x1==0) && (p_TheProbe->m_Rect[0].m_y1==0) && (p_TheProbe->m_Rect[0].m_x2==(unsigned)SimW) &&
746  (p_TheProbe->m_Rect[0].m_y2==(unsigned)SimH)) {
747  return (float) sz;
748  }
749  }
750  // Asking for a subset - need to test them all
751  for ( unsigned j = 0; j < sz; j++ ) {
752  Sp = TheArray[ ListIndex ] [ j ]->SupplyPosition();
753  for ( unsigned i = 0; i < p_TheProbe->m_NoAreas; i++ ) {
754  if ( ( Sp.m_x >= p_TheProbe->m_Rect[ i ].m_x1 ) && ( Sp.m_y >= p_TheProbe->m_Rect[ i ].m_y1 )
755  && ( Sp.m_x <= p_TheProbe->m_Rect[ i ].m_x2 ) && ( Sp.m_y <= p_TheProbe->m_Rect[ i ].m_y2 ) )
756  NumberSk++; // it is in the square so increment number
757  }
758  }
759  }
760  }
761  return NumberSk;
762 }
rectangle m_Rect[10]
A class defining an animals position.
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
TTypesOfLandscapeElement m_EleType
unsigned m_NoAreas
unsigned m_RefFarms[25]
vector< TListOfAnimals > TheArray
unsigned m_NoVegTypes
TTypesOfVegetation m_RefVeg[25]
unsigned m_x1
TTypesOfVegetation m_VegType
The base class for all farm types.
Definition: farm.h:683
TTypesOfLandscapeElement m_RefEle[25]
unsigned m_NoEleTypes
unsigned m_y1
unsigned m_NoFarms
unsigned m_x2
unsigned m_y2
int Population_Manager::ProbeFileInput ( char *  p_Filename,
int  p_ProbeNo 
)

Default probe file input

Definition at line 585 of file PopulationManager.cpp.

585  {
586  FILE * PFile;
587  int data = 0;
588  int data2 = 0;
589  char S[ 255 ];
590  PFile = fopen(p_Filename, "r" );
591  if ( !PFile ) {
592  m_TheLandscape->Warn( "Population Manager - cannot open Probe File ", p_Filename );
593  exit( 0 );
594  }
595  fgets( S, 255, PFile ); // dummy line
596  fgets( S, 255, PFile ); // dummy line
597  fscanf( PFile, "%d\n", & data ); // Reporting interval
598  TheProbe[ p_ProbeNo ]->m_ReportInterval = data;
599  fgets( S, 255, PFile ); // dummy line
600  fscanf( PFile, "%d\n", & data ); // Write to file
601  if ( data == 0 ) TheProbe[ p_ProbeNo ]->m_FileRecord = false; else
602  TheProbe[ p_ProbeNo ]->m_FileRecord = true;
603  fgets( S, 255, PFile ); // dummy line
604  for ( int i = 0; i < 10; i++ ) {
605  fscanf( PFile, "%d", & data );
606  if ( data > 0 ) TheProbe[ p_ProbeNo ]->m_TargetTypes[ i ] = true; else
607  TheProbe[ p_ProbeNo ]->m_TargetTypes[ i ] = false;
608  }
609 
610  fgets( S, 255, PFile ); // dummy line
611  fgets( S, 255, PFile ); // dummy line
612  fscanf( PFile, "%d", & data );
613  TheProbe[ p_ProbeNo ]->m_NoAreas = data;
614  fgets( S, 255, PFile ); // dummy line
615  fgets( S, 255, PFile ); // dummy line
616  fscanf( PFile, "%d", & data2 ); // No References areas
617  fgets( S, 255, PFile ); // dummy line
618  fgets( S, 255, PFile ); // dummy line
619  fscanf( PFile, "%d", & data ); // Type reference for probe
620  if ( data == 1 ) TheProbe[ p_ProbeNo ]->m_NoEleTypes = data2; else
621  TheProbe[ p_ProbeNo ]->m_NoEleTypes = 0;
622  if ( data == 2 ) TheProbe[ p_ProbeNo ]->m_NoVegTypes = data2; else
623  TheProbe[ p_ProbeNo ]->m_NoVegTypes = 0;
624  if ( data == 3 ) TheProbe[ p_ProbeNo ]->m_NoFarms = data2; else
625  TheProbe[ p_ProbeNo ]->m_NoFarms = 0;
626  fgets( S, 255, PFile ); // dummy line
627  fgets( S, 255, PFile ); // dummy line
628  // Now read in the areas data
629  for ( int i = 0; i < 10; i++ ) {
630  fscanf( PFile, "%d", & data );
631  TheProbe[ p_ProbeNo ]->m_Rect[ i ].m_x1 = data;
632  fscanf( PFile, "%d", & data );
633  TheProbe[ p_ProbeNo ]->m_Rect[ i ].m_y1 = data;
634  fscanf( PFile, "%d", & data );
635  TheProbe[ p_ProbeNo ]->m_Rect[ i ].m_x2 = data;
636  fscanf( PFile, "%d", & data );
637  TheProbe[ p_ProbeNo ]->m_Rect[ i ].m_y2 = data;
638  }
639  fgets( S, 255, PFile ); // dummy line
640  fgets( S, 255, PFile ); // dummy line
641  if ( TheProbe[ p_ProbeNo ]->m_NoVegTypes > 0 ) {
642  for ( int i = 0; i < 25; i++ ) {
643  fscanf( PFile, "%d", & data );
644  if ( data != 999 )
645  TheProbe[ p_ProbeNo ]->m_RefVeg[ i ] = m_TheLandscape->TranslateVegTypes( data );
646  }
647  } else if ( TheProbe[ p_ProbeNo ]->m_NoFarms > 0 ) {
648  for ( int i = 0; i < 25; i++ ) {
649  fscanf( PFile, "%d", & data );
650  if ( data != 999 )
651  TheProbe[ p_ProbeNo ]->m_RefFarms[ i ] = data;
652  }
653  } else {
654  for ( int i = 0; i < 25; i++ ) {
655  fscanf( PFile, "%d", & data );
656  if ( data != 999 ) TheProbe[ p_ProbeNo ]->m_RefEle[ i ] = m_TheLandscape->TranslateEleTypes( data );
657  }
658  }
659  fclose( PFile );
660  return data2; // number of data references
661 }
rectangle m_Rect[10]
bool m_TargetTypes[10]
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: landscape.h:1581
unsigned m_NoAreas
unsigned m_RefFarms[25]
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: landscape.h:1574
unsigned m_ReportInterval
unsigned m_NoVegTypes
probe_data * TheProbe[100]
TTypesOfVegetation m_RefVeg[25]
unsigned m_x1
TTypesOfLandscapeElement m_RefEle[25]
unsigned m_NoEleTypes
unsigned m_y1
unsigned m_NoFarms
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1505
unsigned m_x2
Landscape * m_TheLandscape
unsigned m_y2
char * Population_Manager::ProbeReport ( int  a_time)

Definition at line 1343 of file PopulationManager.cpp.

References g_str.

1343  {
1344 
1345  int No;
1346  char str[100]; // 100 out to be enough!!
1347  strcpy(g_str,"");
1348  for ( int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++ ) {
1349  No = 0;
1350  // See if we need to record/update this one
1351  // if time/months/years ==0 or every time
1352  if ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 3 )
1353  || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 2 ) && ( BeginningOfMonth() ) )
1354  || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 1 ) && ( Time % 365 == 0 ) ) ) {
1355  // Goes through each area and sends a value to OutputForm
1356  unsigned Index = SupplyListIndexSize();
1357  for ( unsigned listindex = 0; listindex < Index; listindex++ ) {
1358  if ( TheProbe[ ProbeNo ]->m_TargetTypes[ listindex ] )
1359  No += (int) Probe( listindex, TheProbe[ ProbeNo ] );
1360  }
1361  TheProbe[ ProbeNo ]->FileOutput( No, Time, ProbeNo );
1362  sprintf(str," %d ", No );
1363  strcat(g_str,str);
1364  }
1365  }
1366  return g_str;
1367 }
unsigned SupplyListIndexSize()
virtual float Probe(int ListIndex, probe_data *p_TheProbe)
void FileOutput(int No, int time, int ProbeNo)
probe_data * TheProbe[100]
char g_str[255]
char * Population_Manager::ProbeReportTimed ( int  a_time)

Definition at line 1370 of file PopulationManager.cpp.

References g_str.

1370  {
1371  int No;
1372  char str[100]; // 100 ought to be enough!!
1373  strcpy(g_str,"");
1374  for ( int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++ ) {
1375  No = 0;
1376  unsigned Index = SupplyListIndexSize();
1377  for ( unsigned listindex = 0; listindex < Index; listindex++ ) {
1378  if ( TheProbe[ ProbeNo ]->m_TargetTypes[ listindex ] ) No += (int) Probe( listindex, TheProbe[ ProbeNo ] );
1379  }
1380  TheProbe[ ProbeNo ]->FileOutput( No, Time, ProbeNo );
1381  sprintf(str," %d ", No );
1382  strcat(g_str,str);
1383  }
1384  return g_str;
1385 }
unsigned SupplyListIndexSize()
virtual float Probe(int ListIndex, probe_data *p_TheProbe)
void FileOutput(int No, int time, int ProbeNo)
probe_data * TheProbe[100]
char g_str[255]
void Population_Manager::Run ( int  NoTSteps)
virtual

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(), DoAlmostLast(), 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.

Definition at line 349 of file PopulationManager.cpp.

References cfg_CatastropheEventStartYear, cfg_CIPEGridOutput_day, cfg_CIPEGridOutput_Interval, cfg_CIPEGridOutput_used, cfg_ReallyBigOutput_day1, cfg_ReallyBigOutput_day2, cfg_ReallyBigOutput_day3, cfg_ReallyBigOutput_day4, cfg_ReallyBigOutput_interval, cfg_ReallyBigOutput_used, cfg_ReallyBigOutputFirstYear, cfg_RipleysOutput_day, cfg_RipleysOutput_interval, cfg_RipleysOutput_used, cfg_RipleysOutputFirstYear, cfg_RipleysOutputMonthly_used, CfgInt::value(), and CfgBool::value().

349  {
353  for ( int TSteps = 0; TSteps < NoTSteps; TSteps++ )
354  {
355  unsigned size2;
356  unsigned size1 = (unsigned) TheArray.size();
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 #ifdef __ALMASS_VISUAL
367  if (m_MainForm!=NULL)
368  {
369  int n = 0;
370  for ( unsigned listindex = 0; listindex < size1; listindex++ ) n += (int) m_LiveArraySize[ listindex ];
372  //if (n>0) DisplayLocations();
373  }
374 #endif
375  // begin step actions ...
376  // set all stepdone to false.... is this really necessary??
377  for ( unsigned listindex = 0; listindex < size1; listindex++ )
378  {
379  size2 = (unsigned) GetLiveArraySize(listindex);
380  for ( unsigned j = 0; j < size2; j++ )
381  {
382  TheArray[ listindex ] [ j ]->SetStepDone( false );
383  }
384  }
385 
386  for ( unsigned listindex = 0; listindex < size1; listindex++ ) {
387  // Call the Shuffle/Sort procedures
388  Shuffle_or_Sort( listindex );
389  }
390  // Need to check if Ripleys Statistic needs to be saved
391  if ( cfg_RipleysOutput_used.value() ) {
392  int Year = m_TheLandscape->SupplyYearNumber();
393  if (Year>=cfg_RipleysOutputFirstYear.value()) {
394  if ( Year % cfg_RipleysOutput_interval.value() == 0 ) {
395  int day = m_TheLandscape->SupplyDayInYear();
396  if ( cfg_RipleysOutput_day.value() == day ) {
397  // Do the Ripley Probe
399  TheNWordOutputProbe(); // These two go hand in hand.
400  }
401  }
402  }
403  }
404  // Need to check if Monthly Ripleys Statistic needs to be saved
406  if (m_TheLandscape->SupplyDayInMonth()==1) {
407  int Year = m_TheLandscape->SupplyYearNumber();
408  if (Year>=cfg_RipleysOutputFirstYear.value()) {
409  if ( Year % cfg_RipleysOutput_interval.value() == 0 ) {
410  int month = m_TheLandscape->SupplyMonth();
411  // Do the Ripley Probe
412  switch (month) {
414  break;
416  break;
418  break;
420  break;
422  break;
424  break;
426  break;
428  break;
430  break;
432  break;
434  break;
436  break;
437  }
438  }
439  }
440  }
441  }
442  // Need to check if Really Big Probe needs to be saved
444  int Year = m_TheLandscape->SupplyYearNumber();
445  if (Year>=cfg_ReallyBigOutputFirstYear.value()) {
446  if ( Year % cfg_ReallyBigOutput_interval.value() == 0 ) {
447  int day = m_TheLandscape->SupplyDayInYear();
449  {
450  // Do the Ripley Probe
452  }
453  }
454  }
455  }
456  // Need to check if CIPEGrid Statistic needs to be saved
457  if ( cfg_CIPEGridOutput_used.value() ) {
458  int Year = m_TheLandscape->SupplyYearNumber();
459  if ( Year % cfg_CIPEGridOutput_Interval.value() == 0 ) {
460  int day = m_TheLandscape->SupplyDayInYear();
461  if ( cfg_CIPEGridOutput_day.value() == day ) {
462  // Do the Ripley Probe
464  }
465  }
466  }
468  if ( yr > cfg_CatastropheEventStartYear.value() ) {
470  Catastrophe(); // This method must be overidden in descendent classes
471  }
472  DoFirst();
473  // call the begin-step-method of all objects
474  for ( unsigned listindex = 0; listindex < size1; listindex++ ) {
475  size2 = (unsigned)GetLiveArraySize( listindex );
476  for (unsigned j = 0; j < size2; j++)
477  TheArray[ listindex ] [ j ]->BeginStep();
478  }
479  DoBefore();
480  // call the step-method of all objects
481  do {
482  for ( unsigned listindex = 0; listindex < size1; listindex++ ) {
483  size2 = (unsigned)GetLiveArraySize( listindex );
484  for (unsigned j = 0; j < size2; j++) {
485  TheArray[ listindex ] [ j ]->Step();
486  }
487  } // for listindex
488  } while ( !StepFinished() );
489  DoAfter();
490  // call the end-step-method of all objects
491  for ( unsigned listindex = 0; listindex < size1; listindex++ ) {
492  size2 = (unsigned)GetLiveArraySize( listindex );
493  for (unsigned j = 0; j < size2; j++) {
494  TheArray[ listindex ] [ j ]->EndStep();
495  }
496  }
497  // ----------------
498  // end of this step actions
499  // For each animal list
500  DoAlmostLast();
501 
502 DoLast();
503  } // End of time step loop
504 }
CfgBool cfg_RipleysOutputMonthly_used("G_RIPLEYSOUTPUTMONTHLY_USED", CFG_CUSTOM, false)
void Shuffle_or_Sort(unsigned Type)
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
int SupplyMonth(void)
Definition: landscape.h:1527
virtual void TheReallyBigOutputProbe()
static CfgInt cfg_ReallyBigOutput_interval("G_REALLYBIGOUTPUT_INTERVAL", CFG_CUSTOM, 1)
static CfgInt cfg_ReallyBigOutput_day2("G_REALLYBIGOUTPUT_DAY_TWO", CFG_CUSTOM, 91)
static CfgInt cfg_RipleysOutput_interval("G_RIPLEYSOUTPUT_INTERVAL", CFG_CUSTOM, 1)
CfgBool cfg_RipleysOutput_used("G_RIPLEYSOUTPUT_USED", CFG_CUSTOM, true)
CfgInt cfg_CatastropheEventStartYear("PM_CATASTROPHEEVENTSTARTYEAR", CFG_CUSTOM, 99999)
vector< TListOfAnimals > TheArray
static CfgInt cfg_ReallyBigOutput_day1("G_REALLYBIGOUTPUT_DAY_ONE", CFG_CUSTOM, 1)
static CfgInt cfg_RipleysOutputFirstYear("G_RIPLEYSOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
virtual void TheCIPEGridOutputProbe()
virtual void TheNWordOutputProbe()
virtual bool StepFinished()
Overrides the population manager StepFinished - there is no chance that hunters do not finish a step ...
virtual void DoAlmostLast()
static CfgInt cfg_ReallyBigOutput_day3("G_REALLYBIGOUTPUT_DAY_THREE", CFG_CUSTOM, 182)
virtual void TheRipleysOutputProbe(FILE *a_prb)
int SupplyYearNumber(void)
Definition: landscape.h:1542
bool value(void)
Definition: configurator.h:123
int SupplyDayInMonth(void)
Definition: landscape.h:1532
CfgInt cfg_CIPEGridOutput_Interval("G_CIPEGRIDOUTPUT_INTERVAL", CFG_CUSTOM, 1)
int SupplyDayInYear(void)
Definition: landscape.h:1522
CfgInt cfg_CIPEGridOutput_day("G_CIPEGRIDOUTPUT_DAY", CFG_CUSTOM, 1)
CfgBool cfg_CIPEGridOutput_used("G_CIPEGRIDOUTPUT_USED", CFG_CUSTOM, false)
int value(void)
Definition: configurator.h:92
unsigned PartitionLiveDead(unsigned Type)
static CfgInt cfg_RipleysOutput_day("G_RIPLEYSOUTPUT_DAY", CFG_CUSTOM, 60)
virtual void Catastrophe()
static CfgInt cfg_ReallyBigOutput_day4("G_REALLYBIGOUTPUT_DAY_FOUR", CFG_CUSTOM, 274)
static CfgInt cfg_ReallyBigOutputFirstYear("G_REALLYBIGOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
vector< unsigned > m_LiveArraySize
CfgBool cfg_ReallyBigOutput_used("G_REALLYBIGOUTPUT_USED", CFG_CUSTOM, false)
Landscape * m_TheLandscape
void Population_Manager::SetNoProbes ( int  a_pn)
inline

Definition at line 406 of file populationmanager.h.

406 { m_NoProbes=a_pn; }
void Population_Manager::Shuffle ( unsigned  Type)
protected

Run once through the list swapping randomly chosen elements

Definition at line 1125 of file PopulationManager.cpp.

1125  {
1126  unsigned s = (unsigned)GetLiveArraySize( Type );
1127  for ( unsigned i = 0; i < s; i++ ) {
1128  TAnimal * temp;
1129  unsigned a = random( s );
1130  unsigned b = random( s );
1131  temp = TheArray[ Type ] [ a ];
1132  TheArray[ Type ] [ a ] = TheArray[ Type ] [ b ];
1133  TheArray[ Type ] [ b ] = temp;
1134  }
1135 }
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
vector< TListOfAnimals > TheArray
The base class for all ALMaSS animal classes.
void Population_Manager::Shuffle_or_Sort ( unsigned  Type)
protected

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

Definition at line 1143 of file PopulationManager.cpp.

References g_rand_uni.

1143  {
1144  switch ( BeforeStepActions[ Type ] ) {
1145  case 0:
1146  Shuffle( Type );
1147  break;
1148  case 1:
1149  SortX( Type );
1150  break;
1151  case 2:
1152  SortY( Type );
1153  break;
1154  case 3:
1155  SortXIndex( Type );
1156  break;
1157  case 4: // Do nothing
1158  break;
1159  case 5:
1160  if (g_rand_uni() < double (1/500)) Shuffle( Type );
1161  break;
1162  default:
1163  m_TheLandscape->Warn( "Population_Manager::Shuffle_or_Sort- BeforeStepAction Unknown", NULL );
1164  exit( 1 );
1165  }
1166 }
void SortX(unsigned Type)
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
unsigned BeforeStepActions[10]
void Shuffle(unsigned Type)
void SortXIndex(unsigned Type)
void SortY(unsigned Type)
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1505
Landscape * m_TheLandscape
void Population_Manager::SortState ( unsigned  Type)
protected

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

Definition at line 1069 of file PopulationManager.cpp.

1069  {
1070  sort( TheArray[ Type ].begin(), TheArray[ Type ].end(), CompareState() );
1071 }
vector< TListOfAnimals > TheArray
Function to compare to TAnimal&#39;s Current behavioural state.
void Population_Manager::SortStateR ( unsigned  Type)
protected

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

Definition at line 1078 of file PopulationManager.cpp.

1078  {
1079  sort(TheArray[Type].begin(), TheArray[Type].begin()+m_LiveArraySize[Type], CompareStateR());
1080 }
vector< TListOfAnimals > TheArray
Function to compare to TAnimal&#39;s m_CurrentStateNo.
vector< unsigned > m_LiveArraySize
void Population_Manager::SortX ( unsigned  Type)
protected

Sort TheArray w.r.t. the m_Location_x attribute

Definition at line 1049 of file PopulationManager.cpp.

1049  {
1050  vector<TAnimal*>::iterator nth = TheArray[Type].begin() + m_LiveArraySize[Type];
1051  sort( TheArray[ Type ].begin(), nth, CompareX() );
1052 }
vector< TListOfAnimals > TheArray
vector< unsigned > m_LiveArraySize
Function to compare to TAnimal&#39;s m_Location_x.
void Population_Manager::SortXIndex ( unsigned  Type)
protected

Sort TheArray w.r.t. the m_Location_x attribute, and make an indexing array

Definition at line 1097 of file PopulationManager.cpp.

1097  {
1098  vector<TAnimal*>::iterator nth = TheArray[Type].begin() + m_LiveArraySize[Type];
1099  sort(TheArray[Type].begin(), nth, CompareX());
1100  unsigned s = (unsigned)GetLiveArraySize( Type );
1101  // Now make the index array to X;
1102  int counter = 0;
1103  int x;
1104  // for each individual
1105  for ( unsigned i = 0; i < s; i++ ) {
1106  // Get Next co-ordiated
1107  x = TheArray[ Type ] [ i ]->Supply_m_Location_x();
1108  // fill gaps up to x
1109  while ( counter < x ) IndexArrayX[ Type ] [ counter++ ] = -1;
1110  if ( x == counter ) {
1111  IndexArrayX[ Type ] [ counter++ ] = i;
1112  }
1113  }
1114  // Fill up the rest of the array with -1;
1115  for ( int c = counter; c < 10000; c++ ) {
1116  IndexArrayX[ Type ] [ c ] = -1;
1117  }
1118 }
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
vector< TListOfAnimals > TheArray
int IndexArrayX[5][10000]
vector< unsigned > m_LiveArraySize
Function to compare to TAnimal&#39;s m_Location_x.
void Population_Manager::SortY ( unsigned  Type)
protected

Sort TheArray w.r.t. the m_Location_y attribute

Definition at line 1059 of file PopulationManager.cpp.

1059  {
1060  vector<TAnimal*>::iterator nth = TheArray[Type].begin() + m_LiveArraySize[Type];
1061  sort(TheArray[Type].begin(), nth, CompareY());
1062 }
vector< TListOfAnimals > TheArray
Function to compare to TAnimal&#39;s m_Location_y.
vector< unsigned > m_LiveArraySize
char * Population_Manager::SpeciesSpecificReporting ( int  a_species,
int  a_time 
)

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

Definition at line 1191 of file PopulationManager.cpp.

References g_str.

1191  {
1192  strcpy(g_str,"");
1193 // Vole Model
1194  if ( a_species == 1 ) {
1195 /*
1196 // The next lines are obselete code from genetic simulations
1197 float MeanNoAlleles;
1198  float MeanHO;
1199  float MeanHE;
1200  unsigned size;
1201 
1202  if ( m_time % ( 365 * 24 * 60 ) == 0 ) // End of year
1203  {
1204 
1205  // empty the GenStruc data
1206  for ( int ProbeNo = 0; ProbeNo < ( int )m_NoProbes; ProbeNo++ ) {
1207  fprintf( m_GeneticsFile, "%d ", m_time );
1208  int TotalSize = 0;
1209  m_AManager->AlFreq->Flush();
1210  for ( unsigned listindex = 0; listindex <= 1; listindex++ ) {
1211  size = 0;
1212  m_AManager->TheGeneticProbe( listindex, ProbeNo, size );
1213  TotalSize += size;
1214  }
1215  if ( TotalSize > 0 ) {
1216  m_AManager->AlFreq->CalcAF();
1217  m_AManager->AlFreq->CalcNoAlleles();
1218  m_AManager->AlFreq->CalcHE();
1219  m_AManager->AlFreq->CalcHO( TotalSize );
1220  }
1221  // Get the means
1222  // For N alleles
1223  int NA = 0;
1224  float NHO = 0;
1225  float NHE = 0;
1226  for ( int l = 0; l < 16; l++ ) {
1227  NA += m_AManager->AlFreq->SupplyNoAlleles( l );
1228  }
1229  MeanNoAlleles = ( float )NA / 16.0;
1230  for ( int l = 0; l < 16; l++ ) {
1231  NHO += m_AManager->AlFreq->SupplyHO( l );
1232  }
1233  MeanHO = NHO / 16.0;
1234  for ( int l = 0; l < 16; l++ ) {
1235  NHE += m_AManager->AlFreq->SupplyHE( l );
1236  }
1237  MeanHE = NHE / 16.0;
1238 
1239  // Do some output
1240  // Output is to two files, the genetics file and the AllelerequencyFile
1241  fprintf( m_GeneticsFile, "%2.2f ", MeanNoAlleles );
1242  fprintf( m_GeneticsFile, "%1.3f ", MeanHO );
1243  fprintf( m_GeneticsFile, "%1.3f ", MeanHE );
1244  for ( int l = 0; l < 16; l++ ) {
1245  fprintf( m_GeneticsFile, "%04i ", m_AManager->AlFreq->SupplyNoAlleles( l ) );
1246  }
1247  for ( int l = 0; l < 16; l++ ) {
1248  fprintf( m_GeneticsFile, "%1.3f ", m_AManager->AlFreq->SupplyHO( l ) );
1249  }
1250  for ( int l = 0; l < 16; l++ ) {
1251  fprintf( m_GeneticsFile, "%1.3f ", m_AManager->AlFreq->SupplyHE( l ) );
1252  }
1253  fprintf( m_GeneticsFile, "\n" );
1254  fprintf( m_AlleleFreqsFile, "%d ", m_time );
1255  for ( int l = 0; l < 16; l++ ) {
1256  for ( int al = 0; al < 4; al++ ) {
1257  fprintf( m_AlleleFreqsFile, "%1.3f ", m_AManager->AlFreq->SupplyAF( l, al ) );
1258  }
1259  }
1260  fprintf( m_AlleleFreqsFile, "\n" );
1261  }
1262  // make sure progress reaches the disk
1263  fflush( m_GeneticsFile );
1264  fflush( m_AlleleFreqsFile );
1265  }
1266 
1267  if ( cfg_UseEasyPop.value()) {
1268  int targettime=a_time % ( 365 * 100 );
1269  if ( ( targettime == 59 ) ||(targettime == 181)||(targettime ==304)||(targettime ==59+365)||(targettime ==181+365)||(targettime ==304+365)) {
1270  for ( unsigned listindex = 0; listindex <= 1; listindex++ ) {
1271  GeneticsResultsOutput( m_EasyPopRes, listindex);
1272  }
1273  fflush( m_EasyPopRes );
1274  }
1275  }
1276 */
1277  /* Three times a year reporting
1278  if ( m_time % 365 == 60 ) ProbeReportNow( m_time );
1279  if ( m_time % 365 == 152 ) ProbeReportNow( m_time );
1280  if ( m_time % 365 == 273 ) ProbeReportNow( m_time ); */
1281  ProbeReport( a_time );
1282 #ifdef __SpecificPesticideEffectsVinclozolinLike__
1283  ImpactProbeReport( a_time );
1284 #endif
1285 #ifdef __WithinOrchardPesticideSim__
1286  ImpactProbeReport( a_time );
1287 #endif
1288 
1289  }
1290  // Skylark Model
1291  else if ( a_species == 0 ) {
1292  int No;
1293  int a_day = a_time % 365;
1294  if ( a_time % 365 == 364 )
1295  {
1296  //Write the Breeding Attempts Probe
1297  int BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales, BreedingAttempts;
1298  int No = TheBreedingSuccessProbe( BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales, BreedingAttempts );
1299  float bs = 0;
1300  if ( BreedingFemales > 0 ) {
1301  bs = No / ( float )BreedingFemales; //bs = successful breeding attempt per attempting to breed female
1302  }
1303  BreedingSuccessProbeOutput( bs, BreedingFemales, YoungOfTheYear, TotalPop,
1304  TotalFemales, TotalMales, a_time, BreedingAttempts );
1305  }
1306  if ( a_day == 152 ) {
1307  // Need to fill in the landscape from 1st June, it will change before
1308  // the count of fledgelings is needed
1310  }
1311  if ( a_day == 197 ) {
1312  for ( int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++ ) {
1313  No = TheFledgelingProbe();
1314  // Do some output
1315  FledgelingProbeOutput( No, a_time );
1316  }
1317  }
1318 #ifdef __SKPOM
1319  // This is clunky but for purposes of validation we want probes throughout the year
1320  // First get the breeding pairs data.
1321  BreedingPairsOutput(a_day);
1322 #else
1323  ProbeReport( a_time );
1324 #endif
1325  }
1326  else return ProbeReport( a_time );
1327  return g_str;
1328 }
virtual void BreedingSuccessProbeOutput(double, int, int, int, int, int, int, int)
void FillVegAreaData()
Definition: Landscape.cpp:3405
virtual void BreedingPairsOutput(int)
void ImpactProbeReport(int a_Time)
char * ProbeReport(int a_time)
virtual void FledgelingProbeOutput(int, int)
char g_str[255]
virtual int TheFledgelingProbe()
virtual int TheBreedingSuccessProbe(int &, int &, int &, int &, int &, int &)
Landscape * m_TheLandscape
bool Population_Manager::StepFinished ( void  )
protectedvirtual

Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour.

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

Definition at line 509 of file PopulationManager.cpp.

509  {
510  for ( unsigned listindex = 0; listindex < TheArray.size(); listindex++ ) {
511  for (unsigned j = 0; j < (unsigned)GetLiveArraySize( listindex ); j++) {
512  if ( TheArray[ listindex ] [ j ]->GetStepDone() == false ) {
513  return false;
514  }
515  }
516  }
517  return true;
518 }
unsigned GetLiveArraySize(int a_listindex)
Gets the number of &#39;live&#39; objects for a list index in the TheArray.
vector< TListOfAnimals > TheArray
virtual int Population_Manager::SupplyCovPosx ( int  )
inlinevirtual

Definition at line 607 of file populationmanager.h.

607  {
608  return 0;
609  }
virtual int Population_Manager::SupplyCovPosy ( int  )
inlinevirtual

Definition at line 610 of file populationmanager.h.

610  {
611  return 0;
612  }
unsigned Population_Manager::SupplyListIndexSize ( )
inline

Definition at line 439 of file populationmanager.h.

439  {
440  return (unsigned)TheArray.size();
441  }
vector< TListOfAnimals > TheArray
const char* Population_Manager::SupplyListName ( int  i)
inline

Definition at line 449 of file populationmanager.h.

449  {
450  return m_ListNames[ i ];
451  }
const char * m_ListNames[10]
int Population_Manager::SupplyListNameLength ( )
inline

Definition at line 436 of file populationmanager.h.

436  {
437  return m_ListNameLength;
438  }
unsigned Population_Manager::SupplyListSize ( unsigned  listindex)
inline

Definition at line 442 of file populationmanager.h.

442  {
443  return (unsigned) TheArray[ listindex ].size();
444  }
vector< TListOfAnimals > TheArray
virtual void Population_Manager::SupplyLocXY ( unsigned  listindex,
unsigned  j,
int &  x,
int &  y 
)
inlinevirtual

Definition at line 464 of file populationmanager.h.

464  {
465  x = TheArray[ listindex ] [ j ]->Supply_m_Location_x();
466  y = TheArray[ listindex ] [ j ]->Supply_m_Location_y();
467  }
vector< TListOfAnimals > TheArray
virtual int Population_Manager::SupplyPegPosx ( int  )
inlinevirtual

Definition at line 601 of file populationmanager.h.

601  {
602  return 0;
603  }
virtual int Population_Manager::SupplyPegPosy ( int  )
inlinevirtual

Definition at line 604 of file populationmanager.h.

604  {
605  return 0;
606  }
int Population_Manager::SupplySimH ( )
inline

Definition at line 430 of file populationmanager.h.

430  {
431  return SimH;
432  }
int Population_Manager::SupplySimW ( )
inline

Definition at line 427 of file populationmanager.h.

427  {
428  return SimW;
429  }
int Population_Manager::SupplyState ( unsigned  listindex,
unsigned  j 
)
inline

IntArray100 * SupplyStateList() { return & StateList; }

Definition at line 461 of file populationmanager.h.

461  {
462  return TheArray[ listindex ] [ j ]->WhatState();
463  }
vector< TListOfAnimals > TheArray
const char* Population_Manager::SupplyStateNames ( int  i)
inline

Definition at line 468 of file populationmanager.h.

468  {
469  return StateNames[ i ];
470  }
const char * StateNames[100]
unsigned Population_Manager::SupplyStateNamesLength ( )
inline

Definition at line 471 of file populationmanager.h.

471  {
472  return StateNamesLength;
473  }
int Population_Manager::SupplyStepSize ( )
inline

Definition at line 424 of file populationmanager.h.

424  {
425  return m_StepSize;
426  }
virtual int Population_Manager::TheBreedingFemalesProbe ( int  )
inlinevirtual

Definition at line 624 of file populationmanager.h.

624  {
625  return 0;
626  }
virtual int Population_Manager::TheBreedingSuccessProbe ( int &  ,
int &  ,
int &  ,
int &  ,
int &  ,
int &   
)
inlinevirtual

Definition at line 632 of file populationmanager.h.

632  {
633  return 0;
634  }
void Population_Manager::TheCIPEGridOutputProbe ( )
virtual

This method MUST be overridden in descendent classes, if you want it to work

Definition at line 799 of file PopulationManager.cpp.

799  {
800 }
virtual int Population_Manager::TheFledgelingProbe ( )
inlinevirtual

Definition at line 627 of file populationmanager.h.

627  {
628  return 0;
629  }
virtual void Population_Manager::TheGeneticProbe ( unsigned  ,
int  ,
unsigned &   
)
inlinevirtual

Definition at line 637 of file populationmanager.h.

637  {
638  }
virtual void Population_Manager::TheNWordOutputProbe ( )
inlinevirtual

Reimplemented in Rabbit_Population_Manager.

Definition at line 542 of file populationmanager.h.

542 {};
void Population_Manager::TheReallyBigOutputProbe ( )
virtual

This method must be overridden in descendent classes

Definition at line 989 of file PopulationManager.cpp.

989  {
990 }
void Population_Manager::TheRipleysOutputProbe ( FILE *  a_prb)
virtual

This method must be overridden in descendent classes

Definition at line 994 of file PopulationManager.cpp.

994  {
995 }

Member Data Documentation

unsigned Population_Manager::BeforeStepActions[10]
protected

Definition at line 511 of file populationmanager.h.

FILE* Population_Manager::CIPEGridOutputPrb
protected

Definition at line 567 of file populationmanager.h.

FILE* Population_Manager::CIPEGridOutputPrbB
protected

Definition at line 568 of file populationmanager.h.

int Population_Manager::IndexArrayX[5][10000]

Definition at line 480 of file populationmanager.h.

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

Definition at line 578 of file populationmanager.h.

FILE* Population_Manager::m_AlleleFreqsFile
protected

Definition at line 498 of file populationmanager.h.

int Population_Manager::m_catastrophestartyear
protected

Definition at line 502 of file populationmanager.h.

int* Population_Manager::m_cgridcount
protected

Definition at line 571 of file populationmanager.h.

int Population_Manager::m_cgridcountwidth
protected

Definition at line 573 of file populationmanager.h.

int Population_Manager::m_cipegridsize
protected

Definition at line 575 of file populationmanager.h.

FILE* Population_Manager::m_EasyPopRes
protected

Definition at line 499 of file populationmanager.h.

FILE* Population_Manager::m_GeneticsFile
protected

Definition at line 497 of file populationmanager.h.

int* Population_Manager::m_gridcount[4]
protected

Definition at line 572 of file populationmanager.h.

int Population_Manager::m_gridcountsize[4]
protected

Definition at line 576 of file populationmanager.h.

int Population_Manager::m_gridcountwidth[4]
protected

Definition at line 574 of file populationmanager.h.

unsigned Population_Manager::m_ListNameLength
protected
const char* Population_Manager::m_ListNames[10]
protected
vector<unsigned> Population_Manager::m_LiveArraySize
protected

Definition at line 495 of file populationmanager.h.

int Population_Manager::m_NoProbes
protected

Definition at line 496 of file populationmanager.h.

TTypesOfPopulation Population_Manager::m_population_type
protected

Definition at line 553 of file populationmanager.h.

int Population_Manager::m_SeasonNumber
protected

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

Definition at line 513 of file populationmanager.h.

char Population_Manager::m_SimulationName[255]
int Population_Manager::m_StepSize
protected

Definition at line 503 of file populationmanager.h.

Landscape* Population_Manager::m_TheLandscape
FILE* Population_Manager::NWordOutputPrb
protected

Definition at line 570 of file populationmanager.h.

bool Population_Manager::ProbesSet

Definition at line 485 of file populationmanager.h.

FILE* Population_Manager::ReallyBigOutputPrb
protected

Definition at line 569 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb
protected

Definition at line 554 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb1
protected

Definition at line 555 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb10
protected

Definition at line 564 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb11
protected

Definition at line 565 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb12
protected

Definition at line 566 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb2
protected

Definition at line 556 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb3
protected

Definition at line 557 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb4
protected

Definition at line 558 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb5
protected

Definition at line 559 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb6
protected

Definition at line 560 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb7
protected

Definition at line 561 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb8
protected

Definition at line 562 of file populationmanager.h.

FILE* Population_Manager::RipleysOutputPrb9
protected

Definition at line 563 of file populationmanager.h.

int Population_Manager::SimH
unsigned Population_Manager::SimHH

Definition at line 483 of file populationmanager.h.

int Population_Manager::SimW
unsigned Population_Manager::SimWH

Definition at line 483 of file populationmanager.h.

const char* Population_Manager::StateNames[100]
protected

Definition at line 501 of file populationmanager.h.

unsigned Population_Manager::StateNamesLength
protected

Definition at line 505 of file populationmanager.h.

FILE* Population_Manager::TestFile
protected

Definition at line 509 of file populationmanager.h.

FILE* Population_Manager::TestFile2
protected

Definition at line 510 of file populationmanager.h.

vector< TListOfAnimals > Population_Manager::TheArray
protected
probe_data* Population_Manager::TheProbe[100]

Definition at line 481 of file populationmanager.h.


The documentation for this class was generated from the following files: