ALMaSS Bembidion ODdox  1.1
The bembidion model description following ODdox protocol
Bembidion_all.cpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
24 
25 #include <string.h>
26 #include <iostream>
27 #include <fstream>
28 #include "../Landscape/ls.h"
29 #include "../BatchALMaSS/PopulationManager.h"
30 #include "../BatchALMaSS/AOR_Probe.h"
31 #include "../BatchALMaSS/MovementMap.h"
32 #include "../BatchALMaSS/positionmap.h"
33 #include "../Bembidion/bembidion_all.h"
34 
35 #include "../BatchALMaSS/BoostRandomGenerators.h"
36 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> > g_rand_uni;
37 
38 //---------------------------------------------------------------------------
39 
40 using namespace std;
41 
42 //---------------------------------------------------------------------------
43 
44 // Externals
51 extern const int Vector_x[8];
52 extern const int Vector_y[8];
53 //---------------------------------------------------------------------------
54 
55 //Pesticide configs
57 static CfgFloat cfg_BemAdultPPPElimiationRate("BEM_ADPPPELIMIATIONRATE", CFG_CUSTOM, 0.0, 0.0, 1.0);
59 static CfgFloat cfg_BemAdultPPPThreshold("BEM_ADPPPTHRESHOLD", CFG_CUSTOM, 9999999999.9);
61 static CfgFloat cfg_BemAdultPPPEffectProb("BEM_ADPPPEFFECTPROB", CFG_CUSTOM, 0, 0.0, 1.0);
63 static CfgFloat cfg_BemAdultPPPEffectProbDecay("BEM_ADPPPEFFECTPROBDECAY", CFG_CUSTOM, 0, 0.0, 1.0);
65 static CfgBool cfg_SavePesticideMortLocation("BEM_SAVEPESTMORTLOC", CFG_CUSTOM, false);
67 static CfgBool cfg_SaveInfieldLocation("BEM_SAVEINFIELDLOC", CFG_CUSTOM, false);
69 static CfgInt cfg_InCropRef("BEM_INCROPREF", CFG_CUSTOM, 603); // 603 == tov_WWheatPTreatment
71 static CfgInt cfg_SaveInfieldLocationInterval("BEM_INCROPREFINTERVAL", CFG_CUSTOM, 10000);
73 static CfgInt cfg_SaveInfieldLocationStartDay("BEM_INCROPREFSTARTDAY", CFG_CUSTOM, -2); // -2 will cause counting on 1st of every month
74 
75 
76 //---------------------------------------------------------------------------
77 
79 static CfgInt cfg_beetlestartnos("BEM_STARTNO",CFG_CUSTOM,10000);
81 static CfgInt cfg_DDepRange("BEM_DDEPRANGE",CFG_CUSTOM,3);
83 static CfgInt cfg_LDDepMort0("BEM_LDDEPMORTZERO",CFG_CUSTOM,3); //1-7
85 static CfgInt cfg_LDDepMort1("BEM_LDDEPMORTONE",CFG_CUSTOM,0); //0-100
87 static CfgInt cfg_ADDepMort0("BEM_ADDEPMORTZERO",CFG_CUSTOM,2);
89 static CfgInt cfg_ADDepMort1("BEM_ADDEPMORTONE",CFG_CUSTOM,10); //0-1000
91 static CfgInt cfg_MaxDailyMovement("BEM_MAXDAILYMOVEMENT",CFG_CUSTOM,14);
92 
93 const char* SimulationName="Bembidion lampros";
94 
95 // Must sure that the static arrays are actually initialised
100 
102 extern double g_SpeedyDivides[2001];
103 
104 //const int AdultActivityThreshold = 10; //Chiverton 1988, Mitchell 1963
106 const double DailyEggMort = 0.007;
108 const double DailyLarvaeMort = 0.001;
110 const double DailyPupaeMort = 0.001;
112 const double DailyAdultMort = 0.001;
114 const double LarvalDailyMort [3][6] = {{0.0855,0.0855,0.1036,0.0563,0.0515,0.0657},
115  {0.0626,0.0626,0.0940,0.0529,0.0492,0.0633},
116  {0.0631,0.0631,0.0545,0.0268,0.0236,0.0295}};
118 const double DevelopmentInflectionPoint = 12.0;
120 const double DevelConst1 = 3.0; // Threshold for all development stages
122 const double EggDevelConst2 = 178.58;
124 const double LDevelConst2 [3] = {101.4,107.4,190.4};
126 const double PupaDevelConst2 = 147.7;
128 const double above12Egg = EggDevelConst2/124.9;
130 const double above12Larvae[3] = {(LDevelConst2[0]/87.5),(LDevelConst2[1]/95.2),(LDevelConst2[2]/189.3)};
132 const double above12Pupae = EggDevelConst2/132.3;
134 const double AdultEggLayingThreshold = 3; //6;
135 const double EggProductionSlope = 0.6;
137 static CfgInt cfg_TotalNoEggs("BEM_TOTALEGGS",CFG_CUSTOM,256); // was 257 010904
139 const float DispersalThreshold = 6.0;
141 const int DipsersalDayDegrees = 8;
143 const int FieldHibernateChance = 25; //25
145 int MaxDailyMovement;//14; // max observed daily movement in m minus 1
147 const int AdultTurnRate = 80;
149 const int StartAggregatingDay = 270;
151 const int StartAggregatingDayProb = 260;
153 const int StopAggregationDay = 280;
154 
156 static CfgFloat cfg_BeetleStriglingMort("BEM_STRIGLINGMORT", CFG_CUSTOM, 0.250);
158 static CfgFloat cfg_BeetleHarvestMort("BEM_HARVESTMORT", CFG_CUSTOM, 0.290);
160 static CfgFloat cfg_Egg_SoilCultivationMortality("BEM_EGGSOILMORT",CFG_CUSTOM,0.500);
162 static CfgFloat cfg_Larva_SoilCultivationMortality("BEM_LARVAESOILMORT",CFG_CUSTOM,0.500);
164 static CfgFloat cfg_Pupa_SoilCultivationMortality("BEM_PUPAESOILMORT",CFG_CUSTOM,0.500);
166 static CfgFloat cfg_Adult_SoilCultivationMortality("BEM_ADULTSOILMORT",CFG_CUSTOM,0.270);
167 
169 static CfgFloat cfg_Egg_InsecticideApplication("BEM_EGGINSECTICIDEMORT", CFG_CUSTOM,0);
171 static CfgFloat cfg_Larva_InsecticideApplication("BEM_LARVAEINSECTICIDEMORT", CFG_CUSTOM,0.800);
173 static CfgFloat cfg_Pupa_InsecticideApplication("BEM_PUPAEINSECTICIDEMORT", CFG_CUSTOM,0.800);
175 static CfgFloat cfg_Adult_InsecticideApplication("BEM_ADULTINSECTICIDEMORT", CFG_CUSTOM,0.800);
176 
178 static CfgInt cfg_PesticideTrialEggTreatmentMort("BEM_PTRIALEGGMORT",CFG_CUSTOM,0);
180 static CfgInt cfg_PesticideTrialLarvaeTreatmentMort("BEM_PTRIALLARVAEMORT",CFG_CUSTOM,0);
182 static CfgInt cfg_PesticideTrialPupaeTreatmentMort("BEM_PTRIALPUPAEMORT",CFG_CUSTOM,0);
184 static CfgInt cfg_PesticideTrialAdultTreatmentMort("BEM_PTRIALADULTMORT",CFG_CUSTOM,0);
185 
194 
195 
196 // Initialise any static variables
197 double Bembidion_Adult::m_AdultPPPElimRate = 0; // Initialize static variable
198 double Bembidion_Adult::m_PPPEffectProb = 0; // Initialize static variable
199 double Bembidion_Adult::m_PPPEffectProbDecay = 0; // Initialize static variable
200 double Bembidion_Adult::m_PPPThreshold = 0; // Initialize static variable
201 
202 //---------------------------------------------------------------------------
203 // BEMBIDION_BASE
204 //---------------------------------------------------------------------------
207  : TAnimal( x, y, L ) {
208  m_OurPopulation = BPM;
210 }
211 //---------------------------------------------------------------------------
212 
214  ReinitialiseObject( x, y, L );
215  m_OurPopulation = BPM;
217 }
218 //---------------------------------------------------------------------------
219 
220 
225 {
227  m_CurrentStateNo=-1;
228  m_StepDone=true;
229 #ifdef __LAMBDA_RECORD
231 #endif
232 }
233 //---------------------------------------------------------------------------
234 
235 
240 void Bembidion_Base::CopyMyself(int a_beetle)
241 {
242  struct_Bembidion * BS;
243  BS = new struct_Bembidion;
244  BS->x = m_Location_x;
245  BS->y = m_Location_y;
246  BS->L = m_OurLandscape;
247  BS->BPM = m_OurPopulation;
248  m_OurPopulation->CreateObjects(a_beetle,this,NULL,BS,1);
249  delete BS;
250 }
251 //---------------------------------------------------------------------------
252 
253 
258 void Bembidion_Base::CopyMyselfB(int a_beetle)
259 {
260  struct_Bembidion * BS;
261  for (int i=0; i<a_beetle; i++) {
262  BS = new struct_Bembidion;
263  int coord = ((m_Location_x + (random(64)-32))+m_OurPopulation->SimW) % m_OurPopulation->SimW ;
264  BS->x = coord;
265  coord = ((m_Location_y + (random(64)-32))+m_OurPopulation->SimH) % m_OurPopulation->SimH ;
266  BS->y = coord;
267  BS->L = m_OurLandscape;
268  BS->BPM = m_OurPopulation;
269  m_OurPopulation->CreateObjects(1,this,NULL,BS,1);
270  delete BS;
271  }
272 
273 }
274 //---------------------------------------------------------------------------
275 
276 
277 //---------------------------------------------------------------------------
278 // BEMBIDION_EGG
279 //---------------------------------------------------------------------------
280 
282  Landscape* L): Bembidion_Base(0,0,L,BPM)
283 {
284  m_DayMade=today;
285 }
286 //---------------------------------------------------------------------------
287 
288 
290 {
292  {
293  return 1; // go to hatch
294  }
295  else return 0; // carry on developing
296 }
297 //---------------------------------------------------------------------------
298 
299 
301 {
302  struct_Bembidion * BS;
303  BS = new struct_Bembidion;
304  int size=(int)EggList.size();
305 
306  for (int i=0; i<size; i++)
307  {
308  BS->x = EggList[i].m_x;
309  BS->y = EggList[i].m_y;
310  BS->L = m_OurLandscape;
311  BS->BPM = m_OurPopulation;
312  m_OurPopulation->CreateObjects(1,this,NULL,BS,1);
313  }
314  EggList.erase(EggList.begin(),EggList.end()); // empty the list
315  delete BS;
316 #ifdef __LAMBDA_RECORD
318 #endif
319 
320 }
321 //---------------------------------------------------------------------------
322 
324 {
325  DailyMortality();
326 }
327 //---------------------------------------------------------------------------
328 
329 
331 {
332  if (m_StepDone || m_CurrentStateNo == -1) return;
333  switch (CurrentBState)
334  {
335  case tobs_Initiation: // Initial
337  break;
338  case tobs_EDeveloping: // Developing
339  switch(st_Develop())
340  {
341  case 0: // nothing
342  m_StepDone = true;
343  break;
344  case 1: // hatch
346  break;
347  }
348  break;
349  case tobs_Hatching:
350  st_Hatch();
352  m_StepDone=true;
353  break;
354  default:
355  m_OurLandscape->Warn("Bembidion Egg - Unknown State",NULL);
356  g_msg->Warn(WARN_BUG, "State attempted was: ", int(CurrentBState));
357  exit(1);
358  }
359 }
360 //---------------------------------------------------------------------------
361 
362 
364 {
365  // Needs to go through all eggs in the list and test for background mortality
366  // and while we are here for OnFarmEvent stuff
367  int size=(int)EggList.size();
368  for (int i=size-1; i>=0; i--)
369  {
370  if (g_rand_uni()<DailyEggMort)
371  {
372  // Remove the Egg it is dead
373  //EggList.erase(EggList.begin()+i);
374  EggList[i].m_x = -999; // Code for kill it
375  }
376  else
377  {
378  int res=0;
379  FarmToDo event;
381  m_Location_y, &res)) != sleep_all_day)
382 
383  switch(event)
384  {
385  case sleep_all_day:
386  break;
387  case autumn_plough:
389  //EggList.erase(EggList.begin()+i);
390  EggList[i].m_x = -999; // Code for kill it
391  break;
392  case stubble_plough:
394  //EggList.erase(EggList.begin()+i);
395  EggList[i].m_x = -999; // Code for kill it
396  break;
399  //EggList.erase(EggList.begin()+i);
400  EggList[i].m_x = -999; // Code for kill it
401  break;
404  //EggList.erase(EggList.begin()+i);
405  EggList[i].m_x = -999; // Code for kill it
406  break;
407  case autumn_harrow:
409  //EggList.erase(EggList.begin()+i);
410  EggList[i].m_x = -999; // Code for kill it
411  break;
414  //EggList.erase(EggList.begin()+i);
415  EggList[i].m_x = -999; // Code for kill it
416  break;
419  //EggList.erase(EggList.begin()+i);
420  EggList[i].m_x = -999; // Code for kill it
421  break;
422  case autumn_roll:
424  //EggList.erase(EggList.begin()+i);
425  EggList[i].m_x = -999; // Code for kill it
426  break;
427  case autumn_sow:
429  //EggList.erase(EggList.begin()+i);
430  EggList[i].m_x = -999; // Code for kill it
431  break;
432  case winter_plough:
434  //EggList.erase(EggList.begin()+i);
435  EggList[i].m_x = -999; // Code for kill it
436  break;
437  case deep_ploughing:
439  //EggList.erase(EggList.begin()+i);
440  EggList[i].m_x = -999; // Code for kill it
441  break;
442  case spring_plough:
444  //EggList.erase(EggList.begin()+i);
445  EggList[i].m_x = -999; // Code for kill it
446  break;
447  case spring_harrow:
449  //EggList.erase(EggList.begin()+i);
450  EggList[i].m_x = -999; // Code for kill it
451  break;
452  case shallow_harrow:
454  //EggList.erase(EggList.begin()+i);
455  EggList[i].m_x = -999; // Code for kill it
456  break;
457  case spring_roll:
458  break;
459  case spring_sow:
460  break;
462  break;
463 case fp_npks:
464  break;
465 case fp_npk:
466  break;
467 case fp_pk:
468  break;
469 case fp_liquidNH3:
470  break;
471 case fp_slurry:
472  break;
474  break;
476  break;
477 case fp_manure:
478  break;
479 case fp_greenmanure:
480  break;
481 case fp_sludge:
482  break;
483 case fp_rsm:
484  break;
485 case fp_calcium:
486  break;
487 case fa_npks:
488  break;
489 case fa_npk:
490  break;
491 case fa_pk:
492  break;
493 case fa_slurry:
494  break;
496  break;
498  break;
499 case fa_manure:
500  break;
501 case fa_greenmanure:
502  break;
503 case fa_sludge:
504  break;
505 case fa_rsm:
506  break;
507 case fa_calcium:
508  break;
509 case herbicide_treat:
510  break;
511 case growth_regulator:
512  break;
513 case fungicide_treat:
514  break;
515 case insecticide_treat:
517  //EggList.erase(EggList.begin()+i);
518  EggList[i].m_x = -999; // Code for kill it
519  break;
520 case molluscicide:
521  break;
522 case row_cultivation:
523  break;
524 case strigling:
525  break;
526 case hilling_up:
527  break;
528 case water:
529  break;
530 case swathing:
531  break;
532 case harvest:
533  break;
534 case cattle_out:
535  break;
536 case cattle_out_low:
537  break;
538 case cut_to_hay:
539  break;
540 case cut_to_silage:
541  break;
542 case straw_chopping:
543  break;
544 case hay_turning:
545  break;
546 case hay_bailing:
547  break;
548 case burn_straw_stubble:
549  break;
550 case stubble_harrowing:
551  break;
554  //EggList.erase(EggList.begin()+i);
555  EggList[i].m_x = -999; // Code for kill it
556  break;
557 case flammebehandling: // 50
558  break;
559 case mow:
560  break;
561 case cut_weeds:
562  break;
563 case pigs_out:
564  break;
565 case strigling_sow:
567  //EggList.erase(EggList.begin()+i);
568  EggList[i].m_x = -999; // Code for kill it
569  break;
570 case strigling_hill:
572  //EggList.erase(EggList.begin()+i);
573  EggList[i].m_x = -999; // Code for kill it
574  break;
576  if (random(1000)<cfg_PesticideTrialEggTreatmentMort.value())
577  //EggList.erase(EggList.begin()+i);
578  EggList[i].m_x = -999; // Code for kill it
579  break;
580 case trial_toxiccontrol:
581  if (random(1000)<PesticideTrialEggToxicMort)
582  //EggList.erase(EggList.begin()+i);
583  EggList[i].m_x = -999; // Code for kill it
584  break;
585 case trial_control:
586 case product_treat:
587  break;
588 case glyphosate:
589  break;
591  if (random(1000)<cfg_PesticideTrialEggTreatmentMort.value())
592  //EggList.erase(EggList.begin()+i);
593  EggList[i].m_x = -999; // Code for kill it
594  break;
595 case biocide:
596  break;
597 case bed_forming:
599  //EggList.erase(EggList.begin()+i);
600  EggList[i].m_x = -999; // Code for kill it
601  break;
602 case flower_cutting:
603  break;
604 case bulb_harvest:
606  //EggList.erase(EggList.begin()+i);
607  EggList[i].m_x = -999; // Code for kill it
608  break;
609 case straw_covering:
610  break;
611 case straw_removal:
612  break;
613 default:
614  m_OurLandscape->Warn("Bembidion Egg - Treatment in Daily Mortality",NULL);
615  exit(1);
616 }
617  }
618  }
619  // Now sort the list based on x values
620  SortXR();
621  // Then erase all the -999
622  vector<APoint>::reverse_iterator ritE=EggList.rend();
623  vector<APoint>::reverse_iterator ritB=EggList.rbegin();
624  while (ritB!=ritE) {
625  if ((*ritB).m_x<0) ritB++; else break;
626  }
627  EggList.erase((ritB).base(),EggList.end());
628 }
629 //---------------------------------------------------------------------------
630 
635  sort( EggList.begin(), EggList.end(), CompareEggX() );
636 }
637 
638 //-----------------------------------------------------------------------------
639 
640 
641 //---------------------------------------------------------------------------
642 // BEMBIDION_LARVAE
643 //---------------------------------------------------------------------------
644 
645 
646 
649  Bembidion_Base( x, y, L, BPM ) {
650  m_LarvalStage = 0;
651  m_AgeDegrees = 0;
652  m_DayMade = L->SupplyDayInYear();
653 }
654 //---------------------------------------------------------------------------
655 
657  Bembidion_Base::ReInit( x, y, L, BPM );
658  m_LarvalStage = 0;
659  m_AgeDegrees = 0;
660  m_DayMade = L->SupplyDayInYear();
661 }
662 //---------------------------------------------------------------------------
663 
665 {
666  switch(event)
667  {
668  case sleep_all_day:
669  break;
670  case autumn_plough:
672  break;
673  case stubble_plough: // assumed to be the same as for autumn plough
675  break;
676  case stubble_cultivator_heavy: // assumed to be the same as for autumn plough
678  break;
679  case heavy_cultivator_aggregate: // assumed to be the same as for autumn plough
681  break;
682  case autumn_harrow:
684  break;
685  case preseeding_cultivator: // assumed to be the same as for harrow
687  break;
688  case preseeding_cultivator_sow: // assumed to be the same as for harrow
690  break;
691  case autumn_roll:
693  break;
694  case autumn_sow:
696  break;
697  case winter_plough:
699  break;
700  case deep_ploughing:
702  break;
703  case spring_plough:
705  break;
706  case spring_harrow:
708  break;
709  case shallow_harrow:
711  break;
712  case spring_roll:
713  break;
714  case spring_sow:
715  break;
717  break;
718  case fp_npks:
719  break;
720  case fp_npk:
721  break;
722  case fp_pk:
723  break;
724  case fp_liquidNH3:
725  break;
726  case fp_slurry:
727  break;
729  break;
730  case fp_ammoniumsulphate:
731  break;
732  case fp_manure:
733  break;
734  case fp_greenmanure:
735  break;
736  case fp_sludge:
737  break;
738  case fp_rsm:
739  break;
740  case fp_calcium:
741  break;
742  case fa_npks:
743  break;
744  case fa_npk:
745  break;
746  case fa_pk:
747  break;
748  case fa_slurry:
749  break;
750  case fa_ammoniumsulphate:
751  break;
753  break;
754  case fa_manure:
755  break;
756  case fa_greenmanure:
757  break;
758  case fa_sludge:
759  break;
760  case fa_rsm:
761  break;
762  case fa_calcium:
763  break;
764 case herbicide_treat:
765  break;
766 case growth_regulator:
767  break;
768 case fungicide_treat:
769  break;
770 case insecticide_treat:
772  break;
773 case molluscicide:
774  break;
775 case row_cultivation:
776  break;
777 case strigling:
778  //if (g_rand_uni()<cfg_BeetleStriglingMort.value()) CurrentBState=tobs_LDying;
779 break;
780 case hilling_up:
781  break;
782 case water:
783  break;
784 case swathing:
785  break;
786 case harvest:
787  break;
788 case cattle_out:
789  break;
790 case cattle_out_low:
791  break;
792 case cut_to_hay:
793  break;
794 case cut_to_silage:
795  break;
796 case straw_chopping:
797  break;
798 case hay_turning:
799  break;
800 case hay_bailing:
801  break;
802 case flammebehandling:
803  break;
804 case stubble_harrowing:
805  break;
808  break;
809 case burn_straw_stubble:
810  break;
811 case mow:
812  break;
813 case cut_weeds:
814  break;
815 case pigs_out:
816  break;
817 case strigling_sow:
819  break;
820 case strigling_hill:
822  break;
825  break;
826 case trial_toxiccontrol:
828  break;
829 case trial_control:
830 case product_treat:
831  break;
832 case glyphosate:
833  break;
836  break;
837 case biocide:
838  break;
839 case bed_forming:
841  break;
842 case flower_cutting:
843  break;
844 case bulb_harvest:
846  break;
847 case straw_covering:
848  break;
849 case straw_removal:
850  break;
851 default:
852  m_OurLandscape->Warn("Bembidion Larvae - Unknown Treatment in Daily Mortality"
853  ,NULL);
854  exit(1);
855  }
856  // Must incorporate a test here in case the animal is dead - killing it twice
857  // can be a bad idea
858  if (CurrentBState==tobs_LDying) return true;
859  else
860  return false;
861 }
862 //---------------------------------------------------------------------------
863 
865 {
877  if (temp2<0) temp2=0; else if (temp2>25) temp2=25;
878  temp2=(int)(floor((float)temp2+2.0)*0.2); // same as (temp2+2)/5
879  // take a mortality test
880  if (g_rand_uni()<(LarvalDailyMort[m_LarvalStage][temp2])) return true;// die
881  else return false;
882 }
883 //------------------------------------------------------------------------------
884 
886 {
892  int temp2=(int) floor(m_OurLandscape->SupplyTemp()+0.5);
893  if (TempRelatedLarvalMortality(temp2))
894  {
895  // To ensure that we don't influence anyone else clear the position
897  return 2; // die
898  }
899  // Find out if there is any danger of using wrap round
900  if ((m_Location_x==0)||(m_Location_y==0)||(m_Location_x>=
902  {
903  // No density dependent mortality at the edge (this is a fudge, but a small one with large landscapes)
904  }
905  else
906  {
907  // Do density dependent mortality based on the +/- 1 m in all directions.
910  {
911  // To ensure that we don't influence anyone else clear the position
913  return 2; // die
914  }
915  }
916  }
917  // Still alive so now do the development bit
919  {
920  m_LarvalStage++; // turn into next larval stage
921  }
922  if (m_LarvalStage==3) return 1; // become a pupa
923  else return 0; // carry on developing
924 }
925 //---------------------------------------------------------------------------
926 
927 
929 {
930  // Must clear the map position
932  struct_Bembidion * BS;
933  BS = new struct_Bembidion;
934  BS->x = m_Location_x;
935  BS->y = m_Location_y;
936  BS->L = m_OurLandscape;
937  BS->BPM = m_OurPopulation;
938  BS->DayDegrees=(int)m_AgeDegrees;
939  // carry the extra degrees over to next stage
940  m_OurPopulation->CreateObjects(2,this,NULL,BS,1);
941  delete BS;
942 }
943 //---------------------------------------------------------------------------
944 
945 
947 {
949 }
950 //---------------------------------------------------------------------------
951 
952 
954 {
955  CheckManagement();
957 }
958 //---------------------------------------------------------------------------
959 
960 
962 {
963  if (m_StepDone || m_CurrentStateNo == -1) return;
964  switch (CurrentBState)
965  {
966  case 0: // Initial
968  break;
969  case tobs_LDeveloping: // Developing
970  switch(st_Develop())
971  {
972  case 0: // nothing
973  m_StepDone = true;
974  break;
975  case 1: // pupating
977  break;
978  case 2: // die
980  break;
981  }
982  break;
983  case tobs_Pupating:
984  st_Pupate();
985  m_CurrentStateNo=-1; //Destroys object
987  m_StepDone=true;
988  break;
989  case tobs_LDying:
990  // Remove itself from the position map
992  st_Die();
993  m_StepDone=true;
994  break;
995  default:
996  m_OurLandscape->Warn("Bembidion Larvae - Unknown State",NULL);
997  g_msg->Warn(WARN_BUG, "State attempted was: ", int(CurrentBState));
998  exit(1);
999  }
1000 }
1001 //---------------------------------------------------------------------------
1002 
1003 
1005 {
1007  {
1008  return true;
1009  }
1010  return false;
1011 }
1012 //---------------------------------------------------------------------------
1013 
1014 
1015 //---------------------------------------------------------------------------
1016 // BEMBIDION_PUPAE
1017 //---------------------------------------------------------------------------
1018 
1019 
1021 {
1022  m_AgeDegrees=0;
1024 }
1025 //---------------------------------------------------------------------------
1026 
1027 
1029  Bembidion_Base::ReInit( x, y, L, BPM );
1030  m_AgeDegrees = 0;
1031  m_DayMade = L->SupplyDayInYear();
1032 }
1033 //---------------------------------------------------------------------------
1034 
1036 {
1037  switch(event)
1038  {
1039  case sleep_all_day:
1040  break;
1041  case autumn_plough:
1043  break;
1044  case stubble_plough: // assumed to be the same as for autumn plough
1046  break;
1047  case stubble_cultivator_heavy: // assumed to be the same as for autumn plough
1049  break;
1050  case heavy_cultivator_aggregate: // assumed to be the same as for autumn plough
1052  break;
1053  case autumn_harrow:
1055  break;
1056  case preseeding_cultivator: // assumed to be the same as for harrow
1058  break;
1059  case preseeding_cultivator_sow: // assumed to be the same as for harrow
1061  break;
1062  case autumn_roll:
1064  break;
1065  case autumn_sow:
1067  break;
1068  case winter_plough:
1070  break;
1071  case deep_ploughing:
1073  break;
1074  case spring_plough:
1076  break;
1077  case spring_harrow:
1079  break;
1080  case shallow_harrow:
1082  break;
1083  case spring_roll:
1084  break;
1085  case spring_sow:
1086  break;
1087  case spring_sow_with_ferti:
1088  break;
1089  case fp_npks:
1090  break;
1091  case fp_npk:
1092  break;
1093  case fp_pk:
1094  break;
1095  case fp_liquidNH3:
1096  break;
1097  case fp_slurry:
1098  break;
1099  case fp_manganesesulphate:
1100  break;
1101  case fp_ammoniumsulphate:
1102  break;
1103  case fp_manure:
1104  break;
1105  case fp_greenmanure:
1106  break;
1107  case fp_sludge:
1108  break;
1109  case fp_rsm:
1110  break;
1111  case fp_calcium:
1112  break;
1113  case fa_npks:
1114  break;
1115  case fa_npk:
1116  break;
1117  case fa_pk:
1118  break;
1119  case fa_slurry:
1120  break;
1121  case fa_ammoniumsulphate:
1122  break;
1123  case fa_manganesesulphate:
1124  break;
1125  case fa_manure:
1126  break;
1127  case fa_greenmanure:
1128  break;
1129  case fa_sludge:
1130  break;
1131  case fa_rsm:
1132  break;
1133  case fa_calcium:
1134  break;
1135 case herbicide_treat:
1136  break;
1137 case growth_regulator:
1138  break;
1139 case fungicide_treat:
1140  break;
1141 case insecticide_treat:
1143  break;
1144 case molluscicide:
1145  break;
1146 case row_cultivation:
1147  break;
1148 case strigling:
1149 //if (g_rand_uni()<cfg_BeetleStriglingMort.value()) CurrentBState=tobs_PDying;
1150  break;
1151 case hilling_up:
1152  break;
1153 case water:
1154  break;
1155 case swathing:
1156  break;
1157 case harvest:
1158  break;
1159 case cattle_out:
1160  break;
1161 case cattle_out_low:
1162  break;
1163 case cut_to_hay:
1164  break;
1165 case cut_to_silage:
1166  break;
1167 case straw_chopping:
1168  break;
1169 case hay_turning:
1170  break;
1171 case hay_bailing:
1172  break;
1173 case flammebehandling:
1174  break;
1175 case stubble_harrowing:
1176  break;
1179  break;
1180 case burn_straw_stubble:
1181  break;
1182 case mow:
1183  break;
1184 case cut_weeds:
1185  break;
1186 case pigs_out:
1187  break;
1188 case strigling_sow:
1190  break;
1191 case strigling_hill:
1193  break;
1196  break;
1197 case trial_toxiccontrol:
1199  break;
1200 case trial_control:
1201 case product_treat:
1202 case glyphosate:
1203  break;
1206  break;
1207 case biocide:
1208  break;
1209 case bed_forming:
1211  break;
1212 case flower_cutting:
1213  break;
1214 case bulb_harvest:
1216  break;
1217 case straw_covering:
1218  break;
1219 case straw_removal:
1220  break;
1221  default:
1222  m_OurLandscape->Warn("Bembidion Pupae - Unknown Treatment in Daily Mortality",NULL);
1223  g_msg->Warn(WARN_BUG, "State attempted was: ", int(CurrentBState));
1224  exit(1);
1225  }
1226  // Must incorporate a test here in case the animal is dead - killing it twice
1227  // can be a bad idea
1228  if (CurrentBState==tobs_PDying) return true;
1229  else
1230  return false;
1231 }
1232 //---------------------------------------------------------------------------
1233 
1234 
1236 {
1237  double DailyMortChance;
1238  int temp2=(int) floor(m_OurLandscape->SupplyTemp()+0.5);
1239  int LengthOfStageAtTemp;
1240  // watch out for -ve & zero
1241  if (temp2 <1) temp2=1;
1242  if (temp2<13)
1243  {
1244  // How long to develop at this temp
1245  LengthOfStageAtTemp = (int)(PupaDevelConst2*g_SpeedyDivides[temp2]);
1246  // Get the mortality per day
1247  // Equation modified from Boye Jensen 1990
1248  DailyMortChance = (100-(-7.1429+1.42857*temp2))*
1249  g_SpeedyDivides[LengthOfStageAtTemp];
1250  }
1251  else if (temp2<23)
1252  {
1253  // How long to develop at this temp
1254  LengthOfStageAtTemp = (int)(PupaDevelConst2*g_SpeedyDivides[temp2]);
1255  // Get the mortality per day
1256  // Equation modified from Boye Jensen 1990
1257  DailyMortChance = (100-(-74.623+7.26415*temp2))
1258  *g_SpeedyDivides[LengthOfStageAtTemp];
1259  }
1260  else // temp>=23
1261  {
1262  // How long to develop at this temp
1263  LengthOfStageAtTemp = (int)(PupaDevelConst2*g_SpeedyDivides[temp2]);
1264  // Get the mortality per day
1265  // Equation modified from Boye Jensen 1990
1266  DailyMortChance = (20.0)*g_SpeedyDivides[LengthOfStageAtTemp];
1267  }
1268  // take a mortality test
1269  if (random(1000) < (DailyMortChance*10)) return 2; // die
1270  // Still alive so now do the development bit
1271  if (temp2>0) m_AgeDegrees+=temp2;
1273  {
1274  return 1; // go to emerge
1275  }
1276  else return 0; // carry on developing
1277 }
1278 //---------------------------------------------------------------------------
1279 
1280 
1282 {
1283  struct_Bembidion * BS;
1284  BS = new struct_Bembidion;
1285  int NoToMake=1;
1286  BS->x = m_Location_x;
1287  BS->y = m_Location_y;
1288  BS->L = m_OurLandscape;
1289  BS->BPM = m_OurPopulation;
1290  // object destroyed by OwnerRTS
1291  m_OurPopulation->CreateObjects(3,this,NULL,BS,NoToMake);
1292  delete BS;
1293 }
1294 //---------------------------------------------------------------------------
1295 
1296 
1298 {
1300 }
1301 //---------------------------------------------------------------------------
1302 
1303 
1305 {
1306  CheckManagement();
1308 }
1309 //---------------------------------------------------------------------------
1310 
1311 
1313 {
1314  if (m_StepDone || m_CurrentStateNo == -1) return;
1315  switch (CurrentBState)
1316  {
1317  case 0: // Initial
1319  break;
1320  case tobs_PDeveloping: // Developing
1321  switch(st_Develop())
1322  {
1323  case 0: // nothing
1324  m_StepDone = true;
1325  break;
1326  case 1: // emerging
1328  break;
1329  case 2: // die
1331  break;
1332  }
1333  break;
1334  case tobs_Emerging:
1335  st_Emerge();
1336  m_StepDone=true;
1338  m_CurrentStateNo=-1; //Destroys object
1339  break;
1340  case tobs_PDying:
1341  st_Die();
1342  m_StepDone=true;
1343  break;
1344  default:
1345  m_OurLandscape->Warn("Bembidion Pupae - Unknown State",NULL);
1346  exit(1);
1347  }
1348 }
1349 //---------------------------------------------------------------------------
1350 
1351 
1353 {
1354  if (g_rand_uni()<DailyPupaeMort)
1355  {
1356  return true;
1357  }
1358  return false;
1359 }
1360 //---------------------------------------------------------------------------
1361 
1362 
1363 //---------------------------------------------------------------------------
1364 // BEMBIDION_ADULTS
1365 //---------------------------------------------------------------------------
1367 Bembidion_Base( x, y, L, BPM ) {
1368  Init();
1369 }
1370 //---------------------------------------------------------------------------
1371 
1373  Bembidion_Base::ReInit( x, y, L, BPM );
1374  Init();
1375 }
1376 //---------------------------------------------------------------------------
1377 
1379 {
1380 }
1381 //---------------------------------------------------------------------------
1382 
1384 {
1385  m_negDegrees=0; //No negative degrees to sum
1386  // don't want to start accumulating Hibernate degrees until Jan 1st
1387  m_HibernateDegrees=-99999;
1388  OldDirection=random(8);
1389  m_EggCounter=0;
1390  m_CanReproduce=false;
1391  m_body_burden = 0;
1393 }
1394 //---------------------------------------------------------------------------
1395 
1396 
1398 {
1399  switch(event)
1400  {
1401  case sleep_all_day:
1402  break;
1403  case autumn_plough:
1405  break;
1406  case stubble_plough: // assumed to be the same as for autumn plough
1408  break;
1409  case stubble_cultivator_heavy: // assumed to be the same as for autumn plough
1411  break;
1412  case heavy_cultivator_aggregate: // assumed to be the same as for autumn plough
1414  break;
1415  case autumn_harrow:
1417  break;
1418  case preseeding_cultivator: // assumed to be the same as for harrow
1420  break;
1421  case preseeding_cultivator_sow: // assumed to be the same as for harrow
1423  break;
1424  case autumn_roll:
1426  break;
1427  case autumn_sow:
1429  break;
1430  case winter_plough:
1432  break;
1433  case deep_ploughing:
1435  break;
1436  case spring_plough:
1438  break;
1439  case spring_harrow:
1441  break;
1442  case shallow_harrow:
1444  break;
1445  case spring_roll:
1446  break;
1447  case spring_sow:
1448  break;
1449  case spring_sow_with_ferti:
1450  break;
1451 case fp_npks:
1452  break;
1453 case fp_npk:
1454  break;
1455 case fp_pk:
1456  break;
1457 case fp_liquidNH3:
1458  break;
1459 case fp_slurry:
1460  break;
1462  break;
1463 case fp_ammoniumsulphate:
1464  break;
1465 case fp_manure:
1466  break;
1467 case fp_greenmanure:
1468  break;
1469 case fp_sludge:
1470  break;
1471 case fp_rsm:
1472  break;
1473 case fp_calcium:
1474  break;
1475 case fa_npks:
1476  break;
1477 case fa_npk:
1478  break;
1479 case fa_pk:
1480  break;
1481 case fa_slurry:
1482  break;
1483 case fa_ammoniumsulphate:
1484  break;
1486  break;
1487 case fa_manure:
1488  break;
1489 case fa_greenmanure:
1490  break;
1491 case fa_sludge:
1492  break;
1493 case fa_rsm:
1494  break;
1495 case fa_calcium:
1496  break;
1497 case herbicide_treat:
1498  break;
1499 case growth_regulator:
1500  break;
1501 case fungicide_treat:
1502  break;
1503 case insecticide_treat:
1505  break;
1506 case molluscicide:
1507  break;
1508 case row_cultivation:
1509  break;
1510 case strigling:
1512  break;
1513 case hilling_up:
1514  break;
1515 case water:
1516  break;
1517 case swathing:
1518  break;
1519 case harvest:
1521  break;
1522 case cattle_out:
1523  break;
1524 case cattle_out_low:
1525  break;
1526 case cut_to_hay:
1527  break;
1528 case cut_to_silage:
1529  break;
1530 case straw_chopping:
1531  break;
1532 case hay_turning:
1533  break;
1534 case hay_bailing:
1535  break;
1536 case flammebehandling:
1537  break;
1538 case stubble_harrowing:
1539  break;
1542  break;
1543 case burn_straw_stubble:
1544  break;
1545 case mow:
1546  break;
1547 case cut_weeds:
1548  break;
1549 case pigs_out:
1550  break;
1551 case strigling_sow:
1553  break;
1554 case strigling_hill:
1556  break;
1559  break;
1560 case trial_toxiccontrol:
1562  break;
1563 case trial_control:
1564 case product_treat:
1565 case glyphosate:
1566  break;
1569  break;
1570 case biocide:
1571  break;
1572 case bed_forming:
1574  break;
1575 case flower_cutting:
1576  break;
1577 case bulb_harvest:
1579  break;
1580 case straw_covering:
1581  break;
1582 case straw_removal:
1583  break;
1584  default:
1585  m_OurLandscape->Warn("Bembidion Adult - Unknown Treatment in Daily Mortality"
1586  ,NULL);
1587  exit(1);
1588  }
1589  // Must incorporate a test here in case the animal is dead - killing it twice
1590  // can be a bad idea
1591  if (CurrentBState==tobs_ADying) return true;
1592  else
1593  return false;
1594 }
1595 //---------------------------------------------------------------------------
1596 
1597 
1605 {
1606  if (DailyMovement(random(MaxDailyMovement)+1, true)==2) return 2;// Die
1607  int Day=m_OurLandscape->SupplyDayInYear();
1608  if (Day<StartAggregatingDay) return 0;
1609  else
1610  {
1611  if (random(100)<Day-StartAggregatingDayProb)
1612  {
1613  // Stop laying eggs now
1614  if (m_CanReproduce==true) // must be from last year so kill it
1615  return 2;
1616  return 1; // start aggregating
1617  }
1618  }
1619  return 0;
1620 }
1621 //-----------------------------------------------------------------------------
1622 
1623 
1625 {
1626  return DailyMovement(random(MaxDailyMovement)+1, false);
1627 }
1628 //-----------------------------------------------------------------------------
1629 
1636 {
1637  int day=m_OurLandscape->SupplyDayInYear();
1638  if (day==0) m_HibernateDegrees=0;
1639  else if (day>100) return 0; // don't disperse if after spring
1640  double temp=m_OurLandscape->SupplyTemp();
1642  if ((day>=60)||(m_HibernateDegrees>=DipsersalDayDegrees))
1643  {
1644  //If we don't start dispersing then ensure we enter this code next time
1646  // test against the chance of dispersal
1647  // assume that it takes about one month to get 120 DDs
1648  // 30*(10-6)=120 - ALSO ASSUMES MEAN TEMP OF 10 DEGREES C
1649  // Therefore the probability of dispersing per day is that prob when
1650  // summed culmulatively gives 0.92 after 30 days (0.92 is the observed
1651  // dispersal % at 120DDs above 6 degrees C
1652  // this value is 0.081
1653  if (random(1000)<81)
1654  {
1655  m_CanReproduce=true;//Can only repoduce after hibernating else too young
1656  return 1; // dispersing
1657  }
1658  if (day>90)
1659  {
1660  m_CanReproduce=true;//Can only repoduce after hibernating else too young
1661  return 1; // dispersing
1662  }
1663  }
1664  return 0; // still hibernating
1665 }
1666 //-----------------------------------------------------------------------------
1667 
1668 
1670 {
1671  if (WinterMort()) return 2; // die - a once only test
1675  DailyMovement(random(MaxDailyMovement)+1, true);
1676  return 0;
1677 }
1678 //---------------------------------------------------------------------------
1679 
1680 // This version has no ageing whilst hibernating
1682 {
1683  double temp=m_OurLandscape->SupplyTemp();
1684  if (temp<0.0) m_negDegrees+=temp;
1685  // Check should the beetle die today if not hibernating
1687  {
1688  if (DailyMortality()) return true; // go to die
1689  if (m_CanReproduce)
1690  {
1691  if (m_EggCounter<0) return true; // All eggs laid so die
1692  }
1693  }
1694  return false; // carry on
1695 }
1696 //---------------------------------------------------------------------------
1697 
1699 {
1700  // Beetles are immobile during winter so only call this once at the
1701  // end of overwintering
1702  double mortchance;
1703  if (m_negDegrees>-40)
1704  {
1705  mortchance = 0.94925+(m_negDegrees*0.00426);
1706  }
1707  else if (m_negDegrees>-80)
1708  {
1709  mortchance = 1.16913+(m_negDegrees*0.01149);
1710  }
1711  else if (m_negDegrees>-107)
1712  {
1713  mortchance = 0.6665+(m_negDegrees*0.00528);
1714  }
1715  else mortchance=0.1; // max 90% mortality
1716  if (random(1000) < ((1-mortchance)*1000)) return true; // die
1717  else return false;
1718 }
1719 //---------------------------------------------------------------------------
1720 
1724 int Bembidion_Adult::DailyMovement(int p_distance, bool p_disp_aggreg)
1725 {
1726  // If its too cold then do not do any movement today
1727  if (m_OurLandscape->SupplyTemp() < 1.0) return 0;
1728  // are we aggregating or dispersing?
1729  if (p_disp_aggreg == true)
1730  {
1731  // Dispersing
1732  int turning = AdultTurnRate; // almost no change of turning
1733  // Do the movement
1734  MoveTo(p_distance, OldDirection, turning);
1735  if (DDepMort()) return 2; // die
1736  return 0; // carry on dispersing
1737  }
1738  else
1739  {
1740  return MoveToAggr(p_distance, OldDirection, AdultTurnRate);
1741  }
1742 }
1743 //---------------------------------------------------------------------------
1744 
1745 
1746 void Bembidion_Adult::MoveTo(int p_distance,unsigned p_direction,int p_turning)
1747 {
1759  int vx = m_Location_x;
1760  int vy = m_Location_y;
1761  pPoint.direction=p_direction;
1762  pList.nsteps=0;
1763  if (random(100)<p_turning)
1764  {
1765  // change direction
1766  if (random(2)==1) pPoint.direction=((1+pPoint.direction) & 7U);
1767  else pPoint.direction=((7+pPoint.direction) & 0x07); //same as p_direction-1 but +ve
1768  }
1769 
1770  /*
1771  Improved speed here by checking if the max distance goes out of bounds
1772  i.e. x+p_distance, y+p_distance & x-p_distance,y-p_distance
1773  if not then there is no need to check for out of bounds later at all
1774  */
1775 
1776  if ((vx-p_distance<0) || (vy-p_distance<0) || (vx+p_distance>=m_OurPopulation->SimW)
1777  || (vy+p_distance>=m_OurPopulation->SimH))
1778  {
1779  //---- Duplicated with out of bounds check for speed
1780  for (int i=0; i<p_distance; i++)
1781  {
1782  // test the squares at Vector, Vector+1+2, Vector-1-2
1783  // if they are inaccessible (water,buildings,forest) try another square
1784  //
1785  int qual=3;
1786  int tries=0;
1787  while ((qual==3)&&(tries++<10))
1788  {
1789  // first watch out for out of bounds
1792  if (pPoint.x<0) pPoint.x=
1794  else if (pPoint.x>=m_OurPopulation->SimW)
1796  if (pPoint.y<0)
1797  {
1799  }
1800  else if (pPoint.y>=m_OurPopulation->SimH)
1801  {
1803  }
1804  qual=MoveTo_quality_assess();
1805  }
1806  if (qual!=3)
1807  {
1810  vx=pPoint.x;
1811  vy=pPoint.y;
1813  }
1814  else
1815  {
1817  pList.BeenThereY[pList.nsteps++]=vy;
1818  }
1819  }
1820  }
1821  //---- Duplicated for speed
1822  else // No Out of bounds possible
1823  {
1824  for (int i=0; i<p_distance; i++)
1825  {
1826  // test the squares at Vector, Vector+1+2, Vector-1-2
1827  // if they are inaccessible (water,buildings,forest) try another square
1828  //
1829  int qual=3;
1830  int tries=0;
1831  while ((qual==3)&&(tries++<10))
1832  {
1835  qual=MoveTo_quality_assess();
1836  }
1837  if (qual!=3)
1838  {
1841  vx=pPoint.x;
1842  vy=pPoint.y;
1844  }
1845  else
1846  {
1848  pList.BeenThereY[pList.nsteps++]=vy;
1849  }
1850  }
1851  }
1852  // alter the location
1854  m_Location_x=vx;
1855  m_Location_y=vy;
1858  CanReproduce();
1859 }
1860 //---------------------------------------------------------------------------
1861 
1863 {
1864  //are we reproducing?
1865  if (m_CanReproduce)
1866  {
1869  // First find out how many eggs to produce depending on temperature
1871  // Calcuated in the pop man so it only needs calculating once
1872  switch(tole)
1873  {
1874  case tole_Field:
1875  case tole_Orchard:
1876  case tole_FieldBoundary:
1878  break;
1879  case tole_PermPasture:
1882  case tole_RoadsideVerge:
1883  case tole_NaturalGrassDry: // 110
1884  case tole_NaturalGrassWet:
1885  case tole_YoungForest:
1886  case tole_MownGrass:
1887  case tole_BeetleBank:
1888  case tole_WaterBufferZone:
1889  NoEggs = NoEggs>>1;
1890  break;
1891  default:
1892  NoEggs=0;
1893  break;
1894  }
1895  if (NoEggs>0)
1896  {
1897  for (int i=0; i<NoEggs; i++)
1898  {
1899  int place=random(pList.nsteps);
1900  Reproduce(pList.BeenThereX[place],pList.BeenThereY[place]);
1901  }
1902  m_EggCounter-=NoEggs;
1903  // _EggCounter will go negative when all eggs are used
1904  //- allows a small over-production
1905  }
1906  }
1907 };
1908 //---------------------------------------------------------------------------
1909 
1910 void Bembidion_Adult::Reproduce(int p_x, int p_y)
1911 {
1912  struct_Bembidion * BS;
1913  BS = new struct_Bembidion;
1914  BS->x = p_x;
1915  BS->y = p_y;
1916  BS->L = m_OurLandscape;
1917  BS->BPM = m_OurPopulation;
1918  BS->DayDegrees=0;
1919  BS->HowMany=1;
1920  // don't need delete because object destroyed by Population_Manager
1921  m_OurPopulation->CreateObjects(0,this,NULL,BS,1);
1922  delete BS;
1923 }
1924 //---------------------------------------------------------------------------
1925 
1926 
1927 
1932 {
1933  int qual;
1934  // get the quality of the test area
1935  // if it is 3 then don't go here
1936  // 2 can walk there but it is non-habitat
1937  // 1 linear features e.g. hedges, roadside verges
1938  // 1 grassland
1939  // 0 crop field
1940  if (!m_OurPopulation->m_AdultPosMap->GetMapValue(pPoint.x,pPoint.y))
1941  {
1942  qual = m_OurPopulation->m_MoveMap->GetMapValue(pPoint.x,pPoint.y);
1943  }
1944  else qual=3;
1945  // if it is 3 then don't go here
1946  switch (qual)
1947  {
1948  case 3: // Cannot go
1949  // try another direction
1950  if (random(2)==1) pPoint.direction=((1+pPoint.direction) & 0x07);
1951  else pPoint.direction=((7+pPoint.direction)& 0x07);
1952  break;
1953  case 2:
1954  // Have a 40% chance of moving on to it
1955  if (random(100)>=40)
1956  {
1957  // try another direction
1958  if (random(2)==1) pPoint.direction=((1+pPoint.direction) & 0x07);
1959  else pPoint.direction=((7+pPoint.direction) & 0x07); // Reverse
1960  break;
1961  }
1962  case 1:
1963  case 0:
1964  break;
1965  default:
1966  // Should never happen
1967  m_OurLandscape->Warn("Bembidion Adult:: MoveTo QA Bad Direction",NULL);
1968  exit(1);
1969  }
1970  return qual;
1971 }
1972 //---------------------------------------------------------------------------
1973 
1974 int Bembidion_Adult::MoveToAggr(int p_distance,unsigned p_direction,int p_turning)
1975 {
1983  int vx = m_Location_x;
1984  int vy = m_Location_y;
1985  int tvx=0;
1986  int tvy=0;
1987  if (random(100)<p_turning)
1988  {
1989  // change direction
1990  if (random(2)==1) p_direction=((1+p_direction) & 0x07);
1991  else p_direction=((7+p_direction) & 0x07);
1992  }
1993 
1994  /*
1995  Improved speed here by checking if the max distance goes out of bounds
1996  i.e. x+p_distance, y+p_distance & x-p_distance,y-p_distance
1997  if not then there is no need to check for out of bounds later at all
1998  */
1999  if ((vx-p_distance<0) || (vy-p_distance<0)
2000  || (vx+p_distance>=m_OurPopulation->SimW)
2001  || (vy+p_distance>=m_OurPopulation->SimH))
2002  {
2003  //---- Duplicated with out of bounds check for speed
2004  for (int i=0; i<p_distance; i++)
2005  {
2006  // test the squares at Vector, Vector+1+2, Vector-1-2
2007  // if they are inaccessible (water,buildings,forest) try another square
2008  //
2009  int qual=3;
2010  int tries=0;
2011  while ((qual==3)&&(tries++<10))
2012  {
2013  // first watch out for out of bounds
2014  tvx=vx+Vector_x[p_direction];
2015  tvy=vy+Vector_y[p_direction];
2016  if (tvx<0) tvx=(tvx+m_OurPopulation->SimW)%m_OurPopulation->SimW;
2017  else if (tvx>=m_OurPopulation->SimW) tvx=tvx%m_OurPopulation->SimW;
2018  if (tvy<0) {tvy=(tvy+m_OurPopulation->SimH)%m_OurPopulation->SimH;}
2019  else if (tvy>=m_OurPopulation->SimH) {tvy=tvy%m_OurPopulation->SimH;}
2020  // get the quality of the test area
2021  qual = m_OurPopulation->m_MoveMap->GetMapValue(tvx,tvy);
2022  // if it is 3 then don't go here
2023  switch (qual)
2024  {
2025  case 3: // Cannot go
2026  // try another direction
2027  if (random(2)==1) p_direction=((1+p_direction) & 0x07);
2028  else p_direction=((7+p_direction) & 0x07);
2029  break;
2030  case 2:
2031  // Have a 40% chance of moving on to it
2032  if (random(100)>=40)
2033  {
2034  // try another direction
2035  if (random(2)==1) p_direction=((1+p_direction) & 0x07);
2036  else p_direction=((7+p_direction) & 0x07);
2037  break;
2038  }
2039  case 1:
2040  // This is where we want to be
2041  i=p_distance;
2042  case 0:
2043  break;
2044  default:
2045  // Should never happen
2046  m_OurLandscape->Warn("Bembidion Adult:: MoveTo Aggr Bad Direction",NULL);
2047  exit(1);
2048  }
2049  }
2050  if (qual!=3)
2051  {
2052  vx=tvx;
2053  vy=tvy;
2054  OldDirection=p_direction;
2055  }
2056  }
2057  }
2058  //---- Duplicated for speed
2059  else // No Out of bounds possible
2060  {
2061  for (int i=0; i<p_distance; i++)
2062  {
2063  tvx=vx+Vector_x[p_direction];
2064  tvy=vy+Vector_y[p_direction];
2065  // if they are inaccessible (water,buildings,forest) try another square
2066  //
2067  int qual=3;
2068  int tries=0;
2069  while ((qual==3)&(tries++<10))
2070  {
2071  // get the quality of the test area
2072  // if it is 3 then don't go here
2073  // 2 can walk there but it is non-habitat
2074  // 1 linear features e.g. hedges, roadside verges
2075  // 1 grassland
2076  // 0 crop field
2077  qual = m_OurPopulation->m_MoveMap->GetMapValue(tvx,tvy);
2078  // if it is 3 then don't go here
2079  switch (qual)
2080  {
2081  case 3: // Cannot go
2082  // try another direction
2083  if (random(2)==1) p_direction=((1+p_direction) & 0x07);
2084  else p_direction=((7+p_direction) & 0x07);
2085  break;
2086  case 2:
2087  // Have a 40% chance of moving on to it
2088  if (random(100)>=40)
2089  {
2090  // try another direction
2091  if (random(2)==1) p_direction=((1+p_direction) & 0x07);
2092  else p_direction=((7+p_direction) & 0x07);
2093  break;
2094  }
2095  case 1:
2096  // where we want to be so stop for a while
2097  i=p_distance;
2098  case 0:
2099  break;
2100  default:
2101  // Should never happen
2102  m_OurLandscape->Warn("Bembidion Adult:: MoveTo Aggr 2 Bad Direction",NULL);
2103  exit(1);
2104  }
2105  }
2106  if (qual!=3)
2107  {
2108  vx=tvx;
2109  vy=tvy;
2110  OldDirection=p_direction;
2111  }
2112  }
2113  }
2114  // alter the location
2116  m_Location_x=vx;
2117  m_Location_y=vy;
2119  int hab=m_OurPopulation->m_MoveMap->GetMapValue(m_Location_x, m_Location_y);
2120  if (m_OurLandscape->SupplyDayInYear()>363)
2121  {
2122  // Has reached January so must decide if can hibernate here or die
2123  if ((hab==1)||(random(100)<FieldHibernateChance)) return 1;
2124  else return 2; // die
2125  }
2126  else
2128  {
2130  switch (tole)
2131  {
2132  case tole_Hedges: // 130
2133  case tole_RoadsideVerge: // 13
2134  case tole_FieldBoundary: // 160
2135  case tole_HedgeBank:
2136  case tole_BeetleBank:
2137  case tole_PermPasture: // 35
2138  case tole_PermPastureLowYield: // 35
2139  case tole_PermPastureTussocky: // 26
2140  case tole_Heath:
2141  case tole_NaturalGrassDry: // 110
2142  case tole_NaturalGrassWet:
2143  case tole_AmenityGrass:
2144  case tole_Orchard: //55
2145  case tole_MownGrass: //58
2146  case tole_YoungForest:
2147  case tole_WaterBufferZone:
2148  return 1; //late in year in an OK place so stop
2149  default:
2150  return 0; // Carry on aggregating
2151  }
2152  }
2153  return 0; // Carry on aggregating
2154 }
2155 //---------------------------------------------------------------------------
2156 //-------------------------------------------------------------------------------------
2161  // Test against the threshold level for Adult to determine if an effect needs to be tested for
2162  if (m_body_burden > m_PPPThreshold) {
2163  // We are above the PPP body burden threshold, so make a test for effect
2164  if (g_rand_uni() <m_PPPEffectProb) {
2166  switch (tp) {
2167  case ttop_NoPesticide:
2168  break;
2169  case ttop_ReproductiveEffects: // Reproductive effects
2170  // TODO
2171  break;
2172  case ttop_AcuteEffects: // Acute mortality
2173  st_Die(); // Kill this one now
2174  break;
2177  break;
2178  case ttop_MultipleEffects:
2179  break;
2180  default:
2181  g_msg->Warn("Unknown pesticide type used in Bembidion_Adult::InternalPesticideHandlingAndResponse() pesticide code ", int(tp));
2182  exit(47);
2183  }
2184  }
2185  }
2186 }
2187 //-------------------------------------------------------------------------------------
2188 
2190 {
2191  CheckManagement();
2192  // Die if mortality occurs or is too old
2194 }
2195 //---------------------------------------------------------------------------
2196 
2198 {
2199 #ifdef __BEETLEPESTICIDE1
2201  // Pick up the pesticide to add to the body burden
2204  if (m_currentPPPEffectProb != 0)
2205  {
2206  // Kill the beetle following a fixed probability of death. The test is taken each day until it dies.
2208  }
2209 #endif
2210 }
2211 //---------------------------------------------------------------------------
2212 
2214 {
2215  if (m_StepDone || m_CurrentStateNo == -1) return;
2216  switch (CurrentBState)
2217  {
2218  case 0: // nothing
2220  break;
2221  case tobs_Foraging: // Forage
2222  switch (st_Forage())
2223  {
2224  case 0:
2225  m_StepDone=true;
2226  break;
2227  case 1:
2229  m_StepDone=true;
2230  break;
2231  case 2:
2233  m_StepDone=true;
2234  break;
2235  }
2236  break;
2237  case tobs_Aggregating: // Aggregate
2238  switch (st_Aggregate())
2239  {
2240  case 0:
2241  m_StepDone=true;
2242  break;
2243  case 1:
2245  m_StepDone=true;
2246  break;
2247  case 2:
2249  m_StepDone=true;
2250  break;
2251  default:
2252  // Should never happen
2253  m_OurLandscape->Warn("Bembidion Adult Unknown Return State From st_Aggregate",NULL);
2254  exit(1);
2255  }
2256  break;
2257  case tobs_Hibernating: // Hibernate
2258  switch (st_Hibernate())
2259  {
2260  case 0:
2261  m_StepDone=true;
2262  break;
2263  case 1:
2264  CurrentBState=tobs_Dispersing; // Dispersal
2265  m_StepDone=true;
2266  break;
2267  default:
2268  m_OurLandscape->Warn("Bembidion Adult Unknown Return State From st_Hibernate",NULL);
2269  exit(1);
2270  break;
2271  }
2272  break;
2273  case tobs_Dispersing: // Disperse
2274  switch (st_Dispersal())
2275  {
2276  case 0:
2277  m_EggCounter=cfg_TotalNoEggs.value(); // start the egg production counter
2278  CurrentBState=tobs_Foraging; // Forage
2279  m_StepDone=true;
2280  break;
2281  case 2:
2282  CurrentBState=tobs_ADying; // die
2283  break;
2284  default:
2285  m_OurLandscape->Warn("Bembidion Adult Unknown Return State From st_Dispersal",NULL);
2286  exit(1);
2287  }
2288  break;
2289  case tobs_ADying: // Die
2291  st_Die();
2292  m_StepDone=true;
2293  break;
2294  default:
2295  m_OurLandscape->Warn("Bembidion Adult Unknown State",NULL);
2296  g_msg->Warn(WARN_BUG, "State attempted was: ", int(CurrentBState));
2297  exit(1);
2298  }
2299 }
2300 //---------------------------------------------------------------------------
2301 
2307 {
2308  if (g_rand_uni()<DailyAdultMort)
2309  {
2310  return true;
2311  }
2312  return false;
2313 }
2314 //---------------------------------------------------------------------------
2315 
2316 
2322 {
2323 // Modified ***CJT*** 26-05-2009
2324  int range=cfg_DDepRange.value();
2325  int x=m_Location_x;
2326  int y=m_Location_y;
2327  // Find out if there is any danger of using wrap round
2328  if ((x<0)||(y<0)|| (x>=m_OurPopulation->SimW-range) ||(y>=m_OurPopulation->SimH-range))
2329  {
2330  int diff = 0;
2331  if (x<0) {
2332  diff = abs(x);
2333  } else if (x>=m_OurPopulation->SimW-range) diff = (x+range)-m_OurPopulation->SimW;
2334  if (y<0) {
2335  if (diff< abs(y)) diff = abs(y);
2336  } else if (y>=m_OurPopulation->SimH-range){
2337  int diff2=(y+range)-m_OurPopulation->SimH;
2338  if (diff2>diff) diff=diff2;
2339  }
2340  range-=diff;
2341  }
2342  if (m_OurPopulation->m_AdultPosMap->GetMapDensity(m_Location_x-range,m_Location_y-range,range*2)>m_OurPopulation->ADDepMort0) {
2343  if (g_rand_uni()<m_OurPopulation->ADDepMort1) return true; // die
2344  }
2345  return false;
2346 }
2347 //---------------------------------------------------------------------------
2348 
2349 
2350 //---------------------------------------------------------------------------
2351 // BEMBIDION_POPULATION_MANAGER
2352 //---------------------------------------------------------------------------
2353 
2354 
2356  : Population_Manager(p_L)
2357 {
2358  // Four lists are needed so need to remove 6 of the ten default arrays
2359  // Eggs, Larvae, Pupae & Adults
2360  for (int i=0; i<4; i++)
2361  {
2362  TheArray.pop_back();
2363  }
2364  m_MoveMap=new MovementMap(p_L, 0); // 0 for beetles
2365  m_LarvaePosMap=new SimplePositionMap(p_L);
2366  m_AdultPosMap=new SimplePositionMap(p_L);
2367 // Create the egg lists
2368  for (int i=0; i<365; i++)
2369  {
2370  m_EList[i]=new Bembidion_Egg_List(i,this,p_L);
2371 
2372  }
2373  // Clear the m_DayDeg array
2374  for (int i=0; i<365; i++)
2375  {
2376  m_EDayDeg[i]=0;
2377  m_LDayDeg[i][0]=0;
2378  m_LDayDeg[i][1]=0;
2379  m_LDayDeg[i][2]=0;
2380  m_PDayDeg[i]=0;
2381  }
2388  Init();
2389 }
2390 //---------------------------------------------------------------------------
2391 
2392 
2394 {
2395  for (int i=0; i<365; i++) delete m_EList[i];
2396  delete m_MoveMap;
2397  delete m_LarvaePosMap;
2398  delete m_AdultPosMap;
2399 }
2400 //---------------------------------------------------------------------------
2401 
2409 {
2410 
2411  // autom. called by constructor
2412  if (cfg_RipleysOutput_used.value()) {
2414  }
2415  if ( cfg_ReallyBigOutput_used.value() ) {
2417  } else ReallyBigOutputPrb=0;
2418  strcpy(m_SimulationName,"Bembidion");
2419  // Create cfg_beetlestartnos adults
2420  struct_Bembidion* aps;
2421  aps = new struct_Bembidion;
2422  aps->BPM = this;
2423  aps->L = m_TheLandscape;
2424  for (int i=0; i<cfg_beetlestartnos.value(); i++)
2425  {
2426  do
2427  {
2428  aps->x = random(m_TheLandscape->SupplySimAreaWidth());
2429  aps->y = random(m_TheLandscape->SupplySimAreaHeight());
2430  } while (!IsStartHabitat(aps->x, aps->y));
2431  CreateObjects(3,NULL,NULL,aps,1);
2432  }
2433  delete aps;
2435  m_EPopSize=0;
2436  m_LPopSize=0;
2437  m_PPopSize=0;
2438 
2439 // Load List of Animal Classes
2440  m_ListNames[0]="Egg";
2441  m_ListNames[1]="Larva";
2442  m_ListNames[2]="Pupa";
2443  m_ListNames[3]="Adult";
2444  m_ListNameLength = 4;
2446 
2447 // Load State Names
2448  StateNames[tobs_Initiation] = "Initiation";
2449 //Egg
2450  StateNames[tobs_EDeveloping] = "Developing";
2451  StateNames[tobs_Hatching] = "Hatching";
2452  StateNames[tobs_EDying] = "Dying";
2453 //Larva
2454  StateNames[tobs_LDeveloping] = "Developing";
2455  StateNames[tobs_Pupating] = "Pupating";
2456  StateNames[tobs_LDying] = "Dying";
2457 //Pupa
2458  StateNames[tobs_PDeveloping] = "Developing";
2459  StateNames[tobs_Emerging] = "Emerging";
2460  StateNames[tobs_PDying] = "Dying";
2461 //Adult
2462  StateNames[tobs_Foraging] = "Foraging";
2463  StateNames[tobs_Aggregating] = "Aggregating";
2464  StateNames[tobs_Hibernating] = "Hibernating";
2465  StateNames[tobs_Dispersing] = "Dispersing";
2466  StateNames[tobs_ADying] = "Dying";
2467 
2468  // Ensure that larvae are sorted w.r.t. x position not shuffled
2469  BeforeStepActions[1]=1; // 1 = SortX
2470 
2471 #ifdef __RECORD_RECOVERY_POLYGONS
2472  /* Open the output file and append */
2473  ofstream ofile("RecoveryPolygonsCounter.txt",ios::out);
2474  ofile << "This file records the number of females in each polygon each day" << endl;
2475  ofile.close();
2476  /* Open the polygon recovery file and read in polygons to m_RecoveryPolygons */
2477  ifstream ifile("RecoveryPolygonsList.txt",ios::in);
2478  int n;
2479  ifile >> n;
2480  m_RecoveryPolygons[0] = n;
2481  for (int i=0; i<n; i++) ifile >> m_RecoveryPolygons[1+i];
2482  for (int i=0; i<n; i++) m_RecoveryPolygonsC[1+i]=0;
2483  ifile.close();
2484 #endif
2485 
2486 #ifdef __BEETLEPESTICIDE1
2487  PestMortLocOutputOpen();
2488  m_InFieldNo = 0;
2489  m_OffFieldNo = 0;
2490  m_InCropNo = 0;
2492  if (cfg_SaveInfieldLocation.value()) LocOutputOpen();
2493 #endif
2494  Bembidion_Adult ba(0,0,NULL,NULL);
2495 
2496  // Initialise any static variables
2497  ba.SetAdultPPPElimRate(cfg_BemAdultPPPElimiationRate.value()); // Initialize static variable
2498  ba.SetPPPThreshold(cfg_BemAdultPPPThreshold.value()); // Initialize static variable
2499  ba.SetPPPEffectProb(cfg_BemAdultPPPEffectProb.value()); // Initialize static variable
2500  ba.SetPPPEffectProbDecay(cfg_BemAdultPPPEffectProbDecay.value()); // Initialize static variable
2501 }
2502 //---------------------------------------------------------------------------
2503 #ifdef __RECORD_RECOVERY_POLYGONS
2504 void Bembidion_Population_Manager::RecordRecoveryPolygons()
2505 {
2510  int sz = (int) GetLiveArraySize[bob_Adult];
2511  for (int j=0; j<sz; j++)
2512  {
2513  int p = TheArray[bob_Adult][j]->SupplyPolygonRef();
2514  for (int i=1; i<=m_RecoveryPolygons[0]; i++)
2515  {
2516  if (p == m_RecoveryPolygons[i]) {
2517  m_RecoveryPolygonsC[i]++;
2518  break;
2519  }
2520  }
2521  }
2522  /* Open the output file and append */
2523  ofstream ofile("RecoveryPolygonsCounter.txt",ios::app);
2524  for (int i=1; i<=m_RecoveryPolygons[0]; i++)
2525  {
2526  ofile << m_RecoveryPolygonsC[i] << '\t';
2527  m_RecoveryPolygonsC[i] = 0;
2528  }
2529  ofile << endl;
2530  ofile.close();
2531 }
2532 //---------------------------------------------------------------------------
2533 #endif
2534 
2536 {
2538  tole=m_TheLandscape->SupplyElementType(a_x, a_y);
2539  switch(tole)
2540  {
2541  case tole_Field:
2542  case tole_Orchard:
2543  case tole_PermPasture:
2546  case tole_RoadsideVerge:
2547  case tole_NaturalGrassDry:
2548  case tole_NaturalGrassWet:
2549  case tole_FieldBoundary:
2551  case tole_YoungForest:
2552  case tole_WaterBufferZone:
2553  return true;
2554  default:
2555  return false;
2556  }
2557 }
2558 
2560 {
2569 #ifdef __RECORD_RECOVERY_POLYGONS
2570 
2573  RecordRecoveryPolygons();
2574 #endif
2575  int today=m_TheLandscape->SupplyDayInYear();
2576  // WHOOAA!! This is really dangerous if these objects are registered anywhere
2577  // else in the system
2578  if (today==364)
2579  {
2580  for (unsigned j = 0; j<GetLiveArraySize( bob_Egg ); j++)
2581  {
2582  TheArray[bob_Egg][j]->KillThis(); // Destroy this
2583  }
2584  for (unsigned j = 0; j<GetLiveArraySize( bob_Larva ); j++)
2585  {
2586  TheArray[bob_Larva][j]->KillThis(); // Destroy this
2587  }
2588  for (unsigned j = 0; j<GetLiveArraySize( bob_Pupa ); j++)
2589  {
2590  TheArray[bob_Pupa][j]->KillThis(); // Destroy this
2591  }
2592  }
2593  else if (today==0)
2594  {
2595  for (int i=0; i<365; i++)
2596  {
2597  m_EList[i]->EggList.clear();
2598  m_EDayDeg[i]=0;
2599  m_LDayDeg[i][0]=0;
2600  m_LDayDeg[i][1]=0;
2601  m_LDayDeg[i][2]=0;
2602  m_PDayDeg[i]=0;
2603  }
2604  }
2605 
2606  double temptoday=m_TheLandscape->SupplyTemp();
2607  // Calculate the number of eggs laid today
2608  if (temptoday>AdultEggLayingThreshold)
2609  TodaysEggProduction=(int) floor(0.5+(((double)temptoday-
2611  else TodaysEggProduction=0;
2612  if (TodaysEggProduction>10)TodaysEggProduction=10; // ensure no bigger than 10
2613  // Calculated the DayDegrees for the different stages today
2614  if (temptoday>DevelConst1)
2615  {
2616  temptoday-=DevelConst1; // Subtract the threshold
2617  if (temptoday>DevelopmentInflectionPoint)
2618  {
2619  for(int i=0; i<=today; i++)
2620  {
2621  double et,l1t,l2t,l3t,pt;
2622  et=temptoday*above12Egg;
2623  l1t=temptoday*above12Larvae[0];
2624  l2t=temptoday*above12Larvae[1];
2625  l3t=temptoday*above12Larvae[2];
2626  pt=temptoday*above12Pupae;
2627  m_EDayDeg[i]+=et;
2628  m_LDayDeg[i][0]+=l1t;
2629  m_LDayDeg[i][1]+=l2t;
2630  m_LDayDeg[i][2]+=l3t;
2631  m_PDayDeg[i] += pt;
2632  }
2633  }
2634  else
2635  {
2636  for(int i=0; i<=today; i++)
2637  {
2638  m_EDayDeg[i]+=temptoday;
2639  m_LDayDeg[i][0]+=temptoday;
2640  m_LDayDeg[i][1]+=temptoday;
2641  m_LDayDeg[i][2]+=temptoday;
2642  m_PDayDeg[i]+=temptoday;
2643  }
2644  }
2645  }
2646  // Store the current population sizes
2651 
2652 #ifdef __LAMBDA_RECORD
2653  if (today==March) {
2654  LamdaDumpOutput();
2655  LamdaClear();
2656  }
2657 #endif
2658 
2659 #ifdef __BEETLEPESTICIDE1
2660  if (today==0) PestMortLocOutput();
2661 #endif
2662 
2663  // This replaces the BeginStep function for the eggs
2664  for (int i=0; i<365; i++)
2665  {
2666  m_EList[i]->BeginStep();
2667  }
2668 }
2669 //---------------------------------------------------------------------------
2670 
2672 {
2673  // This replaces the step function for the eggs
2674  for (int i=0; i<365; i++) m_EList[i]->SetStepDone(false);
2675  for (int i=0; i<365; i++) m_EList[i]->Step();
2676 
2677 }
2678 //---------------------------------------------------------------------------
2679 
2680 //---------------------------------------------------------------------------
2681 //---------------------------------------------------------------------------
2682 
2683 /*
2684 class ReturnLessThanX
2685 {
2686  public:
2687  bool operator()(TAnimal* A1, int x) const
2688  {
2689  return (A1->Supply_m_Location_x()<x);
2690  }
2691 };
2692 */
2693 //---------------------------------------------------------------------------
2694 /*
2695 class ReturnMoreThanX
2696 {
2697  public:
2698  bool operator()(int x,TAnimal* A1) const
2699  {
2700  return (A1->Supply_m_Location_x()>x);
2701  }
2702 };
2703 */
2704 //---------------------------------------------------------------------------
2705 
2710 {
2712 #ifdef __BEETLEPESTICIDE1
2713  int today=m_TheLandscape->SupplyDayInYear();
2715  {
2717  {
2719  {
2720  if (m_TheLandscape->SupplyDayInMonth() == 1) DoInFieldLocationOutput();
2721  }
2722  else
2723  {
2724  if ( (today - cfg_SaveInfieldLocationStartDay.value()) % cfg_SaveInfieldLocationInterval.value() == 0) DoInFieldLocationOutput();
2725  }
2726  }
2727  }
2728 #endif
2729 }
2730 //---------------------------------------------------------------------------
2731 
2737 {
2738 }
2739 //---------------------------------------------------------------------------
2740 
2745 float Bembidion_Population_Manager::Probe(int ListIndex,probe_data* p_TheProbe)
2746 {
2747  // Counts through the list and goes through each area to see if the animal
2748  // is standing there and if the farm, veg or element conditions are met
2749  AnimalPosition Sp;
2750  float NumberSk = 0;
2751  if (ListIndex==0)
2752  {
2753  unsigned X;
2754  unsigned Y;
2755  // Four possibilites
2756  // either NoVegTypes or NoElementTypes or NoFarmTypes is >0 or all==0
2757  if (p_TheProbe->m_NoFarms!=0)
2758  {
2759  for (int n=0; n<365; n++)
2760  {
2761  for (unsigned j=0; j<m_EList[n]->EggList.size(); j++)
2762  {
2763  Y=m_EList[n]->EggList[j].m_y;
2764  X=m_EList[n]->EggList[j].m_x;
2765  unsigned Farm=m_TheLandscape->SupplyFarmOwner(X,Y);
2766  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2767  {
2768  if ((X>=p_TheProbe->m_Rect[i].m_x1)
2769  && (Y>=p_TheProbe->m_Rect[i].m_y1)
2770  && (X<=p_TheProbe->m_Rect[i].m_x2)
2771  && (Y<=p_TheProbe->m_Rect[i].m_y2))
2772  for (unsigned k=0; k<p_TheProbe->m_NoFarms; k++)
2773  {
2774  if (p_TheProbe->m_RefFarms[k]==Farm)
2775  NumberSk++; // it is in the square so increment number
2776  }
2777  }
2778  }
2779  }
2780  }
2781  else if (p_TheProbe->m_NoEleTypes!=0)
2782  {
2783  for (int n=0; n<365; n++)
2784  {
2785  for (unsigned j=0; j<m_EList[n]->EggList.size(); j++)
2786  {
2787  Y=m_EList[n]->EggList[j].m_y;
2788  X=m_EList[n]->EggList[j].m_x;
2789  int EleType = (int)m_TheLandscape->SupplyElementType(X,Y);
2790  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2791  {
2792  if ((X>=p_TheProbe->m_Rect[i].m_x1)
2793  && (Y>=p_TheProbe->m_Rect[i].m_y1)
2794  && (X<=p_TheProbe->m_Rect[i].m_x2)
2795  && (Y<=p_TheProbe->m_Rect[i].m_y2))
2796  for (unsigned k=0; k<p_TheProbe->m_NoEleTypes; k++)
2797  {
2798  if (p_TheProbe->m_RefEle[k]==EleType)
2799  NumberSk++; // it is in the square so increment number
2800  }
2801  }
2802  }
2803  }
2804  }
2805  else if (p_TheProbe->m_NoVegTypes!=0)
2806  {
2807  for (int n=0; n<365; n++)
2808  {
2809  for (unsigned j=0; j<m_EList[n]->EggList.size(); j++)
2810  {
2811  Y=m_EList[n]->EggList[j].m_y;
2812  X=m_EList[n]->EggList[j].m_x;
2813  int VegType = (int)m_TheLandscape->SupplyVegType(X,Y);
2814  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2815  {
2816  if ((X>=p_TheProbe->m_Rect[i].m_x1)
2817  && (Y>=p_TheProbe->m_Rect[i].m_y1)
2818  && (X<=p_TheProbe->m_Rect[i].m_x2)
2819  && (Y<=p_TheProbe->m_Rect[i].m_y2))
2820  for (unsigned k=0; k<p_TheProbe->m_NoVegTypes; k++)
2821  {
2822  if (p_TheProbe->m_RefVeg[k]==VegType)
2823  NumberSk++; // it is in the square so increment number
2824  }
2825  }
2826  }
2827  }
2828  }
2829  else // both must be zero
2830  {
2831  for (int n=0; n<365; n++)
2832  {
2833  for (unsigned j=0; j<m_EList[n]->EggList.size(); j++)
2834  {
2835  Y=m_EList[n]->EggList[j].m_y;
2836  X=m_EList[n]->EggList[j].m_x;
2837  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2838  {
2839  if ((X>=p_TheProbe->m_Rect[i].m_x1)
2840  && (Y>=p_TheProbe->m_Rect[i].m_y1)
2841  && (X<=p_TheProbe->m_Rect[i].m_x2)
2842  && (Y<=p_TheProbe->m_Rect[i].m_y2))
2843  NumberSk++; // it is in the square so increment number
2844 
2845  }
2846  }
2847  }
2848  }
2849  }
2850  else
2851  {
2852  // Four possibilites
2853  // either NoVegTypes or NoElementTypes or NoFarmTypes is >0 or all==0
2854  if (p_TheProbe->m_NoFarms!=0)
2855  {
2856  for (unsigned j = 0; j<GetLiveArraySize( ListIndex ); j++)
2857  {
2858  Sp=TheArray[ListIndex][j]->SupplyPosition();
2859  unsigned Farm=TheArray[ListIndex][j]->SupplyFarmOwnerRef();
2860  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2861  {
2862  if ((Sp.m_x>=p_TheProbe->m_Rect[i].m_x1)
2863  && (Sp.m_y>=p_TheProbe->m_Rect[i].m_y1)
2864  && (Sp.m_x<=p_TheProbe->m_Rect[i].m_x2)
2865  && (Sp.m_y<=p_TheProbe->m_Rect[i].m_y2))
2866  for (unsigned k=0; k<p_TheProbe->m_NoFarms; k++)
2867  {
2868  if (p_TheProbe->m_RefFarms[k]==Farm)
2869  NumberSk++; // it is in the square so increment number
2870  }
2871  }
2872  }
2873  }
2874  else if (p_TheProbe->m_NoEleTypes!=0)
2875  {
2876  for (unsigned j = 0; j < (unsigned) GetLiveArraySize( ListIndex ); j++)
2877  {
2878  Sp=TheArray[ListIndex][j]->SupplyPosition();
2879  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2880  {
2881  if ((Sp.m_x>=p_TheProbe->m_Rect[i].m_x1)
2882  && (Sp.m_y>=p_TheProbe->m_Rect[i].m_y1)
2883  && (Sp.m_x<=p_TheProbe->m_Rect[i].m_x2)
2884  && (Sp.m_y<=p_TheProbe->m_Rect[i].m_y2))
2885  for (unsigned k=0; k<p_TheProbe->m_NoEleTypes; k++)
2886  {
2887  if (p_TheProbe->m_RefEle[k]==Sp.m_EleType)
2888  NumberSk++; // it is in the square so increment number
2889  }
2890  }
2891  }
2892  }
2893  else
2894  {
2895  if (p_TheProbe->m_NoVegTypes!=0)
2896  {
2897  for (unsigned j = 0; j<(unsigned)GetLiveArraySize( ListIndex ); j++)
2898  {
2899  Sp=TheArray[ListIndex][j]->SupplyPosition();
2900  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2901  {
2902  if ((Sp.m_x>=p_TheProbe->m_Rect[i].m_x1)
2903  && (Sp.m_y>=p_TheProbe->m_Rect[i].m_y1)
2904  && (Sp.m_x<=p_TheProbe->m_Rect[i].m_x2)
2905  && (Sp.m_y<=p_TheProbe->m_Rect[i].m_y2))
2906 
2907  {
2908  for (unsigned k=0; k<p_TheProbe->m_NoVegTypes; k++)
2909  {
2910  if (p_TheProbe->m_RefVeg[k]==Sp.m_VegType)
2911  NumberSk++; // it is in the square so increment number
2912  }
2913  }
2914  }
2915  }
2916  }
2917  else // both must be zero
2918  {
2919  for (unsigned j = 0; j<(unsigned)GetLiveArraySize( ListIndex ); j++)
2920  {
2921  Sp=TheArray[ListIndex][j]->SupplyPosition();
2922  for (unsigned i=0; i<p_TheProbe->m_NoAreas; i++)
2923  {
2924  if ((Sp.m_x>=p_TheProbe->m_Rect[i].m_x1)
2925  && (Sp.m_y>=p_TheProbe->m_Rect[i].m_y1)
2926  && (Sp.m_x<=p_TheProbe->m_Rect[i].m_x2)
2927  && (Sp.m_y<=p_TheProbe->m_Rect[i].m_y2))
2928  NumberSk++; // it is in the square so increment number
2929  }
2930  }
2931  }
2932  }
2933  }
2934  return NumberSk;
2935 }
2936 //---------------------------------------------------------------------------
2937 
2943  TAnimal * /* pvo */ ,void* /* null */ ,struct_Bembidion * data,int number)
2944 {
2945  Bembidion_Adult* new_Adult;
2946  Bembidion_Pupae* new_Pupa;
2947  Bembidion_Larvae* new_Larva;
2948 
2949  for (int i=0; i<number; i++)
2950  {
2951  if (ob_type == 0)
2952  {
2953  m_EList[data->L->SupplyDayInYear()]->AddEgg(data->x, data->y);
2954  }
2955  if (ob_type == 1) {
2956  // Will not create a new larva in a square already occupied
2957  if (m_LarvaePosMap->GetMapValue( data->x, data->y ) == 0) {
2958  m_LarvaePosMap->SetMapValue( data->x, data->y );
2959  if (unsigned(TheArray[ob_type].size())>GetLiveArraySize(ob_type )) {
2960  // We need to reuse an object
2961  dynamic_cast<Bembidion_Larvae*>(TheArray[ob_type][GetLiveArraySize(ob_type) ])->ReInit(data->x, data->y, data->L, this);
2962  IncLiveArraySize(ob_type);
2963  }
2964  else {
2965  new_Larva = new Bembidion_Larvae( data->x, data->y, data->L, this );
2966  //TheArray[ ob_type ].insert( TheArray[ ob_type ].begin(), new_Larva );
2967  TheArray[ ob_type ].push_back( new_Larva );
2968  IncLiveArraySize(ob_type);
2969  }
2970  }
2971  }
2972  if (ob_type == 2)
2973  {
2974  if (unsigned(TheArray[ob_type].size())>GetLiveArraySize(ob_type)) {
2975  // We need to reuse an object
2976  dynamic_cast<Bembidion_Pupae*>(TheArray[ob_type][GetLiveArraySize(ob_type)])->ReInit(data->x, data->y, data->L, this);
2977  IncLiveArraySize(ob_type);
2978  }
2979  else {
2980  new_Pupa = new Bembidion_Pupae( data->x, data->y, data->L, this );
2981  TheArray[ ob_type ].push_back( new_Pupa );
2982  IncLiveArraySize(ob_type);
2983  }
2984  }
2985  if (ob_type == 3)
2986  {
2987  if (unsigned(TheArray[ob_type].size())>GetLiveArraySize(ob_type)) {
2988  // We need to reuse an object
2989  dynamic_cast<Bembidion_Adult*>(TheArray[ob_type][GetLiveArraySize(ob_type)])->ReInit(data->x, data->y, data->L, this);
2990  IncLiveArraySize(ob_type);
2991  }
2992  else {
2993  new_Adult = new Bembidion_Adult( data->x, data->y, data->L, this );
2994  TheArray[ ob_type ].push_back( new_Adult );
2995  IncLiveArraySize(ob_type);
2996  }
2997  }
2998  }
2999 }
3000 //-----------------------------------------------------------------------------
3001 
3002 
3003 
3008  Bembidion_Adult* FS;
3009  unsigned totalF = (unsigned)(unsigned)GetLiveArraySize( bob_Adult );
3010  int x,y;
3013  fprintf(a_prb,"%d %d %d %d %d\n", 0,w ,0, h, totalF);
3014  for (unsigned j=0; j<totalF; j++) //adult females
3015  {
3016  FS = dynamic_cast<Bembidion_Adult*>(TheArray[bob_Adult][j]);
3017  if (FS->GetCurrentStateNo() != -1) {
3018  x = FS->Supply_m_Location_x();
3019  y = FS->Supply_m_Location_y();
3020  fprintf(a_prb, "%d\t%d\n", x, y);
3021  }
3022  }
3023  fflush(a_prb);
3024 }
3025 //-----------------------------------------------------------------------------
3026 
3031  Bembidion_Adult* FS;
3032  unsigned totalF = (unsigned)GetLiveArraySize( bob_Adult );
3033  int x,y;
3036  fprintf(ReallyBigOutputPrb,"%d %d %d %d %d\n", 0,w ,0, h, totalF);
3037  for (unsigned j=0; j<totalF; j++) //adult females
3038  {
3039  FS=dynamic_cast<Bembidion_Adult*>(TheArray[3][j]);
3040  if (FS->GetCurrentStateNo() != -1) {
3041  x = FS->Supply_m_Location_x();
3042  y = FS->Supply_m_Location_y();
3043  int poly = m_TheLandscape->SupplyPolyRef(x, y);
3044  fprintf(ReallyBigOutputPrb, "%d\t%d\t%d\n", x, y, poly);
3045  }
3046  }
3047  fflush(ReallyBigOutputPrb);
3048 }
3050 {
3051  m_AOR_Probe->DoProbe(bob_Adult);
3052 }
3053 //-----------------------------------------------------------------------------
3054 
3061 
3062  // First do we have the right day?
3063  int today = m_TheLandscape->SupplyDayInYear();
3064  if (today!=1) return;
3065  // First do we have the right year?
3067  if (year%cfg_pm_eventfrequency.value()!=0) return;
3068 
3069  Bembidion_Adult* BA = NULL;
3070  // Now if the % decrease is higher or lower than 100 we need to do different things
3071  int esize=cfg_pm_eventsize.value();
3072  if (esize<100) {
3073  unsigned size2;
3074  size2 = (unsigned)GetLiveArraySize( bob_Adult );
3075  for ( unsigned j = 0; j < size2; j++ ) {
3076  if (random(100) > esize) {
3077  BA = dynamic_cast < Bembidion_Adult * > ( TheArray[ bob_Adult ] [ j ] );
3078  BA->CurrentBState=tobs_ADying; // Kill it
3079  }
3080  }
3081  }
3082  else if (esize>100) {
3083  // This also requires a copy method in the target animals
3084  // esize also needs translating 120 = 20%, 200 = 100%
3085  if (esize<200) {
3086  esize-=100;
3087  unsigned size2;
3088  size2 = (unsigned)GetLiveArraySize( bob_Adult );
3089  for ( unsigned j = 0; j < size2; j++ ) {
3090  if (random(100) < esize) {
3091  BA = dynamic_cast < Bembidion_Adult * > ( TheArray[ bob_Adult ] [ j ] );
3092  BA->CopyMyself(bob_Adult); // Duplicate it
3093  }
3094  }
3095  } else {
3096  esize-=100;
3097  esize/=100; // this will throw away fractional parts so will get 1, 2, 3 from 200, 350 400
3098  unsigned size2;
3099  size2 = (unsigned)GetLiveArraySize( bob_Adult );
3100  for ( unsigned j = 0; j < size2; j++ ) {
3101  for ( int e=0; e<esize; e++) {
3102  BA = dynamic_cast < Bembidion_Adult * > (TheArray[bob_Adult][j]);
3103  BA->CopyMyself(bob_Adult); // Duplicate it
3104  }
3105  }
3106  }
3107  }
3108  else return; // No change so do nothing
3109 }
3110 //-----------------------------------------------------------------------------
3111 #ifdef __BEETLEPESTICIDE1
3112 
3113 void Bembidion_Population_Manager::PestMortLocOutputError( void )
3114 {
3115  cout << "Cannot open output file for Bembidion pesticide location output " << "Bem_PesticideLocationMort.txt" << endl;
3116  char ch;
3117  cin >> ch;
3118  exit(1);
3119 }
3120 
3121 void Bembidion_Population_Manager::PestMortLocOutputOpen( void )
3122 {
3123  ofstream ofile("Bem_PesticideLocationMort.txt",ios::out);
3124  if ( !ofile.is_open() ) PestMortLocOutputError();
3125  ofile << "Year" << '\t' << "inCrop" << '\t' << "inField" << '\t' << "offField" << endl;
3126  ofile.close();
3127 }
3128 
3129 void Bembidion_Population_Manager::PestMortLocOutput( void )
3130 {
3131  ofstream ofile("Bem_PesticideLocationMort.txt",ios::app);
3132  if ( !ofile.is_open() ) PestMortLocOutputError();
3133  ofile << m_TheLandscape->SupplyYearNumber()-1 << '\t' << m_InCropNo << '\t' << m_InFieldNo << '\t' << m_OffFieldNo << endl;
3134  ofile.close();
3135  m_InCropNo = 0;
3136  m_InFieldNo = 0;
3137  m_OffFieldNo = 0;
3138 }
3139 
3140 void Bembidion_Population_Manager::LocOutputOpen( void )
3141 {
3142  ofstream ofile("Bem_Locations.txt",ios::out);
3143  if ( !ofile.is_open() ) PestMortLocOutputError();
3144  ofile << "Year" << '\t' << "Day" << '\t' ;
3145  for (int i=0; i< 100; i++)
3146  {
3147  ofile << "inCrop" << i << '\t' << "inField" << i << '\t' << "offField" << i << '\t';
3148  }
3149  ofile << "inCropTotal" << '\t' << "inFieldTotal" << '\t' << "offFieldTotal" << endl;
3150  ofile.close();
3151 }
3152 
3153 
3154 void Bembidion_Population_Manager::DoInFieldLocationOutput()
3155 {
3156  // Records only adults
3157  unsigned no = (unsigned)GetLiveArraySize( bob_Adult );
3158  int incrop[100];
3159  int infield[100];
3160  int offfield[100];
3161  int mw10 = (m_TheLandscape->SupplySimAreaWidth()/10);
3162  int mh10 = (m_TheLandscape->SupplySimAreaHeight()/10);
3163  // Zero the counts
3164  for (int i=0; i<100; i++)
3165  {
3166  incrop[i] = 0;
3167  infield[i] = 0;
3168  offfield[i] = 0;
3169  }
3170  for (unsigned i=0; i<no; i++)
3171  {
3172  // Need to get the element type, if a field need to check the crop
3173  APoint p = TheArray[bob_Adult][i]->SupplyPoint();
3174  // Find the right grid cell of our 100.
3175  int cell = (p.m_x / mw10) + ((p.m_y / mh10) * 10);
3177  if (tole == tole_Orchard) incrop[cell]++;
3178  else if ((tole == tole_Field) || ((tole == tole_UnsprayedFieldMargin)))
3179  {
3180  if (m_TheLandscape->SupplyVegType(p.m_x, p.m_y) == m_InCropRef) incrop[cell]++;
3181  else infield[cell]++;
3182  } else offfield[cell]++;
3183  }
3184  ofstream ofile("Bem_Locations.txt",ios::app);
3185  if ( !ofile.is_open() ) LocOutputError();
3186  ofile << m_TheLandscape->SupplyYearNumber() << '\t' << m_TheLandscape->SupplyDayInYear() << '\t';
3187  int incr=0,offc=0,offf=0;
3188  for (int i=0; i< 100; i++)
3189  {
3190  ofile << incrop[i] << '\t' << infield[i] << '\t' << offfield[i] << '\t';
3191  incr += incrop[i];
3192  offc += infield[i];
3193  offf += offfield[i];
3194  }
3195  ofile << incr << '\t' << offc << '\t' << offf << endl;
3196  ofile.close();
3197 }
3198 
3199 void Bembidion_Population_Manager::LocOutputError( void )
3200 {
3201  cout << "Cannot open output file for Bembidion location output " << "Bem_Locations.txt" << endl;
3202  char ch;
3203  cin >> ch;
3204  exit(1);
3205 }
3206 
3207 
3208 #endif
3209 
3210 
3211 
3212 
3213 
3214 
3215 
3216 
3217 
3218 
3219 
Bembidion_Adult::SetPPPThreshold
void SetPPPThreshold(double a_thresh)
Definition: bembidion_all.h:310
insecticide_treat
Definition: treatment.h:74
struct_Bembidion::HowMany
int HowMany
Definition: bembidion_all.h:121
bob_Egg
Definition: bembidion_all.h:62
ttop_ReproductiveEffects
Definition: landscape.h:69
tole_HedgeBank
Definition: tole_declaration.h:68
param_List15::nsteps
int nsteps
Definition: bembidion_all.h:108
Bembidion_Adult::BeginStep
virtual void BeginStep()
Adult BeginStep.
Definition: Bembidion_all.cpp:2189
tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
Bembidion_Adult::st_Aging
bool st_Aging()
Daily ageing.
Definition: Bembidion_all.cpp:1681
strigling
Definition: treatment.h:77
PupaDevelConst2
const double PupaDevelConst2
Day degree constant.
Definition: Bembidion_all.cpp:126
tobs_PDeveloping
Definition: bembidion_all.h:45
Bembidion_Egg_List::AddEgg
void AddEgg(int x, int y)
Add an egg to the list.
Definition: bembidion_all.h:188
Bembidion_Pupae::m_AgeDegrees
double m_AgeDegrees
Record pupal day degrees.
Definition: bembidion_all.h:281
LarvalDailyMort
const double LarvalDailyMort[3][6]
Daily fixed mortality probability based on three larval stages and temperature.
Definition: Bembidion_all.cpp:114
hay_bailing
Definition: treatment.h:89
struct_Bembidion::L
Landscape * L
Definition: bembidion_all.h:119
cfg_SavePesticideMortLocation
static CfgBool cfg_SavePesticideMortLocation("BEM_SAVEPESTMORTLOC", CFG_CUSTOM, false)
Controls whether pesticide mortality location should be recorded.
EggDevelConst2
const double EggDevelConst2
Day degree constant.
Definition: Bembidion_all.cpp:122
flower_cutting
Definition: treatment.h:109
param_List15::BeenThereY
int BeenThereY[101]
Definition: bembidion_all.h:107
autumn_roll
Definition: treatment.h:38
Landscape::TranslateVegTypes
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: landscape.h:1655
spring_sow_with_ferti
Definition: treatment.h:103
Bembidion_Adult::DDepMort
bool DDepMort()
Density-dependent mortality.
Definition: Bembidion_all.cpp:2321
Population_Manager::m_catastrophestartyear
int m_catastrophestartyear
Definition: populationmanager.h:532
Landscape::SupplyTemp
double SupplyTemp(void)
Definition: landscape.h:1386
Population_Manager::DoLast
virtual void DoLast()
Definition: PopulationManager.cpp:530
Bembidion_Larvae::st_Develop
int st_Develop()
Larvae state development.
Definition: Bembidion_all.cpp:885
Bembidion_Adult::Bembidion_Adult
Bembidion_Adult(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
Definition: Bembidion_all.cpp:1366
Bembidion_Adult::pPoint
static param_Point pPoint
A helper attribute when simulating movement.
Definition: bembidion_all.h:367
Landscape::SupplyVegType
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1321
Bembidion_Adult::OldDirection
int OldDirection
The last direction moved.
Definition: bembidion_all.h:359
probe_data::m_NoAreas
unsigned m_NoAreas
Definition: populationmanager.h:292
Landscape::SupplyElementType
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
Bembidion_Larvae::st_Pupate
void st_Pupate()
Larvae state pupation.
Definition: Bembidion_all.cpp:928
Bembidion_Population_Manager
The population manager class for beetles.
Definition: bembidion_all.h:385
Bembidion_Pupae::st_Develop
int st_Develop()
Pupal state development.
Definition: Bembidion_all.cpp:1235
ttop_AcuteDelayedEffects
Definition: landscape.h:76
param_List15
Definition: bembidion_all.h:103
Bembidion_Adult::~Bembidion_Adult
virtual ~Bembidion_Adult()
Definition: Bembidion_all.cpp:1378
Bembidion_Population_Manager::CreateObjects
void CreateObjects(int ob_type, TAnimal *pvo, void *null, struct_Bembidion *data, int number)
Method to add beetles to the population.
Definition: Bembidion_all.cpp:2942
cfg_Pupa_SoilCultivationMortality
static CfgFloat cfg_Pupa_SoilCultivationMortality("BEM_PUPAESOILMORT", CFG_CUSTOM, 0.500)
probe_data::m_RefFarms
unsigned m_RefFarms[25]
Definition: populationmanager.h:299
Bembidion_Adult::CanReproduce
void CanReproduce()
Does reproduction if possible.
Definition: Bembidion_all.cpp:1862
Bembidion_Larvae::ReInit
void ReInit(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
ReInit for object pool.
Definition: Bembidion_all.cpp:656
Population_Manager::TheArray
vector< TListOfAnimals > TheArray
Definition: populationmanager.h:534
Vector_x
const int Vector_x[8]
Bembidion_Adult::Reproduce
void Reproduce(int p_x, int p_y)
Produces the eggs.
Definition: Bembidion_all.cpp:1910
Bembidion_Population_Manager::TheRipleysOutputProbe
virtual void TheRipleysOutputProbe(FILE *a_prb)
Special output functionality.
Definition: Bembidion_all.cpp:3007
Bembidion_Larvae::Step
virtual void Step()
Larvae Step code.
Definition: Bembidion_all.cpp:961
Population_Manager::m_population_type
TTypesOfPopulation m_population_type
Definition: populationmanager.h:580
fa_ammoniumsulphate
Definition: treatment.h:65
cfg_PesticideTrialPupaeTreatmentMort
static CfgInt cfg_PesticideTrialPupaeTreatmentMort("BEM_PTRIALPUPAEMORT", CFG_CUSTOM, 0)
autumn_harrow
Definition: treatment.h:37
cfg_LDDepMort1
static CfgInt cfg_LDDepMort1("BEM_LDDEPMORTONE", CFG_CUSTOM, 0)
Larval density dependent mortality.
Bembidion_Population_Manager::m_EPopSize
int m_EPopSize
To store the current population size.
Definition: bembidion_all.h:455
bob_Adult
Definition: bembidion_all.h:65
cfg_beetlestartnos
static CfgInt cfg_beetlestartnos("BEM_STARTNO", CFG_CUSTOM, 10000)
Controls the numbers of adults entering the simulation.
preseeding_cultivator
Definition: treatment.h:39
Bembidion_Population_Manager::m_LDayDeg
double m_LDayDeg[365][3]
Storage for daily day degrees for larve.
Definition: bembidion_all.h:463
cfg_Adult_SoilCultivationMortality
static CfgFloat cfg_Adult_SoilCultivationMortality("BEM_ADULTSOILMORT", CFG_CUSTOM, 0.270)
cfg_Egg_SoilCultivationMortality
static CfgFloat cfg_Egg_SoilCultivationMortality("BEM_EGGSOILMORT", CFG_CUSTOM, 0.500)
flammebehandling
Definition: treatment.h:78
Bembidion_Pupae::st_Emerge
void st_Emerge()
Pupal state emergence.
Definition: Bembidion_all.cpp:1281
Bembidion_Adult::st_Aggregate
int st_Aggregate()
Aggregation behaviour.
Definition: Bembidion_all.cpp:1624
autumn_sow
Definition: treatment.h:41
probe_data::m_Rect
rectangle m_Rect[10]
Definition: populationmanager.h:293
ttop_NoPesticide
Definition: landscape.h:67
Bembidion_Base
The class describing the base class for beetle objects objects.
Definition: bembidion_all.h:141
glyphosate
Definition: treatment.h:102
cfg_SaveInfieldLocation
static CfgBool cfg_SaveInfieldLocation("BEM_SAVEINFIELDLOC", CFG_CUSTOM, false)
Controls whether in-field off-field location should be recorded.
harvest
Definition: treatment.h:82
Population_Manager::ReallyBigOutputPrb
FILE * ReallyBigOutputPrb
Definition: populationmanager.h:595
param_Point::x
int x
Definition: bembidion_all.h:97
Bembidion_Population_Manager::m_AdultPosMap
SimplePositionMap * m_AdultPosMap
Optimsied map of adult positions.
Definition: bembidion_all.h:472
tobs_PDying
Definition: bembidion_all.h:47
Bembidion_Population_Manager::Bembidion_Population_Manager
Bembidion_Population_Manager(Landscape *p_L)
Constructor.
Definition: Bembidion_all.cpp:2355
TAnimal::m_OurLandscape
Landscape * m_OurLandscape
Definition: populationmanager.h:229
Bembidion_Egg_List::m_DayMade
int m_DayMade
Definition: bembidion_all.h:207
fp_slurry
Definition: treatment.h:52
Bembidion_Population_Manager::Init
virtual void Init(void)
Intialises the population manager.
Definition: Bembidion_all.cpp:2408
Bembidion_Pupae::KillThis
virtual void KillThis()
Kill this pupa.
Definition: Bembidion_all.cpp:1297
DailyAdultMort
const double DailyAdultMort
Daily fixed mortality probability.
Definition: Bembidion_all.cpp:112
Bembidion_Population_Manager::m_AdPopSize
int m_AdPopSize
To store the current population size.
Definition: bembidion_all.h:453
DipsersalDayDegrees
const int DipsersalDayDegrees
Definition: Bembidion_all.cpp:141
Bembidion_Egg_List
The class describing the beetle Egg_List objects.
Definition: bembidion_all.h:172
tobs_EDying
Definition: bembidion_all.h:39
Population_Manager::OpenTheRipleysOutputProbe
bool OpenTheRipleysOutputProbe(string a_NWordFilename)
Definition: PopulationManager.cpp:757
cfg_pm_eventsize
CfgInt cfg_pm_eventsize
tole_RoadsideVerge
Definition: tole_declaration.h:38
fp_rsm
Definition: treatment.h:58
fa_sludge
Definition: treatment.h:68
Bembidion_Population_Manager::DoAlmostLast
virtual void DoAlmostLast(void)
Removes dead or pupated larvae from the simulation.
Definition: Bembidion_all.cpp:2736
fa_rsm
Definition: treatment.h:69
cfg_BemAdultPPPEffectProb
static CfgFloat cfg_BemAdultPPPEffectProb("BEM_ADPPPEFFECTPROB", CFG_CUSTOM, 0, 0.0, 1.0)
The probability of daily effect per day on threshold excedence.
Bembidion_Adult::st_Forage
int st_Forage()
Foraging behaviour.
Definition: Bembidion_all.cpp:1604
WARN_BUG
Definition: maperrormsg.h:34
Bembidion_Population_Manager::LDDepMort1
double LDDepMort1
Storage for density-dependent mortality parameter.
Definition: bembidion_all.h:476
cfg_Pupa_InsecticideApplication
static CfgFloat cfg_Pupa_InsecticideApplication("BEM_PUPAEINSECTICIDEMORT", CFG_CUSTOM, 0.800)
fp_greenmanure
Definition: treatment.h:56
StartAggregatingDayProb
const int StartAggregatingDayProb
Definition: Bembidion_all.cpp:151
Population_Manager::m_SimulationName
char m_SimulationName[255]
Definition: populationmanager.h:513
AnimalPosition::m_x
unsigned m_x
Definition: populationmanager.h:172
cfg_BemAdultPPPElimiationRate
static CfgFloat cfg_BemAdultPPPElimiationRate("BEM_ADPPPELIMIATIONRATE", CFG_CUSTOM, 0.0, 0.0, 1.0)
Pesticide body burden is multiplied by this daily.
Bembidion_Population_Manager::SupplyEDayDeg
double SupplyEDayDeg(int day)
Get egg day degress for a specific day.
Definition: bembidion_all.h:416
Bembidion_Population_Manager::~Bembidion_Population_Manager
virtual ~Bembidion_Population_Manager()
Destructor.
Definition: Bembidion_all.cpp:2393
rectangle::m_y1
unsigned m_y1
Definition: populationmanager.h:101
straw_removal
Definition: treatment.h:112
Population_Manager::GetLiveArraySize
unsigned GetLiveArraySize(int a_listindex)
Gets the number of 'live' objects for a list index in the TheArray.
Definition: populationmanager.h:433
hay_turning
Definition: treatment.h:88
cfg_Adult_InsecticideApplication
static CfgFloat cfg_Adult_InsecticideApplication("BEM_ADULTINSECTICIDEMORT", CFG_CUSTOM, 0.800)
DevelopmentInflectionPoint
const double DevelopmentInflectionPoint
Inflection point in larval day degree calculations.
Definition: Bembidion_all.cpp:118
cfg_SaveInfieldLocationStartDay
static CfgInt cfg_SaveInfieldLocationStartDay("BEM_INCROPREFSTARTDAY", CFG_CUSTOM, -2)
Start day in year to record in-field locations.
bulb_harvest
Definition: treatment.h:110
TAnimal::Supply_m_Location_x
int Supply_m_Location_x()
Definition: populationmanager.h:213
Bembidion_Base::CopyMyself
void CopyMyself(int a_beetle)
For experimental purposes.
Definition: Bembidion_all.cpp:240
straw_covering
Definition: treatment.h:111
shallow_harrow
Definition: treatment.h:107
tobs_Destroy
Definition: bembidion_all.h:55
heavy_cultivator_aggregate
Definition: treatment.h:108
probe_data::m_NoVegTypes
unsigned m_NoVegTypes
Definition: populationmanager.h:295
SimulationName
const char * SimulationName
Definition: Bembidion_all.cpp:93
water
Definition: treatment.h:80
Bembidion_Pupae::Bembidion_Pupae
Bembidion_Pupae(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
Pupae class constructor.
Definition: Bembidion_all.cpp:1020
Bembidion_Population_Manager::m_PPopSize
int m_PPopSize
To store the current population size.
Definition: bembidion_all.h:459
cfg_BemAdultPPPEffectProbDecay
static CfgFloat cfg_BemAdultPPPEffectProbDecay("BEM_ADPPPEFFECTPROBDECAY", CFG_CUSTOM, 0, 0.0, 1.0)
The probability of daily effect per day on threshold excedence.
cfg_PesticideTrialEggTreatmentMort
static CfgInt cfg_PesticideTrialEggTreatmentMort("BEM_PTRIALEGGMORT", CFG_CUSTOM, 0)
Bembidion_Population_Manager::TheAOROutputProbe
virtual void TheAOROutputProbe()
Special output functionality.
Definition: Bembidion_all.cpp:3049
fp_liquidNH3
Definition: treatment.h:51
Vector_y
const int Vector_y[8]
FieldHibernateChance
const int FieldHibernateChance
Definition: Bembidion_all.cpp:143
tole_MownGrass
Definition: tole_declaration.h:74
molluscicide
Definition: treatment.h:75
Bembidion_Population_Manager::m_LarvaePosMap
SimplePositionMap * m_LarvaePosMap
Optimised map of larval positions.
Definition: bembidion_all.h:470
AdultTurnRate
const int AdultTurnRate
Definition: Bembidion_all.cpp:147
cfg_Egg_InsecticideApplication
static CfgFloat cfg_Egg_InsecticideApplication("BEM_EGGINSECTICIDEMORT", CFG_CUSTOM, 0)
burn_straw_stubble
Definition: treatment.h:92
struct_Bembidion::y
int y
Definition: bembidion_all.h:118
tole_YoungForest
Definition: tole_declaration.h:55
rectangle::m_x2
unsigned m_x2
Definition: populationmanager.h:102
Population_Manager::SimW
int SimW
Definition: populationmanager.h:511
Bembidion_Pupae::BeginStep
virtual void BeginStep()
Pupae BeginStep code.
Definition: Bembidion_all.cpp:1304
struct_Bembidion::DayDegrees
int DayDegrees
Definition: bembidion_all.h:116
Bembidion_Base::ReInit
void ReInit(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
ReInit for object pool.
Definition: Bembidion_all.cpp:213
param_Point::y
int y
Definition: bembidion_all.h:98
Bembidion_Population_Manager::m_LPopSize
int m_LPopSize
To store the current population size.
Definition: bembidion_all.h:457
Bembidion_Adult::pList
static param_List15 pList
A helper attribute when simulating movement.
Definition: bembidion_all.h:365
g_msg
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:41
tobs_LDeveloping
Definition: bembidion_all.h:41
Bembidion_Base::Bembidion_Base
Bembidion_Base(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
Constructor.
Definition: Bembidion_all.cpp:205
DailyEggMort
const double DailyEggMort
Daily fixed mortality probability.
Definition: Bembidion_all.cpp:106
cattle_out_low
Definition: treatment.h:100
Population_Manager::m_AOR_Probe
AOR_Probe * m_AOR_Probe
Definition: populationmanager.h:526
Bembidion_Adult::SetAdultPPPElimRate
void SetAdultPPPElimRate(double a_rate)
Definition: bembidion_all.h:316
fp_pk
Definition: treatment.h:50
fa_npk
Definition: treatment.h:61
probe_data::m_RefEle
TTypesOfLandscapeElement m_RefEle[25]
Definition: populationmanager.h:298
Landscape
The landscape class containing all environmental and topographical data.
Definition: landscape.h:112
Population_Manager::LamdaClear
void LamdaClear()
Definition: populationmanager.h:609
cattle_out
Definition: treatment.h:83
Population_Manager::LamdaBirth
void LamdaBirth(int x, int y)
Definition: populationmanager.h:603
PesticideTrialEggToxicMort
const int PesticideTrialEggToxicMort
Definition: Bembidion_all.cpp:193
cfg_ReallyBigOutput_used
CfgBool cfg_ReallyBigOutput_used
fp_npk
Definition: treatment.h:49
Bembidion_Adult::MoveTo
void MoveTo(int p_dist, unsigned p_direction, int p_turning)
Moves attempting egg laying under way.
Definition: Bembidion_all.cpp:1746
fa_npks
Definition: treatment.h:60
stubble_harrowing
Definition: treatment.h:90
cfg_DDepRange
static CfgInt cfg_DDepRange("BEM_DDEPRANGE", CFG_CUSTOM, 3)
Adult/Larve density dependent range.
Bembidion_Larvae::KillThis
virtual void KillThis()
Kill this larva.
Definition: Bembidion_all.cpp:946
Landscape::SupplyPesticide
double SupplyPesticide(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets total pesticide for a location.
Definition: Landscape.cpp:586
Landscape::SupplyDayInMonth
int SupplyDayInMonth(void)
Definition: landscape.h:1606
stubble_plough
Definition: treatment.h:35
autumn_plough
Definition: treatment.h:34
probe_data::m_RefVeg
TTypesOfVegetation m_RefVeg[25]
Definition: populationmanager.h:297
PesticideTrialLarvaeToxicMort
const int PesticideTrialLarvaeToxicMort
Definition: Bembidion_all.cpp:191
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
Landscape::SupplyFarmOwner
int SupplyFarmOwner(int a_x, int a_y)
Definition: landscape.h:1152
fp_manure
Definition: treatment.h:55
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
TAnimal::m_Location_y
int m_Location_y
Definition: populationmanager.h:228
strigling_sow
Definition: treatment.h:95
bob_Larva
Definition: bembidion_all.h:63
tobs_Pupating
Definition: bembidion_all.h:42
cfg_BemAdultPPPThreshold
static CfgFloat cfg_BemAdultPPPThreshold("BEM_ADPPPTHRESHOLD", CFG_CUSTOM, 9999999999.9)
Adult PPP threshold for effect.
CfgBool
Bool configurator entry class.
Definition: configurator.h:127
tole_PermPasture
Definition: tole_declaration.h:47
cfg_MaxDailyMovement
static CfgInt cfg_MaxDailyMovement("BEM_MAXDAILYMOVEMENT", CFG_CUSTOM, 14)
Max daily movement in m.
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
Bembidion_Adult::st_Dispersal
int st_Dispersal()
Intiate Dispersal behaviour.
Definition: Bembidion_all.cpp:1669
Population_Manager::LamdaDumpOutput
void LamdaDumpOutput()
Definition: PopulationManager.cpp:657
TAnimal
The base class for all ALMaSS animal classes.
Definition: populationmanager.h:205
param_Point
Definition: bembidion_all.h:94
DailyLarvaeMort
const double DailyLarvaeMort
Daily fixed mortality probability.
Definition: Bembidion_all.cpp:108
winter_plough
Definition: treatment.h:42
LDevelConst2
const double LDevelConst2[3]
Day degree constant.
Definition: Bembidion_all.cpp:124
Bembidion_Population_Manager::Catastrophe
virtual void Catastrophe()
Method to arbitrarily alter populations size.
Definition: Bembidion_all.cpp:3060
AnimalPosition
A class defining an animals position.
Definition: populationmanager.h:168
Bembidion_Adult::ReInit
void ReInit(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
ReInit for object pool.
Definition: Bembidion_all.cpp:1372
cfg_RipleysOutput_used
CfgBool cfg_RipleysOutput_used
Bembidion_Adult::m_CanReproduce
bool m_CanReproduce
Signal reproductive readiness.
Definition: bembidion_all.h:363
Population_Manager::BeforeStepActions
unsigned BeforeStepActions[12]
Definition: populationmanager.h:542
Bembidion_Larvae::DailyMortality
virtual bool DailyMortality()
Larvae non-temperature or density related mortality.
Definition: Bembidion_all.cpp:1004
tobs_Hatching
Definition: bembidion_all.h:38
Bembidion_Adult::DailyMortality
virtual bool DailyMortality()
Density-independent mortality.
Definition: Bembidion_all.cpp:2306
Bembidion_Adult::SetPPPEffectProbDecay
void SetPPPEffectProbDecay(double a_decay)
Definition: bembidion_all.h:314
Bembidion_Egg_List::st_Develop
int st_Develop()
Egg_List state development.
Definition: Bembidion_all.cpp:289
Bembidion_Egg_List::Bembidion_Egg_List
Bembidion_Egg_List(int today, Bembidion_Population_Manager *BPM, Landscape *L)
Egg_List class constructor.
Definition: Bembidion_all.cpp:281
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
probe_data
Data structure to hold & output probe data probe data is designed to be used to return the number of ...
Definition: populationmanager.h:283
fp_sludge
Definition: treatment.h:57
Population_Manager
Base class for all population managers.
Definition: populationmanager.h:424
Bembidion_Population_Manager::LDDepMort0
int LDDepMort0
Storage for density-dependent mortality parameter.
Definition: bembidion_all.h:474
straw_chopping
Definition: treatment.h:87
fungicide_treat
Definition: treatment.h:73
deep_ploughing
Definition: treatment.h:43
preseeding_cultivator_sow
Definition: treatment.h:40
Bembidion_Larvae
The class describing the beetle larvae objects.
Definition: bembidion_all.h:217
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Definition: landscape.h:1596
mow
Definition: treatment.h:93
fa_pk
Definition: treatment.h:62
struct_Bembidion::x
int x
Definition: bembidion_all.h:117
TALMaSSObject::m_StepDone
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: populationmanager.h:118
Bembidion_Adult::m_currentPPPEffectProb
double m_currentPPPEffectProb
Current effect probability.
Definition: bembidion_all.h:373
Landscape::SupplyPesticideType
TTypesOfPesticide SupplyPesticideType(void)
Definition: landscape.h:433
Bembidion_Adult::m_EggCounter
int m_EggCounter
The number of eggs produced.
Definition: bembidion_all.h:361
rectangle::m_y2
unsigned m_y2
Definition: populationmanager.h:103
MaxDailyMovement
int MaxDailyMovement
Definition: Bembidion_all.cpp:145
spring_harrow
Definition: treatment.h:45
Bembidion_Adult::InternalPesticideHandlingAndResponse
virtual void InternalPesticideHandlingAndResponse()
Hand pesticide events code for the beetle.
Definition: Bembidion_all.cpp:2157
tobs_Aggregating
Definition: bembidion_all.h:50
Landscape::SupplyYearNumber
int SupplyYearNumber(void)
Definition: landscape.h:1616
Bembidion_Population_Manager::ADDepMort1
double ADDepMort1
Storage for density-dependent mortality parameter.
Definition: bembidion_all.h:480
tole_NaturalGrassWet
Definition: tole_declaration.h:87
DevelConst1
const double DevelConst1
Day degree threshold constant for all stages.
Definition: Bembidion_all.cpp:120
tole_Orchard
Definition: tole_declaration.h:71
Bembidion_Adult::MoveToAggr
int MoveToAggr(int p_dist, unsigned p_direction, int p_turning)
Moves using a stopping rule for hibernation.
Definition: Bembidion_all.cpp:1974
Bembidion_Adult::m_negDegrees
double m_negDegrees
The number of negative day degrees experienced.
Definition: bembidion_all.h:354
tobs_ADying
Definition: bembidion_all.h:53
AnimalPosition::m_EleType
TTypesOfLandscapeElement m_EleType
Definition: populationmanager.h:174
g_SpeedyDivides
double g_SpeedyDivides[2001]
Facilitating array for divisions by integers (= *1/N)
Definition: Landscape.cpp:250
Bembidion_Adult::m_body_burden
double m_body_burden
Current body burden of pesticide.
Definition: bembidion_all.h:371
AdultEggLayingThreshold
const double AdultEggLayingThreshold
Temperature threshold for egg laying.
Definition: Bembidion_all.cpp:134
CfgFloat::value
double value(void)
Definition: configurator.h:118
struct_Bembidion::BPM
Bembidion_Population_Manager * BPM
Definition: bembidion_all.h:120
AnimalPosition::m_y
unsigned m_y
Definition: populationmanager.h:173
Bembidion_Adult::SetPPPEffectProb
void SetPPPEffectProb(double a_conc)
Definition: bembidion_all.h:312
Bembidion_Pupae
The class describing the beetle pupae objects.
Definition: bembidion_all.h:255
cfg_Larva_SoilCultivationMortality
static CfgFloat cfg_Larva_SoilCultivationMortality("BEM_LARVAESOILMORT", CFG_CUSTOM, 0.500)
Bembidion_Population_Manager::DoBefore
virtual void DoBefore(void)
Replaces the Step function for the Egg_List.
Definition: Bembidion_all.cpp:2671
Bembidion_Pupae::DailyMortality
virtual bool DailyMortality()
Pupae non-temperature or density related mortality.
Definition: Bembidion_all.cpp:1352
Bembidion_Population_Manager::m_EList
Bembidion_Egg_List * m_EList[365]
Replacement for TheArray[0].
Definition: bembidion_all.h:484
Bembidion_Adult::Step
virtual void Step()
Adult Step.
Definition: Bembidion_all.cpp:2213
Bembidion_Population_Manager::SupplyLDayDeg
double SupplyLDayDeg(int L, int day)
Get larval day degress for a specific dayand instar.
Definition: bembidion_all.h:418
above12Larvae
const double above12Larvae[3]
Day degree constant above inflection point.
Definition: Bembidion_all.cpp:130
struct_Bembidion
A data class for Bembidion data.
Definition: bembidion_all.h:113
Bembidion_Larvae::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Larvae reactions to management events.
Definition: Bembidion_all.cpp:664
Bembidion_Base::CurrentBState
TTypesOfBeetleState CurrentBState
Current behavioural state.
Definition: bembidion_all.h:159
hilling_up
Definition: treatment.h:79
tobs_Emerging
Definition: bembidion_all.h:46
bob_Pupa
Definition: bembidion_all.h:64
TAnimal::CopyMyself
virtual void CopyMyself()
Definition: populationmanager.h:224
cfg_BeetleHarvestMort
static CfgFloat cfg_BeetleHarvestMort("BEM_HARVESTMORT", CFG_CUSTOM, 0.290)
Bembidion_Adult::m_AdultPPPElimRate
static double m_AdultPPPElimRate
the daily elimination rate for pesticides
Definition: bembidion_all.h:369
Bembidion_Base::st_Die
virtual void st_Die()
Common state Die.
Definition: Bembidion_all.cpp:224
biocide
Definition: treatment.h:104
Population_Manager::StateNames
const char * StateNames[100]
Definition: populationmanager.h:531
ppp_1
Definition: farm.h:422
Bembidion_Larvae::BeginStep
virtual void BeginStep()
Larvae class BeginStep code.
Definition: Bembidion_all.cpp:953
cfg_LDDepMort0
static CfgInt cfg_LDDepMort0("BEM_LDDEPMORTZERO", CFG_CUSTOM, 3)
Larval density dependent mortality.
DailyPupaeMort
const double DailyPupaeMort
Daily fixed mortality probability.
Definition: Bembidion_all.cpp:110
fa_calcium
Definition: treatment.h:70
CFG_CUSTOM
Definition: configurator.h:60
syninsecticide_treat
Definition: treatment.h:99
fa_manure
Definition: treatment.h:66
tole_PermPastureTussocky
Definition: tole_declaration.h:45
fp_npks
Definition: treatment.h:48
row_cultivation
Definition: treatment.h:76
Bembidion_Adult
The class describing the adult (female) beetle objects.
Definition: bembidion_all.h:291
Population_Manager::m_TheLandscape
Landscape * m_TheLandscape
Definition: populationmanager.h:515
Bembidion_Adult::Init
void Init()
Intitialise attribute values.
Definition: Bembidion_all.cpp:1383
trial_insecticidetreat
Definition: treatment.h:96
cfg_PesticideTrialLarvaeTreatmentMort
static CfgInt cfg_PesticideTrialLarvaeTreatmentMort("BEM_PTRIALLARVAEMORT", CFG_CUSTOM, 0)
Population_Manager::OpenTheReallyBigProbe
bool OpenTheReallyBigProbe()
Definition: PopulationManager.cpp:859
cfg_pm_eventfrequency
CfgInt cfg_pm_eventfrequency
Bembidion_Adult::st_Hibernate
int st_Hibernate()
Hibernation behaviour.
Definition: Bembidion_all.cpp:1635
tole_Field
Definition: tole_declaration.h:43
ttop_AcuteEffects
Definition: landscape.h:68
Bembidion_Larvae::Bembidion_Larvae
Bembidion_Larvae(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
Larvae class constructor.
Definition: Bembidion_all.cpp:647
Bembidion_Adult::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Adult reactions to management events.
Definition: Bembidion_all.cpp:1397
tole_FieldBoundary
Definition: tole_declaration.h:40
Bembidion_Pupae::ReInit
void ReInit(int x, int y, Landscape *L, Bembidion_Population_Manager *BPM)
ReInit for object pool.
Definition: Bembidion_all.cpp:1028
Bembidion_Egg_List::st_Hatch
void st_Hatch()
Egg_List state hatching.
Definition: Bembidion_all.cpp:300
Bembidion_Population_Manager::m_PDayDeg
double m_PDayDeg[365]
Storage for daily day degrees for pupae.
Definition: bembidion_all.h:465
tole_PermPastureLowYield
Definition: tole_declaration.h:44
tole_WaterBufferZone
Definition: tole_declaration.h:108
TOP_Beetle
Definition: populationmanager.h:63
Population_Manager::SimH
int SimH
Definition: populationmanager.h:511
Bembidion_Base::CopyMyselfB
void CopyMyselfB(int a_beetle)
For experimental purposes.
Definition: Bembidion_all.cpp:258
fp_ammoniumsulphate
Definition: treatment.h:54
rectangle::m_x1
unsigned m_x1
Definition: populationmanager.h:100
Bembidion_Adult::m_PPPThreshold
static double m_PPPThreshold
PPP effects threshold.
Definition: bembidion_all.h:375
CfgInt
Integer configurator entry class.
Definition: configurator.h:87
stubble_cultivator_heavy
Definition: treatment.h:36
Population_Manager::m_ListNameLength
unsigned m_ListNameLength
Definition: populationmanager.h:538
Bembidion_Population_Manager::TheReallyBigOutputProbe
virtual void TheReallyBigOutputProbe()
Special output functionality.
Definition: Bembidion_all.cpp:3030
TALMaSSObject::GetCurrentStateNo
int GetCurrentStateNo()
Returns the current state number.
Definition: populationmanager.h:121
Bembidion_Larvae::m_AgeDegrees
double m_AgeDegrees
Record larvae day degrees.
Definition: bembidion_all.h:242
spring_plough
Definition: treatment.h:44
Bembidion_Pupae::Step
virtual void Step()
Pupae Step code.
Definition: Bembidion_all.cpp:1312
Farm
The base class for all farm types.
Definition: farm.h:767
Bembidion_Pupae::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Pupal reactions to management events.
Definition: Bembidion_all.cpp:1035
fa_greenmanure
Definition: treatment.h:67
tobs_Dispersing
Definition: bembidion_all.h:52
Bembidion_Population_Manager::SupplyPDayDeg
double SupplyPDayDeg(int day)
Get pupal day degress for a specific day.
Definition: bembidion_all.h:420
cfg_BeetleStriglingMort
static CfgFloat cfg_BeetleStriglingMort("BEM_STRIGLINGMORT", CFG_CUSTOM, 0.250)
TTypesOfLandscapeElement
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
Bembidion_Population_Manager::ADDepMort0
int ADDepMort0
Storage for density-dependent mortality parameter.
Definition: bembidion_all.h:478
tobs_EDeveloping
Definition: bembidion_all.h:37
param_Point::direction
unsigned direction
Definition: bembidion_all.h:99
cfg_AOROutput_used
CfgBool cfg_AOROutput_used
TAnimal::CheckManagement
void CheckManagement(void)
Definition: PopulationManager.cpp:1404
probe_data::m_NoEleTypes
unsigned m_NoEleTypes
Definition: populationmanager.h:294
Bembidion_Population_Manager::DoFirst
virtual void DoFirst(void)
Does day degree development calculations here.
Definition: Bembidion_all.cpp:2559
TAnimal::Supply_m_Location_y
int Supply_m_Location_y()
Definition: populationmanager.h:216
Bembidion_Adult::EndStep
virtual void EndStep()
Adult EndStep.
Definition: Bembidion_all.cpp:2197
probe_data::m_NoFarms
unsigned m_NoFarms
Definition: populationmanager.h:296
fp_calcium
Definition: treatment.h:59
CfgFloat
Double configurator entry class.
Definition: configurator.h:106
Bembidion_Pupae::m_DayMade
int m_DayMade
Definition: bembidion_all.h:283
trial_toxiccontrol
Definition: treatment.h:97
spring_roll
Definition: treatment.h:46
Bembidion_Base::m_OurPopulation
Bembidion_Population_Manager * m_OurPopulation
Pointer to the population manager.
Definition: bembidion_all.h:161
fa_manganesesulphate
Definition: treatment.h:64
bed_forming
Definition: treatment.h:106
cut_weeds
Definition: treatment.h:94
Bembidion_Population_Manager::m_EDayDeg
double m_EDayDeg[365]
Storage for daily day degrees for eggs.
Definition: bembidion_all.h:461
CfgInt::value
int value(void)
Definition: configurator.h:98
Bembidion_Egg_List::SortXR
void SortXR()
Definition: Bembidion_all.cpp:634
fp_manganesesulphate
Definition: treatment.h:53
herbicide_treat
Definition: treatment.h:71
EggProductionSlope
const double EggProductionSlope
Definition: Bembidion_all.cpp:135
PesticideTrialAdultToxicMort
const int PesticideTrialAdultToxicMort
Definition: Bembidion_all.cpp:187
PesticideTrialPupaeToxicMort
const int PesticideTrialPupaeToxicMort
Definition: Bembidion_all.cpp:189
tobs_LDying
Definition: bembidion_all.h:43
ttop_MultipleEffects
Definition: landscape.h:74
cfg_ADDepMort1
static CfgInt cfg_ADDepMort1("BEM_ADDEPMORTONE", CFG_CUSTOM, 10)
Chance of death if there is another adult within the density-dependent range square this beetle is in...
Bembidion_Egg_List::BeginStep
virtual void BeginStep()
Egg_List class BeginStep code.
Definition: Bembidion_all.cpp:323
cfg_ReallyBigOutputMonthly_used
CfgBool cfg_ReallyBigOutputMonthly_used
Bembidion_Larvae::m_LarvalStage
int m_LarvalStage
Current larval growth stage (1-3)
Definition: bembidion_all.h:244
above12Pupae
const double above12Pupae
Day degree constant above inflection point.
Definition: Bembidion_all.cpp:132
growth_regulator
Definition: treatment.h:72
Bembidion_Egg_List::EggList
TListOfEggs EggList
The list of eggs.
Definition: bembidion_all.h:197
Bembidion_Population_Manager::TodaysEggProduction
int TodaysEggProduction
Daily temperature determined egg production.
Definition: bembidion_all.h:482
cut_to_silage
Definition: treatment.h:86
TALMaSSObject::ReinitialiseObject
virtual void ReinitialiseObject()
Used to re-use an object - must be implemented in descendent classes.
Definition: populationmanager.h:143
product_treat
Definition: treatment.h:101
FarmToDo
FarmToDo
Definition: treatment.h:31
StartAggregatingDay
const int StartAggregatingDay
Definition: Bembidion_all.cpp:149
tobs_Hibernating
Definition: bembidion_all.h:51
cfg_SaveInfieldLocationInterval
static CfgInt cfg_SaveInfieldLocationInterval("BEM_INCROPREFINTERVAL", CFG_CUSTOM, 10000)
Interval for recording in-crop locations - > 364 is ignored.
TALMaSSObject::m_CurrentStateNo
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: populationmanager.h:116
Bembidion_Population_Manager::Probe
virtual float Probe(int ListIndex, probe_data *p_TheProbe)
Overides the Population_Manager::Probe method.
Definition: Bembidion_all.cpp:2745
tole_Hedges
Definition: tole_declaration.h:37
pigs_out
Definition: treatment.h:84
Landscape::SupplyLastTreatment
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1331
trial_control
Definition: treatment.h:98
Bembidion_Adult::m_HibernateDegrees
double m_HibernateDegrees
The number of day degrees experienced in the spring which may trigger dispersal.
Definition: bembidion_all.h:356
Bembidion_Population_Manager::DoLast
virtual void DoLast(void)
Adds output adult locations to DoLast.
Definition: Bembidion_all.cpp:2709
Bembidion_Adult::WinterMort
bool WinterMort()
Density-independent winter mortality.
Definition: Bembidion_all.cpp:1698
Bembidion_Larvae::m_DayMade
int m_DayMade
Definition: bembidion_all.h:246
cut_to_hay
Definition: treatment.h:85
Population_Manager::m_ListNames
const char * m_ListNames[32]
Definition: populationmanager.h:537
spring_sow
Definition: treatment.h:47
tobs_Foraging
Definition: bembidion_all.h:49
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
StopAggregationDay
const int StopAggregationDay
Definition: Bembidion_all.cpp:153
cfg_InCropRef
static CfgInt cfg_InCropRef("BEM_INCROPREF", CFG_CUSTOM, 603)
Defines the crop reference for in-crop if pest mort location or in-field locations are switched on.
March
const int March
Definition: landscape.h:38
Bembidion_Adult::MoveTo_quality_assess
int MoveTo_quality_assess()
Moves w.r.t. habitat quality only.
Definition: Bembidion_all.cpp:1931
sleep_all_day
Definition: treatment.h:33
CfgBool::value
bool value(void)
Definition: configurator.h:135
Bembidion_Adult::m_PPPEffectProb
static double m_PPPEffectProb
Effect probability on threshold excedence.
Definition: bembidion_all.h:377
CompareEggX
Function class to compare to Eggs X.
Definition: bembidion_all.h:129
tole_AmenityGrass
Definition: tole_declaration.h:76
Bembidion_Adult::DailyMovement
int DailyMovement(int p_distance, bool disp_aggreg)
Initiates the daily movement for the beelt.
Definition: Bembidion_all.cpp:1724
TAnimal::m_Location_x
int m_Location_x
Definition: populationmanager.h:225
cfg_PesticideTrialAdultTreatmentMort
static CfgInt cfg_PesticideTrialAdultTreatmentMort("BEM_PTRIALADULTMORT", CFG_CUSTOM, 0)
Bembidion_Population_Manager::IsStartHabitat
bool IsStartHabitat(int a_x, int a_y)
Used to specify legal starting habitats for simulation start-up.
Definition: Bembidion_all.cpp:2535
TTypesOfPesticide
TTypesOfPesticide
Definition: landscape.h:65
above12Egg
const double above12Egg
Day degree constant above inflection point.
Definition: Bembidion_all.cpp:128
tole_NaturalGrassDry
Definition: tole_declaration.h:48
Bembidion_Egg_List::Step
virtual void Step()
Egg_List class Step code.
Definition: Bembidion_all.cpp:330
autumn_or_spring_plough
Definition: treatment.h:91
tobs_Initiation
Definition: bembidion_all.h:35
tole_BeetleBank
Definition: tole_declaration.h:69
Landscape::SupplyPolyRef
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
cfg_TotalNoEggs
static CfgInt cfg_TotalNoEggs("BEM_TOTALEGGS", CFG_CUSTOM, 256)
The maximum number of eggs it is possible to produce per female.
strigling_hill
Definition: treatment.h:105
cfg_Larva_InsecticideApplication
static CfgFloat cfg_Larva_InsecticideApplication("BEM_LARVAEINSECTICIDEMORT", CFG_CUSTOM, 0.800)
Bembidion_Population_Manager::m_MoveMap
MovementMap * m_MoveMap
Map of suitability for movement.
Definition: bembidion_all.h:468
fa_slurry
Definition: treatment.h:63
swathing
Definition: treatment.h:81
Bembidion_Egg_List::DailyMortality
void DailyMortality()
Egg_List non-temperature or density related mortality.
Definition: Bembidion_all.cpp:363
Bembidion_Larvae::TempRelatedLarvalMortality
bool TempRelatedLarvalMortality(int temp2)
Determine larval temperature related mortality.
Definition: Bembidion_all.cpp:864
Bembidion_Adult::m_PPPEffectProbDecay
static double m_PPPEffectProbDecay
Effect probability on threshold excedence.
Definition: bembidion_all.h:379
Population_Manager::LamdaDeath
void LamdaDeath(int x, int y)
Definition: populationmanager.h:599
DispersalThreshold
const float DispersalThreshold
Adult dispersal temp threshold for DD calcuation.
Definition: Bembidion_all.cpp:139
AnimalPosition::m_VegType
TTypesOfVegetation m_VegType
Definition: populationmanager.h:175
tole_Heath
Definition: tole_declaration.h:70
cfg_ADDepMort0
static CfgInt cfg_ADDepMort0("BEM_ADDEPMORTZERO", CFG_CUSTOM, 2)
Adult density dependent mortality constant.
Population_Manager::IncLiveArraySize
void IncLiveArraySize(int a_listindex)
Increments the number of 'live' objects for a list index in the TheArray.
Definition: populationmanager.h:437
param_List15::BeenThereX
int BeenThereX[101]
Definition: bembidion_all.h:106