ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
farm.h
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 */
36 //
37 // farm.h
38 //
39 /*
40 
41 Copyright (c) 2003, National Environmental Research Institute, Denmark (NERI)
42 
43 All rights reserved.
44 
45 
46 Redistribution and use in source and binary forms, with or without
47 modification, are permitted provided that the following conditions are met:
48 
49 *) Redistributions of source code must retain the above copyright notice, this
50 list of conditions and the following disclaimer.
51 *) Redistributions in binary form must reproduce the above copyright notice,
52 this list of conditions and the following disclaimer in the documentation
53 and/or other materials provided with the distribution.
54 *) Neither the name of the NERI nor the names of its contributors
55 may be used to endorse or promote products derived from this software without
56 specific prior written permission.
57 
58 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
59 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
62 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
66 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
68 POSSIBILITY OF SUCH DAMAGE.
69 
70 */
71 
72 #ifndef FARM_H
73 #define FARM_H
74 
75 // This really needs to be a #define.
76 #define PROG_START 1
77 
78 
79 class Population_Manager;
80 class FarmManager;
81 class BroadBeans;
82 class Carrots;
83 class CloverGrassGrazed1;
84 class CloverGrassGrazed2;
85 class FieldPeas;
86 class FieldPeasSilage;
87 class Fodderbeet;
88 class FodderGrass;
89 class Maize;
90 class MaizeSilage;
91 class OMaizeSilage;
92 class OBarleyPeaCloverGrass;
93 class OCarrots;
94 class OCloverGrassGrazed1;
95 class OCloverGrassGrazed2;
96 class OCloverGrassSilage1;
97 class OFieldPeas;
98 class OFieldPeasSilage;
99 class OFirstYearDanger;
100 class OGrazingPigs;
101 class OOats;
102 class Oats;
103 class OrchardCrop;
104 class OFodderbeet;
105 class OPermanentGrassGrazed;
106 class OPotatoes;
107 class OSBarleySilage;
108 class OSeedGrass1;
109 class OSeedGrass2;
110 class OSpringBarley;
111 class OSpringBarleyExt;
112 class OSpringBarleyPigs;
113 class OWinterBarley;
114 class OWinterBarleyExt;
115 class OWinterRape;
116 class OWinterRye;
117 class OWinterWheatUndersown;
118 class OWinterWheatUndersownExt;
119 class PermanentGrassGrazed;
120 class PermanentGrassLowYield;
121 class PermanentGrassTussocky;
122 class PermanentSetAside;
123 class Potatoes;
124 class PotatoesIndustry;
125 class SeedGrass1;
126 class SeedGrass2;
127 class SetAside;
128 class SpringBarley;
129 class SpringBarleySpr;
130 class SpringBarleyPTreatment;
131 class SpringBarleySKManagement;
132 class SpringBarleyCloverGrass;
133 class SpringBarleySeed;
134 class SpringBarleySilage;
135 class SpringRape;
136 class Sugarbeet;
137 class Triticale;
138 class OTriticale;
139 class WinterBarley;
140 class WinterRape;
141 class WinterRye;
142 class WinterWheat;
143 class WWheatPControl;
144 class WWheatPTreatment;
145 class WWheatPToxicControl;
146 class AgroChemIndustryCereal;
147 class WinterWheatStrigling;
148 class WinterWheatStriglingSingle;
149 class WinterWheatStriglingCulm;
150 class SpringBarleyCloverGrassStrigling;
151 class SpringBarleyStrigling;
152 class SpringBarleyStriglingCulm;
153 class SpringBarleyStriglingSingle;
154 class MaizeStrigling;
155 class WinterRapeStrigling;
156 class WinterRyeStrigling;
157 class WinterBarleyStrigling;
158 class FieldPeasStrigling;
159 class SpringBarleyPeaCloverGrassStrigling;
160 class YoungForestCrop;
161 class Hunter;
162 class OWinterWheat;
163 
164 typedef vector<unsigned >polylist;
165 typedef vector < Hunter* > HunterList;
166 
167 typedef enum
168 {
220 }TTypesOfFarm;
221 
222 
223 //enums for the OptimisingFarms: toof, tos, tofs, toa, toc, top, tolp, tocv
224 typedef enum {
228  toof_Pig, // 3
229  toof_Foobar // Must be in here and the last one as well!
231 
232 typedef enum {
233  tos_Sand = 0,
234  tos_Other, // 1
235  tos_Clay, // 2
236  tos_Foobar // Must be in here and the last one as well!
238 
239 typedef enum {
242  tofs_Foobar // Must be in here and the last one as well!
244 
245 typedef enum {
247  toa_DCow, // 1
266  toa_Foobar // Must be in here and the last one as well!
268 
269 typedef enum {
271  toc_Oats, //1
275  toc_WRye, //5
280  toc_Peas, //10
313  toc_Foobar // Must be in here and the last one as well!
315 
316 //crop parameters that do not vary with farm type, soil type etc.
317 typedef enum {
335  top_Foobar // Must be in here and the last one as well!
337 
338 typedef enum {
342  tolp_Foobar // Must be in here and the last one as well!
344 
345 typedef enum {
362  tocv_Foobar // Must be in here and the last one as well!
364 
365 typedef enum {
371 
372 
373 
374 
376 struct PermCropData {
378  int Pct;
379 };
380 
382 struct tpct {
383  int index;
384  int pct;
385 };
386 
391 struct FarmEvent
392 {
393  bool m_lock;
396  long m_run;
397  int m_todo;
401 
402  FarmEvent( TTypesOfVegetation a_event, LE *a_field, int a_todo, long a_run,
403  bool a_lock, int a_start, bool a_first_year,
404  TTypesOfVegetation a_nextcrop )
405  {
406  m_event = a_event;
407  m_field = a_field;
408  m_todo = a_todo;
409  m_run = a_run;
410  m_lock = a_lock;
411  m_startday = a_start;
412  m_first_year = a_first_year;
413  m_next_tov=a_nextcrop;
414  }
415 };
416 
421 struct farminfo {
430  APoint m_farmvalid;
432 };
433 
434 
439 {
440 public:
442  int refID;
444  int homeX;
446  int homeY;
448  vector<int> FarmHuntRef;
450  vector<int> CheckedFarms;
451 
453  FarmHuntRef.resize( 0 );
454  CheckedFarms.resize( 0 );
455  }
456 };
457 
462 class Crop
463 {
464 protected:
469  int m_count;
472 
477  void SimpleEvent( long a_date, int a_todo, bool a_lock );
478 
479 public:
480  virtual ~Crop() {}
481  Crop();
482  int GetFirstDate( void ) { return m_first_date; }
483  virtual bool Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev );
485  void ChooseNextCrop (int a_no_dates);
486 
487 };
488 
489 
492 // v. similar to PermCropData, but has double instead of int.
493 //Used originally for saving Bedriftsmodel (original farm optimization model) type crops in almass type. Also used to store data on biomass_factors
494 //so changed the name of the member - from Pct to Number
495 
496  struct AlmassCrop {
497  double Number;
499  };
500 
506 
507 public:
509 
510  //Data at a general level
511  void Set_livestockTypes(TTypesOfAnimals livestock_type){m_livestockTypes.push_back(livestock_type);};
512  void Set_cropTypes(TTypesOfCrops crop_type){m_cropTypes.push_back(crop_type);};
513  void Set_cropTypes_str (string crop_type){m_str_cropTypes.push_back(crop_type);};
514  TTypesOfAnimals Get_livestockTypes(int i){return m_livestockTypes[i];};
515  string Get_cropTypes_str (int i) {return m_str_cropTypes[i];};
516  TTypesOfCrops Get_cropTypes(int i) {return m_cropTypes[i];};
517 
518  //Individual data for farms (vector size is no_farms x given_Foobar)
519  void Set_livestockNumber(int a_number){m_livestockNumbers.push_back(a_number);};
520  void Set_cropArea(double a_area){m_cropAreas.push_back(a_area);};
521  int Get_livestockNumber(int index){return m_livestockNumbers[index];};
522  int Get_livestockNumbersSize(){return (int)m_livestockNumbers.size();};
523  double Get_cropArea(int index){return m_cropAreas[index];};
524  int Get_cropAreasSize(){return (int)m_cropAreas.size();};
525 
526  //Data for farms
528  TTypesOfOptFarms Get_farmType (int a_almass_no);
529  void Set_winterMax (int a_value, int i){m_winterMax[i]=a_value;};
530  int Get_winterMax (int i) {return m_winterMax[i];};
531 
532  //Data for livestock
533  void Set_livestockParameter(double a_value, int i){m_livestockParameters[i]=a_value;};
534  double Get_livestockParameter(int i){return m_livestockParameters[i];};
535 
536  //Data for crops
537  void Set_cropParameter (double a_value, int i){m_cropParameters[i]=a_value;};
538  double Get_cropParameter (int i) {return m_cropParameters[i];};
539 
540  void Set_alfa (double a_value, int i){m_alfa[i]=a_value;};
541  double Get_alfa (int i) {return m_alfa[i];};
542  void Set_beta1 (double a_value, int i){m_beta1[i]=a_value;};
543  double Get_beta1 (int i) {return m_beta1[i];};
544  void Set_beta2 (double a_value, int i){m_beta2[i]=a_value;};
545  double Get_beta2 (int i) {return m_beta2[i];};
546  void Set_Nnorm (double a_value, int i){m_Nnorm[i]=a_value;};
547  double Get_Nnorm (int i) {return m_Nnorm[i];};
548 
549 
550  void Set_fixed (string a_value, int i){
551  if(a_value=="yes" || a_value=="YES" || a_value=="Yes" || a_value=="1"){m_fixed[i]=true;}
552  else {m_fixed[i]=false;}
553  };
554  bool Get_fixed (int i) {return m_fixed[i];};
555  void Set_fodder (string a_value, int i){
556  if(a_value=="yes" || a_value=="YES" || a_value=="Yes" || a_value=="1"){m_fodder[i]=true;}
557  else {m_fodder[i]=false;}
558  };
559  bool Get_fodder (int i) {return m_fodder[i];};
560  void Set_FUKey (double a_value, int i){m_FUKey[i]=a_value;};
561  double Get_FUKey (int i) {return m_FUKey[i];};
562 
563  void Set_sellingPrice (double a_value, int i){m_sellingPrice[i]=a_value;};
564  double Get_sellingPrice (int i) {return m_sellingPrice[i];};
565  void Set_sellingPrice_lastyr (double a_value, int i){m_sellingPrice_lastyr[i]=a_value;};
566  double Get_sellingPrice_lastyr (int i) {return m_sellingPrice_lastyr[i];};
567 
568  void Set_rotationMax (double a_value, int i){m_rotationMax[i]=a_value;};
569  double Get_rotationMax (int i) {return m_rotationMax[i];};
570  void Set_rotationMin (double a_value, int i){m_rotationMin[i]=a_value;};
571  double Get_rotationMin (int i) {return m_rotationMin[i];};
572 
573 
574  //versions for almass crops
575  void Set_biomass_factor (double a_value, int i){m_biomass_factors[i] = a_value;};
576  double Get_biomass_factor (int i) { return m_biomass_factors[i];}
577 
578  void Set_cropTypes_almass(TTypesOfVegetation crop_type){m_cropTypes_almass.push_back(crop_type);};
579  TTypesOfVegetation Get_cropTypes_almass (int i) {return m_cropTypes_almass[i];};
580  int Get_cropTypes_almass_size (){return (int)m_cropTypes_almass.size();};
581  void Set_cropTypes_almass_str (string crop_type){m_str_cropTypes_almass.push_back(crop_type);};
582  string Get_cropTypes_almass_str (int i) {return m_str_cropTypes_almass[i];};
583 
584  void Set_noCrops (int no) {m_noCrops = no;};
585  int Get_noCrops (){return m_noCrops;};
586 
587  void Set_emaize_price (double a_value){m_energy_maize_price.push_back(a_value);};
588  double Get_emaize_price (int i){return m_energy_maize_price[i];};
589 
591  class FarmData{
592  public:
599  };
600 
601  vector<FarmData*>m_farm_data;
602 
603 
604 protected:
605  //called in the constructor
607  void InitializeVector(vector<double>&vector);
609  int m_noCrops; //how many crops will be optimised - the number is taken from one of the input files; it has to be the same in all input files with crop data!
610 
611 //I. Data at a general level - changed to config variables
612 
613 //II. Data for farms
614 
616  vector<string>m_str_cropTypes; //used in output function
618  vector<TTypesOfCrops>m_cropTypes;
619  //for almass crop types
621  vector<string>m_str_cropTypes_almass;
623  vector<TTypesOfVegetation>m_cropTypes_almass;
625  vector<TTypesOfAnimals>m_livestockTypes;
627  vector<double>m_cropAreas;
629  vector<int>m_livestockNumbers;
630 
632  vector<int>m_winterMax;
633 
634 //III. Data for livestock
636  vector<double>m_livestockParameters; //full list of the parameters - enum declaration (TTypesOfLivestockParameters)
637 
638 //IV. Data for crops
639  //1. parameters that do not vary with farm type, soil type etc. (number of parameters = top_Foobar !)
641  vector<double>m_cropParameters; //full list of the parameters - enum declaration (enum TTypesOfParameters)
642  //2. parameters that vary with a soil type
644  vector<double>m_alfa;
646  vector<double>m_beta1;
648  vector<double>m_beta2;
650  vector<double>m_Nnorm;
653  vector<double>m_biomass_factors;
654 
655  //3. parameters that vary with a farm type
657  vector<bool>m_fixed;
659  vector<bool>m_fodder;
661  vector<double>m_FUKey;
662  //4. parameters that vary with a farm and soil type
664  vector<double>m_sellingPrice;
666  vector<double>m_sellingPrice_lastyr;
667  //5. parameters that vary with a farm type, farm size and a soil type
669  vector<double>m_rotationMax;
671  vector<double>m_rotationMin;
672 
673  //6. Energy maize runs
675  vector<double>m_energy_maize_price;
676 
677 };
678 
683 class Farm
684 {
685 public:
686  // Management() will use the global date.
687  virtual void Management( void );
688 
689  // InitiateManagement() must be called after all the fields have
690  // been added to the farm.
691  virtual void InitiateManagement( void );
692 
693  void AddField( LE* a_newfield );
694  void RemoveField( LE* a_field );
695  Farm( FarmManager* a_manager );
696  virtual ~Farm( void );
697  void SetFarmNumber( int a_farm_num ) { m_farm_num = a_farm_num; }
698  int GetFarmNumber( void ) { return m_farm_num; }
699  //TTypesOfVegetation TranslateCropCodes(std::string& str); 19.03.13 - moved to farm manager
700  virtual bool Spraying_herbicides(TTypesOfVegetation){return true; };
701  virtual bool Spraying_fungins(TTypesOfVegetation){return true; };
702  virtual double Prob_multiplier (){return 1;};
703  void Assign_rotation(vector<TTypesOfVegetation>a_new_rotation);
704 
706  polylist* ListOpenFields( int a_openness ); //14.01.13
708  void Centroids();
710  int GetNoFields() { return (int) m_fields.size(); }
712  int GetNoOpenFields(int a_openness);
714  int GetAreaOpenFields(int a_openness);
716  APoint GetValidCoords() { APoint pt; pt.m_x = m_fields[0]->GetValidX(); pt.m_y = m_fields[0]->GetValidY(); return pt; }
719  {
720  int op = 0;
721  for (int i = 0; i < m_fields.size(); i++)
722  {
723  int openness = m_fields[i]->GetOpenness();
724  if (openness > op) op = openness;
725  }
726  return op;
727  }
728 
729  // And (*sigh*) the crop treatment functions... :-)
730  virtual bool SleepAllDay( LE *a_field, double a_user, int a_days );
731  virtual bool AutumnPlough( LE *a_field, double a_user, int a_days );
732  virtual bool AutumnHarrow( LE *a_field, double a_user, int a_days );
733  virtual bool AutumnRoll( LE *a_field, double a_user, int a_days );
734  virtual bool AutumnSow( LE *a_field, double a_user, int a_days );
735  virtual bool WinterPlough( LE *a_field, double a_user, int a_days );
736  virtual bool DeepPlough( LE *a_field, double a_user, int a_days );
737  virtual bool SpringPlough( LE *a_field, double a_user, int a_days );
738  virtual bool SpringHarrow( LE *a_field, double a_user, int a_days );
739  virtual bool SpringRoll( LE *a_field, double a_user, int a_days );
740  virtual bool SpringSow( LE *a_field, double a_user, int a_days );
741  virtual bool HerbicideTreat( LE *a_field, double a_user, int a_days );
742  virtual bool GrowthRegulator( LE *a_field, double a_user, int a_days );
743  virtual bool FungicideTreat( LE *a_field, double a_user, int a_days );
744  virtual bool InsecticideTreat( LE *a_field, double a_user, int a_days );
745  virtual bool SynInsecticideTreat( LE *a_field, double a_user, int a_days );
746  virtual bool ProductApplication0( LE *a_field, double a_user, int a_days );
747  virtual bool ProductApplication1( LE *a_field, double a_user, int a_days );
748  virtual bool Molluscicide( LE *a_field, double a_user, int a_days );
749  virtual bool RowCultivation( LE *a_field, double a_user, int a_days );
750  virtual bool Strigling( LE *a_field, double a_user, int a_days );
751  virtual bool StriglingSow( LE *a_field, double a_user, int a_days );
752  virtual bool HillingUp( LE *a_field, double a_user, int a_days );
753  virtual bool Water( LE *a_field, double a_user, int a_days );
754  virtual bool Swathing( LE *a_field, double a_user, int a_days );
755  virtual bool Harvest(LE *a_field, double a_user, int a_days);
756  virtual bool HarvestLong(LE *a_field, double a_user, int a_days);
757  virtual bool CattleOut(LE *a_field, double a_user, int a_days);
758  virtual bool CattleOutLowGrazing( LE *a_field, double a_user, int a_days );
759  virtual bool CattleIsOut( LE *a_field, double a_user, int a_days, int a_max );
760  virtual bool CattleIsOutLow( LE *a_field, double a_user, int a_days, int a_max );
761  virtual bool PigsOut( LE *a_field, double a_user, int a_days );
762  virtual bool PigsAreOut( LE *a_field, double a_user, int a_days );
763  virtual bool PigsAreOutForced( LE *a_field, double a_user, int a_days );
764  virtual bool CutToHay( LE *a_field, double a_user, int a_days );
765  virtual bool CutWeeds( LE *a_field, double a_user, int a_days );
766  virtual bool CutToSilage( LE *a_field, double a_user, int a_days );
767  virtual bool CutOrch( LE *a_field, double a_user, int a_days ); //added 27.08.12
768  virtual bool StrawChopping( LE *a_field, double a_user, int a_days );
769  virtual bool HayTurning( LE *a_field, double a_user, int a_days );
770  virtual bool HayBailing( LE *a_field, double a_user, int a_days );
771  virtual bool BurnStrawStubble( LE *a_field, double a_user, int a_days );
772  virtual bool StubbleHarrowing( LE *a_field, double a_user, int a_days );
773  virtual bool FP_NPKS( LE *a_field, double a_user, int a_days );
774  virtual bool FP_NPK( LE *a_field, double a_user, int a_days );
775  virtual bool FP_PK( LE *a_field, double a_user, int a_days );
776  virtual bool FP_LiquidNH3( LE *a_field, double a_user, int a_days );
777  virtual bool FP_Slurry( LE *a_field, double a_user, int a_days );
778  virtual bool FP_ManganeseSulphate( LE *a_field, double a_user, int a_days );
779  virtual bool FP_Manure( LE *a_field, double a_user, int a_days );
780  virtual bool FP_GreenManure( LE *a_field, double a_user, int a_days );
781  virtual bool FP_Sludge( LE *a_field, double a_user, int a_days );
782  virtual bool FA_NPK( LE *a_field, double a_user, int a_days );
783  virtual bool FA_PK( LE *a_field, double a_user, int a_days );
784  virtual bool FA_Slurry( LE *a_field, double a_user, int a_days );
785  virtual bool FA_AmmoniumSulphate( LE *a_field, double a_user, int a_days );
786  virtual bool FA_Manure( LE *a_field, double a_user, int a_days );
787  virtual bool FA_GreenManure( LE *a_field, double a_user, int a_days );
788  virtual bool FA_Sludge( LE *a_field, double a_user, int a_days );
789  // Pesticide Trial Farm Function Code
790  virtual bool Trial_PesticideTreat( LE *a_field, double a_user, int a_days );
791  virtual bool Trial_PesticideTreat_DateLimited(LE *a_field, double /*a_user*/, int /*a_days*/);
792  virtual bool Trial_PesticideTreat_GS( LE *a_field, double a_user, int a_days );
793  virtual bool Trial_ToxicControl( LE *a_field, double a_user, int a_days );
794  virtual bool Trial_Control( LE *a_field, double a_user, int a_days );
795  virtual bool Glyphosate( LE *a_field, double a_user, int a_days );
796 
797  // User functions for the treatment steps:
798  void AddNewEvent( TTypesOfVegetation a_event, long a_date,
799  LE *a_field, int a_todo, long a_num,
800  bool a_lock, int a_start,
801  bool a_first_year, TTypesOfVegetation a_crop );
802  bool DoIt( int a_probability );
803  TTypesOfFarm GetType( void ) { return m_farmtype; }
804  int GetArea(void);
805  int GetTotalArea(void);
806  double GetAreaDouble(void);
807  bool IsStockFarmer( void ) { return m_stockfarmer; }
808  virtual void MakeStockFarmer( void ) { m_stockfarmer = true; }
809  int GetIntensity( void ) { return m_intensity; }
810  APoint GetCentroids() { APoint pt; pt.m_x = m_farm_centroidx; pt.m_y = m_farm_centroidy; return pt; }
812  int ind = a_index - 1;
813  if (ind < 0) ind = (int)m_rotation.size() - 1;
814  return m_rotation[ind];
815  }
817  return m_rotation[a_index];
818  }
820  int ind = a_index + 1;
821  if (ind >= (int)m_rotation.size()) ind = ind - (int)m_rotation.size();
822  return m_rotation[ind];
823  }
824  void AddHunter(Hunter* a_hunter) {
825  m_HuntersList.push_back( a_hunter );
826  }
827  bool RemoveHunter( Hunter* a_hunter ) {
828  for (int h = 0; h < m_HuntersList.size(); h++) {
829  if (m_HuntersList[ h ] == a_hunter) {
830  m_HuntersList.erase( m_HuntersList.begin() + h );
831  }
832  }
833  }
834 
835 protected:
839  vector< LE* > m_fields;
840  vector<TTypesOfVegetation> m_rotation;
841  vector<PermCropData> m_PermCrops;
849  int GetFirstDate( TTypesOfVegetation a_tov );
850  int GetNextCropStartDate( LE* a_field,TTypesOfVegetation &a_curr_veg );
851  virtual int GetFirstCropIndex( TTypesOfLandscapeElement a_type );
852  virtual int GetNextCropIndex( int a_rot_index );
853  virtual void HandleEvents( void );
854  bool LeSwitch( FarmEvent *ev );
855  void CheckRotationManagementLoop( FarmEvent *ev );
856  void ReadRotation(std::string fname);
857 
858  void AssignPermanentCrop(TTypesOfVegetation tov, int pct); //MOVED FROM THE USER DEFINED FARM
859  int InvIntPartition(vector<tpct>* items, int target);
864 
865 
866  // The program function objects for the individual crops.
867  // Remember to add these into the Farm class con- and destructor too.
868  Carrots *m_carrots;
869  BroadBeans *m_broadbeans;
870  FodderGrass *m_foddergrass;
871  CloverGrassGrazed1 *m_CGG1;
872  CloverGrassGrazed2 *m_CGG2;
873  FieldPeas *m_fieldpeas;
874  FieldPeasSilage *m_fieldpeassilage;
875  Fodderbeet *m_fodderbeet;
876  Sugarbeet *m_sugarbeet;
877  OFodderbeet *m_ofodderbeet;
878  Maize *m_maize;
879  MaizeSilage *m_maizesilage;
880  OMaizeSilage *m_omaizesilage;
881  OBarleyPeaCloverGrass *m_OBarleyPCG;
882  OCarrots *m_ocarrots;
883  OCloverGrassGrazed1 *m_OCGG1;
884  OCloverGrassGrazed2 *m_OCGG2;
885  OCloverGrassSilage1 *m_OCGS1;
886  OFieldPeas *m_ofieldpeas;
887  OFieldPeasSilage *m_ofieldpeassilage;
888  OFirstYearDanger *m_ofirstyeardanger;
889  OGrazingPigs *m_ograzingpigs;
890  OrchardCrop *m_orchardcrop;
891  Oats *m_oats;
892  OOats *m_ooats;
893  OPermanentGrassGrazed *m_opermgrassgrazed;
894  OPotatoes *m_opotatoes;
895  OSeedGrass1 *m_oseedgrass1;
896  OSeedGrass2 *m_oseedgrass2;
897  OSpringBarley *m_ospringbarley;
898  OSpringBarleyExt *m_ospringbarleyext;
899  OSpringBarleyPigs *m_ospringbarleypigs;
900  OSBarleySilage *m_osbarleysilage;
901  OTriticale *m_otriticale;
902  OWinterBarley *m_owinterbarley;
903  OWinterBarleyExt *m_owinterbarleyext;
904  OWinterRape *m_owinterrape;
905  OWinterRye *m_owinterrye;
906  OWinterWheatUndersown *m_owinterwheatundersown;
907  OWinterWheat *m_owinterwheat;
908  OWinterWheatUndersownExt *m_owinterwheatundersownext;
909  PermanentGrassGrazed *m_permgrassgrazed;
910  PermanentGrassLowYield *m_permgrasslowyield;
911  PermanentGrassTussocky *m_permgrasstussocky;
912  PermanentSetAside *m_permanentsetaside;
913  Potatoes *m_potatoes;
914  PotatoesIndustry *m_potatoesindustry;
915  SeedGrass1 *m_seedgrass1;
916  SeedGrass2 *m_seedgrass2;
917  SetAside *m_setaside;
918  SpringBarley *m_springbarley;
919  SpringBarleySpr *m_springbarleyspr;
920  SpringBarleySKManagement *m_springbarleyskmanagement;
921  SpringBarleyPTreatment *m_springbarleyptreatment;
922  SpringBarleyCloverGrass *m_sbarleyclovergrass;
923  SpringBarleySeed *m_springbarleyseed;
924  SpringBarleySilage *m_springbarleysilage;
925  SpringRape *m_springrape;
926  Triticale *m_triticale;
927  WinterBarley *m_winterbarley;
928  WinterRape *m_winterrape;
929  WinterRye *m_winterrye;
930  WinterWheat *m_winterwheat;
931  WWheatPControl *m_wwheatpcontrol;
932  WWheatPToxicControl *m_wwheatptoxiccontrol;
933  WWheatPTreatment *m_wwheatptreatment;
934  AgroChemIndustryCereal *m_agrochemindustrycereal;
935  WinterWheatStrigling *m_winterwheatstrigling;
936  WinterWheatStriglingCulm *m_winterwheatstriglingculm;
937  WinterWheatStriglingSingle *m_winterwheatstriglingsingle;
938  SpringBarleyCloverGrassStrigling *m_springbarleyclovergrassstrigling;
939  SpringBarleyStrigling *m_springbarleystrigling;
940  SpringBarleyStriglingCulm *m_springbarleystriglingculm;
941  SpringBarleyStriglingSingle *m_springbarleystriglingsingle;
942  MaizeStrigling *m_maizestrigling;
943  WinterRapeStrigling *m_winterrapestrigling;
944  WinterRyeStrigling *m_winterryestrigling;
945  WinterBarleyStrigling *m_winterbarleystrigling;
946  FieldPeasStrigling *m_fieldpeasstrigling;
947  SpringBarleyPeaCloverGrassStrigling *m_springbarleypeaclovergrassstrigling;
948  YoungForestCrop *m_youngforest;
949  };
950 
951 
955 class ConventionalCattle : public Farm
956 {
957 public:
958  ConventionalCattle( FarmManager* a_manager );
959 //protected:
960 // virtual TTypesOfVegetation GetFirstCrop( void );
961 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
962 };
963 
967 class ConventionalPig : public Farm
968 {
969 public:
970  ConventionalPig(FarmManager* a_manager);
971 //protected:
972 // virtual TTypesOfVegetation GetFirstCrop( void );
973 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
974 };
975 
979 class ConventionalPlant : public Farm
980 {
981 public:
982  ConventionalPlant(FarmManager* a_manager);
983  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
984 //protected:
985 // virtual TTypesOfVegetation GetFirstCrop( void );
986 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
987 };
988 
992 class OrganicPlant : public Farm
993 {
994 public:
995  OrganicPlant(FarmManager* a_manager);
996  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
997 //protected:
998 // virtual TTypesOfVegetation GetFirstCrop( void );
999 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1000 };
1001 
1005 class OrganicPig : public Farm
1006 {
1007 public:
1008  OrganicPig(FarmManager* a_manager);
1009 //protected:
1010 // virtual TTypesOfVegetation GetFirstCrop( void );
1011 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1012 };
1013 
1017 class OrganicCattle : public Farm
1018 {
1019 public:
1020  OrganicCattle(FarmManager* a_manager);
1021 //protected:
1022 // virtual TTypesOfVegetation GetFirstCrop( void );
1023 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1024 };
1025 
1030 {
1031 public:
1032  PesticideTrialControl(FarmManager* a_manager);
1033  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1034 };
1035 
1040 {
1041 public:
1043  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1044 };
1045 
1050 {
1051 public:
1053  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1054 };
1055 
1056 
1057 
1061 class ConvMarginalJord : public Farm
1062 {
1063 public:
1064  ConvMarginalJord(FarmManager* a_manager);
1065 };
1066 
1067 
1072 {
1073 public:
1075 };
1076 
1081 {
1082 public:
1084 };
1085 
1090 {
1091 public:
1093 };
1094 
1099 {
1100 public:
1101  NoPesticideBaseFarm(FarmManager* a_manager);
1102 };
1103 
1107 class NoPesticideNoPFarm : public Farm
1108 {
1109 public:
1110  NoPesticideNoPFarm(FarmManager* a_manager);
1111 };
1112 
1124 class UserDefinedFarm : public Farm
1125 {
1126 public:
1127  UserDefinedFarm(const char* fname, FarmManager* a_manager);
1128 protected:
1129  virtual void InitiateManagement( void );
1130  //void AssignPermanentCrop(TTypesOfVegetation tov, int pct); //MOVED TO THE FARM CLASS
1131  //int InvIntPartition(vector<tpct>* items, int target);
1132  //void TranslateBitsToFields(int bits, vector<LE*> &f_cpy, TTypesOfVegetation tov);
1133 };
1134 
1135 class UserDefinedFarm1 : public Farm
1136 {
1137 public:
1138  UserDefinedFarm1(FarmManager* a_manager);
1139 };
1140 
1144 class UserDefinedFarm2 : public Farm
1145 {
1146 public:
1147  UserDefinedFarm2(FarmManager* a_manager);
1148 };
1149 
1153 class UserDefinedFarm3 : public Farm
1154 {
1155 public:
1156  UserDefinedFarm3(FarmManager* a_manager);
1157 };
1158 
1162 class UserDefinedFarm4 : public Farm
1163 {
1164 public:
1165  UserDefinedFarm4(FarmManager* a_manager);
1166 };
1167 
1171 class UserDefinedFarm5 : public Farm
1172 {
1173 public:
1174  UserDefinedFarm5(FarmManager* a_manager);
1175 };
1176 
1180 class UserDefinedFarm6 : public Farm
1181 {
1182 public:
1183  UserDefinedFarm6(FarmManager* a_manager);
1184 };
1185 
1189 class UserDefinedFarm7 : public Farm
1190 {
1191 public:
1192  UserDefinedFarm7(FarmManager* a_manager);
1193 };
1194 
1198 class UserDefinedFarm8 : public Farm
1199 {
1200 public:
1201  UserDefinedFarm8(FarmManager* a_manager);
1202 };
1203 
1207 class UserDefinedFarm9 : public Farm
1208 {
1209 public:
1210  UserDefinedFarm9(FarmManager* a_manager);
1211 };
1212 
1216 class UserDefinedFarm10 : public Farm
1217 {
1218 public:
1219  UserDefinedFarm10(FarmManager* a_manager);
1220 };
1221 
1225 class UserDefinedFarm11 : public Farm
1226 {
1227 public:
1228  UserDefinedFarm11(FarmManager* a_manager);
1229 };
1230 
1234 class UserDefinedFarm12 : public Farm
1235 {
1236 public:
1237  UserDefinedFarm12(FarmManager* a_manager);
1238 };
1239 
1243 class UserDefinedFarm13 : public Farm
1244 {
1245 public:
1246  UserDefinedFarm13(FarmManager* a_manager);
1247 };
1248 
1252 class UserDefinedFarm14 : public Farm
1253 {
1254 public:
1255  UserDefinedFarm14(FarmManager* a_manager);
1256 };
1257 
1261 class UserDefinedFarm15 : public Farm
1262 {
1263 public:
1264  UserDefinedFarm15(FarmManager* a_manager);
1265 };
1266 
1270 class UserDefinedFarm16 : public Farm
1271 {
1272 public:
1273  UserDefinedFarm16(FarmManager* a_manager);
1274 };
1275 
1279 class UserDefinedFarm17 : public Farm
1280 {
1281 public:
1282  UserDefinedFarm17(FarmManager* a_manager);
1283 };
1284 
1289 {
1290 public:
1292  UserDefinedFarm18(const char* fname, FarmManager* a_manager);
1293 };
1294 
1299 {
1300 public:
1302  UserDefinedFarm19(const char* fname, FarmManager* a_manager);
1303 };
1304 
1309 {
1310 public:
1312  UserDefinedFarm20(const char* fname, FarmManager* a_manager);
1313 };
1314 
1319 {
1320 public:
1322  UserDefinedFarm21(const char* fname, FarmManager* a_manager);
1323 };
1324 
1329 {
1330 public:
1332  UserDefinedFarm22(const char* fname, FarmManager* a_manager);
1333 };
1334 
1339 {
1340 public:
1342  UserDefinedFarm23(const char* fname, FarmManager* a_manager);
1343 };
1344 
1349 {
1350 public:
1352  UserDefinedFarm24(const char* fname, FarmManager* a_manager);
1353 };
1354 
1359 {
1360 public:
1362  UserDefinedFarm25(const char* fname, FarmManager* a_manager);
1363 };
1364 
1369 {
1370 public:
1372  UserDefinedFarm26(const char* fname, FarmManager* a_manager);
1373 };
1374 
1379 {
1380 public:
1382  UserDefinedFarm27(const char* fname, FarmManager* a_manager);
1383 };
1384 
1389 {
1390 public:
1392  UserDefinedFarm28(const char* fname, FarmManager* a_manager);
1393 };
1394 
1399 {
1400 public:
1402  UserDefinedFarm29(const char* fname, FarmManager* a_manager);
1403 };
1404 
1409 {
1410 public:
1412  UserDefinedFarm30(const char* fname, FarmManager* a_manager);
1413 };
1414 
1419 {
1420 public:
1422  UserDefinedFarm31(const char* fname, FarmManager* a_manager);
1423 };
1424 
1429 {
1430 public:
1432  UserDefinedFarm32(const char* fname,FarmManager* a_manager);
1433 };
1434 
1439 {
1440 public:
1442  UserDefinedFarm33(const char* fname,FarmManager* a_manager);
1443 };
1444 
1449 {
1450 public:
1452  UserDefinedFarm34(const char* fname,FarmManager* a_manager);
1453 };
1454 
1459 {
1460 public:
1462  UserDefinedFarm35(const char* fname,FarmManager* a_manager);
1463 };
1464 
1465 
1466 
1467 //--------------------------------------------------------------------------------------------
1468 //--------------------------OptimisingFarm----------------------------------------------------
1469 //--------------------------------------------------------------------------------------------
1470 
1474 class Livestock {
1475  public:
1477  Livestock(TTypesOfAnimals a_animalType, int a_number);
1485  double m_FUdemand;
1486  };
1487 
1492  public:
1494  CropOptimised(TTypesOfCrops a_cropType, double a_initialArea);
1495  CropOptimised(TTypesOfVegetation a_cropType, double a_initialArea);
1496  CropOptimised(); //another constructor - for the fake crop
1497 
1504 
1505  //parameters: here saved - to make it easier to read them (they are needed very often)
1510 
1511  //optimised variables
1513  double m_n;
1515  double m_nt;
1517  double m_optimalN;
1518 
1520  double m_benefit;
1522  double m_resp;
1524  double m_BIHerb;
1526  double m_BIFi;
1528  double m_BI;
1530  double m_grooming;
1532  double m_hoeing;
1534  double m_weeding;
1536  double m_lossHerb;
1538  double m_lossFi;
1540  double m_totalLoss;
1542  double m_costs_ha;
1544  double m_income_ha;
1546  double m_GM;
1548  double m_savings;
1556  double m_area_ha;
1557 };
1558 
1564 {
1565 public:
1567  FarmManager();
1569  ~FarmManager();
1571  void FarmManagement();
1572  void InitiateManagement( void );
1573  void AddField(int a_OwnerIndex, LE* a_newland, int a_Owner);
1574  void RemoveField(int a_OwnerIndex, LE* a_field);
1575  int ConnectFarm(int a_owner);
1576  TTypesOfVegetation TranslateCropCodes(std::string& str); //moved from farm
1577  void DumpFarmAreas();
1579  void DumpFarmrefs();
1581  void InitFarms();
1583  void Save_diff_farm_types_areas();
1585  int GetFarmTotalSize(int a_farmref)
1586  {
1587  return (GetFarmPtr(a_farmref)->GetTotalArea());
1588  }
1590  int GetFarmArableSize(int a_farmref)
1591  {
1592  return (GetFarmPtr(a_farmref)->GetArea());
1593  }
1595  TTypesOfFarm GetFarmType(int a_farmref)
1596  {
1597  return (GetFarmPtr(a_farmref)->GetType());
1598  }
1600  int GetFarmNoFields(int a_farmref)
1601  {
1602  return (GetFarmPtr(a_farmref)->GetNoFields());
1603  }
1605  APoint GetFarmValidCoords(int a_farmref)
1606  {
1607  return (GetFarmPtr(a_farmref)->GetValidCoords());
1608  }
1609 
1611  int GetFarmNoOpenFields(int a_farmref, int a_openness)
1612  {
1613  return (GetFarmPtr(a_farmref)->GetNoOpenFields(a_openness));
1614  }
1615 
1617  int GetFarmAreaOpenFields(int a_farmref, int a_openness)
1618  {
1619  return (GetFarmPtr(a_farmref)->GetAreaOpenFields(a_openness));
1620  }
1621 
1623  Farm* GetFarmPtr( int a_owner ) {
1624  for (unsigned int i = 0; i < m_farms.size( ); i++) {
1625  if (a_owner == m_farms[ i ]->GetFarmNumber( )) {
1626  return m_farms[ i ];
1627  }
1628  }
1629  g_msg->Warn( "FarmManager::GetFarmPtr - missing farm ref", a_owner );
1630  exit( 92 );
1631  }
1632 
1634  Farm* GetFarmPtrIndex( int a_index) {
1635  return m_farms[ a_index ];
1636  }
1638  int GetRandomFarmRefnum() { return m_farms[random((int)m_farms.size())]->GetFarmNumber(); }
1640  void CalcCentroids() { for (unsigned int i = 0; i < m_farms.size(); i++) m_farms[i]->Centroids(); }
1642  bool InIllegalList( int a_farm_ref, vector<int> * a_farmlist );
1644  void AddToIllegalList( int a_farm_ref, vector<int> * a_farmlist );
1646  int FindClosestFarm(HunterInfo a_hinfo, vector<int> *a_farmlist);
1648  //int FindClosestFarmProb(HunterInfo a_hinfo, vector<int> *a_farmlist);
1650  int FindClosestFarmOpenness( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness );
1652  int FindClosestFarmOpennessProb( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness );
1654  int FindClosestFarmOpennessProbSmallIsBest( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness, vector<int> * a_farmsizelist );
1656  int FindClosestFarmOpennessProbNearRoostIsBest( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness, vector<APoint> * a_farmsizelist );
1658  int FindFarmWithRandom(vector<int> * a_farmlist);
1660  int FindFarmWithOpenness(vector<int> * a_farmlist, int a_openness);
1662  int FindOpennessFarm(int a_openness);
1664  bool CheckOpenness( int a_openness, int a_ref );
1666  APoint GetFarmCentroid(int a_farmref)
1667  {
1668  for (unsigned int i = 0; i < m_farms.size(); i++)
1669  {
1670  if (a_farmref == m_farms[i]->GetFarmNumber())
1671  {
1672  return m_farms[i]->GetCentroids();
1673  }
1674  }
1675  g_msg->Warn("FarmManager::GetFarmCentroid - missing farm ref", a_farmref);
1676  exit(92);
1677  }
1679  bool IsDuplicateRef(int a_ref, HunterInfo* a_hinfo);
1681  double GetSpilledGrain();
1683  double GetSpilledMaize();
1685  void SetSpilledGrain( bool a_spilledgrain ) {
1686  m_SpilledGrain = a_spilledgrain;
1687  }
1688 //for the decision making
1690  void FindNeighbours();
1692  double GetDD (void){return daydegrees;};
1693  void SetDD (double a_dd){daydegrees = a_dd;};
1694  double Get_cropTotals (int i) {return m_cropTotals[i];};
1695  void Add_to_cropTotals (int i, double value){m_cropTotals[i] += value;};
1696  void Set_cropTotals (int i, double value){m_cropTotals[i] = value;};
1697  int Get_cropTotals_size (){return (int)m_cropTotals.size();};
1699  void ActualProfit();
1701  void ChooseDecisionMode_for_farms();
1703  void Save_last_years_crops_for_farms();
1705  void PrintDecModes_counts();
1707  void PrintFinalResults();
1709  void Switch_rotation();
1710  TTypesOfVegetation Get_crops_summary_BIs_tov (int i){return m_crops_summary_BIs[i].Tov;};
1711  void Set_crops_summary_BIs_herb(int i, double BIherb){m_crops_summary_BIs[i].BIherb += BIherb;};
1712  void Set_crops_summary_BIs_fi(int i, double BIfi){m_crops_summary_BIs[i].BIfi += BIfi;};
1713  void Set_crops_summary_BIs (int i, double BI){m_crops_summary_BIs[i].BI += BI;};
1714  void Set_cropTotals_sum(int i, double crop_area){m_cropTotals_sum[i] += crop_area;};
1715  void Set_cropTotals_plant_sum(int i, double crop_area){m_cropTotals_plant_sum[i] += crop_area;};
1716  void Set_cropTotals_pig_sum(int i, double crop_area){m_cropTotals_pig_sum[i] += crop_area;};
1717  void Set_cropTotals_cattle_sum(int i, double crop_area){m_cropTotals_cattle_sum[i] += crop_area;};
1718  void Set_cropTotals_other_sum(int i, double crop_area){m_cropTotals_other_sum[i] += crop_area;};
1719 
1720  void Set_crops_fertilizer (int i, double fert){m_crops_fertilizer[i] += fert;};
1721  void Set_crops_fertilizer_trade (int i, double fert_trade){m_crops_fertilizer_trade[i] += fert_trade;};
1722 
1723 
1724  TTypesOfOptFarms TranslateFarmCodes(string &str);
1725  TTypesOfSoils TranslateSoilCodes(string &str);
1726  TTypesOfFarmSize TranslateFarmSizeCodes(string &str);
1727  TTypesOfAnimals TranslateAnimalsCodes (string &str);
1728  TTypesOfCrops TranslateCropsCodes (string &str);
1729  TTypesOfParameters TranslateParametersCodes (string &str);
1730  TTypesOfLivestockParameters TranslateLivestockParametersCodes (string &str);
1731  TTypesOfCropVariables TranslateCropVariablesCodes (string &str);
1734  ofstream * pm_output_file;
1735 
1736  int Get_lookup_table(int index){return m_crop_lookup_table[index];};
1737 
1739  int GetFarmNoLookup(int a_ref) { return m_farmmapping_lookup[a_ref * 2]; }
1741  int GetFarmTypeLookup(int a_ref) { return m_farmmapping_lookup[a_ref * 2 + 1]; }
1743  bool GetIsRenumbered() { return m_renumbered; }
1745  int GetRenumberedFarmRef(int a_farmref)
1746  {
1747  for (int i = 0; i < (int)m_farms.size(); i++)
1748  {
1749  if (m_farmmapping_lookup[i * 2] == a_farmref)
1750  {
1751  return i;
1752  }
1753  }
1754  g_msg->Warn( "FarmManager::GetRenumberedFarmRef(int a_farmref) Farm reference number not found in m_farmmapping_lookup ", a_farmref );
1755  exit( 9 );
1756  }
1757  int GetNoFarms( ) {
1758  return (int)m_farms.size();
1759  }
1760 
1761 
1762 protected:
1763  vector<Farm*> m_farms;
1765  void CreateFarms( const char *a_farmfile );
1767  double daydegrees;
1770 
1775 
1776 
1777 //for the optimisation
1778 
1782  double BIherb;
1783  double BIfi;
1784  double BI;
1785  };
1786 
1792 
1794  vector<double>m_cropTotals;
1798  vector<double>m_cropTotals_sum;
1800  vector<double>m_cropTotals_plant_sum;
1802  vector<double>m_cropTotals_pig_sum;
1806  vector<double>m_cropTotals_other_sum;
1808  vector<PesticideData>m_crops_summary_BIs;
1810  vector<double>m_crops_fertilizer;
1814  vector<double>m_crop_areas_stages;
1815 
1816 
1817  //data at a farm level
1819  void ReadFarmsData();
1821  void ReadLivestockNumbers();
1823  void ReadInitialCropAreas();
1824 
1825  //data for farms
1827  void ReadFarmsData_perFarmType();
1828 
1829  //data for livestock
1831  void ReadLivestockData();
1832 
1833  //data for crops
1835  void ReadCropsData();
1837  void ReadCropsData_perSoilType();
1839  void ReadCropsData_perFarmType();
1841  void ReadCropsData_perFarm_and_Soil();
1843  void ReadCropsData_perFarm_and_Soil_and_Size();
1844 
1845  //data for almass crops:
1847  void ReadInitialCropAreas_almass();
1849  void ReadCropsData_almass();
1851  void ReadCropsData_perSoilType_almass();
1853  void ReadCropsData_perFarmType_almass();
1855  void ReadCropsData_perFarm_and_Soil_almass();
1857  void ReadCropsData_perFarm_and_Soil_and_Size_almass();
1858 
1859  //for energy maize runs
1860  void ReadEnergyMaizePrice();
1861 
1862  //methods
1863 
1865  void OptimisationOutput();
1867  void PrintOutput(TTypesOfCropVariables a_var, string a_fileName);
1869  void CropDistribution();
1871  void Create_Output_file_for_farms();
1873  void ReadLookupTable();
1875  void PrintNeighbours();
1877  void DistributeFarmerTypes();
1878 
1879 };
1880 
1881 
1885 class OptimisingFarm : public Farm
1886 {
1887 public:
1889  OptimisingFarm( FarmManager* a_myfarmmanager, int a_No);
1890  virtual ~OptimisingFarm() { ; }
1891  TTypesOfOptFarms Get_farmType (void) {return m_farmType;}
1892  TTypesOfSoils Get_soilType (void) {return m_soilType;}
1893  TTypesOfFarmSize Get_farmSize (void) {return m_farmSize;}
1894  int Get_farmRealID (void) {return m_farmRealID;}
1895  int Get_soilSubType (void) {return m_soilSubType;}
1896  int Get_almass_no (void) {return m_almass_no;}
1897  CropOptimised* Get_crop (int i) {return m_crops[i];}
1898  int Get_cropsSize(void) {return (int)m_crops.size();}
1899  void Set_Livestock (Livestock* p_lvs){m_livestock.push_back(p_lvs);};
1900  void Set_Crop(CropOptimised* p_crop){m_crops.push_back(p_crop);};
1901 
1902  //-------------------------------------------------------------------------------------------------------------
1903  //for the modified dec. making - using CONSUMAT approach
1904 
1905  void Set_Neighbour(OptimisingFarm* farm){m_neighbours.push_back(farm);};
1906  int Get_NeighboursSize(void) {return (int)m_neighbours.size();};
1907  OptimisingFarm * Get_Neighbour (int i){return m_neighbours[i];};
1908  vector<AlmassCrop> Get_rotational_crops(){return m_rotational_crops;};
1909  vector<AlmassCrop> Get_rotational_crops_visible(){return m_rotational_crops_visible;};
1910  double Get_actual_profit() {return m_actual_profit;};
1911  double Get_actual_aggregated_yield() {return m_actual_aggregated_yield;};
1912  int GetFarmCentroidX() { return m_farm_centroidx; }
1913  int GetFarmCentroidY() { return m_farm_centroidy; }
1914  void Set_main_goal (TTypeOfFarmerGoal a_goal){m_main_goal = a_goal;};
1915  TTypeOfFarmerGoal Get_main_goal() {return m_main_goal;};
1916  void Set_animals_no (int a_number){animals_no = a_number;};
1917  int Get_decision_mode_counters (int index){return m_decision_mode_counters[index];};
1919  bool Harvest( LE *a_field, double a_user, int a_days );
1921  void Match_crop_to_field(LE* a_field);
1923  OptimisingFarm * Find_neighbour_to_imitate();
1924 
1926  void ActualProfit();
1928  void Save_last_years_crops();
1930  void ChooseDecisionMode();
1932  virtual bool Spraying_herbicides(TTypesOfVegetation a_tov_type);
1934  virtual bool Spraying_fungins(TTypesOfVegetation a_tov_type);
1936  virtual double Prob_multiplier ();
1937 
1938  //-------------------------------------------------------------------------------------------------------------
1939 
1941  void Init(ofstream * ap_output_file);
1942 
1943 protected:
1945  virtual void InitiateManagement( void );
1947  void Initialize(FarmManager * a_pfm);
1948  virtual void HandleEvents( void );
1950  virtual bool FungicideTreat( LE *a_field, double /*a_user*/, int a_days );
1952  virtual bool InsecticideTreat( LE *a_field, double /*a_user*/, int a_days );
1954  virtual bool HerbicideTreat( LE *a_field, double /*a_user*/, int a_days );
1955 
1956  //----------------------------------------------------------------------------------------------------
1957  //'farmer' variables - for the modified decision making
1958 
1961  //TTypeOfFarmerGoal m_pest_goal;
1962  //TTypeOfFarmerGoal m_fert_goal;
1963 
1965  vector<OptimisingFarm*>m_neighbours;
1972 
1973  //the actual and expected values
1985  double m_exp_costs;
1992 
1994  vector<double>m_previous_profits;
1996  vector<double>m_previous_incomes;
1998  vector<double>m_previous_costs;
2005 
2007  vector<double>m_animals_numbers;
2012 
2013  //-----------------------------------------------------------------------------------------------------
2014 
2015 
2016  //structs
2018  struct CropSort {
2019  double key;
2021  };
2022 
2024  struct reverseSort {
2025  bool operator()(CropSort a, CropSort b) { return a.key > b.key; }
2026  };
2027 
2030  struct MakeRotation {
2031  bool taken;
2033  };
2034 
2035 
2036  //lists - vectors
2038  vector<Livestock*>m_livestock;
2040  vector<CropOptimised*>m_crops;
2042  vector<CropSort>m_variableCrops;
2047  vector<CropSort>m_variableCrops2;
2049  vector<CropOptimised*>m_grownVariableCrops;
2051  vector<CropOptimised*>m_fixedCrops;
2053  vector<CropSort>m_rotationCrops;
2055  vector<CropSort>m_winterCrops;
2057  vector<AlmassCrop>m_crops_almass;
2059  vector<AlmassCrop>m_rotational_crops;
2061  vector<AlmassCrop>m_rotational_crops_copy;
2063  vector<AlmassCrop>m_rotational_crops_visible;
2064 
2065  //farm parameters (not-farm specific parameters are stored in the DataForOptimisation class)
2078 
2079  //variables
2081  double m_totalArea;
2089  double m_Nanim;
2095  double m_totalFUt;
2099  double m_assigned;
2101  double m_totalN;
2103  double m_totalNt;
2107  double m_totalBIFi;
2109  double m_totalBI;
2123  double m_area_rot;
2124 
2125 
2126  // methods
2127 
2129  virtual void createCropsLists(int a_foobar);
2131  void createVariableCrops(int a_foobar);
2133  void FarmLevelCalculation();
2135  void OptimiseFarm(int a_foobar);
2136 
2138  void Check_SG_and_CGG();
2139 
2140  //METHODS FOR FARM VARIABLES
2142  void findTotalArea();
2144  void findTotalNanim();
2146  void findNanim();
2148  virtual void findFodderDemand();
2150  virtual void preventCashCrops(){};
2151 
2152 
2153  //OPTIMISATION
2155  void optimizeCrops(int a_foobar);
2156 
2157  //OPTIMISATION - SIMPLIFIED METHOD
2159  void findFertilizer(CropOptimised * a_crop, int a_foobar, double benefit);
2161  void findResponse(CropOptimised * a_crop, int a_foobar);
2163  void findBIs(CropOptimised * a_crop, double benefit);
2165  void fixBI();
2167  void findMWeedControl(CropOptimised * a_crop);
2169  void findYieldLoss(CropOptimised * a_crop);
2171  void findGrossMargin(CropOptimised * a_crop, int a_foobar, double benefit);
2172 
2173  //AREA ASSIGNMENT
2175  void assignFixed();
2177  void sumMinAreas();
2179  virtual void determineAreas(int a_foobar);
2181  void determineAreas_ha(vector<CropOptimised*>crops);
2182 
2183  //RESTRICTIONS - CROPS AREA
2185  virtual void checkRestrictions();
2187  virtual void checkWinterRotation1(){};
2189  virtual void checkWinterCrops(){};
2191  void setRotationCropsAtMax();
2192 
2193  //OTHER FUNCTIONS
2195  double crop_parameter(int index, string par_name);
2197  CropOptimised * findCropByName (string crop_name);
2199  CropOptimised * findCropByName_almass (string crop_name);
2201  CropOptimised * findCropByName_almass (TTypesOfVegetation a_tov_type);
2203  double total(TTypesOfCropVariables variable_name);
2205  void sortCrops(vector<CropSort> &cropsToSort, string sortingKey);
2207  void randomizeCropList(vector<CropSort> &listToRandomize, string key);
2209  virtual void increaseCrops(vector<CropSort>cropsToIncrease, double &howMuchToIncrease);
2211  virtual void decreaseCrops(vector<CropSort>cropsToDecrease, double &howMuchToDecrease);
2213  void Print_FarmVariables (ofstream * ap_output_file);
2215  void Make_rotations();
2217  void Check_if_area_100();
2219  void Translate_crops_to_almass();
2221  void Make_almass_crops_vector();
2223  void Make_rotational_crops();
2225  void Print_rotations(ofstream * ap_output_file);
2226 
2227 };
2228 
2233 public:
2234  AnimalFarm(FarmManager * a_myfarmmanager, int a_No);
2235  virtual ~AnimalFarm(){};
2236 protected:
2237 
2239  CropOptimised *m_fakeCrop;
2243  vector<CropSort>m_fodderCrops;
2244 
2245  //variables
2246 
2255 
2256  //methods
2257  virtual void createCropsLists(int a_foobar);
2259  virtual void determineAreas(int a_foobar);
2260 
2261  //FODDER CROPS
2263  void createFodderCrops(int a_foobar);
2265  void findFodderCropSavings();
2267  void correctFodderDemand(int a_foobar);
2269  void determineFodderAreas(int a_foobar);
2271  void determineMinFodder(int a_foobar);
2272 
2273  //RESTRICTIONS - CROPS AREA
2275  virtual void checkWinterRotation1();
2277  virtual void checkWinterCrops();
2278 
2279  //OTHER
2281  virtual void increaseCrops(vector<CropSort>cropsToIncrease, double &howMuchToIncrease);
2283  virtual void decreaseCrops(vector<CropSort>cropsToDecrease, double &howMuchToDecrease);
2284 
2285 };
2286 
2291 public:
2292  OptimisingPigFarm(FarmManager* a_myfarmmanager, int a_No);
2293  virtual ~OptimisingPigFarm(){};
2294 
2295 protected:
2297  virtual void checkRestrictions();
2299  void check_WRape_WBarley();
2300 };
2301 
2306 public:
2307  OptimisingCattleFarm(FarmManager* a_myfarmmanager, int a_No);
2309 
2310 protected:
2312  vector<CropSort>m_cattleCrops;
2314  vector<CropSort>m_cattleCrops_almass;
2316  virtual void checkRestrictions();
2318  void checkCattleRotation();
2320  void checkCattleRotation_almass();
2322  void setCattleCropsAtMin();
2324  virtual void preventCashCrops();
2325 
2326 };
2327 
2328 
2333 public:
2334  NonAnimalFarm(FarmManager * a_myfarmmanager, int a_No);
2335  virtual ~NonAnimalFarm(){};
2336 protected:
2337 
2338  //methods
2339  //METHODS FOR FARM VARIABLES
2340  virtual void findFodderDemand();
2341 
2342  //RESTRICTIONS
2344  virtual void checkWinterRotation1();
2346  virtual void checkWinterCrops();
2347 };
2348 
2353 public:
2354  OptimisingPlantFarm(FarmManager* a_myfarmmanager, int a_No);
2356 };
2357 
2362 public:
2363  OptimisingOtherFarm(FarmManager* a_myfarmmanager, int a_No);
2365 };
2366 
2367 
2368 
2369 
2370 
2371 #endif // FARM_H
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1234
TTypesOfOptFarms
Definition: farm.h:224
TTypesOfFarmSize Get_farmSize(void)
Definition: farm.h:1893
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:909
Inbuilt farm type.
Definition: farm.h:955
PotatoesIndustry * m_potatoesindustry
Definition: farm.h:914
double m_rotationMin
Minimum area in percent of farm&#39;s arable area for a given crop (depends on a farm size...
Definition: farm.h:1509
void Set_cropArea(double a_area)
Definition: farm.h:520
TTypeOfFarmerGoal Get_main_goal()
Definition: farm.h:1915
The base class for all crops.
Definition: farm.h:462
Inbuilt farm type.
Definition: farm.h:967
void Set_biomass_factor(double a_value, int i)
Definition: farm.h:575
TTypesOfLivestockParameters
Definition: farm.h:338
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1252
OGrazingPigs * m_ograzingpigs
Definition: farm.h:889
int m_startday
Definition: farm.h:394
int m_rotation_sync_index
Definition: farm.h:847
vector< double > m_previous_satisfaction_levels
Vector of satisfaction levels in five previous years.
Definition: farm.h:2002
virtual bool Spraying_fungins(TTypesOfVegetation)
Definition: farm.h:701
vector< int > m_crop_lookup_table
Specifies which crop order is allowed in a rotation (i.e. if a given crop can follow another crop)...
Definition: farm.h:1796
Population_Manager * m_population_manager
Definition: farm.h:1764
vector< CropSort > m_winterCrops
Vector of structs containing pointers to winter crops.
Definition: farm.h:2055
Subclass of the OptimisingFarm. Either pig or cattle farm.
Definition: farm.h:2232
APoint m_farmvalid
Definition: farm.h:430
OTriticale * m_otriticale
Definition: farm.h:901
Definition: farm.h:235
double m_FUdemand
Amount of fodder needed for a given type of livestock. [fodder units].
Definition: farm.h:1485
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1189
void SetDD(double a_dd)
Definition: farm.h:1693
int Get_almass_no(void)
Definition: farm.h:1896
TTypesOfFarm
Definition: farm.h:167
Inbuilt special purpose farm type.
Definition: farm.h:1049
int GetRandomFarmRefnum()
Returns a random farm reference number.
Definition: farm.h:1638
bool m_SpilledGrain
Is it 2013 (true) or 2014 (false) as far as grain goes.
Definition: farm.h:1769
void Set_main_goal(TTypeOfFarmerGoal a_goal)
Definition: farm.h:1914
virtual ~OptimisingFarm()
Definition: farm.h:1890
vector< double > m_cropParameters
Vector storing parameters of all crop types.
Definition: farm.h:641
FieldPeasStrigling * m_fieldpeasstrigling
Definition: farm.h:946
vector< bool > m_fixed
Crop Boolean parameter - fixed/variable crop. Farm type specific.
Definition: farm.h:657
int GetFarmNoFields(int a_farmref)
Returns the number of fields owned by a from the farm ref num.
Definition: farm.h:1600
SpringBarleySpr * m_springbarleyspr
Definition: farm.h:919
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1005
void Set_noCrops(int no)
Definition: farm.h:584
TTypesOfVegetation GetNextCrop(int a_index)
Definition: farm.h:819
APoint GetFarmValidCoords(int a_farmref)
Returns the number of fields owned by a from the farm ref num.
Definition: farm.h:1605
TTypesOfFarmSize md_farmSize
Definition: farm.h:596
OPotatoes * m_opotatoes
Definition: farm.h:894
vector< CropOptimised * > m_fixedCrops
Vector of pointers to fixed crops.
Definition: farm.h:2051
int Get_winterMax(int i)
Definition: farm.h:530
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:883
void Set_Crop(CropOptimised *p_crop)
Definition: farm.h:1900
TTypesOfFarm GetType(void)
Definition: farm.h:803
void SetFarmNumber(int a_farm_num)
Definition: farm.h:697
SetAside * m_setaside
Definition: farm.h:917
vector< LE * > m_fields
Definition: farm.h:839
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1428
TTypesOfOptFarms m_farmType
Farm&#39;s type (cattle, pig, plant, other).
Definition: farm.h:2067
long m_run
Definition: farm.h:396
int GetFarmTotalSize(int a_farmref)
Returns the total farm area from the farm ref num.
Definition: farm.h:1585
Triticale * m_triticale
Definition: farm.h:926
double m_totalFUgrown
Fodder grown, i.e. obtained from growing fodder crops. [fodder units].
Definition: farm.h:2097
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:906
Struct used for storing data on pesticide usage throughout the whole simulation (one instance...
Definition: farm.h:1780
TTypesOfParameters
Definition: farm.h:317
Definition: farm.h:352
vector< int > FarmHuntRef
The hunter&#39;s is the farm reference number to where he hunts.
Definition: farm.h:448
OWinterBarley * m_owinterbarley
Definition: farm.h:902
vector< double > m_previous_incomes
Vector of incomes from previous years.
Definition: farm.h:1996
bool IsStockFarmer(void)
Definition: farm.h:807
double m_totalBIHerb
Total amount of herbicides which is planned to be applied at a farm. Expressed as a Treatment frequen...
Definition: farm.h:2105
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1448
double Get_sellingPrice_lastyr(int i)
Definition: farm.h:566
Inbuilt special purpose farm type.
Definition: farm.h:1071
vector< int > m_decision_mode_counters
Vector with counters for each decision mode. 0 - imitation, 1 - social comparison, 2 - repeat, 3 - deliberation.
Definition: farm.h:1971
void Set_emaize_price(double a_value)
Definition: farm.h:587
Class storing farm information: farm&#39;s number used in ALMaSS system, farm&#39;s soil type, farm&#39;s size (business or private) and farm&#39;s real ID number.
Definition: farm.h:591
OOats * m_ooats
Definition: farm.h:892
double totalOptFarmsArea_cattle
Definition: farm.h:1790
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1144
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1368
void Set_winterMax(int a_value, int i)
Definition: farm.h:529
vector< CropOptimised * > m_crops
Vector of pointers to all crops.
Definition: farm.h:2040
vector< TTypesOfCrops > m_cropTypes
Crop types saved as enumarator types (Bedriftsmodel i.e. original crop optimization model crop mode)...
Definition: farm.h:618
SpringRape * m_springrape
Definition: farm.h:925
vector< AlmassCrop > m_crops_almass
Vector of structs with almass type crops with positive areas in % (result of optimisation).
Definition: farm.h:2057
vector< double > m_beta2
Crop parameter for response (growth) function (resp = alfa + beta1*N + beta2*N^2; defines relationshi...
Definition: farm.h:648
double totalOptFarmsArea_other
Definition: farm.h:1791
SeedGrass2 * m_seedgrass2
Definition: farm.h:916
void Set_crops_summary_BIs(int i, double BI)
Definition: farm.h:1713
vector< CropSort > m_variableCrops
Vector of structs containing pointers to crops which are not fixed.
Definition: farm.h:2042
OWinterWheat * m_owinterwheat
Definition: farm.h:907
SpringBarley * m_springbarley
Definition: farm.h:918
double totalOptFarmsArea_plant
Definition: farm.h:1788
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1288
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:923
TTypeOfFarmerGoal m_main_goal
Farmer&#39;s main goal (determined by a farmer&#39;s type) .
Definition: farm.h:1960
Inbuilt special purpose farm type.
Definition: farm.h:1061
vector< int > m_livestockNumbers
Vector containing numbers of all livestock types at farms included in the simulation.
Definition: farm.h:629
double m_exp_income
An expected farm&#39;s income at a farm in a given year.
Definition: farm.h:1981
OMaizeSilage * m_omaizesilage
Definition: farm.h:880
TTypesOfVegetation Tov
Definition: farm.h:498
double m_area_rot
Area assigned to rotational crops. [ha].
Definition: farm.h:2123
virtual void MakeStockFarmer(void)
Definition: farm.h:983
double m_actual_profit
An actual profit realised at a farm in a given year.
Definition: farm.h:1975
virtual void preventCashCrops()
Prevents small cattle farms from growing cash crops and maize silage.
Definition: farm.h:2150
TTypesOfFarmSize m_farmSize
Scale of the farm - business (size above 10 ha) or private (size below 10 ha).
Definition: farm.h:2071
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:934
void Set_livestockNumber(int a_number)
Definition: farm.h:519
A data structure to hold hunter information for distribution.
Definition: farm.h:438
void Set_cropParameter(double a_value, int i)
Definition: farm.h:537
double m_income_ha
Value of income per ha of a crop. Includes value of sales and subsidy [DKK/ha].
Definition: farm.h:1544
Subclass of the NonAnimalFarm.
Definition: farm.h:2352
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1153
int GetFarmArableSize(int a_farmref)
Returns the arable area from the farm ref num.
Definition: farm.h:1590
TTypesOfAnimals m_animalType
Type of livestock.
Definition: farm.h:1479
vector< CropSort > m_rotationCrops
Vector of structs containing pointers to (winter) rotation crops.
Definition: farm.h:2053
double m_costs_ha
Costs of growing 1 ha of a crop. Include costs of labour and machine (constant), pesticides (herbicid...
Definition: farm.h:1542
TTypesOfVegetation GetCrop(int a_index)
Definition: farm.h:816
int GetNoFarms()
Definition: farm.h:1757
bool operator()(CropSort a, CropSort b)
Definition: farm.h:2025
OCarrots * m_ocarrots
Definition: farm.h:882
vector< Hunter * > HunterList
Definition: farm.h:165
int homeY
Hunter home y-coord.
Definition: farm.h:446
OWinterRape * m_owinterrape
Definition: farm.h:904
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1225
double Get_FUKey(int i)
Definition: farm.h:561
void Set_Nnorm(double a_value, int i)
Definition: farm.h:546
double m_BIFi
Value of BI for fung- and insecticides [BI/ha].
Definition: farm.h:1526
virtual void MakeStockFarmer(void)
Definition: farm.h:1033
Sugarbeet * m_sugarbeet
Definition: farm.h:876
void Set_crops_summary_BIs_fi(int i, double BIfi)
Definition: farm.h:1712
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:871
Definition: farm.h:253
void Set_cropTypes_almass_str(string crop_type)
Definition: farm.h:581
int m_first_date
Definition: farm.h:468
APoint m_farmcentroid
Definition: farm.h:429
A class for storing livestock parameters and variables for optimising farms.
Definition: farm.h:1474
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1243
bool m_renumbered
A flag to show whether renumbering was already done.
Definition: farm.h:1774
Definition: farm.h:348
int Pct
Definition: farm.h:378
int Get_cropsSize(void)
Definition: farm.h:1898
void SetSpilledGrain(bool a_spilledgrain)
Set m_SpilledGrain which is the flag for either 2013 (true) or 2014 (false) spilled grain distributio...
Definition: farm.h:1685
void Set_fodder(string a_value, int i)
Definition: farm.h:555
FodderGrass * m_foddergrass
Definition: farm.h:870
int Get_decision_mode_counters(int index)
Definition: farm.h:1917
vector< int > m_winterMax
Maximal area taken by winter crops at a farm. [%].
Definition: farm.h:632
virtual ~OptimisingPigFarm()
Definition: farm.h:2293
TTypesOfAnimals Get_livestockTypes(int i)
Definition: farm.h:514
double Get_cropArea(int index)
Definition: farm.h:523
OFodderbeet * m_ofodderbeet
Definition: farm.h:877
vector< CropSort > m_cattleCrops_almass
Vector of crops used in checkCattleRotation_almass.
Definition: farm.h:2314
double m_Nanim
Amount of animal fertilizer available at a farm per hectar. [kg/ha].
Definition: farm.h:2089
Definition: farm.h:258
bool m_fakeCropTest
Set to true if the fake crop is present after determineAreas function.
Definition: farm.h:2241
double m_totalNanim
Total animal fertilizer at a farm. A sum of Livestock::m_NanimUsable (from all types of livestock)...
Definition: farm.h:2087
virtual ~Crop()
Definition: farm.h:480
void Set_beta1(double a_value, int i)
Definition: farm.h:542
int GetFarmNoOpenFields(int a_farmref, int a_openness)
Returns the number of fields with openness more than a_openness.
Definition: farm.h:1611
double Get_actual_profit()
Definition: farm.h:1910
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:872
virtual ~AnimalFarm()
Definition: farm.h:2235
double m_lossFi
Value of the yield loss due to the limited use of fung- and insecticides [%].
Definition: farm.h:1538
Struct redefining operator < - used for sorting crops.
Definition: farm.h:2024
TTypesOfVegetation
double m_actual_aggregated_yield
Actual aggregated yield at a farm in a given year.
Definition: farm.h:1988
TTypesOfOptFarms Get_farmType(void)
Definition: farm.h:1891
WinterRapeStrigling * m_winterrapestrigling
Definition: farm.h:943
int GetFarmTypeLookup(int a_ref)
Get a farm type from the lookup table.
Definition: farm.h:1741
Definition: elements.h:81
TTypesOfVegetation Tov
Definition: farm.h:377
vector< AlmassCrop > m_rotational_crops_copy
A copy of m_rotational_crops used when matching crops to fields.
Definition: farm.h:2061
vector< double > m_crops_fertilizer_trade
Stores information on aggregate (all farms) fertilizer trade (Nt) usage for each crop.
Definition: farm.h:1812
double m_totalWeeding
Total manual weeding planned at a farm.
Definition: farm.h:2115
double m_totalFUdemandBefore
Farm&#39;s total demand for fodder. [fodder units]
Definition: farm.h:2091
Definition: farm.h:247
double m_areaPercent
Area of a crop in percent of a farm&#39;s total area [%].
Definition: farm.h:1552
vector< int > CheckedFarms
A list of farms that has been tested for duplicates.
Definition: farm.h:450
Subclass of the NonAnimalFarm.
Definition: farm.h:2361
virtual void MakeStockFarmer(void)
Definition: farm.h:1043
Definition: farm.h:259
vector< Farm * > m_farms
Definition: farm.h:1763
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:1885
Base class for all population managers.
vector< PesticideData > m_crops_summary_BIs
Stores information on aggregate (all farms)pesticide usage for each crop.
Definition: farm.h:1808
int GetFarmCentroidX()
Definition: farm.h:1912
double m_resp
Response - yield of a crop per ha [hkg/ha].
Definition: farm.h:1522
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1418
TTypesOfVegetation m_event
Definition: farm.h:398
virtual ~OptimisingPlantFarm()
Definition: farm.h:2355
TTypesOfFarmSize
Definition: farm.h:239
Struct for storing ALMaSS crop type (TTypesOfVegetation) with a corresponding value (mainly crop area...
Definition: farm.h:496
void Set_animals_no(int a_number)
Definition: farm.h:1916
double m_totalFUt
Fodder from trade (has to be purchased). [fodder units].
Definition: farm.h:2095
void Set_Livestock(Livestock *p_lvs)
Definition: farm.h:1899
WinterRye * m_winterrye
Definition: farm.h:929
double m_totalArea
Total area of a farm. A sum of initial crop areas (if in bedriftsmodel, i.e. original farm optimizati...
Definition: farm.h:2081
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1438
Inbuilt special purpose farm type.
Definition: farm.h:1080
double m_areaVariable
Area of a crop that can be changed when checking for restrictions (=m_areaPercent - m_rotationMin) [%...
Definition: farm.h:1554
Definition: farm.h:233
vector< CropSort > m_variableCrops2
Vector of structs containing pointers to crops which are not fixed and: in case of the winter rotatio...
Definition: farm.h:2047
double m_actual_costs
Actual costs at a farm in a given year.
Definition: farm.h:1983
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
int Get_livestockNumber(int index)
Definition: farm.h:521
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1358
WinterRape * m_winterrape
Definition: farm.h:928
TTypesOfSoils Get_soilType(void)
Definition: farm.h:1892
double m_grooming
Value of mechanical weed control for a crop - grooming [DKK/ha].
Definition: farm.h:1530
Used during saving farm/hunter information.
Definition: farm.h:421
double totalOptFarmsArea
Definition: farm.h:1787
double Get_Nnorm(int i)
Definition: farm.h:547
Inbuilt special purpose farm type.
Definition: farm.h:1029
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1279
double m_GM
Value of gross margin for a crop (m_income_ha - m_costs_ha) [DKK/ha].
Definition: farm.h:1546
double m_totalLoss
Summary value of the yield loss due to the limited use of herbicides and fung- and insecticides [%]...
Definition: farm.h:1540
double m_exp_aggregated_yield
Expected aggregated yield at a farm in a given year.
Definition: farm.h:1991
double Get_sellingPrice(int i)
Definition: farm.h:564
int GetFarmNumber(void)
Definition: farm.h:698
MaizeStrigling * m_maizestrigling
Definition: farm.h:942
Definition: farm.h:263
int GetFarmCentroidY()
Definition: farm.h:1913
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:908
int Get_soilSubType(void)
Definition: farm.h:1895
double m_totalArea_original
Total area of a farm as in bedriftsmodel, i.e. original farm optimization model. [ha].
Definition: farm.h:2083
int m_number
Number of animals of a given type at a farm.
Definition: farm.h:1481
OSeedGrass2 * m_oseedgrass2
Definition: farm.h:896
APoint GetFarmCentroid(int a_farmref)
Gets the farm centroid as an APoint.
Definition: farm.h:1666
int m_soilSubType
Farm&#39;s soil subtype. Defined only for cattle farms on sandy soil (0-bad, 1-good, 2-undefined).
Definition: farm.h:2075
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:940
Definition: farm.h:349
WinterBarleyStrigling * m_winterbarleystrigling
Definition: farm.h:945
Inbuilt special purpose farm type.
Definition: farm.h:1089
double m_nt
Amount of purchased (and applied) fertilizer per ha of a crop [kg N/ha].
Definition: farm.h:1515
The Farm Manager class.
Definition: farm.h:1563
bool Get_fodder(int i)
Definition: farm.h:559
double Get_livestockParameter(int i)
Definition: farm.h:534
void Set_Neighbour(OptimisingFarm *farm)
Definition: farm.h:1905
int refID
Unique reference number.
Definition: farm.h:442
void Set_cropTypes_str(string crop_type)
Definition: farm.h:513
Inbuilt special purpose farm type.
Definition: farm.h:1098
double m_totalCosts
Planned total costs of growing crops at a farm. [DKK].
Definition: farm.h:2117
TTypesOfOptFarms md_farmType
Definition: farm.h:594
PermanentSetAside * m_permanentsetaside
Definition: farm.h:912
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1216
int m_farm_centroidy
Farm&#39;s centroid, value y. Equal to the average of the y centroid values of all farm&#39;s fields...
Definition: farm.h:863
Farm * GetFarmPtrIndex(int a_index)
Returns the pointer to a farm with a specific index.
Definition: farm.h:1634
LE * m_field
Definition: farm.h:400
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
TTypesOfFarm m_farmtype
Definition: farm.h:842
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
Definition: farm.h:938
Inbuilt special purpose farm type.
Definition: farm.h:1107
Class for storing data for optimisation.
Definition: farm.h:505
vector< CropOptimised * > m_grownVariableCrops
Vector of pointers to variable crops that are grown on area larger than areaMin (after determineAreas...
Definition: farm.h:2049
TTypeOfFarmerGoal
Definition: farm.h:365
int m_farm_centroidx
Farm&#39;s centroid, value x. Equal to the average of the x centroid values of all farm&#39;s fields...
Definition: farm.h:861
The base class for all farm types.
Definition: farm.h:683
double Get_rotationMax(int i)
Definition: farm.h:569
vector< double > m_cropAreas
Vector containing values of initial (i.e. in year the data is taken for) crop areas at farms included...
Definition: farm.h:627
Maize * m_maize
Definition: farm.h:878
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:936
vector< TTypesOfVegetation > m_cropTypes_almass
Crop types saved as enumarator types (ALMaSS crop mode).
Definition: farm.h:623
void Set_fixed(string a_value, int i)
Definition: farm.h:550
int m_farmref
Definition: farm.h:422
string Get_cropTypes_almass_str(int i)
Definition: farm.h:582
virtual void checkWinterRotation1()
Checks if the restriction on a winter rotation is fulfilled.
Definition: farm.h:2187
Definition: farm.h:260
OSpringBarley * m_ospringbarley
Definition: farm.h:897
vector< AlmassCrop > m_rotational_crops
Vector of structs with almass type crops with positive areas in % (result of optimisation): includes ...
Definition: farm.h:2059
int m_openfields
Definition: farm.h:427
int m_farmRealID
Farm&#39;s real ID number.
Definition: farm.h:2073
void Set_rotationMin(double a_value, int i)
Definition: farm.h:570
double Get_cropParameter(int i)
Definition: farm.h:538
bool cash_crops_allowed
Sets to true if cash crops are allowed. True by default.
Definition: farm.h:2254
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1398
FarmEvent(TTypesOfVegetation a_event, LE *a_field, int a_todo, long a_run, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_nextcrop)
Definition: farm.h:402
Definition: farm.h:254
double m_totalBIFi
Total amount of fung- and insecticides which is planned to be applied at a farm. Expressed as a Treat...
Definition: farm.h:2107
vector< double > m_previous_profits
Vector of profits from previous years.
Definition: farm.h:1994
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1017
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:992
Subclass of the AnimalFarm.
Definition: farm.h:2290
vector< double > m_cropTotals_other_sum
Stores the sums of crops areas on other farms within one simulation at the landscape level...
Definition: farm.h:1806
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:920
Struct used for sorting crops.
Definition: farm.h:2018
CropOptimised * Get_crop(int i)
Definition: farm.h:1897
ofstream * pm_output_file
Definition: farm.h:1734
double Get_emaize_price(int i)
Definition: farm.h:588
int GetIntensity(void)
Definition: farm.h:809
vector< Livestock * > m_livestock
Vector of pointers to animals belonging to a farm.
Definition: farm.h:2038
double m_area_ha
Area of a crop in ha at a farm [ha].
Definition: farm.h:1556
double m_totalProfit
Planned total profit (= income - costs) at a farm. In case of animal farms costs of purchased fodder ...
Definition: farm.h:2121
double m_actual_income
An actual income at a farm in a given year.
Definition: farm.h:1979
WinterRyeStrigling * m_winterryestrigling
Definition: farm.h:944
Fodderbeet * m_fodderbeet
Definition: farm.h:875
vector< double > m_beta1
Crop parameter for response (growth) function (resp = alfa + beta1*N + beta2*N^2; defines relationshi...
Definition: farm.h:646
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1408
void Set_beta2(double a_value, int i)
Definition: farm.h:544
virtual void MakeStockFarmer(void)
Definition: farm.h:808
bool m_stockfarmer
Definition: farm.h:845
virtual void MakeStockFarmer(void)
Definition: farm.h:1053
vector< bool > m_fodder
Crop Boolean parameter - fodder/non-fodder crop. Farm type specific.
Definition: farm.h:659
int pct
Definition: farm.h:384
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:874
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1180
A struct to hold the information required to trigger a farm event.
Definition: farm.h:391
TTypesOfCrops Get_cropTypes(int i)
Definition: farm.h:516
double m_exp_costs
Expected costs at a farm in a given year.
Definition: farm.h:1985
int GetNoFields()
Returns the number of the fields owned.
Definition: farm.h:710
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1328
Inbuilt special purpose farm type.
Definition: farm.h:1039
vector< double > m_cropTotals_pig_sum
Stores the sums of crops areas on pig farms within one simulation at the landscape level...
Definition: farm.h:1802
int m_nofields
Definition: farm.h:426
virtual double Prob_multiplier()
Definition: farm.h:702
TTypesOfVegetation m_cropType_almass
Type/name of a crop (ALMaSS crops).
Definition: farm.h:1503
double Get_beta2(int i)
Definition: farm.h:545
Oats * m_oats
Definition: farm.h:891
vector< double > m_previous_costs
Vector of costs from previous years.
Definition: farm.h:1998
int m_NoHunters
Definition: farm.h:431
A class for storing all parameters and results of crop optimisation.
Definition: farm.h:1491
CropOptimised * crop
Definition: farm.h:2020
int Get_NeighboursSize(void)
Definition: farm.h:1906
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1348
int GetFarmNoLookup(int a_ref)
Get a farm reference from the lookup table.
Definition: farm.h:1739
double totalOptFarmsArea_pig
Definition: farm.h:1789
int GetMaxOpenness()
Returns the maximum openness score of the fields.
Definition: farm.h:718
vector< double > m_rotationMin
Minimum acreage of a crop at a farm [%]. Farm type, soil type and farm size specific.
Definition: farm.h:671
LowPriority< FarmEvent * > m_queue
Definition: farm.h:838
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:911
TTypesOfVegetation Tov
Definition: farm.h:2032
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1270
WinterBarley * m_winterbarley
Definition: farm.h:927
double m_assigned
Variable holding a value of area already reserved for certain crops at a farm. [0-100%].
Definition: farm.h:2099
vector< double > m_energy_maize_price
Vector with energy maize prices for each year of simulation.
Definition: farm.h:675
vector< double > m_FUKey
Crop parameter: Fodder unit key, i.e. a number of fodder units obtained from a given crop [FU/hkg]...
Definition: farm.h:661
double m_certainty_level
Farmer&#39;s certainty level.
Definition: farm.h:1969
FarmManager * m_OurManager
Pointer to the FarmManager.
Definition: farm.h:837
vector< double > m_rotationMax
Maximum acreage of a crop at a farm [%]. Farm type, soil type and farm size specific.
Definition: farm.h:669
void Set_sellingPrice(double a_value, int i)
Definition: farm.h:563
double m_initialArea
Initial area of a crop on a farm [ha].
Definition: farm.h:1499
int GetFarmAreaOpenFields(int a_farmref, int a_openness)
Returns the area of fields with openness more than a_openness.
Definition: farm.h:1617
vector< PermCropData > m_PermCrops
Definition: farm.h:841
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:937
int GetFirstDate(void)
Definition: farm.h:482
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:924
void Set_cropTotals(int i, double value)
Definition: farm.h:1696
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1207
void Set_rotationMax(double a_value, int i)
Definition: farm.h:568
double Get_biomass_factor(int i)
Definition: farm.h:576
TTypesOfAnimals
Definition: farm.h:245
virtual bool Spraying_herbicides(TTypesOfVegetation)
Definition: farm.h:700
TTypesOfCrops
Definition: farm.h:269
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:884
double m_n
Total amount of fertilizer applied per ha of a crop [kg N/ha].
Definition: farm.h:1513
DataForOptimisation * pm_data
Pointer to the DataForOptimisation.
Definition: farm.h:1733
Struct used only in Bedriftsmodel crop type mode for creating m_rotation vector. Bool member used for...
Definition: farm.h:2030
void Set_cropTotals_plant_sum(int i, double crop_area)
Definition: farm.h:1715
int m_intensity
Definition: farm.h:848
Definition: farm.h:360
vector< unsigned > polylist
Definition: farm.h:162
int Get_livestockNumbersSize()
Definition: farm.h:522
OFieldPeas * m_ofieldpeas
Definition: farm.h:886
double m_fodderToProduce
Fodder that has to be produced to fulfill the min. fodder production restriction at the end of a year...
Definition: farm.h:2250
double m_fodderToProduceBefore
Fodder that has to be produced to fulfill the min. fodder production restriction at the beginning of ...
Definition: farm.h:2252
vector< AlmassCrop > Get_rotational_crops_visible()
Definition: farm.h:1909
virtual ~NonAnimalFarm()
Definition: farm.h:2335
TTypesOfVegetation Tov
Definition: farm.h:1781
double m_savings
Value of savings resulting from growing a fodder crop and not purchasing amount of fodder correspondi...
Definition: farm.h:1548
Used for storing permanent crop data for the farm rotation.
Definition: farm.h:376
int m_last_date
Definition: farm.h:470
OSeedGrass1 * m_oseedgrass1
Definition: farm.h:895
void Set_cropTotals_other_sum(int i, double crop_area)
Definition: farm.h:1718
APoint GetValidCoords()
Returns the valid coordinates of the first field owned by a farm.
Definition: farm.h:716
vector< OptimisingFarm * > m_neighbours
Vector of pointers to the farms considered neighbours (fulfilling the neighbourship condition) of a g...
Definition: farm.h:1965
double m_area_scaling_factor
Factor used to scale areas of fixed crops and livestock numbers. Used to adjust these values to the f...
Definition: farm.h:2085
void CalcCentroids()
calculate all farm centroids
Definition: farm.h:1640
double m_totalGrooming
Total grooming planned at a farm.
Definition: farm.h:2111
double m_optimalN
Optimal amount of fertilizer per ha of a crop supposing ferilizer price equals zero [kg N/ha]...
Definition: farm.h:1517
vector< double > m_crop_areas_stages
Stores information on crop areas calculated in different stages of model development: for comparison ...
Definition: farm.h:1814
double Get_actual_aggregated_yield()
Definition: farm.h:1911
double m_GM_Savings
Holds the value of m_GM in case of non-fodder crops and a value of m_savings in case of fodder crops ...
Definition: farm.h:1550
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:893
void Set_alfa(double a_value, int i)
Definition: farm.h:540
TTypesOfVegetation Get_cropTypes_almass(int i)
Definition: farm.h:579
TTypesOfCropVariables
Definition: farm.h:345
Subclass of the OptimisingFarm. Either plant or other farm.
Definition: farm.h:2332
double m_totalNt
Total amount of fertilizer purchased at a farm. [kg].
Definition: farm.h:2103
double Get_cropTotals(int i)
Definition: farm.h:1694
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:931
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:941
void Set_cropTypes_almass(TTypesOfVegetation crop_type)
Definition: farm.h:578
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1388
void Set_crops_fertilizer(int i, double fert)
Definition: farm.h:1720
SeedGrass1 * m_seedgrass1
Definition: farm.h:915
double m_totalIncome
Planned total income from growing crops at a farm. [DKK].
Definition: farm.h:2119
TTypesOfVegetation GetPreviousCrop(int a_index)
Definition: farm.h:811
~HunterInfo()
Definition: farm.h:452
bool force_deliberation
If set to true, a farm must use deliberation as a decision strategy.
Definition: farm.h:2009
double m_lossHerb
Value of the yield loss due to the limited use of herbicides [%].
Definition: farm.h:1536
vector< double > m_crops_fertilizer
Stores information on aggregate (all farms) fertilizer usage for each crop.
Definition: farm.h:1810
Definition: farm.h:275
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:933
void AddHunter(Hunter *a_hunter)
Definition: farm.h:824
MaizeSilage * m_maizesilage
Definition: farm.h:879
double m_totalHoeing
Total hoeing planned at a farm.
Definition: farm.h:2113
OWinterRye * m_owinterrye
Definition: farm.h:905
OFirstYearDanger * m_ofirstyeardanger
Definition: farm.h:888
virtual ~OptimisingCattleFarm()
Definition: farm.h:2308
vector< double > m_animals_numbers
Vector for storing numbers of animals at a farm in previous years (3).
Definition: farm.h:2007
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:899
Definition: farm.h:257
double m_hoeing
Value of mechanical weed control for a crop - hoeing [DKK/ha].
Definition: farm.h:1532
vector< CropSort > m_fodderCrops
List of pointers to variable (non-fixed) fodder crops.
Definition: farm.h:2243
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:922
double GetDD(void)
Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops th...
Definition: farm.h:1692
vector< string > m_str_cropTypes_almass
Crop types saved in string format (ALMaSS crop mode).
Definition: farm.h:621
virtual void checkWinterCrops()
Checks if the restriction on a max. share of winter crops is fulfilled.
Definition: farm.h:2189
OptimisingFarm * m_previously_imitated_neighbour
The neighbouring farmer whose crops might be copied in imitation and social comparison decision modes...
Definition: farm.h:2004
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:903
void Set_cropTotals_sum(int i, double crop_area)
Definition: farm.h:1714
bool RemoveHunter(Hunter *a_hunter)
Definition: farm.h:827
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1171
double m_BI
Summary value of BI for herbicides and fung- and insecticides [BI/ha].
Definition: farm.h:1528
double Number
Definition: farm.h:497
vector< double > m_biomass_factors
Factor used to determine actual response (yield per ha) based on crop biomass at a harvest...
Definition: farm.h:653
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1318
OSBarleySilage * m_osbarleysilage
Definition: farm.h:900
Inbuilt farm type.
Definition: farm.h:979
double daydegrees
Daydegress for period March 1st - November 1st. Used to determine yield of crops that are not harvest...
Definition: farm.h:1767
Definition: farm.h:228
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:881
int Get_cropAreasSize()
Definition: farm.h:524
YoungForestCrop * m_youngforest
Definition: farm.h:948
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:921
Farm * m_farm
Definition: farm.h:465
LE * m_field
Definition: farm.h:466
int * m_farmmapping_lookup
Used for a dynamic array of lookups converting farm references to internal renumbering.
Definition: farm.h:1772
vector< AlmassCrop > Get_rotational_crops()
Definition: farm.h:1908
Definition: farm.h:271
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1338
FarmEvent * m_ev
Definition: farm.h:467
APoint GetCentroids()
Definition: farm.h:810
Used for storing farmers field size vectors.
Definition: farm.h:382
double m_exp_profit
An expected farm&#39;s profit for a given year.
Definition: farm.h:1977
int GetRenumberedFarmRef(int a_farmref)
Returns the farm ref index for a farmref.
Definition: farm.h:1745
void Set_livestockParameter(double a_value, int i)
Definition: farm.h:533
Potatoes * m_potatoes
Definition: farm.h:913
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1261
vector< double > m_Nnorm
Maximum amount of fertilizer (N) that can be applied for a given crop [kg N/ha]. Soil specific...
Definition: farm.h:650
vector< double > m_previous_aggregated_yields
Vector of aggregated yields from previous years.
Definition: farm.h:2000
int m_farmsize
Definition: farm.h:424
TTypesOfLandscapeElement
int m_areaopenfields
Definition: farm.h:428
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
Definition: farm.h:947
vector< double > m_livestockParameters
Vector storing parameters of all livestock types.
Definition: farm.h:636
bool Get_fixed(int i)
Definition: farm.h:554
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1124
vector< FarmData * > m_farm_data
Definition: farm.h:601
int Get_cropTypes_almass_size()
Definition: farm.h:580
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:932
void Add_to_cropTotals(int i, double value)
Definition: farm.h:1695
BroadBeans * m_broadbeans
Definition: farm.h:869
int animals_no
Holds the number of animals in a farm at a particular day in a year (depends on a species)...
Definition: farm.h:2011
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1198
double m_need_satisfaction_level
Farmer&#39;s actual satisfaction level.
Definition: farm.h:1967
int index
Definition: farm.h:383
double m_rotationMax
Maximum area in percent of farm&#39;s arable area for a given crop (depends on a farm size...
Definition: farm.h:1507
vector< double > m_cropTotals_sum
Stores the sums of crops areas within one simulation at the landscape level.
Definition: farm.h:1798
int homeX
Hunter home x-coord.
Definition: farm.h:444
int m_noCrops
Number of crops used in the simulation.
Definition: farm.h:609
void Set_livestockTypes(TTypesOfAnimals livestock_type)
Definition: farm.h:511
int m_farmarable
Definition: farm.h:425
vector< string > m_str_cropTypes
Crop types saved in string format (Bedriftsmodel i.e. original crop optimization model crop mode)...
Definition: farm.h:616
int m_todo
Definition: farm.h:397
double m_BIHerb
Value of BI for herbicides [BI/ha].
Definition: farm.h:1524
double m_totalFodderToProduce
Fodder that has to be produced by a farm to fulfill the min. fodder production restriction. [fodder units].
Definition: farm.h:2248
virtual void MakeStockFarmer(void)
Definition: farm.h:996
void Set_sellingPrice_lastyr(double a_value, int i)
Definition: farm.h:565
bool GetIsRenumbered()
Returns the flag for renumbering.
Definition: farm.h:1743
vector< double > m_cropTotals_cattle_sum
Stores the sums of crops areas on cattle farms within one simulation at the landscape level...
Definition: farm.h:1804
TTypesOfCrops m_cropType
Type/name of a crop (original farm optimization model crop types).
Definition: farm.h:1501
OFieldPeasSilage * m_ofieldpeassilage
Definition: farm.h:887
int m_count
Definition: farm.h:469
TTypesOfSoils
Definition: farm.h:232
int m_almass_no
Farm&#39;s almass number.
Definition: farm.h:2077
int Get_farmRealID(void)
Definition: farm.h:1894
vector< double > m_sellingPrice_lastyr
Selling price of a crop in a previous year [DKK/hkg]. Farm type specific and soil type specific...
Definition: farm.h:666
Subclass of the AnimalFarm.
Definition: farm.h:2305
vector< TTypesOfAnimals > m_livestockTypes
Livestock types saved as enumarator types.
Definition: farm.h:625
double m_weeding
Value of mechanical weed control for a crop - manual weeding [DKK/ha].
Definition: farm.h:1534
vector< double > m_alfa
Crop parameter for response (growth) function (resp = alfa + beta1*N + beta2*N^2; defines relationshi...
Definition: farm.h:644
void Set_cropTotals_pig_sum(int i, double crop_area)
Definition: farm.h:1716
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:939
double m_totalFUdemand
Farm&#39;s total demand for fodder (it is covered by growing fodder crops and/or purchasing fodder and th...
Definition: farm.h:2093
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1458
TTypesOfVegetation Get_crops_summary_BIs_tov(int i)
Definition: farm.h:1710
int Get_noCrops()
Definition: farm.h:585
void Set_cropTypes(TTypesOfCrops crop_type)
Definition: farm.h:512
void Set_crops_summary_BIs_herb(int i, double BIherb)
Definition: farm.h:1711
Carrots * m_carrots
Definition: farm.h:868
HunterList m_HuntersList
A list of hunters allocated to this farm.
Definition: farm.h:844
Definition: farm.h:304
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:910
FieldPeas * m_fieldpeas
Definition: farm.h:873
double Get_beta1(int i)
Definition: farm.h:543
WinterWheat * m_winterwheat
Definition: farm.h:930
Farm * GetFarmPtr(int a_owner)
Returns the pointer to a farm with a specific number.
Definition: farm.h:1623
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1378
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:935
int m_farm_num
Definition: farm.h:846
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:885
TTypesOfSoils md_soilType
Definition: farm.h:595
vector< double > m_cropTotals_plant_sum
Stores the sums of crops areas on plant farms within one simulation at the landscape level...
Definition: farm.h:1800
OrchardCrop * m_orchardcrop
Definition: farm.h:890
virtual ~OptimisingOtherFarm()
Definition: farm.h:2364
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:898
TTypesOfVegetation m_next_tov
Definition: farm.h:399
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1298
TTypesOfFarm GetFarmType(int a_farmref)
Returns the farm type from the farm ref num.
Definition: farm.h:1595
string Get_cropTypes_str(int i)
Definition: farm.h:515
int Get_cropTotals_size()
Definition: farm.h:1697
Definition: farm.h:280
int m_ddegstoharvest
Definition: farm.h:471
void Set_cropTotals_cattle_sum(int i, double crop_area)
Definition: farm.h:1717
double Get_rotationMin(int i)
Definition: farm.h:571
double m_NanimUsable
Amount of usable animal fertilizer from a given type of livestock. [kg].
Definition: farm.h:1483
vector< double > m_cropTotals
Stores crops areas at the landscape level per year.
Definition: farm.h:1794
double Get_alfa(int i)
Definition: farm.h:541
vector< AlmassCrop > m_rotational_crops_visible
Stores a copy of m_rotational_crops from a previous year and is accessible to farmers who want to cop...
Definition: farm.h:2063
int m_farmtype
Definition: farm.h:423
bool m_lock
Definition: farm.h:393
bool m_first_year
Definition: farm.h:395
double m_totalBI
Total amount of pesticides (sum of m_totalBIHerb and m_totalBIFi) which is planned to be applied at a...
Definition: farm.h:2109
TTypesOfSoils m_soilType
Farm&#39;s soil type (sandy, clay, other).
Definition: farm.h:2069
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1162
int Get_lookup_table(int index)
Definition: farm.h:1736
OptimisingFarm * Get_Neighbour(int i)
Definition: farm.h:1907
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1308
double m_benefit
A value of selling price for non-fodder crops or a value of fodder units obtained from a hkg of a fod...
Definition: farm.h:1520
vector< double > m_sellingPrice
Selling price of a crop [DKK/hkg]. Farm type specific and soil type specific.
Definition: farm.h:664
double m_totalN
Total amount of fertilizer used at a farm. [kg].
Definition: farm.h:2101
void Set_crops_fertilizer_trade(int i, double fert_trade)
Definition: farm.h:1721
void Set_FUKey(double a_value, int i)
Definition: farm.h:560