ALMaSS Vole ODDox
1.1
The vole model description following ODdox protocol
|
Go to the documentation of this file.
45 #include "../Landscape/ls.h"
46 #include "../BatchALMaSS/PopulationManager.h"
47 #include "../BatchALMaSS/AOR_Probe.h"
48 #include "../BatchALMaSS/BinaryMapBase.h"
49 #include "../BatchALMaSS/MovementMap.h"
50 #include "../Vole/vole_all.h"
51 #include "../Vole/VolePopulationManager.h"
52 #include "../Vole/GeneticMaterial.h"
53 #include "../Vole/Predators.h"
54 #include "../BatchALMaSS/BoostRandomGenerators.h"
56 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> >
g_rand_uni;
100 static CfgInt
cfg_MateRadius(
"FEMALE_MATE_RADIUS", CFG_CUSTOM, 250);
171 const float ReproTable_base [2][12] = { {0,0,0,0,4,4,4,4,3,2,3,0},
172 {0,0,4,4,5,5,5,5,4,4,0,0}
178 static CfgInt
cfg_MaxAllele(
"GENETICS_MAXALLELE",CFG_CUSTOM,255);
200 for (
int i=0; i<6; i++)
239 (*m_VoleAgeSexLocationFile).close();
261 ofstream ofile(
"VoleLandscapeGridData.txt",ios::out);
271 FILE* GFile = fopen(
"VoleGeneticsOutput.txt",
"w" );
273 g_msg->Warn( WARN_FILE,
"Population_Manager::Init(): ""Unable to open VoleGeneticsOutput.txt",
"");
289 #ifdef __VOLEPESTICIDEON
293 m_geneticimpacted = 0;
295 m_LittersProduced = 0;
297 impf = fopen(
"Impacted.res",
"w");
299 m_TheLandscape->
Warn(
"Vole_Population_Manager Destructor",
"Could Not Open Impacted.Res File");
310 for (
int i = 0; i < 12; i++)
346 av->
x = random(
SimW);
347 av->
y = random(
SimH);
372 av->
x = random(
SimW);
373 av->
y = random(
SimH);
415 TestFile = fopen(
"TestFile.Txt",
"w" );
417 m_TheLandscape->
Warn(
"Population_Manager::Population_Manager -",
"Could Not Open TestFile.txt");
420 TestFile2 = fopen(
"TestFile2.Txt",
"w" );
423 m_TheLandscape->
Warn(
"Population_Manager::Population_Manager -",
"Could Not Open TestFile2.txt");
426 #ifdef __VOLEPESTICIDEON
436 strcpy( Nme,
"GeneticsOutput.txt" );
438 strcpy( Nme,
"AlleleFreqs.txt" );
440 strcpy( Nme,
"forEASYPOP.txt" );
453 m_VoleRecordMort->
OPrint(
"Year\tDay\tMStarve\tFStarve\tMBck\tFBck\tMFarm\tFFarm\tMDisp\tFDisp\tMPred\tFPred\tMLife\tFLife\tMPest\tFPest\t");
525 MyFile=fopen(
"VoleImpactedProbe.txt",
"a");
527 m_TheLandscape->
Warn(
"Vole_Population_Manager::ImpactedProbe",
"Could Not Open VoleImpactedProbe.txt File");
537 for (
unsigned j=0; j<size; j++) {
543 fprintf(MyFile,
"%d\t%d\t%d\n",tno,dno,gno);
570 for (
unsigned p = 0; p<sz; p++)
602 printf(
"The start day is: %d\n",today);
645 #ifdef __VOLEPESTICIDEON
647 FILE* impf = fopen(
"Impacted.res",
"a");
649 m_TheLandscape->
Warn(
"Vole_Population_Manager Destructor",
"Could Not Open Impacted.Res File");
652 fprintf(impf,
"%d\t%d\t%d\t%d\t%d\n",m_notimpacted, m_impacted, m_geneticimpacted, m_LittersProduced, m_LittersLost);
658 m_LittersProduced = 0;
665 gfout.open(
"VoleGeneticsOutput.txt",ios::app);
667 g_msg->Warn(
"Population_Manager::SpeciesSpecificReporting(int a_species, int a_time) ",
"Cannot open file VoleGeneticsOutput.txt for append" );
675 int x = 0;
int y = 0;
677 if ( s > no_samples ) s = no_samples;
678 for (
int i = 0; i<s; i++) {
680 gfout << year <<
'\t';
683 gfout << x <<
'\t' << y <<
'\t' <<
"F";
684 for (
int a=0; a<16; a++) {
687 gfout <<
'\t' << allele1 <<
'\t' << allele2;
692 if ( s > no_samples ) s = no_samples;
693 for (
int i = 0; i<s; i++) {
695 gfout << year <<
'\t';
698 gfout << x <<
'\t' << y <<
'\t' <<
"M";
699 for (
int a=0; a<16; a++) {
702 gfout <<
'\t' << allele1 <<
'\t' << allele2;
720 for (
int i = 0; i<s; i++) {
730 for (
int i = 0; i<s; i++) {
740 for (
int i = 0; i<s; i++) {
751 for (
int i = 0; i<s; i++) {
786 double digestability = 1.0;
787 double score = -9999;
889 if (Cover < 0.20) score = 0;
990 m_TheLandscape->
Warn(
"Vole_Population_Manager::AssessHabitat - Unknown vegt type", NULL);
997 static char errornum[20];
998 sprintf(errornum,
"%d", ElementType);
1003 return (score*digestability);
1008 if (p_today != 1)
return false;
1009 if (p_year<p_start_year)
return false;
1010 p_year -= p_start_year;
1011 if (p_year % p_interval != 0)
return false;
1016 unsigned p_Age,
unsigned p_range)
1024 int x=p_x - p_range;
1026 int y=p_y - p_range;
1028 int range_x=p_range*2;
1029 int range_y=p_range*2;
1031 int xextent0 = x+range_x;
1032 int yextent0 = y+range_y;
1033 int xextent1 = (x+range_x)-
SimW;
1034 int yextent1 = (y+range_y)-
SimH;
1059 else Dfiny=yextent0;
1084 for (
int i=0; i<Afinx; i++)
1086 for (
int j=Asty; j<Afiny; j++)
1102 for (
int j=y; j<Dfiny; j++)
1119 for (
int i=x; i<Dfinx; i++)
1121 for (
int j=y; j<Dfiny; j++)
1137 for (
int j=0; j<Afiny; j++)
1164 int x=p_x - p_range;
1166 int y=p_y - p_range;
1168 int range_x=p_range*2;
1169 int range_y=p_range*2;
1172 int xextent0 = x+range_x;
1173 int yextent0 = y+range_y;
1174 int xextent1 = (x+range_x)-
SimW;
1175 int yextent1 = (y+range_y)-
SimH;
1200 else Dfiny=yextent0;
1224 for (
int i=0; i<Afinx; i++)
1226 for (
int j=Asty; j<Afiny; j++)
1228 if(
m_VoleMap->GetMapValue(i,j)!=NULL) Voles++;
1231 for (
int j=y; j<Dfiny; j++)
1233 if (
m_VoleMap->GetMapValue(i, j) != NULL) Voles++;
1237 for (
int i=x; i<Dfinx; i++)
1239 for (
int j=y; j<Dfiny; j++)
1241 if (
m_VoleMap->GetMapValue(i, j) != NULL) Voles++;
1244 for (
int j=0; j<Afiny; j++)
1246 if (
m_VoleMap->GetMapValue(i, j) != NULL) Voles++;
1266 if (F_y == M_y)
return true;
1268 for (
int j = F_y; j < M_y; j++){
1270 if (poly2 != poly1){
1299 for (
int j = M_y; j < F_y; j++){
1301 if (poly1 != poly2){
1332 for (
int i = F_x; i < M_x; i++){
1334 if (poly1 != poly2){
1363 for (
int i = M_x; i < F_x; i++){
1365 if (poly1 != poly2){
1396 unsigned diff_x = M_x - F_x;
1397 unsigned diff_y = M_y - F_y;
1398 if (diff_x <= diff_y){
1401 for (
int i = F_x; i < M_x; i++){
1404 if (poly1 != poly2){
1430 if (diff_x != diff_y){
1431 int j_extent = F_y + diff_x;
1432 for (
int j_y = j_extent; j_y < M_y; j_y++){
1434 if (poly1 != poly2){
1463 if (diff_x > diff_y) {
1465 for (
int j = F_y; j < M_y; j++){
1468 if (poly1 != poly2){
1494 int i_extent = diff_y + F_x;
1495 for (
int i_x = i_extent; i_x < M_x; i_x++){
1497 if (poly1 != poly2){
1527 int diff_x = M_x - F_x;
1528 int diff_y = F_y - M_y;
1529 if (diff_x <= diff_y){
1531 for (
int i = F_x; i < M_x; i++){
1534 if (poly1 != poly2){
1560 if (diff_x != diff_y){
1561 int j_extent = F_y - diff_x;
1562 for (
int j_y = j_extent; j_y > M_y; j_y--){
1564 if (poly1 != poly2){
1595 for (
int j = F_y; j > M_y; j--){
1598 if (poly1 != poly2){
1624 int i_extent = diff_y + F_x;
1625 for (
int i_x = i_extent; i_x < M_x; i_x++){
1627 if (poly1 != poly2){
1659 unsigned diff_x = F_x - M_x;
1660 unsigned diff_y = M_y - F_y;
1661 if (diff_x <= diff_y){
1663 for (
int i = M_x; i < F_x; i++){
1666 if (poly1 != poly2){
1693 if (diff_x != diff_y){
1694 int j_extent = M_y - diff_x;
1695 for (
int j_y = j_extent; j_y > F_y; j_y--){
1697 if (poly1 != poly2){
1728 for (
int j = M_y; j > F_y; j--){
1731 if (poly1 != poly2){
1757 int i_extent = diff_y + M_x;
1758 for (
int i_x = i_extent; i_x < F_x; i_x++){
1760 if (poly1 != poly2){
1790 int diff_x = F_x - M_x;
1791 int diff_y = F_y - M_y;
1792 if (diff_x <= diff_y){
1794 for (
int i = M_x; i < F_x; i++){
1797 if (poly1 != poly2){
1823 if (diff_x != diff_y){
1824 int j_extent = M_y + diff_x;
1825 for (
int j_y = j_extent; j_y < F_y; j_y++){
1827 if (poly1 != poly2){
1858 for (
int j = M_y; j < F_y; j++){
1861 if (poly1 != poly2){
1887 int i_extent = diff_y + M_x;
1888 for (
int i_x = i_extent; i_x < F_x; i_x++){
1890 if (poly1 != poly2){
1936 int x=p_x - p_steps;
1938 int y=p_y - p_steps;
1940 int range_x=p_steps*2;
1941 int range_y=p_steps*2;
1944 int xextent0 = x+range_x;
1945 int yextent0 = y+range_y;
1946 int xextent1 = (x+range_x)-
SimW;
1947 int yextent1 = (y+range_y)-
SimH;
1972 else Dfiny=yextent0;
2000 for (
int i=0; i<Afinx; i++)
2002 for (
int j=Asty; j<Afiny; j++)
2012 MList.push_back(AMale);
2019 for (
int j=y; j<Dfiny; j++)
2029 MList.push_back(AMale);
2037 for (
int i=x; i<Dfinx; i++)
2039 for (
int j=y; j<Dfiny; j++)
2049 MList.push_back(AMale);
2056 for (
int j=0; j<Afiny; j++)
2066 MList.push_back(AMale);
2086 int x=p_x - p_steps;
2088 int y=p_y - p_steps;
2090 int range_x=p_steps*2;
2091 int range_y=p_steps*2;
2094 int xextent0 = x+range_x;
2095 int yextent0 = y+range_y;
2096 int xextent1 = (x+range_x)-
SimW;
2097 int yextent1 = (y+range_y)-
SimH;
2122 else Dfiny=yextent0;
2150 for (
int i=0; i<Afinx; i++)
2152 for (
int j=Asty; j<Afiny; j++)
2162 FList.push_back(AFemale);
2169 for (
int j=y; j<Dfiny; j++)
2179 FList.push_back(AFemale);
2187 for (
int i=x; i<Dfinx; i++)
2189 for (
int j=y; j<Dfiny; j++)
2199 FList.push_back(AFemale);
2206 for (
int j=0; j<Afiny; j++)
2216 FList.push_back(AFemale);
2233 int x=p_x - p_steps;
2235 int y=p_y - p_steps;
2237 int range_x=p_steps*2;
2238 int range_y=p_steps*2;
2241 int xextent0 = x+range_x;
2242 int yextent0 = y+range_y;
2243 int xextent1 = (x+range_x)-
SimW;
2244 int yextent1 = (y+range_y)-
SimH;
2269 else Dfiny=yextent0;
2299 for (
int i=0; i<Afinx; i++)
2301 for (
int j=Asty; j<Afiny; j++)
2324 for (
int j=y; j<Dfiny; j++)
2348 for (
int i=x; i<Dfinx; i++)
2350 for (
int j=y; j<Dfiny; j++)
2373 for (
int j=0; j<Afiny; j++)
2410 int xextent0 = x+range_x;
2411 int yextent0 = y+range_y;
2412 int xextent1 = (x+range_x)-
SimW;
2413 int yextent1 = (y+range_y)-
SimH;
2440 else Dfiny=yextent0;
2469 int test =random(size);
2482 if (((x <= i) && (i <= Dfinx)) && ((y <= j) && (j <= Dfiny)))
2490 if (((x <= i) && (i <= Dfinx)) && ((( 0<= j) && (j <=Afiny)) || ((y <= j) && (j <= Dfiny))))
2500 if (((y <= j) && (j <= Dfiny)) && (((0 <= i) && (i <= Afinx)) || ((x <= i) && (i <= Dfinx))))
2508 if ((( 0 <= i) && (i <= Afinx)) && (((0 <= j) && (j <= Afiny)) || ((y <= j) &&(j <= Dfiny))))
2512 if (((x <= i) && (i <= Dfinx)) && (((0 <= j) && (j <= Afiny)) || ((y <= j) &&(j <= Dfiny))))
2519 if (territory ==
false) Found=NULL;
2520 }
while ((Found==NULL) && (size>0));
2531 vector<Vole_Male*> *vbl;
2532 vbl=
new vector<Vole_Male*>;
2545 int xextent0 = x+range_x;
2546 int yextent0 = y+range_y;
2547 int xextent1 = (x+range_x)-
SimW;
2548 int yextent1 = (y+range_y)-
SimH;
2575 else Dfiny=yextent0;
2602 for (
int i=0; i<Afinx; i++)
2604 for (
int j=0; j<Afiny; j++)
2614 vbl->push_back(AMale);
2620 for (
int j=y; j<Dfiny; j++)
2630 vbl->push_back(AMale);
2637 for (
int i=x; i<Dfinx; i++)
2639 for (
int j=y; j<Dfiny; j++)
2649 vbl->push_back(AMale);
2655 for (
int j=0; j<Afiny; j++)
2665 vbl->push_back(AMale);
2672 int l = (int) vbl->size();
2691 int x=p_x - p_steps;
2693 int y=p_y - p_steps;
2695 int range_x=p_steps*2;
2696 int range_y=p_steps*2;
2699 int xextent0 = x+range_x;
2700 int yextent0 = y+range_y;
2701 int xextent1 = (x+range_x)-
SimW;
2702 int yextent1 = (y+range_y)-
SimH;
2727 else Dfiny=yextent0;
2756 for (
int i=0; i<Afinx; i++)
2758 for (
int j=Asty; j<Afiny; j++)
2776 if (Barrier ==
true){
2787 for (
int j=y; j<Dfiny; j++)
2805 if (Barrier ==
true){
2817 for (
int i=x; i<Dfinx; i++)
2819 for (
int j=y; j<Dfiny; j++)
2836 if (Barrier ==
true){
2847 for (
int j=0; j<Afiny; j++)
2865 if (Barrier ==
true){
2886 if (size<1)
return NULL;
2889 int test =random(size);
2893 }
while ((Found==NULL) && (size>0));
2907 int x=p_x - p_TerrRange;
2909 int y=p_y - p_TerrRange;
2911 int range_x=p_TerrRange*2;
2912 int range_y=p_TerrRange*2;
2916 int xextent0 = x+range_x;
2917 int yextent0 = y+range_y;
2918 int xextent1 = (x+range_x)-
SimW;
2919 int yextent1 = (y+range_y)-
SimH;
2944 else Dfiny=yextent0;
2970 for (
int i=0; i<Afinx; i++)
2972 for (
int j=Asty; j<Afiny; j++)
2987 for (
int j=y; j<Dfiny; j++)
3004 for (
int i=x; i<Dfinx; i++)
3006 for (
int j=y; j<Dfiny; j++)
3021 for (
int j=0; j<Afiny; j++)
3037 m_VoleMap->SetMapValue(p_x, p_y, caller);
3044 unsigned p_Age,
unsigned p_Range)
3055 int x=p_x - p_Range;
3057 int y=p_y - p_Range;
3059 int range_x=p_Range*2;
3060 int range_y=p_Range*2;
3063 int xextent0 = x+range_x;
3064 int yextent0 = y+range_y;
3065 int xextent1 = (x+range_x)-
SimW;
3066 int yextent1 = (y+range_y)-
SimH;
3091 else Dfiny=yextent0;
3118 for (
int i=0; i<Afinx; i++)
3120 for (
int j=Asty; j<Afiny; j++)
3134 m_VoleMap->SetMapValue(p_x, p_y, caller);
3145 for (
int j=y; j<Dfiny; j++)
3159 m_VoleMap->SetMapValue(p_x, p_y, caller);
3171 for (
int i=x; i<Dfinx; i++)
3173 for (
int j=y; j<Dfiny; j++)
3187 m_VoleMap->SetMapValue(p_x, p_y, caller);
3198 for (
int j=0; j<Afiny; j++)
3212 m_VoleMap->SetMapValue(p_x, p_y, caller);
3224 m_VoleMap->SetMapValue(p_x, p_y, caller);
3235 int x_extent = p_sqx+p_range;
3236 int y_extent = p_sqy+p_range;
3237 if (x_extent >=
SimW)
3239 if (y_extent >=
SimH)
3249 if ((p_x >=p_sqx) && (p_y >=p_sqy))
return true;
3251 if ((p_x <x_extent-
SimW)&& (p_y>p_sqy))
return true;
3253 if ((p_x <x_extent-
SimW)&&(p_y<y_extent-
SimH))
return true;
3255 if ((p_x >=p_sqx)&& (p_y<y_extent-
SimH))
return true;
3260 if ((p_y >=p_sqy) && (p_y<y_extent))
3262 if (p_x >=p_sqx)
return true;
3263 else if (p_x <x_extent-
SimW)
return true;
3269 if (y_extent >=
SimH)
3271 if ((p_x >=p_sqx) && (p_x<x_extent))
3274 if (p_y >=p_sqy)
return true;
3275 else if (p_y<y_extent-
SimH)
return true;
3280 if ((p_x >=p_sqx) && (p_x<x_extent) &&
3281 (p_y >=p_sqy) && (p_y<y_extent))
return true;
3290 unsigned p_y,
unsigned p_Range)
3294 vector<Vole_Base*> *vbl;
3295 vbl=
new vector<Vole_Base*>;
3301 int range_x=p_Range;
3302 int range_y=p_Range;
3304 int xextent0 = x+range_x;
3305 int yextent0 = y+range_y;
3306 int xextent1 = (x+range_x)-
SimW;
3307 int yextent1 = (y+range_y)-
SimH;
3332 else Dfiny=yextent0;
3358 for (
int i=0; i<Afinx; i++)
3360 for (
int j=Asty; j<Afiny; j++)
3369 for (
int j=y; j<Dfiny; j++)
3379 for (
int i=x; i<Dfinx; i++)
3381 for (
int j=y; j<Dfiny; j++)
3390 for (
int j=0; j<Afiny; j++)
3405 unsigned p_x,
unsigned p_y,
unsigned p_range,
bool p_sex,
double )
3419 unsigned x=AFemale->
SupplyX();
3420 unsigned y=AFemale->
SupplyY();
3423 unsigned dx = abs((
int)(p_x-x));
3424 unsigned dy = abs((
int)(p_y-y));
3427 if ((dx<=p_range) && (dy<=p_range))
3440 m_TheLandscape->
Warn(
"Vole_Population_Manager::SendMessage Error",
"Wrong sex specified for infanticide");
3445 m_TheLandscape->
Warn(
"Vole_Population_Manager::SendMessage Error",
"Unknown message");
3462 for (
int i = 0; i < number; i++)
3473 TheArray[ob_type].push_back(new_JMale);
3478 #ifdef __VOLEPESTICIDEON
3485 new_JMale->SetPesticideInfluenced2(
true);
3495 new_JMale->SetPesticideInfluenced2(
true);
3515 TheArray[ob_type].push_back(new_JFemale);
3520 #ifdef __VOLEPESTICIDEON
3521 new_JFemale->SetMaturityDelay(as->
misc_use);
3533 TheArray[ob_type].push_back(new_Male);
3538 #ifdef __VOLEPESTICIDEON
3545 new_Male->SetPesticideInfluenced2(
true);
3555 new_Male->SetPesticideInfluenced2(
true);
3575 TheArray[ob_type].push_back(new_Female);
3594 for (
int i=0; i<number; i++)
3599 as=dynamic_cast<struct_Vole_Adult *>(data);
3604 TheArray[ob_type].push_back(new_Male);
3607 new_Male->
Set_Age(random(500));
3614 as=dynamic_cast<struct_Vole_Adult *>(data);
3619 TheArray[ob_type].push_back(new_Female);
3636 if (today!=1)
return;
3648 for (
unsigned j = 0; j < size2; j++ ) {
3649 if (random(100) > esize) {
3655 for (
unsigned j = 0; j < size2; j++ ) {
3656 if (random(100) > esize) {
3662 else if (esize>100) {
3672 for (
unsigned j = 0; j < size2; j++ ) {
3673 if (random(100) < esize) {
3674 VB = dynamic_cast < Vole_Base * > (
TheArray[ i ] [ j ] );
3685 for (
unsigned j = 0; j < size2; j++ ) {
3686 for (
int e=0; e<esize; e++) {
3687 VB = dynamic_cast < Vole_Base * > (
TheArray[ i ] [ j ] );
3702 unsigned int totalYM, totalYF, totalAM, totalAF;
3710 for (
int i=0; i<256; i++) gridcount[i] = 0;
3711 double sqwidth = width/16.0;
3713 for (
unsigned j=0; j<totalYM; j++)
3718 gridcount[gx+gy*16]++;
3721 for (
unsigned j=0; j<totalYF; j++)
3726 gridcount[gx+gy*16]++;
3729 for (
unsigned j=0; j<totalAM; j++)
3734 gridcount[gx+gy*16]++;
3737 for (
unsigned j=0; j<totalAF; j++)
3742 gridcount[gx+gy*16]++;
3746 ofstream ofile(
"VoleLandscapeGridData.txt",ios::app);
3747 ofile << a_day <<
'\t' << totalYM <<
'\t' << totalYF <<
'\t' << totalAM <<
'\t' << totalAF<<
'\t';
3748 for (
int i=0; i<255; i++)
3750 ofile << gridcount[i] <<
'\t';
3752 ofile << gridcount[255] << endl;
3769 fprintf(a_prb,
"%d %d %d %d %d\n", 0,w ,0, h, totalF);
3770 for (
unsigned j=0; j<totalF; j++)
3775 fprintf(a_prb,
"%d\t%d\n", x,y);
3786 char sex[4] = {
'm',
'f',
'M',
'F'};
3798 for (
unsigned j=0; j<total; j++)
3800 VB=dynamic_cast<Vole_Base*>(
TheArray[vob][j]);
3804 (* m_VoleAgeSexLocationFile) << year <<
'\t' << day <<
'\t' << sex[vob] <<
'\t' << Age <<
'\t' << x <<
'\t' << y << endl;
3831 for (
unsigned j=0; j<totalM; j++)
3841 fprintf(
ReallyBigOutputPrb,
"%d\t%d\t%d\t%d\t adM\t%d\t%d\t%d\t%d\t%d\t%d\n", year,day,x,y,0,poly,ele,vegt,Age,Ter);
3844 for (
unsigned j=0; j<totalM; j++)
3854 fprintf(
ReallyBigOutputPrb,
"%d\t%d\t%d\t%d\t juvM\t%d\t%d\t%d\t%d\t%d\t%d\n", year,day,x,y,0,poly,ele,vegt,Age,Ter);
3858 for (
unsigned j=0; j<totalF; j++)
3868 fprintf(
ReallyBigOutputPrb,
"%d\t%d\t%d\t%d\t adF\t%d\t%d\t%d\t%d\t%d\t%d\n", year,day,x,y,0,poly,ele,vegt,Age,Ter);
3871 for (
unsigned j=0; j<totalF; j++)
3881 fprintf(
ReallyBigOutputPrb,
"%d\t%d\t%d\t%d\t juvF\t%d\t%d\t%d\t%d\t%d\t%d\n", year,day,x,y,0,poly,ele,vegt,Age,Ter);
3893 g_msg->Warn( WARN_FILE,
"Population_Manager::OpenSexRatiosProbe(): ""Unable to open probe file",
3897 fprintf(
SexRatiosPrb,
"Year\tDay\tSubMales\tAdMalesThisYear\tAdMalesLatYear\tSubFemales\tAdFemalesThisYear\tAdFemalesLatYear\tJuvMales\tJuvFemales\tTotalMales\tTotalFemales\n");
3928 for (
unsigned j = 0; j < total; j++)
3930 VB = dynamic_cast<Vole_Base*>(
TheArray[v][j]);
3936 if (!mature) Sub++;
else if (born_lastyear) Ad2++;
else Ad1++;
3940 Sub = 0; Ad1 = 0; Ad2 = 0;
3962 FILE * inpfile=fopen(a_inifile,
"r" );
3964 g_msg->Warn( WARN_FILE,
" TrapLineMap::Init Unable to open file ", a_inifile );
3968 unsigned input, x, y;
3969 fscanf( inpfile,
"%d\n", & input );
3973 fscanf( inpfile,
"%d\t%d\n", &x, &y );
3977 SetValue( x, y, 1 );
3981 m_ofile = fopen(
"VoleTrapCounts.txt",
"w");
3983 g_msg->Warn( WARN_FILE,
" TrapLineMap::Init Unable to open output file ",
"VoleTrapCounts.txt" );
3986 fprintf(
m_ofile,
"Day\tx\ty\tElement\tVegType\tSex\tTerritorial\tAge\tBornX\tBornY\tID no\n");
3992 if (a_terr) terr=
'Y';
else terr =
'N';
3993 fprintf(
m_ofile,
"%d\t%d\t%d\t%d\t%d\t%d\t%c\t%d\t%d\t%d\t%d\n", a_day, a_tp.
m_x, a_tp.
m_y, a_tp.
m_EleType, a_tp.
m_VegType, a_sex, terr, a_age, a_bx, a_by, a_ID);
4020 (*m_File) << a_value <<
'\t';
4024 (*m_File) << a_value <<
'\t';
4028 (*m_File) << a_value <<
'\t';
4036 m_File =
new ofstream(a_filename,ios::out);
4061 FILE* vfile= fopen (
"GeneticsData.txt",
"a");
4063 if (vfile == NULL) {
4064 m_TheLandscape->
Warn(
"Vole_Population_Manager::GeneticsOutputFile",
"Could Not Open GeneticsData.txt File");
4074 fprintf(vfile,
"\n");
4075 fprintf(vfile,
"%d\t %d\t %d\t %d\t %d\t %d\n", 0,w ,0, h, size, TotalSize);
4076 fprintf(vfile,
"\n");
4077 fprintf(vfile,
"%s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\n",
"Year",
"Mo",
"Day",
"ID",
"Sex",
"Age",
"Birth Yr",
"Terr",
"Ma",
"TotY",
"x",
"y",
"Poly",
"Ele",
"Vege",
"GA",
"DA",
"Bx",
"By",
"Bpol",
"Bele",
"Bveg");
4078 for (
unsigned j=0; j<size; j++)
4103 fprintf(vfile,
"%d\t",Y);
4104 fprintf(vfile,
"%d\t",M);
4105 fprintf(vfile,
"%d\t",D);
4107 fprintf(vfile,
"%d\t",ID);
4108 fprintf(vfile,
"%d\t",sex);
4109 fprintf(vfile,
"%u\t",Age);
4110 fprintf(vfile,
"%d\t",BY);
4111 fprintf(vfile,
"%d\t",Terr);
4112 fprintf(vfile,
"%d\t",Mature);
4113 fprintf(vfile,
"%d\t",TotYoung);
4114 fprintf(vfile,
"%d\t",x);
4115 fprintf(vfile,
"%d\t",y);
4116 fprintf(vfile,
"%d\t",poly);
4117 fprintf(vfile,
"%d\t",ele);
4118 fprintf(vfile,
"%d\t",vegt);
4119 fprintf(vfile,
"%d\t",GA);
4120 fprintf(vfile,
"%d\t",DA);
4121 fprintf(vfile,
"%d\t",BornX);
4122 fprintf(vfile,
"%d\t",BornY);
4123 fprintf(vfile,
"%d\t",BornPoly);
4124 fprintf(vfile,
"%d\t",BornEle);
4125 fprintf(vfile,
"%d\t",BornVegt);
4127 for(
int i=0; i< 16; i++)
4129 for (
int jj=0; jj<2; jj++)
4132 fprintf(vfile,
"%u\t",allele);
4135 fprintf(vfile,
"\n");
4147 char month [13] = {
'0',
'J',
'F',
'M',
'A',
'm',
'j',
'u',
'a',
'S',
'O',
'N',
'D'};
4157 for (
unsigned j=0; j<size; j++)
4164 fprintf(ofile,
"%d\t",ID);
4166 fprintf(ofile,
"%c",month[M]);
4167 fprintf(ofile,
"%d\t",Y);
4168 fprintf(ofile,
"%d\t",x);
4169 fprintf(ofile,
"%d\t",y);
4170 for (
int g=0; g<32; g++)
4173 fprintf(ofile,
"%d\t",allele);
4175 fprintf(ofile,
"%d\t",allele);
4177 fprintf(ofile,
"\n");
4184 for (
unsigned j=0; j<size; j++)
4191 fprintf(ofile,
"%d\t",ID);
4193 fprintf(ofile,
"%c",month[M]);
4194 fprintf(ofile,
"%d\t",Y);
4195 fprintf(ofile,
"%d\t",x);
4196 fprintf(ofile,
"%d\t",y);
4197 for (
int g=0; g<32; g++)
4200 fprintf(ofile,
"%d\t",allele);
4202 fprintf(ofile,
"%d\t",allele);
4204 fprintf(ofile,
"\n");
4217 m_TheLandscape->
Warn(
"Vole_Population_Manager::GeneticsOutputFile",
"Could Not Open VoleResistanceOutput.txt File");
4220 (* m_VoleResistanceOutputFile) <<
"year" <<
'\t' <<
"day" <<
'\t' <<
"Resistgene" <<
'\t' <<
"Neutralgene" <<
'\t' <<
"Frequency" <<
'\t' <<
"Population Size" <<endl;
4233 uint32 allele1, allele2;
4239 for (
int listindex=0; listindex<
vob_foobar; listindex++)
4242 for (
unsigned j=0; j<size; j++)
4244 new_VB = dynamic_cast<Vole_Base *>(
TheArray[listindex][j]);
4249 if ((allele1 == 1) || (allele2 == 1)) Rgene++;
else Ngene++;
4253 if ((allele1 == 1) && (allele2 == 1)) Rgene++;
else Ngene++;
4257 double freq = (double)Rgene/(
double) (Rgene+Ngene);
4258 (* m_VoleResistanceOutputFile) << Y <<
'\t' << D <<
'\t' << Rgene <<
'\t' << Ngene <<
'\t' << freq <<
'\t' << Rgene+Ngene << endl;
double SupplyVegCoverVector(unsigned int a_index)
static CfgInt cfg_GeneticResultOutputSecondYear("GENETICS_RESULT_OUTPUT_SECOND_YEAR", CFG_CUSTOM, 100000)
void TheAgeSexLocationProbe()
static CfgFloat cfg_f1sterilitychance("VOLE_FONESTERILITYCHANCE", CFG_CUSTOM, 0.0)
unsigned int SupplyNumberOfPolygons(void)
vector< APoint > m_TrapCoords
List of trap co-ordinates.
static CfgFloat cfg_GrassStartGrowth("VOLE_GRASSSTARTGROWTH", CFG_CUSTOM, 3.552)
CfgInt cfg_MinFemaleTerritorySize
int m_catastrophestartyear
double SupplyMeanTemp(long a_date, unsigned int a_period)
int SupplyCountFemales(unsigned p_x, unsigned p_y, unsigned p_TerrRange)
double AssessHabitat(int p_Polyref)
Assess the quality of habitat at p_Polyref.
TTypeOfVoleState CurrentVState
static CfgInt cfg_MaxAllele("GENETICS_MAXALLELE", CFG_CUSTOM, 255)
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
void OpenOutput(const char *a_filename)
Vole_Female * FindClosestFemale(int p_x, int p_y, int p_steps)
vector< TListOfAnimals > TheArray
Vole_Male * FindOutsideRadiusMale(int p_x, int p_y)
void CopyMyself(VoleObject a_vole)
Duplicates a vole.
double SupplyVegHeightVector(unsigned int a_index)
TTypesOfPopulation m_population_type
static CfgFloat cfg_ResistanceStartFrequency("VOLE_RESISTANCESTARTFREQ", CFG_CUSTOM, 0.01)
CfgFloat cfg_extradispmort
Base class for voles - all vole objects are descended from this class.
void CloseSexRatiosProbe()
void OpenResistanceOutput()
Opens the output file ready for resistance results.
int SupplyGrowthStartDate()
static CfgInt cfg_SexRatiosOutputFirstYear("VOLE_SEXRATIOSOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
bool OpenSexRatiosProbe()
static CfgStr cfg_SexRatiosOutput_filename("VOLE_SEXRATIOS_FILENAME", CFG_CUSTOM,"VoleSexRatios.txt")
static CfgFloat cfg_MoveToLessFavourable("VOLEMOVETOLESSFAVOURALBLE", CFG_CUSTOM, 0.005)
InTrapPosition SupplyTrapPosition()
FILE * ReallyBigOutputPrb
virtual void Catastrophe()
bool SupplyJustMownVector(unsigned int a_index)
int m_geneticproductfertilityeffect
int SupplyInOlderTerr(unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_Range)
virtual void LandscapeQuadrantOutputProbe(int a_day)
void ChangeData(int a_data, int a_value)
static CfgFloat cfg_VoleBackgroundMort("VOLE_BCKMORT", CFG_CUSTOM, 0.0025)
bool BarrierSearch(int F_x, int F_y, int M_x, int M_y)
int ListClosestMales(int p_x, int p_y, int p_steps)
virtual void ReInit(struct_Vole_Adult *p_aVoleStruct)
CfgInt cfg_pm_eventfrequency
void Init(const char *a_inifile)
Reads in the trap coords, creates the map and sets up the output files.
const float ReproTable_base[2][12]
bool OpenTheRipleysOutputProbe(string a_NWordFilename)
A struct for passing data to create a new vole.
CfgInt cfg_MinMaleTerritorySize
char m_SimulationName[255]
static CfgInt cfg_VoleSampleFileDayOne("VOLE_SAMPLE_FILE_DAY_ONE", CFG_CUSTOM, 109)
A class for simulation virtual traplines.
unsigned GetLiveArraySize(int a_listindex)
Gets the number of 'live' objects for a list index in the TheArray.
int Supply_m_Location_x()
void SendMessage(TTypeOfVoleMessage p_message, unsigned p_x, unsigned p_y, unsigned p_range, bool p_sex, double p_Weight)
static CfgInt cfg_GeneticsResultOutputFirstYear("GENETICS_RESULT_OUTPUT_FIRST_YEAR", CFG_CUSTOM, 100000)
virtual void GeneticsResultsOutput(FILE *ofile, unsigned listindex)
void GeneticsOutputFile(unsigned listindex)
static CfgBool cfg_volestartinoptimalonly("VOLE_STARTINOPTIMALONLY", CFG_CUSTOM, false)
The class for female voles.
vector< double > VoleHabitatBaseQualities
static CfgBool cfg_VoleSampleDataUsed("VOLE_SAMPLE_FILE_USED", CFG_CUSTOM, false)
static CfgStr cfg_VoleTraplinesfile("VOLE_TRAPLINESFILE", CFG_CUSTOM, "VoleTraplines.txt")
void CreateObjects(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
ofstream * m_VoleResistanceOutputFile
unsigned m_noTraps
The total number of traps.
The class for female voles.
void CreateObjects_Init(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
~TrapLineMap()
TrapLineMap destructor.
TTypesOfVegetation SupplyVegTypeVector(unsigned int a_index)
static CfgInt cfg_voleLandscapeGridOutputDay("VOLE_LANDSCAPEGRIDOUTPUTDAY", CFG_CUSTOM, 10000)
The landscape class containing all environmental and topographical data.
CfgBool cfg_GeneticsResultOutputUsed("GENETICS_RESULT_OUTPUT_USED", CFG_CUSTOM, false)
static CfgInt cfg_VoleResistanceDay("VOLE_RESISTANCEOUTPUT_DAY", CFG_CUSTOM, 365)
static CfgFloat cfg_GrassStartGrowthDay("VOLE_GRASSSTARTGROWTHDAY", CFG_CUSTOM, 80)
Class for the genetic material optionally carried by animals in ALMaSS.
unsigned char g_MaxAllele
virtual void TheSexRatiosProbe()
int SupplyGrazingPressureVector(unsigned int a_index)
uint32 SupplyMyAllele(int i, int j)
static CfgFloat cfg_geneticsterilitychance("VOLE_GENETICSTERILITYCHANCE", CFG_CUSTOM, 0)
static CfgInt cfg_genetetic_output_sample_size("VOLE_GENETIC_SAMPLE_SIZE", CFG_CUSTOM, 500)
static CfgStr cfg_VoleRecordMortFile("VOLE_RECORDMORTFILE", CFG_CUSTOM, "VoleMortalityCauses.txt")
vector< Vole_Base * > * SupplyVoleList(unsigned x, unsigned y, unsigned range)
int SupplySimAreaWidth(void)
CfgBool cfg_SexRatiosOutput_used("VOLE_SEXRATIOSOUTPUT_USED", CFG_CUSTOM, false)
Vole_Male * FindWithinRadiusMale(int p_x, int p_y)
virtual void TheAOROutputProbe()
bool InSquare(int p_x, int p_y, int p_sqx, int p_sqy, int p_range)
static CfgInt cfg_MateRadius("FEMALE_MATE_RADIUS", CFG_CUSTOM, 250)
Class to handle statistics and constructs based on allele frequencies.
The base class for all ALMaSS animal classes.
virtual void ImpactedProbe()
Vole_Population_Manager * VPM
static CfgInt cfg_SexRatiosOutput_interval("VOLE_SEXRATIOSOUTPUT_INTERVAL", CFG_CUSTOM, 1)
static CfgBool cfg_useagesexlocation("VOLE_USEAGESEXLOCATION", CFG_CUSTOM, false)
unsigned BeforeStepActions[12]
static CfgInt cfg_vole_starting_numberF("VOLE_START_NO_F", CFG_CUSTOM, 5000)
CfgBool cfg_ReallyBigOutput_used
CfgBool cfg_RipleysOutput_used
static CfgInt cfg_GeneticsResultOutputDay_2("GENETICS_RESULT_OUTPUT_DAY_TWO", CFG_CUSTOM, 6)
bool SupplyOlderFemales(unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_range)
void SetAllele(int pos, uint32 value, int Chromosome)
Base class for all population managers.
int SupplyDayInYear(void)
bool SuitableStartingLocation(int a_x, int a_y)
Vole_Male * FindClosestMale(int p_x, int p_y, int p_steps)
TTypesOfPesticide SupplyPesticideType(void)
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
int SupplyYearNumber(void)
static CfgInt cfg_GeneticsResultOutputInterval_1("GENETICS_RESULT_OUTPUT_INTERVAL_ONE", CFG_CUSTOM, 100000)
TrapLineMap(unsigned int a_width, unsigned int a_height, unsigned int a_resolution, const char *a_file)
TrapLineMap constructor.
TTypesOfLandscapeElement m_EleType
bool RecordGeneticsToday(int p_today, int p_year, int p_start_year, int p_interval)
static CfgInt cfg_GeneticsResultOutputDay_1("GENETICS_RESULT_OUTPUT_DAY_ONE", CFG_CUSTOM, 3)
void Initiation(AlleleFreq *Al)
CfgBool cfg_RecordVoleMort("VOLE_RECORDMORT_ON", CFG_CUSTOM, false)
static CfgBool cfg_genetic_output("VOLE_GENETIC_OUTPUT", CFG_CUSTOM, true)
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
const char * StateNames[100]
Vole_Male * FindRandomMale()
static CfgBool cfg_UseVoleTraplines("VOLE_TRAPLINES_ON_OFF", CFG_CUSTOM, false)
The class for juvenile male voles.
static CfgBool cfg_voleLandscapeGridOutputUsed("VOLE_LANDSCAPEGRIDOUTPUTUSED", CFG_CUSTOM, true)
Landscape * m_TheLandscape
int g_MaleReproductFinish
bool OpenTheReallyBigProbe()
static CfgInt cfg_SexRatiosOutput_day("VOLE_SEXRATIOSOUTPUT_DAY", CFG_CUSTOM, -1)
void Set_BirthYear(int BirthYear)
A class for storing the position of the trap the vole is in.
TrapLineMap * m_Traplines
unsigned m_ListNameLength
ofstream * m_VoleAgeSexLocationFile
CfgBool cfg_ReallyBigOutputMonthly_used
void CloseResistanceOutput()
Closes the output file ready for resistance results.
int GetCurrentStateNo()
Returns the current state number.
VoleSummaryOutput(const char *a_filename, Landscape *a_land, int a_numdataINT, int a_numdataDOUBLE)
The class for male voles.
static CfgInt cfg_VoleSampleFileDayTwo("VOLE_SAMPLE_FILE_DAY_TWO", CFG_CUSTOM, 287)
int Supply_m_Location_y()
static CfgInt cfg_vole_starting_numberM("VOLE_START_NO_M", CFG_CUSTOM, 5000)
TTypeOfVoleMessage
Types of vole message.
double MoveToLessFavourable
static CfgInt cfg_VoleTrapResolution("VOLE_TRAPRESOLUTION", CFG_CUSTOM, 2)
VoleSummaryOutput * m_VoleRecordMort
static CfgInt cfg_vole_reprofinishdate("VOLE_REPROFINISHDATE", CFG_CUSTOM, 243)
A base class for summary outputs.
void Shuffle(unsigned Type)
CfgBool cfg_ResistanceDominant
Vole_Population_Manager(Landscape *p_L)
static CfgInt cfg_geneticproductfertilityeffect("VOLE_GENETICPRODUCTFERTILITYEFFECT", CFG_CUSTOM, 50)
bool SupplyBornLastYear()
Were we born this year?
virtual void TheRipleysOutputProbe(FILE *a_prb)
static CfgFloat cfg_VoleFemaleMove("VOLE_FEMALEMOVE", CFG_CUSTOM, 0.0505)
void ReInit(struct_Vole_Adult *p_aVoleStruct)
void OnInfanticideAttempt()
Determines whether an infanticide attempt will succeed.
int ListClosestFemales(int p_x, int p_y, int p_steps)
int SupplyHowManyVoles(unsigned p_x, unsigned p_y, unsigned p_size)
const char * m_ListNames[32]
static CfgFloat cfg_MutationChance("GENETICS_MUTATION_CHANCE", CFG_CUSTOM, 0.001)
virtual void OPrintEndl()
void Warn(std::string a_msg1, std::string a_msg2)
virtual ~Vole_Population_Manager()
int SupplyAllele(int locus, int allele)
void SetFertile(bool f)
Set the male vole fertility.
virtual ~VoleSummaryOutput()
void ResistanceOutput()
Resistance results file output
int SupplyPolyRef(int a_x, int a_y)
virtual void TheReallyBigOutputProbe()
long SupplyGlobalDate(void)
static CfgBool cfg_VoleUseResistanceOuput("VOLE_RESISTANCEOUTPUT_ON_OFF", CFG_CUSTOM, false)
static CfgInt cfg_sigAgeDiff("VOLE_SIGAGEDIFF", CFG_CUSTOM, 30)
IDMap< TAnimal * > * m_VoleMap
void Output(InTrapPosition a_tp, int a_day, int a_sex, bool a_terr, int a_age, int a_bx, int a_by, int a_ID)
TTypesOfVegetation m_VegType
void IncLiveArraySize(int a_listindex)
Increments the number of 'live' objects for a list index in the TheArray.
double g_DailyMortChanceMaleTerr