39 #ifndef PopulationManagerH 40 #define PopulationManagerH 72 #ifdef __dormouse // LADA 118 return m_CurrentStateNo;
122 m_CurrentStateNo = a_num;
141 m_CurrentStateNo = 0;
148 void OnArrayBoundsError();
154 void DEADCODEError();
203 unsigned SupplyFarmOwnerRef();
205 APoint
SupplyPoint() { APoint p( m_Location_x, m_Location_y);
return p; }
207 return m_OurLandscape->SupplyPolyRef( m_Location_x, m_Location_y );
217 m_CurrentStateNo = -1;
265 void CheckManagement(
void );
266 void CheckManagementXY(
int x,
int y );
284 char m_MyFileName[ 255 ];
295 unsigned m_RefFarms[ 25 ];
297 bool m_TargetTypes[ 10 ];
298 void FileOutput(
int No,
int time,
int ProbeNo );
299 void FileAppendOutput(
int No,
int time );
301 void SetFile( ofstream * F );
302 ofstream * OpenFile(
char * Nme );
305 m_MyFile =
new ofstream(m_MyFileName, ios::app);
306 if (!(*m_MyFile).is_open())
308 g_msg->
Warn(
WARN_FILE,
"PopulationManager::AppendToFile() Unable to open file for append: ", m_MyFileName );
340 if (m_n == 0) m_K = x;
344 m_SumX2 += (x - m_K) * (x - m_K);
351 m_SumX2 -= (x - m_K) * (x - m_K);
363 return m_K + m_SumX / m_n;
371 return (m_SumX2 - (m_SumX*m_SumX) / m_n) / (m_n);
379 return (m_SumX2 - (m_SumX*m_SumX) / m_n) / (m_n - 1);
409 return m_LiveArraySize[a_listindex];
413 m_LiveArraySize[a_listindex]++;
417 unsigned int FarmAnimalCensus(
unsigned int a_farm,
unsigned int a_typeofanimal);
418 char* SpeciesSpecificReporting(
int a_species,
int a_time);
419 char* ProbeReport(
int a_time);
420 char* ProbeReportTimed(
int a_time);
421 void ImpactProbeReport(
int a_Time );
422 bool BeginningOfMonth();
423 void LOG(
const char* fname);
433 virtual void Run(
int NoTSteps );
434 virtual float Probe(
int ListIndex,
probe_data * p_TheProbe );
435 virtual void ImpactedProbe( );
437 return m_ListNameLength;
440 return (
unsigned)TheArray.size();
443 return (
unsigned) TheArray[ listindex ].size();
446 bool CheckXY(
int l,
int i);
450 return m_ListNames[ i ];
453 if ( TheArray[ listindex ].size() > 1 )
return false;
else 462 return TheArray[ listindex ] [ j ]->WhatState();
464 virtual void SupplyLocXY(
unsigned listindex,
unsigned j,
int & x,
int & y ) {
465 x = TheArray[ listindex ] [ j ]->Supply_m_Location_x();
466 y = TheArray[ listindex ] [ j ]->Supply_m_Location_y();
469 return StateNames[ i ];
472 return StateNamesLength;
474 virtual void DisplayLocations();
475 int ProbeFileInput(
char * p_Filename,
int p_ProbeNo );
477 #ifdef __ALMASS_VISUAL 478 MyDialog * m_MainForm;
480 int IndexArrayX[ 5 ] [ 10000 ];
484 char m_SimulationName[ 255 ];
487 TAnimal * FindClosest(
int x,
int y,
unsigned Type );
501 const char* StateNames[ 100 ];
507 const char* m_ListNames[ 10 ];
511 unsigned BeforeStepActions[ 10 ];
516 virtual bool StepFinished();
517 virtual void DoFirst();
518 virtual void DoBefore();
519 virtual void DoAfter();
520 virtual void DoAlmostLast();
521 virtual void DoLast();
523 void EmptyTheArray();
524 void SortX(
unsigned Type );
525 void SortXIndex(
unsigned Type );
526 void SortY(
unsigned Type );
527 void SortState(
unsigned Type );
528 void SortStateR(
unsigned Type);
529 unsigned PartitionLiveDead(
unsigned Type);
530 void Shuffle_or_Sort(
unsigned Type);
531 void Shuffle(
unsigned Type );
532 virtual void Catastrophe();
537 bool OpenTheRipleysOutputProbe();
538 bool OpenTheMonthlyRipleysOutputProbe();
539 bool OpenTheReallyBigProbe();
540 virtual void TheRipleysOutputProbe(FILE* a_prb);
541 virtual void TheReallyBigOutputProbe();
543 void CloseTheMonthlyRipleysOutputProbe();
544 void CloseTheRipleysOutputProbe();
545 void CloseTheReallyBigOutputProbe();
546 bool OpenTheCIPEGridOutputProbe();
547 virtual void TheCIPEGridOutputProbe();
548 void CloseTheCIPEGridOutputProbe();
574 int m_gridcountwidth[4];
576 int m_gridcountsize[4];
578 long int lamdagrid[2][257][257];
582 lamdagrid[1][x / __lgridsize][y / __lgridsize ]++;
585 lamdagrid[0][x / __lgridsize][y / __lgridsize ]++;
588 lamdagrid[0][x / __lgridsize][y / __lgridsize ]+=z;
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;
598 void LamdaDumpOutput();
int m_catastrophestartyear
FILE * ReallyBigOutputPrb
TTypesOfPopulation
An enum to hold all the possible types of population handled by a Population_Manager class...
virtual int SupplyCovPosy(int)
const char * SupplyListName(int i)
The landscape class containing all environmental and topographical data.
A class defining an animals position.
int SupplyListNameLength()
void LamdaDeath(int x, int y)
unsigned SupplyListIndexSize()
bool IsLast(unsigned listindex)
unsigned GetLiveArraySize(int a_listindex)
Gets the number of 'live' objects for a list index in the TheArray.
virtual bool OpenTheFledgelingProbe()
TTypesOfLandscapeElement m_EleType
virtual void TheGeneticProbe(unsigned, int, unsigned &)
virtual bool OnFarmEvent(FarmToDo)
int SupplyState(unsigned listindex, unsigned j)
bool OpenForAppendToFile()
virtual void ReinitialiseObject(int x, int y, Landscape *L)
Used to re-use an object - must be implemented in descendent classes.
virtual void BeginStep(void)
BeingStep behaviour - must be implemented in descendent classes.
double get_varianceP()
Returns the population variance.
virtual int SupplyPegPosy(int)
vector< TListOfAnimals > TheArray
int SupplySimAreaWidth(void)
void CorrectWrapRound()
Corrects wrap around co-ordinate problems.
virtual int SupplyCovPosx(int)
Base class for all population managers.
unsigned m_ReportInterval
virtual int SupplyPegPosx(int)
Population_Manager * GetPopulation(TTypesOfPopulation a_pt)
void IncLiveArraySize(int a_listindex)
Increments the number of 'live' objects for a list index in the TheArray.
virtual void TheNWordOutputProbe()
virtual void BreedingSuccessProbeOutput(double, int, int, int, int, int, int, int)
void add_variable(double x)
Add a value.
void LamdaBirth(int x, int y)
void SetPopulation(Population_Manager *p_pm, TTypesOfPopulation a_pt)
class MapErrorMsg * g_msg
TTypesOfVegetation m_VegType
SimpleStatistics()
SimpleStatistics constructor.
FILE * RipleysOutputPrb10
virtual void EndStep(void)
EndStep behaviour - must be implemented in descendent classes.
FILE * CIPEGridOutputPrbB
int Supply_m_Location_y()
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
void SetNoProbes(int a_pn)
unsigned StateNamesLength
int m_SeasonNumber
Holds the season number. Used when running goose and hunter sims.
void ClearData()
Clears the data.
double get_N()
Returns the number of values.
TTypesOfPopulation GetPopulationType()
void remove_variable(double x)
Remove a value.
FILE * RipleysOutputPrb12
double get_varianceS()
Returns the sample variance.
virtual void Catastrophe(int)
virtual void BreedingPairsOutput(int)
int Supply_m_Location_x()
The base class for all ALMaSS animal classes.
virtual void CopyMyself()
unsigned SupplyStateNamesLength()
virtual void Step(void)
Step behaviour - must be implemented in descendent classes.
double get_meanvalue()
Returns the mean.
double get_Total()
Returns the mean.
int SupplySimAreaHeight(void)
vector< TAnimal * > TListOfAnimals
unsigned SupplyListSize(unsigned listindex)
virtual bool OpenTheBreedingSuccessProbe()
A struct defining two x,y coordinate sets of positive co-ords only.
Landscape * m_OurLandscape
virtual void GeneticsResultsOutput(FILE *, unsigned)
The base class of all ALMaSS objects requiring Step code.
virtual void BeginStep(void)
BeingStep behaviour - must be implemented in descendent classes.
int GetSeasonNumber()
Get the season number.
bool GetStepDone()
Returns the step done indicator flag.
TTypesOfPopulation m_population_type
virtual bool OpenTheBreedingPairsProbe()
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
virtual void FledgelingProbeOutput(int, int)
virtual int TheBreedingFemalesProbe(int)
void SetStepDone(bool a_bool)
Sets the step done indicator flag.
void SetCurrentStateNo(int a_num)
Sets the current state number.
virtual void Step(void)
Step behaviour - must be implemented in descendent classes.
const char * SupplyStateNames(int i)
void LamdaBirth(int x, int y, int z)
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
virtual void SupplyLocXY(unsigned listindex, unsigned j, int &x, int &y)
Data structure to hold & output probe data probe data is designed to be used to return the number of ...
virtual int TheFledgelingProbe()
vector< unsigned > m_LiveArraySize
virtual void ReinitialiseObject()
Used to re-use an object - must be implemented in descendent classes.
int GetCurrentStateNo()
Returns the current state number.
A small class to hold the pointers to active population managers.
unsigned m_ListNameLength
virtual int TheBreedingSuccessProbe(int &, int &, int &, int &, int &, int &)
FILE * RipleysOutputPrb11
Landscape * m_TheLandscape
Part of the basic ALMaSS system (obselete)
virtual void EndStep(void)
EndStep behaviour - must be implemented in descendent classes.