File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DK_OptimalFlowerMix3 Class Reference

#include <DK_OptimalFlowerMix3.h>

Inheritance diagram for DK_OptimalFlowerMix3:
Crop

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 DK_OptimalFlowerMix3 (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
void SetUpFarmCategoryInformation ()
 
- Public Member Functions inherited from Crop
virtual ~Crop ()
 
 Crop (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
int GetFirstDate (void)
 
void ChooseNextCrop (int a_no_dates)
 Chooses the next crop to grow in a field. More...
 
int GetCropClassification ()
 
void SetCropClassification (int a_classification)
 
void GetCropType (TTypesOfCrops a_toc)
 
TTypesOfCrops GetCropType ()
 
FarmManagementCategory LookUpManagementCategory (int a_todo)
 
bool GetForceSpringOK ()
 

Additional Inherited Members

- Public Attributes inherited from Crop
TTypesOfVegetation m_tov
 
- Protected Member Functions inherited from Crop
void SimpleEvent (long a_date, int a_todo, bool a_lock)
 Adds an event to this crop management. More...
 
void SimpleEvent_ (long a_date, int a_todo, bool a_lock, Farm *a_farm, LE *a_field)
 Adds an event to this crop management without relying on member variables. More...
 
bool StartUpCrop (int a_spring, std::vector< std::vector< int >> a_flexdates, int a_todo)
 
Holds the translation between the farm operation enum for each cropand the farm management category associated with it More...
 
bool AphidDamage (LE *a_field)
 Compares aphid numbers per m2 with a threshold to return true if threshold is exceeded. More...
 
- Protected Attributes inherited from Crop
Farmm_farm
 
LEm_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 
int m_base_elements_no
 
Landscapem_OurLandscape
 
bool m_forcespringpossible = false
 Used to signal that the crop can be forced to start in spring. More...
 
TTypesOfCrops m_toc
 The Crop type in terms of the TTypesOfCrops list (smaller list than tov, no country designation) More...
 
int m_CropClassification
 Contains information on whether this is a winter crop, spring crop, or catch crop that straddles the year boundary (0,1,2) More...
 
vector< FarmManagementCategorym_ManagementCategories
 Holds the translation between the farm operation enum for each crop and the farm management category associated with it. More...
 
- Static Protected Attributes inherited from Crop
static int m_date_modifier = 0
 Holds a value that shifts test pesticide use by this many days in crops modified to use it. More...
 

Constructor & Destructor Documentation

◆ DK_OptimalFlowerMix3()

DK_OptimalFlowerMix3::DK_OptimalFlowerMix3 ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline

Member Function Documentation

◆ Do()

bool DK_OptimalFlowerMix3::Do ( Farm a_farm,
LE a_field,
FarmEvent a_ev 
)
virtual

Reimplemented from Crop.

33 {
34  m_farm = a_farm;
35  m_field = a_field;
36  m_ev = a_ev;
37  bool done = false;
38  int d1;
39  TTypesOfVegetation l_tov = tov_DKOptimalFlowerMix3; // this is the second of three management following each other - ryegrass
40 
41  switch ( m_ev->m_todo ) {
42  case dk_ofm3_start:
43  {
44  a_field->ClearManagementActionSum();
45  m_last_date = g_date->DayInYear(11, 11); // Should match the last flexdate below
46  //Create a 2d array of 1 plus the number of operations you use. Change only 4+1 to what you need in the line below
47  std::vector<std::vector<int>> flexdates(2 + 1, std::vector<int>(2, 0));
48  // Set up the date management stuff
49  // Start and stop dates for all events after harvest
50  flexdates[0][1] = g_date->DayInYear(25, 10);
51  // Now these are done in pairs, start & end for each operation. If its not used then -1
52  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
53  flexdates[1][1] = g_date->DayInYear(26, 10); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
54  flexdates[2][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 2)
55  flexdates[2][1] = g_date->DayInYear(11, 11); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 2)
56 
57  // Below if this is a spring crop use 365, otherwise first parameter is always 0, second parameter is fixed, and the third is the start up operation in the first year
58  int isSpring = 365;
59  if (StartUpCrop(isSpring, flexdates, int(dk_ofm3_wait1))) break;
60 
61  // End single block date checking code. Please see next line comment as well.
62  // Reinit d1 to first possible starting date.
63 
64  d1 = g_date->OldDays() + g_date->DayInYear(1, 1)+365;
65  SimpleEvent(d1, dk_ofm3_wait1, false);
66  }
67  break;
68 
69  case dk_ofm3_wait1:
70  if (!a_farm->SleepAllDay(a_field, 0.0, g_date->DayInYear(1, 4) - g_date->DayInYear())) {
71  SimpleEvent(g_date->Date() + 1, dk_ofm3_wait1, true);
72  break;
73  }
75  break;
76 
77  case dk_ofm3_cutting: // only allowed between 1 of aug to 25 oct (when summer cutting)
78  if (!a_farm->CutToHay(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
79  SimpleEvent(g_date->Date() + 1, dk_ofm3_cutting, true);
80  break;
81  }
82  SimpleEvent(g_date->Date() + 1, dk_ofm3_strigling, false);
83  break;
84 
85  case dk_ofm3_strigling:
86  if (a_ev->m_lock || a_farm->DoIt(50)) {
87  if (!a_farm->Strigling(a_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
89  break;
90  }
91  }
92  SimpleEvent(g_date->Date() + 14, dk_ofm3_swathing, false);
93  break;
94 
95  case dk_ofm3_swathing:
96  if (a_field->GetVegBiomass() > 0)
97  {
98  if (!a_farm->Swathing(a_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
99  SimpleEvent(g_date->Date() + 1, dk_ofm3_swathing, true);
100  break;
101  }
102  }
103  // End of management
104  done = true;
105  break;
106 
107  default:
108  g_msg->Warn( WARN_BUG, "DK_OptimalFlowerMix3::Do(): "
109  "Unknown event type! ", "" );
110  exit( 1 );
111  }
112  if (done) m_ev->m_forcespring = true; // Here we need to force the next crop to spring operation, so set the ev->forcespring to true
113  return done;
114 }

References LE::ClearManagementActionSum(), Farm::CutToHay(), Calendar::Date(), Calendar::DayInYear(), dk_ofm3_cutting, dk_ofm3_start, dk_ofm3_strigling, dk_ofm3_swathing, dk_ofm3_wait1, Farm::DoIt(), g_date, g_msg, LE::GetMDates(), LE::GetVegBiomass(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Crop::SimpleEvent(), Farm::SleepAllDay(), Crop::StartUpCrop(), Farm::Strigling(), Farm::Swathing(), tov_DKOptimalFlowerMix3, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DK_OptimalFlowerMix3::SetUpFarmCategoryInformation ( )
inline
67  {
68  const int elements = 2 + (dk_ofm3_foobar - DK_OFM3_BASE);
70 
71  FarmManagementCategory catlist[elements] =
72  {
73  fmc_Others, // zero element unused but must be here
74  fmc_Others, // dk_ofm3_start = 1, // Compulsory, start event must always be 1 (one).
75  fmc_Cultivation, // dk_ofm3_harrow = DK_OFM3_BASE
76  fmc_Cultivation, // dk_ofm3_roll
77  fmc_Others, // dk_ofm3_wait1,
78  fmc_Others, // dk_ofm3_wait2,
79  fmc_Others, // dk_ofm3_sow,
80  fmc_Cutting, // dk_ofm3_cutting,
81  fmc_Cultivation, // dk_ofm3_strigling,
82  fmc_Cutting, // dk_ofm3_swathing,
83  // No foobar entry
84  };
85  // Iterate over the catlist elements and copy them to vector
86  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
87  }

References DK_OFM3_BASE, dk_ofm3_foobar, fmc_Cultivation, fmc_Cutting, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_OptimalFlowerMix3().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
tov_DKOptimalFlowerMix3
Definition: LandscapeFarmingEnums.h:438
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: FarmFuncs.cpp:1206
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
dk_ofm3_swathing
Definition: DK_OptimalFlowerMix3.h:52
dk_ofm3_start
Definition: DK_OptimalFlowerMix3.h:44
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
Farm::CutToHay
virtual bool CutToHay(LE *a_field, double a_user, int a_days)
Carry out hay cutting on a_field.
Definition: FarmFuncs.cpp:1607
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
DK_OptimalFlowerMix3::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OptimalFlowerMix3.h:67
LE::GetVegBiomass
virtual double GetVegBiomass(void)
Definition: Elements.h:164
dk_ofm3_strigling
Definition: DK_OptimalFlowerMix3.h:51
dk_ofm3_cutting
Definition: DK_OptimalFlowerMix3.h:50
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
DK_OFM3_BASE
#define DK_OFM3_BASE
Definition: DK_OptimalFlowerMix3.h:42
dk_ofm3_foobar
Definition: DK_OptimalFlowerMix3.h:53
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Crop::StartUpCrop
bool StartUpCrop(int a_spring, std::vector< std::vector< int >> a_flexdates, int a_todo)
Holds the translation between the farm operation enum for each cropand the farm management category a...
Definition: Farm.cpp:652
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
Crop::m_ManagementCategories
vector< FarmManagementCategory > m_ManagementCategories
Holds the translation between the farm operation enum for each crop and the farm management category ...
Definition: Farm.h:530
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
Farm::SleepAllDay
virtual bool SleepAllDay(LE *a_field, double a_user, int a_days)
Nothing to to today on a_field.
Definition: FarmFuncs.cpp:272
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
Farm::Swathing
virtual bool Swathing(LE *a_field, double a_user, int a_days)
Cut the crop on a_field and leave it lying (probably rape)
Definition: FarmFuncs.cpp:1350
dk_ofm3_wait1
Definition: DK_OptimalFlowerMix3.h:46
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001