48 #include "../Landscape/ls.h" 49 #include "../BatchALMaSS/PopulationManager.h" 50 #include "../GooseManagement/GooseMemoryMap.h" 51 #include "../GooseManagement/Goose_Base.h" 52 #include "../BatchALMaSS/CurveClasses.h" 53 #include "../Hunters/Hunters_all.h" 54 #include "../GooseManagement/Goose_Population_Manager.h" 55 #ifdef __ALMASS_VISUAL 57 #include "wx/spinctrl.h" 58 #include "../GUI/ALMaSS_GUI.h" 60 #include "../BatchALMaSS/BoostRandomGenerators.h" 62 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> >
g_rand_uni;
97 #define _CRTDBG_MAP_ALLOC 137 if ( m_MyFile != NULL ) {
138 if (m_MyFile->is_open()) m_MyFile->close();
227 TheArray.insert( TheArray.end(), 10, alist );
230 SimW = m_TheLandscape->SupplySimAreaWidth();
231 SimHH = m_TheLandscape->SupplySimAreaHeight()/2;
232 SimWH = m_TheLandscape->SupplySimAreaWidth()/2;
233 for (
int i = 0; i < 10; i++) {
235 BeforeStepActions[ i ] = 0;
236 m_ListNames[ i ] =
"Unknown";
237 m_LiveArraySize.push_back( 0 );
240 StateNamesLength = 0;
241 m_catastrophestartyear=-1;
242 #ifdef __LAMBDA_RECORD 243 ofstream fout(
"LambdaGridOuput.txt", ios_base::out);
248 OpenTheMonthlyRipleysOutputProbe();
251 m_cgridcountwidth = SimW/m_cipegridsize;
252 m_cgridcount =
new int[ m_cgridcountwidth * m_cgridcountwidth ];
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] ];
266 #ifdef __ALMASS_VISUAL 278 for (
unsigned i = 0; i < TheArray.size(); i++ ) {
280 for (
unsigned j = 0; j < (unsigned) GetLiveArraySize(i); j++ ) {
281 delete TheArray[ i ] [ j ];
284 TheArray[ i ].clear();
288 CloseTheRipleysOutputProbe();
289 fclose( NWordOutputPrb );
292 CloseTheMonthlyRipleysOutputProbe();
295 CloseTheReallyBigOutputProbe();
297 for (
int d=0; d<4; d++)
delete [] m_gridcount[d];
298 delete [] m_cgridcount;
307 FILE * PFile = fopen(fname,
"w" );
309 m_TheLandscape->Warn(
"PopulationManager::LOG - Could not open file ",fname);
313 for (
unsigned listindex = 0; listindex < TheArray.size(); listindex++ ) {
315 fprintf( PFile,
"%s :\n", m_ListNames[ listindex ] );
317 fprintf( PFile,
"%s :\n", m_ListNames[ listindex ].c_str() );
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 );
353 for (
int TSteps = 0; TSteps < NoTSteps; TSteps++ )
356 unsigned size1 = (unsigned) TheArray.size();
361 for (
unsigned listindex = 0; listindex < size1; listindex++ )
364 m_LiveArraySize[listindex] = PartitionLiveDead(listindex);
366 #ifdef __ALMASS_VISUAL 367 if (m_MainForm!=NULL)
370 for (
unsigned listindex = 0; listindex < size1; listindex++ ) n += (
int) m_LiveArraySize[ listindex ];
377 for (
unsigned listindex = 0; listindex < size1; listindex++ )
379 size2 = (unsigned) GetLiveArraySize(listindex);
380 for (
unsigned j = 0; j < size2; j++ )
382 TheArray[ listindex ] [ j ]->SetStepDone(
false );
386 for (
unsigned listindex = 0; listindex < size1; listindex++ ) {
388 Shuffle_or_Sort( listindex );
392 int Year = m_TheLandscape->SupplyYearNumber();
395 int day = m_TheLandscape->SupplyDayInYear();
398 TheRipleysOutputProbe( RipleysOutputPrb );
399 TheNWordOutputProbe();
406 if (m_TheLandscape->SupplyDayInMonth()==1) {
407 int Year = m_TheLandscape->SupplyYearNumber();
410 int month = m_TheLandscape->SupplyMonth();
413 case 1: TheRipleysOutputProbe( RipleysOutputPrb1 );
415 case 2: TheRipleysOutputProbe( RipleysOutputPrb2 );
417 case 3: TheRipleysOutputProbe( RipleysOutputPrb3 );
419 case 4: TheRipleysOutputProbe( RipleysOutputPrb4 );
421 case 5: TheRipleysOutputProbe( RipleysOutputPrb5 );
423 case 6: TheRipleysOutputProbe( RipleysOutputPrb6 );
425 case 7: TheRipleysOutputProbe( RipleysOutputPrb7 );
427 case 8: TheRipleysOutputProbe( RipleysOutputPrb8 );
429 case 9: TheRipleysOutputProbe( RipleysOutputPrb9 );
431 case 10: TheRipleysOutputProbe( RipleysOutputPrb10 );
433 case 11: TheRipleysOutputProbe( RipleysOutputPrb11 );
435 case 12: TheRipleysOutputProbe( RipleysOutputPrb12 );
444 int Year = m_TheLandscape->SupplyYearNumber();
447 int day = m_TheLandscape->SupplyDayInYear();
451 TheReallyBigOutputProbe();
458 int Year = m_TheLandscape->SupplyYearNumber();
460 int day = m_TheLandscape->SupplyDayInYear();
463 TheCIPEGridOutputProbe();
467 int yr=m_TheLandscape->SupplyYearNumber();
469 if (m_catastrophestartyear==-1) m_catastrophestartyear=yr;
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();
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();
488 }
while ( !StepFinished() );
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();
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 ) {
576 #ifdef __ALMASS_VISUAL 577 m_MainForm->UpdateGraphics();
590 PFile = fopen(p_Filename,
"r" );
592 m_TheLandscape->Warn(
"Population Manager - cannot open Probe File ", p_Filename );
595 fgets( S, 255, PFile );
596 fgets( S, 255, PFile );
597 fscanf( PFile,
"%d\n", & data );
598 TheProbe[ p_ProbeNo ]->m_ReportInterval = data;
599 fgets( S, 255, PFile );
600 fscanf( PFile,
"%d\n", & data );
601 if ( data == 0 ) TheProbe[ p_ProbeNo ]->m_FileRecord =
false;
else 602 TheProbe[ p_ProbeNo ]->m_FileRecord =
true;
603 fgets( S, 255, PFile );
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;
610 fgets( S, 255, PFile );
611 fgets( S, 255, PFile );
612 fscanf( PFile,
"%d", & data );
613 TheProbe[ p_ProbeNo ]->m_NoAreas = data;
614 fgets( S, 255, PFile );
615 fgets( S, 255, PFile );
616 fscanf( PFile,
"%d", & data2 );
617 fgets( S, 255, PFile );
618 fgets( S, 255, PFile );
619 fscanf( PFile,
"%d", & data );
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 );
627 fgets( S, 255, PFile );
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;
639 fgets( S, 255, PFile );
640 fgets( S, 255, PFile );
641 if ( TheProbe[ p_ProbeNo ]->m_NoVegTypes > 0 ) {
642 for (
int i = 0; i < 25; i++ ) {
643 fscanf( PFile,
"%d", & data );
645 TheProbe[ p_ProbeNo ]->m_RefVeg[ i ] = m_TheLandscape->TranslateVegTypes( data );
647 }
else if ( TheProbe[ p_ProbeNo ]->m_NoFarms > 0 ) {
648 for (
int i = 0; i < 25; i++ ) {
649 fscanf( PFile,
"%d", & data );
651 TheProbe[ p_ProbeNo ]->m_RefFarms[ i ] = data;
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 );
669 ofstream fout(
"LambdaGridOuput.txt", ios_base::app);
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;
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++ ) {
705 for (
unsigned k = 0; k < p_TheProbe->
m_NoFarms; k++ ) {
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++ ) {
718 for (
unsigned k = 0; k < p_TheProbe->
m_NoEleTypes; k++ ) {
726 for (
unsigned j = 0; j < (unsigned)GetLiveArraySize( ListIndex ); j++) {
727 Sp = TheArray[ ListIndex ] [ j ]->SupplyPosition();
729 for (
unsigned i = 0; i < p_TheProbe->
m_NoAreas; i++ ) {
732 for (
unsigned k = 0; k < p_TheProbe->
m_NoVegTypes; k++ ) {
741 unsigned sz = (unsigned)GetLiveArraySize( ListIndex );
746 (p_TheProbe->
m_Rect[0].
m_y2==(
unsigned)SimH)) {
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++ ) {
771 if ( !CIPEGridOutputPrb ) {
772 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheCIPEGridOutputProbe(): ""Unable to open probe file",
777 if ( !CIPEGridOutputPrbB ) {
778 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheCIPEGridOutputProbe(): ""Unable to open probe file",
791 if ( CIPEGridOutputPrb != NULL )
792 fclose( CIPEGridOutputPrb );
793 fclose( CIPEGridOutputPrbB );
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]++;
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]);
826 fprintf(NWordOutputPrb,
"\n");
827 fflush(NWordOutputPrb);
836 if ( !RipleysOutputPrb ) {
837 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
841 NWordOutputPrb = fopen(
"NWordOutputPrb.txt",
"w" );
842 if ( !NWordOutputPrb ) {
843 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheCIPEGridOutputProbe(): ""Unable to open NWord probe file",
"" );
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");
855 RipleysOutputPrb1 = fopen(
"RipleyOutput_Jan.txt",
"w" );
856 if ( !RipleysOutputPrb1 ) {
857 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
861 RipleysOutputPrb2 = fopen(
"RipleyOutput_Feb.txt",
"w" );
862 if ( !RipleysOutputPrb2 ) {
863 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
867 RipleysOutputPrb3 = fopen(
"RipleyOutput_Mar.txt",
"w" );
868 if ( !RipleysOutputPrb3 ) {
869 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
873 RipleysOutputPrb4 = fopen(
"RipleyOutput_Apr.txt",
"w" );
874 if ( !RipleysOutputPrb4 ) {
875 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
879 RipleysOutputPrb5 = fopen(
"RipleyOutput_May.txt",
"w" );
880 if ( !RipleysOutputPrb5 ) {
881 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
885 RipleysOutputPrb6 = fopen(
"RipleyOutput_Jun.txt",
"w" );
886 if ( !RipleysOutputPrb6 ) {
887 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
891 RipleysOutputPrb7 = fopen(
"RipleyOutput_Jul.txt",
"w" );
892 if ( !RipleysOutputPrb7 ) {
893 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
897 RipleysOutputPrb8 = fopen(
"RipleyOutput_Aug.txt",
"w" );
898 if ( !RipleysOutputPrb8 ) {
899 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
903 RipleysOutputPrb9 = fopen(
"RipleyOutput_Sep.txt",
"w" );
904 if ( !RipleysOutputPrb9 ) {
905 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
909 RipleysOutputPrb10 = fopen(
"RipleyOutput_Oct.txt",
"w" );
910 if ( !RipleysOutputPrb10 ) {
911 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
915 RipleysOutputPrb11 = fopen(
"RipleyOutput_Nov.txt",
"w" );
916 if ( !RipleysOutputPrb11 ) {
917 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
921 RipleysOutputPrb12 = fopen(
"RipleyOutput_Dec.txt",
"w" );
922 if ( !RipleysOutputPrb12 ) {
923 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
937 if ( !ReallyBigOutputPrb ) {
938 g_msg->
Warn(
WARN_FILE,
"Population_Manager::OpenTheRipleysOutputProbe(): ""Unable to open probe file",
952 fclose( RipleysOutputPrb );
953 RipleysOutputPrb=NULL;
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 );
981 if ( ReallyBigOutputPrb != 0 )
982 fclose( ReallyBigOutputPrb );
983 ReallyBigOutputPrb=0;
1008 int distance = 100000000;
1011 for (
unsigned j = 0; j < (unsigned)GetLiveArraySize( Type ); j++) {
1013 dy = TheArray[ Type ] [ j ]->Supply_m_Location_y();
1020 if ( d < distance ) {
1022 TA = TheArray[ Type ] [ j ];
1034 for (
unsigned i = 0; i < TheArray.size(); i++ )
1037 for (
unsigned j = 0; j < (unsigned) TheArray[i].size(); j++)
1039 delete TheArray[ i ] [ j ];
1042 TheArray[ i ].clear();
1050 vector<TAnimal*>::iterator nth = TheArray[Type].begin() + m_LiveArraySize[Type];
1051 sort( TheArray[ Type ].begin(), nth,
CompareX() );
1060 vector<TAnimal*>::iterator nth = TheArray[Type].begin() + m_LiveArraySize[Type];
1061 sort(TheArray[Type].begin(), nth,
CompareY());
1070 sort( TheArray[ Type ].begin(), TheArray[ Type ].end(),
CompareState() );
1079 sort(TheArray[Type].begin(), TheArray[Type].begin()+m_LiveArraySize[Type],
CompareStateR());
1086 auto it = partition(TheArray[Type].begin(), TheArray[Type].begin() + m_LiveArraySize[Type],
CompareStateAlive());
1089 return unsigned(it - TheArray[Type].begin());
1098 vector<TAnimal*>::iterator nth = TheArray[Type].begin() + m_LiveArraySize[Type];
1099 sort(TheArray[Type].begin(), nth,
CompareX());
1100 unsigned s = (unsigned)GetLiveArraySize( Type );
1105 for (
unsigned i = 0; i < s; i++ ) {
1107 x = TheArray[ Type ] [ i ]->Supply_m_Location_x();
1109 while ( counter < x ) IndexArrayX[ Type ] [ counter++ ] = -1;
1110 if ( x == counter ) {
1111 IndexArrayX[ Type ] [ counter++ ] = i;
1115 for (
int c = counter; c < 10000; c++ ) {
1116 IndexArrayX[ Type ] [ c ] = -1;
1126 unsigned s = (unsigned)GetLiveArraySize( Type );
1127 for (
unsigned i = 0; i < s; i++ ) {
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;
1144 switch ( BeforeStepActions[ Type ] ) {
1160 if (
g_rand_uni() <
double (1/500)) Shuffle( Type );
1163 m_TheLandscape->Warn(
"Population_Manager::Shuffle_or_Sort- BeforeStepAction Unknown", NULL );
1194 if ( a_species == 1 ) {
1281 ProbeReport( a_time );
1282 #ifdef __SpecificPesticideEffectsVinclozolinLike__ 1283 ImpactProbeReport( a_time );
1285 #ifdef __WithinOrchardPesticideSim__ 1286 ImpactProbeReport( a_time );
1291 else if ( a_species == 0 ) {
1293 int a_day = a_time % 365;
1294 if ( a_time % 365 == 364 )
1297 int BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales, BreedingAttempts;
1298 int No = TheBreedingSuccessProbe( BreedingFemales, YoungOfTheYear, TotalPop, TotalFemales, TotalMales, BreedingAttempts );
1300 if ( BreedingFemales > 0 ) {
1301 bs = No / ( float )BreedingFemales;
1303 BreedingSuccessProbeOutput( bs, BreedingFemales, YoungOfTheYear, TotalPop,
1304 TotalFemales, TotalMales, a_time, BreedingAttempts );
1306 if ( a_day == 152 ) {
1309 m_TheLandscape->FillVegAreaData();
1311 if ( a_day == 197 ) {
1312 for (
int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++ ) {
1313 No = TheFledgelingProbe();
1315 FledgelingProbeOutput( No, a_time );
1321 BreedingPairsOutput(a_day);
1323 ProbeReport( a_time );
1326 else return ProbeReport( a_time );
1333 unsigned int No = 0;
1334 unsigned sz = (unsigned)GetLiveArraySize( a_typeofanimal );
1335 for (
unsigned j = 0; j < sz; j++ )
1337 if (a_farm == TheArray[ a_typeofanimal ] [ j ]->SupplyFarmOwnerRef()) No++;
1348 for (
int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++ ) {
1352 if ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 3 )
1353 || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 2 ) && ( BeginningOfMonth() ) )
1354 || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 1 ) && ( Time % 365 == 0 ) ) ) {
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 ] );
1361 TheProbe[ ProbeNo ]->FileOutput( No, Time, ProbeNo );
1362 sprintf(str,
" %d ", No );
1374 for (
int ProbeNo = 0; ProbeNo < m_NoProbes; ProbeNo++ ) {
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 ] );
1380 TheProbe[ ProbeNo ]->FileOutput( No, Time, ProbeNo );
1381 sprintf(str,
" %d ", No );
1393 for (
int ProbeNo = 0; ProbeNo < 1; ProbeNo++ ) {
1396 if ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 3 )
1397 || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 2 ) && ( BeginningOfMonth() ) )
1398 || ( ( TheProbe[ ProbeNo ]->m_ReportInterval == 1 ) && ( a_Time % 365 == 0 ) ) ) {
1417 SkP.
m_x = m_Location_x;
1418 SkP.
m_y = m_Location_y;
1419 SkP.
m_EleType = m_OurLandscape->SupplyElementType( m_Location_x, m_Location_y );
1420 SkP.
m_VegType = m_OurLandscape->SupplyVegType( m_Location_x, m_Location_y );
1430 return m_OurLandscape->SupplyFarmOwner( m_Location_x, m_Location_y );
1451 AmAlive = 0xDEADC0DE;
1454 m_CurrentStateNo = 0;
1477 while ( ( event = (
FarmToDo )m_OurLandscape->SupplyLastTreatment( m_Location_x, m_Location_y, & i ) ) !=
sleep_all_day ) {
1478 if ( OnFarmEvent( event ) )
break;
1490 while ( ( event = (
FarmToDo )m_OurLandscape->SupplyLastTreatment( x, y, & i ) ) !=
sleep_all_day ) {
1491 OnFarmEvent( event );
1504 void TALMaSSObject::DEADCODEError() {
1518 if ( m_FileRecord ) {
1520 if ( ProbeNo == 0 ) {
1522 (*m_MyFile) << endl;
1523 (*m_MyFile) << time <<
'\t' << No;
1525 (*m_MyFile) <<
'\t' << No ;
1527 (*m_MyFile).flush();
1533 m_MyFile->open(m_MyFileName,ios::app);
1534 if ( !m_MyFile->is_open() ) {
1538 if ( m_FileRecord ) {
1539 (*m_MyFile)<< time <<
'\t' << No << endl;
1551 m_FileRecord =
false;
1561 m_MyFile =
new ofstream( Nme );
1562 if ( !m_MyFile->is_open() ) {
1566 strcpy( m_MyFileName, Nme );
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;
void SortX(unsigned Type)
The landscape class containing all environmental and topographical data.
A class defining an animals position.
CfgBool cfg_RipleysOutputMonthly_used("G_RIPLEYSOUTPUTMONTHLY_USED", CFG_CUSTOM, false)
void Shuffle_or_Sort(unsigned Type)
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
bool OpenTheCIPEGridOutputProbe()
virtual ~TALMaSSObject()
The destructor for TALMaSSObject.
virtual void Run(int NoTSteps)
TTypesOfLandscapeElement m_EleType
virtual void TheReallyBigOutputProbe()
TALMaSSObject()
The constructor for TALMaSSObject.
static CfgInt cfg_ReallyBigOutput_interval("G_REALLYBIGOUTPUT_INTERVAL", CFG_CUSTOM, 1)
void CheckManagementXY(int x, int y)
virtual float Probe(int ListIndex, probe_data *p_TheProbe)
bool OpenTheReallyBigProbe()
static CfgInt cfg_ReallyBigOutput_day2("G_REALLYBIGOUTPUT_DAY_TWO", CFG_CUSTOM, 91)
Integer configurator entry class.
static CfgInt cfg_RipleysOutput_interval("G_RIPLEYSOUTPUT_INTERVAL", CFG_CUSTOM, 1)
static CfgInt cfg_DayInMonth("PRB_DAYINMONTH", CFG_CUSTOM, 1)
Function to compare to TAnimal's m_CurrentStateNo to -1.
char * SpeciesSpecificReporting(int a_species, int a_time)
CfgBool cfg_RipleysOutput_used("G_RIPLEYSOUTPUT_USED", CFG_CUSTOM, true)
CfgInt cfg_CatastropheEventStartYear("PM_CATASTROPHEEVENTSTARTYEAR", CFG_CUSTOM, 99999)
void CloseTheMonthlyRipleysOutputProbe()
void NWordOutput()
The output section for the NWord probe. .
AnimalPosition SupplyPosition()
static CfgInt cfg_ReallyBigOutput_day1("G_REALLYBIGOUTPUT_DAY_ONE", CFG_CUSTOM, 1)
unsigned int FarmAnimalCensus(unsigned int a_farm, unsigned int a_typeofanimal)
CfgInt cfg_pm_eventsize("PM_EVENTSIZE", CFG_CUSTOM, 100)
ofstream * OpenFile(char *Nme)
Function to compare to TAnimal's Current behavioural state.
virtual void DisplayLocations()
static CfgInt cfg_RipleysOutputFirstYear("G_RIPLEYSOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
void FileOutput(int No, int time, int ProbeNo)
void SetFile(ofstream *F)
virtual void TheCIPEGridOutputProbe()
static CfgInt cfg_VoleCatastrophe_interval("VOLE_CATASTROPHE_I", CFG_CUSTOM, 365 *5)
Function to compare to TAnimal's m_CurrentStateNo.
void SortState(unsigned Type)
CfgBool cfg_fixed_random_sequence("G_FIXEDRANDOMSEQUENCE", CFG_CUSTOM, false)
virtual bool StepFinished()
Overrides the population manager StepFinished - there is no chance that hunters do not finish a step ...
TTypesOfVegetation m_RefVeg[25]
virtual void DoAlmostLast()
static CfgInt cfg_ReallyBigOutput_day3("G_REALLYBIGOUTPUT_DAY_THREE", CFG_CUSTOM, 182)
void EmptyTheArray()
Removes all objects from the TheArray by deleting them and clearing TheArray.
void Shuffle(unsigned Type)
void CloseTheRipleysOutputProbe()
CfgInt cfg_CIPEGridOutput_day_b("G_CIPEGRIDOUTPUT_DAY_B", CFG_CUSTOM, 270)
virtual void TheRipleysOutputProbe(FILE *a_prb)
class MapErrorMsg * g_msg
TTypesOfVegetation m_VegType
CfgStr cfg_CIPEGridOutput_filename("G_CIPEGRIDOUTPUT_FILENAME", CFG_CUSTOM,"CIPEGridOutput.txt")
The base class for all farm types.
CfgStr cfg_CIPEGridOutput_filenameB("G_CIPEGRIDOUTPUT_FILENAME_B", CFG_CUSTOM,"CIPEGridOutputB.txt")
void CheckManagement(void)
int Supply_m_Location_y()
bool OpenTheMonthlyRipleysOutputProbe()
int Supply_m_Location_x()
The base class for all ALMaSS animal classes.
TTypesOfLandscapeElement m_RefEle[25]
void SortXIndex(unsigned Type)
char * ProbeReportTimed(int a_time)
void FileAppendOutput(int No, int time)
void SortY(unsigned Type)
unsigned SupplyFarmOwnerRef()
String configurator entry class.
Bool configurator entry class.
int SupplySimAreaHeight(void)
vector< TAnimal * > TListOfAnimals
CfgInt cfg_CIPEGridOutput_Interval("G_CIPEGRIDOUTPUT_INTERVAL", CFG_CUSTOM, 1)
static CfgInt cfg_CipeGridSize("G_CIPEGRIDSIZE", CFG_CUSTOM, 500)
bool CheckXY(int l, int i)
Debug method to test for out of bounds coordinates.
void CloseTheCIPEGridOutputProbe()
void ImpactProbeReport(int a_Time)
CfgInt cfg_CIPEGridOutput_day("G_CIPEGRIDOUTPUT_DAY", CFG_CUSTOM, 1)
CfgBool cfg_CIPEGridOutput_used("G_CIPEGRIDOUTPUT_USED", CFG_CUSTOM, false)
char * ProbeReport(int a_time)
static CfgInt cfg_VoleCatastrophe_mortality("VOLE_CATASTROPHE_M", CFG_CUSTOM, 90)
bool OpenTheRipleysOutputProbe()
CfgInt cfg_pm_eventfrequency("PM_EVENTFREQUENCY", CFG_CUSTOM, 0)
Function to compare to TAnimal's m_CurrentStateNo to anything but -1.
Function to compare to TAnimal's m_Location_y.
Population_Manager(Landscape *L)
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
unsigned PartitionLiveDead(unsigned Type)
void SortStateR(unsigned Type)
static CfgInt cfg_RipleysOutput_day("G_RIPLEYSOUTPUT_DAY", CFG_CUSTOM, 60)
static CfgBool cfg_VoleCatastrophe_on("VOLE_CATASTROPHE_ON", CFG_CUSTOM, false)
virtual void ImpactedProbe()
int ProbeFileInput(char *p_Filename, int p_ProbeNo)
virtual void Catastrophe()
static CfgInt cfg_ReallyBigOutput_day4("G_REALLYBIGOUTPUT_DAY_FOUR", CFG_CUSTOM, 274)
static CfgStr cfg_RipleysOutput_filename("G_RIPLEYSOUTPUT_FILENAME", CFG_CUSTOM,"RipleysOutput.txt")
TAnimal * FindClosest(int x, int y, unsigned Type)
void CloseTheReallyBigOutputProbe()
Data structure to hold & output probe data probe data is designed to be used to return the number of ...
void LOG(const char *fname)
virtual ~Population_Manager(void)
static CfgInt cfg_ReallyBigOutputFirstYear("G_REALLYBIGOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
CfgBool cfg_ReallyBigOutput_used("G_REALLYBIGOUTPUT_USED", CFG_CUSTOM, false)
int GetCurrentStateNo()
Returns the current state number.
TAnimal(int x, int y, Landscape *L)
void OnArrayBoundsError()
Used for debugging only, tests basic object properties.
static CfgStr cfg_ReallyBigOutput_filename("G_REALLYBIGOUTPUT_FILENAME", CFG_CUSTOM,"ReallyBigOutput.txt")
Function to compare to TAnimal's m_Location_x.