ALMaSS Rabbit ODdox  1.1
The rabbit model description following ODdox protocol
FarmManager Class Reference

The Farm Manager class. More...

#include <farm.h>

Classes

struct  PesticideData
 Struct used for storing data on pesticide usage throughout the whole simulation (one instance, m_crops_summary_BIs). More...
 

Public Member Functions

 FarmManager ()
 Farm manager constructor. More...
 
 ~FarmManager ()
 Farm manager destructor. More...
 
void FarmManagement ()
 Runs the daily farm management for each farm, but also calculates annual spilled grain and maize. More...
 
void InitiateManagement (void)
 
void AddField (int a_OwnerIndex, LE *a_newland, int a_Owner)
 
void RemoveField (int a_OwnerIndex, LE *a_field)
 
int ConnectFarm (int a_owner)
 
TTypesOfVegetation TranslateCropCodes (std::string &str)
 
void DumpFarmAreas ()
 
void DumpFarmrefs ()
 dumps the farmrefs file to a standard named file More...
 
void InitFarms ()
 Calls OptimisingFarm::Init for all optimising farms. More...
 
void Save_diff_farm_types_areas ()
 Calculates and saves total areas of all optimising farms and specific farm types. More...
 
int GetFarmTotalSize (int a_farmref)
 Returns the total farm area from the farm ref num. More...
 
int GetFarmArableSize (int a_farmref)
 Returns the arable area from the farm ref num. More...
 
TTypesOfFarm GetFarmType (int a_farmref)
 Returns the farm type from the farm ref num. More...
 
int GetFarmNoFields (int a_farmref)
 Returns the number of fields owned by a from the farm ref num. More...
 
APoint GetFarmValidCoords (int a_farmref)
 Returns the number of fields owned by a from the farm ref num. More...
 
int GetFarmNoOpenFields (int a_farmref, int a_openness)
 Returns the number of fields with openness more than a_openness. More...
 
int GetFarmAreaOpenFields (int a_farmref, int a_openness)
 Returns the area of fields with openness more than a_openness. More...
 
FarmGetFarmPtr (int a_owner)
 Returns the pointer to a farm with a specific number. More...
 
FarmGetFarmPtrIndex (int a_index)
 Returns the pointer to a farm with a specific index. More...
 
int GetRandomFarmRefnum ()
 Returns a random farm reference number. More...
 
void CalcCentroids ()
 calculate all farm centroids More...
 
bool InIllegalList (int a_farm_ref, vector< int > *a_farmlist)
 Checks a list to see if a farm matches the illegal list of references. More...
 
void AddToIllegalList (int a_farm_ref, vector< int > *a_farmlist)
 Add to a list if a farm is not already among the illegal list of references. More...
 
int FindClosestFarm (HunterInfo a_hinfo, vector< int > *a_farmlist)
 Finds the closest farm to this co-ordinate. More...
 
int FindClosestFarmOpenness (HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness)
 Finds the closest farm to this co-ordinate but uses a probability distribtution for acceptance. More...
 
int FindClosestFarmOpennessProb (HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness)
 Finds the closest farm to this co-ordinate with openness more than a value but uses a probability distribtution for acceptance based on closeness. More...
 
int FindClosestFarmOpennessProbSmallIsBest (HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness, vector< int > *a_farmsizelist)
 Finds the closest farm to this co-ordinate with openness more than a value but uses a probability distribtution for acceptance based on closeness and another based on farm size. More...
 
int FindClosestFarmOpennessProbNearRoostIsBest (HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness, vector< APoint > *a_farmsizelist)
 Finds the closest farm to this co-ordinate with openness more than a value but uses a probability distribtution for acceptance based on closeness and another based on farm size. More...
 
int FindFarmWithRandom (vector< int > *a_farmlist)
 Finds a farm openness more than a value not on the list. More...
 
int FindFarmWithOpenness (vector< int > *a_farmlist, int a_openness)
 Finds a farm openness more than a value not on the list. More...
 
int FindOpennessFarm (int a_openness)
 Finds a random farm with at least one field with openness above a_openness. More...
 
bool CheckOpenness (int a_openness, int a_ref)
 Check if a farm has at least one field with openness above a_openness. More...
 
APoint GetFarmCentroid (int a_farmref)
 Gets the farm centroid as an APoint. More...
 
bool IsDuplicateRef (int a_ref, HunterInfo *a_hinfo)
 Checks if we already have this ref. More...
 
double GetSpilledGrain ()
 Returns the average amount of spilled grain in KJ/m2 this year. More...
 
double GetSpilledMaize ()
 Returns the average amount of spilled maize in KJ/m2 this year. More...
 
void SetSpilledGrain (bool a_spilledgrain)
 Set m_SpilledGrain which is the flag for either 2013 (true) or 2014 (false) spilled grain distributions. More...
 
void FindNeighbours ()
 Finds all OptimisingFarms' neighbours and saves them in the farm's OptimisingFarm::m_neighbours vector. More...
 
double GetDD (void)
 Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops that are not harvested. More...
 
void SetDD (double a_dd)
 
double Get_cropTotals (int i)
 
void Add_to_cropTotals (int i, double value)
 
void Set_cropTotals (int i, double value)
 
int Get_cropTotals_size ()
 
void ActualProfit ()
 Calls OptimisingFarm::ActualProfit for all optimising farms. More...
 
void ChooseDecisionMode_for_farms ()
 Calls OptimisingFarm::ChooseDecisionMode for all optimising farms. More...
 
void Save_last_years_crops_for_farms ()
 Calls OptimisingFarm::Save_last_years_crops for all optimising farms. More...
 
void PrintDecModes_counts ()
 For each OptimizingFarm it prints the number of times each of the decision modes was used within a single simulation. See also OptimisingFarm::m_decision_mode_counters. More...
 
void PrintFinalResults ()
 At the end of a simulation it prints results on crop distribution, pesticide and fertilizer usage. More...
 
void Switch_rotation ()
 Switches OptimisingFarms Farm::m_rotation to the list of all possible rotational crops. More...
 
TTypesOfVegetation Get_crops_summary_BIs_tov (int i)
 
void Set_crops_summary_BIs_herb (int i, double BIherb)
 
void Set_crops_summary_BIs_fi (int i, double BIfi)
 
void Set_crops_summary_BIs (int i, double BI)
 
void Set_cropTotals_sum (int i, double crop_area)
 
void Set_cropTotals_plant_sum (int i, double crop_area)
 
void Set_cropTotals_pig_sum (int i, double crop_area)
 
void Set_cropTotals_cattle_sum (int i, double crop_area)
 
void Set_cropTotals_other_sum (int i, double crop_area)
 
void Set_crops_fertilizer (int i, double fert)
 
void Set_crops_fertilizer_trade (int i, double fert_trade)
 
TTypesOfOptFarms TranslateFarmCodes (string &str)
 
TTypesOfSoils TranslateSoilCodes (string &str)
 
TTypesOfFarmSize TranslateFarmSizeCodes (string &str)
 
TTypesOfAnimals TranslateAnimalsCodes (string &str)
 
TTypesOfCrops TranslateCropsCodes (string &str)
 
TTypesOfParameters TranslateParametersCodes (string &str)
 
TTypesOfLivestockParameters TranslateLivestockParametersCodes (string &str)
 
TTypesOfCropVariables TranslateCropVariablesCodes (string &str)
 
int Get_lookup_table (int index)
 
int GetFarmNoLookup (int a_ref)
 Get a farm reference from the lookup table. More...
 
int GetFarmTypeLookup (int a_ref)
 Get a farm type from the lookup table. More...
 
bool GetIsRenumbered ()
 Returns the flag for renumbering. More...
 
int GetRenumberedFarmRef (int a_farmref)
 Returns the farm ref index for a farmref. More...
 
int GetNoFarms ()
 

Public Attributes

DataForOptimisationpm_data
 Pointer to the DataForOptimisation. More...
 
ofstream * pm_output_file
 

Protected Member Functions

void CreateFarms (const char *a_farmfile)
 
void ReadFarmsData ()
 Reads farm level parameters and saves them in a vector DataForOptimisation::m_farm_data. More...
 
void ReadLivestockNumbers ()
 Reads the data on livestock numbers and saves them in a vector DataForOptimisation::m_livestockNumbers. More...
 
void ReadInitialCropAreas ()
 Reads the data on farms' initial crop distributions and saves them in a vector DataForOptimisation::m_cropAreas. More...
 
void ReadFarmsData_perFarmType ()
 Reads the data on farms' parameters that vary with a farm type and saves them in a vector of a DataForOptimisation class. More...
 
void ReadLivestockData ()
 Reads the data on livestock parameters (do not vary with farm variables) and saves them in a vector DataForOptimisation::m_livestockParameters. More...
 
void ReadCropsData ()
 Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector DataForOptimisation::m_cropParameters. More...
 
void ReadCropsData_perSoilType ()
 Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2, Nnorm) and saves them in vectors of the DataForOptimisation class. More...
 
void ReadCropsData_perFarmType ()
 Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them in vectors of the DataForOptimisation class. More...
 
void ReadCropsData_perFarm_and_Soil ()
 Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them in a vector DataForOptimisation::m_sellingPrice. More...
 
void ReadCropsData_perFarm_and_Soil_and_Size ()
 Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax, rotationMin) and saves them in vectors of the DataForOptimisation class. More...
 
void ReadInitialCropAreas_almass ()
 Reads the data on farms' initial crop distributions and saves them in a vector of a DataForOptimisation class. ALMaSS crop mode. More...
 
void ReadCropsData_almass ()
 Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector DataForOptimisation::m_cropParameters. ALMaSS crop mode. More...
 
void ReadCropsData_perSoilType_almass ()
 Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2, Nnorm) and saves them in vectors of the DataForOptimisation class. ALMaSS crop mode. More...
 
void ReadCropsData_perFarmType_almass ()
 Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them in vectors of the DataForOptimisation class. ALMaSS crop mode. More...
 
void ReadCropsData_perFarm_and_Soil_almass ()
 Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them in a vector DataForOptimisation:m_sellingPrice. ALMaSS crop mode. More...
 
void ReadCropsData_perFarm_and_Soil_and_Size_almass ()
 Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax, rotationMin) and saves them in vectors of the DataForOptimisation class. ALMaSS crop mode. More...
 
void ReadEnergyMaizePrice ()
 
void OptimisationOutput ()
 Creates output files for all crop level variables and for landscape level crop distribution. Includes results of the initial farm otpimisation. More...
 
void PrintOutput (TTypesOfCropVariables a_var, string a_fileName)
 Makes an output file for one crop variable and prints its values for each crop and each OptimisingFarm. Includes results of the initial farm otpimisation. More...
 
void CropDistribution ()
 Calculates total crop areas (at the landscape level). Includes results of the initial farm otpimisation. More...
 
void Create_Output_file_for_farms ()
 Creates an output file. Prints the crop variables in the first row of the file. The file is used then by farms (OptimisingFarm) to print the farm level results of optimisation. Includes results of the initial farm otpimisation. More...
 
void ReadLookupTable ()
 Reads the lookup table with allowed/forbidden crop order from a text file and saves it into a vector m_crop_lookup_table. More...
 
void PrintNeighbours ()
 Creates an output file with a list of neighbours of each OptimisingFarm. More...
 
void DistributeFarmerTypes ()
 Randomly assigns farmer types to farms (OptimisingFarm) in proportions specified in an input file. More...
 

Protected Attributes

vector< Farm * > m_farms
 
Population_Managerm_population_manager
 
double daydegrees
 Daydegress for period March 1st - November 1st. Used to determine yield of crops that are not harvested (and thus do not have values of biomass at harvest). More...
 
bool m_SpilledGrain
 Is it 2013 (true) or 2014 (false) as far as grain goes. More...
 
int * m_farmmapping_lookup
 Used for a dynamic array of lookups converting farm references to internal renumbering. More...
 
bool m_renumbered
 A flag to show whether renumbering was already done. More...
 
double totalOptFarmsArea
 
double totalOptFarmsArea_plant
 
double totalOptFarmsArea_pig
 
double totalOptFarmsArea_cattle
 
double totalOptFarmsArea_other
 
vector< double > m_cropTotals
 Stores crops areas at the landscape level per year. More...
 
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). More...
 
vector< double > m_cropTotals_sum
 Stores the sums of crops areas within one simulation at the landscape level. More...
 
vector< double > m_cropTotals_plant_sum
 Stores the sums of crops areas on plant farms within one simulation at the landscape level. More...
 
vector< double > m_cropTotals_pig_sum
 Stores the sums of crops areas on pig farms within one simulation at the landscape level. More...
 
vector< double > m_cropTotals_cattle_sum
 Stores the sums of crops areas on cattle farms within one simulation at the landscape level. More...
 
vector< double > m_cropTotals_other_sum
 Stores the sums of crops areas on other farms within one simulation at the landscape level. More...
 
vector< PesticideDatam_crops_summary_BIs
 Stores information on aggregate (all farms)pesticide usage for each crop. More...
 
vector< double > m_crops_fertilizer
 Stores information on aggregate (all farms) fertilizer usage for each crop. More...
 
vector< double > m_crops_fertilizer_trade
 Stores information on aggregate (all farms) fertilizer trade (Nt) usage for each crop. More...
 
vector< double > m_crop_areas_stages
 Stores information on crop areas calculated in different stages of model development: for comparison in sensitivity analysis. More...
 

Detailed Description

The Farm Manager class.

Definition at line 1706 of file farm.h.

Constructor & Destructor Documentation

◆ FarmManager()

FarmManager::FarmManager ( )

Farm manager constructor.

Definition at line 2626 of file farm.cpp.

2627 {
2628 
2629  g_farmmanager = this;
2630 
2631  if ( l_map_read_farmfile.value() ) {
2632  if (cfg_OptimisingFarms.value()){
2633  //make a data object
2635  ReadFarmsData();
2639  //ReadGlobalData();
2640  ReadLookupTable();
2641  ofstream ofile ("Economic_figures.txt", ios::out);
2642  ofile.close();
2643  ofstream ofile1 ("Daydegrees.txt", ios::out);
2644  ofile1.close();
2645  if(cfg_MaizeEnergy.value()){
2646  ofstream ofileEM ("Maize_energy_price_yearly.txt", ios::out);
2647  ofileEM.close();
2648  }
2649 
2652  ReadCropsData();
2657  }
2658  else{
2665  m_crops_summary_BIs.resize(pm_data->Get_noCrops()); //no_crops - from the input file on initial crop areas
2673  m_crop_areas_stages.resize( 2 * pm_data->Get_noCrops()); //use just the results of the baseline and original model
2674  for(int i=0; i<pm_data->Get_noCrops(); i++){
2676  m_crops_summary_BIs[i].BI=0;
2677  m_crops_summary_BIs[i].BIherb=0;
2678  m_crops_summary_BIs[i].BIfi=0;
2679  m_cropTotals_sum[i]=0;
2681  m_cropTotals_pig_sum[i]=0;
2684  m_crops_fertilizer[i]=0;
2686  }
2687 
2688  if(cfg_MaizeEnergy.value()){
2690  }
2691  }
2692  }//if optimising farm
2694  }
2695 
2696 }

References cfg_MaizeEnergy, cfg_OptimiseBedriftsmodelCrops, cfg_OptimisingFarms, CreateFarms(), g_farmmanager, DataForOptimisation::Get_cropTypes_almass(), DataForOptimisation::Get_noCrops(), l_map_farmref_file, l_map_read_farmfile, m_crop_areas_stages, m_crops_fertilizer, m_crops_fertilizer_trade, m_crops_summary_BIs, m_cropTotals_cattle_sum, m_cropTotals_other_sum, m_cropTotals_pig_sum, m_cropTotals_plant_sum, m_cropTotals_sum, pm_data, ReadCropsData(), ReadCropsData_almass(), ReadCropsData_perFarm_and_Soil(), ReadCropsData_perFarm_and_Soil_almass(), ReadCropsData_perFarm_and_Soil_and_Size(), ReadCropsData_perFarm_and_Soil_and_Size_almass(), ReadCropsData_perFarmType(), ReadCropsData_perFarmType_almass(), ReadCropsData_perSoilType(), ReadCropsData_perSoilType_almass(), ReadEnergyMaizePrice(), ReadFarmsData(), ReadFarmsData_perFarmType(), ReadInitialCropAreas(), ReadInitialCropAreas_almass(), ReadLivestockData(), ReadLivestockNumbers(), ReadLookupTable(), CfgBool::value(), and CfgStr::value().

◆ ~FarmManager()

FarmManager::~FarmManager ( )

Farm manager destructor.

Definition at line 2699 of file farm.cpp.

2700 {
2701 
2702  for ( unsigned int i = 0; i < m_farms.size(); i++ )
2703  delete m_farms[ i ];
2704  if (cfg_OptimisingFarms.value()) delete pm_data;
2705 }

References cfg_OptimisingFarms, m_farms, pm_data, and CfgBool::value().

Member Function Documentation

◆ ActualProfit()

void FarmManager::ActualProfit ( )

Calls OptimisingFarm::ActualProfit for all optimising farms.

Definition at line 3433 of file farm.cpp.

3433  {
3434 
3435  for(int i=0; i<(int)m_farms.size(); i++){
3436  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
3437  OptimisingFarm * opf;
3438  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
3439  opf->ActualProfit();
3440  }
3441  }
3442 }

References OptimisingFarm::ActualProfit(), m_farms, and tof_OptimisingFarm.

◆ Add_to_cropTotals()

void FarmManager::Add_to_cropTotals ( int  i,
double  value 
)
inline

Definition at line 1838 of file farm.h.

1838 {m_cropTotals[i] += value;};

References m_cropTotals.

Referenced by OptimisingFarm::ActualProfit().

◆ AddField()

void FarmManager::AddField ( int  a_OwnerIndex,
LE a_newland,
int  a_Owner 
)

Definition at line 2741 of file farm.cpp.

2742 {
2743  m_farms[ a_OwnerIndex ]->AddField( a_newland );
2744  a_newland->SetOwner( m_farms[ a_OwnerIndex ], a_Owner, a_OwnerIndex );
2745 }

References m_farms, and LE::SetOwner().

◆ AddToIllegalList()

void FarmManager::AddToIllegalList ( int  a_farm_ref,
vector< int > *  a_farmlist 
)

Add to a list if a farm is not already among the illegal list of references.

a_farmlist is a pointer to a list of integers with illegal farm ref numbers.

Definition at line 3099 of file farm.cpp.

3099  {
3103  bool found = false;
3104  unsigned sz = (unsigned)a_farmlist->size();
3105  for (unsigned f = 0; f < sz; f++) {
3106  if ((*a_farmlist)[f] == a_farm_ref) {
3107  found = true;
3108  break;
3109  }
3110  }
3111  if (!found) {
3112  a_farmlist->push_back( a_farm_ref );
3113  }
3114 }

Referenced by FindFarmWithOpenness().

◆ CalcCentroids()

void FarmManager::CalcCentroids ( )
inline

calculate all farm centroids

Definition at line 1783 of file farm.h.

1783 { for (unsigned int i = 0; i < m_farms.size(); i++) m_farms[i]->Centroids(); }

References m_farms.

◆ CheckOpenness()

bool FarmManager::CheckOpenness ( int  a_openness,
int  a_ref 
)

Check if a farm has at least one field with openness above a_openness.

Definition at line 3399 of file farm.cpp.

3399  {
3400  if (m_farms[ a_ref ]->GetMaxOpenness() > a_openness) return true;
3401  return false;
3402 }

References m_farms.

◆ ChooseDecisionMode_for_farms()

void FarmManager::ChooseDecisionMode_for_farms ( )

Calls OptimisingFarm::ChooseDecisionMode for all optimising farms.

Definition at line 3444 of file farm.cpp.

3444  {
3445 
3446  for(int i=0; i<(int)m_farms.size(); i++){
3447  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
3448  OptimisingFarm * opf;
3449  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
3450  opf->ChooseDecisionMode();
3451 
3452  }
3453  }
3454 }

References OptimisingFarm::ChooseDecisionMode(), m_farms, and tof_OptimisingFarm.

◆ ConnectFarm()

int FarmManager::ConnectFarm ( int  a_owner)

Definition at line 2752 of file farm.cpp.

2753 {
2754  for ( unsigned int i = 0; i < m_farms.size(); i++ )
2755  {
2756  if ( a_owner == m_farms[ i ]->GetFarmNumber() )
2757  {
2758  // Found it. Set mapping and return.
2759  return i;
2760  }
2761  }
2762  // We didn't find the owner in the list of farms,
2763  // pregenerated in CreateFarms() above. Something
2764  // is not correct here, so raise an appropriate
2765  // error and exit.
2766  char error_num[ 20 ];
2767  sprintf( error_num, "%d", a_owner );
2768  g_msg->Warn( WARN_FILE, "FarmManager::ConnectFarm(): Unknown farm number"" referenced in polygon file:", error_num );
2769  exit( 1 );
2770 }

References g_msg, m_farms, MapErrorMsg::Warn(), and WARN_FILE.

◆ Create_Output_file_for_farms()

void FarmManager::Create_Output_file_for_farms ( )
protected

Creates an output file. Prints the crop variables in the first row of the file. The file is used then by farms (OptimisingFarm) to print the farm level results of optimisation. Includes results of the initial farm otpimisation.

Definition at line 4609 of file farm.cpp.

4609  {
4610 
4611  pm_output_file = new ofstream ("FarmVariables.txt", ios::out);
4612 
4613  (*pm_output_file) << "Farm no \t";
4614 
4615  //print variables' names (18 variables, 09.05.12)
4616  (*pm_output_file) << "mainGoal \t" << "totalArea \t" << "totalIncome \t" << "totalCosts \t" << "totalProfit \t";
4617  (*pm_output_file) << "FodderDemand \t" << "FodderDemand_bef \t" << "FodderTrade \t" << "FodderGrown \t" ;
4618  (*pm_output_file) << "Nanim \t" << "totalNanim \t" << "totalNt \t" << "totalN \t" ;
4619  (*pm_output_file) << "totalBI \t" << "totalBIHerb \t" << "totalBIFi \t" ;
4620  (*pm_output_file) << "totalGrooming \t" << "totalHoeing \t" << "totalWeeding \t";
4621  (*pm_output_file) << endl;
4622 
4623 }

References pm_output_file.

Referenced by InitFarms().

◆ CreateFarms()

void FarmManager::CreateFarms ( const char *  a_farmfile)
protected

Definition at line 2772 of file farm.cpp.

2773 {
2774  int No, FType, NoFarms;
2775  FILE * inpf = fopen(a_farmfile, "r" );
2776  if (!inpf) {
2777  g_msg->Warn( WARN_FILE, "Landscape::CreateFarms(): Unable to open file", a_farmfile );
2778  exit( 1 );
2779  }
2780 
2781  fscanf( inpf, "%d", & NoFarms );
2782 
2783  m_farms.resize( NoFarms );
2784 
2785  m_farmmapping_lookup = new int[NoFarms * 2];
2786 
2787  for (int i = 0; i < NoFarms; i++)
2788  {
2789  // File format:
2790  //
2791  // Two colunms of numbers 0..number of farms, 0-number of farmtypes-1
2792  // the second column determines what type of farm we have
2793  fscanf(inpf, "%d %d", &No, &FType);
2794  m_farmmapping_lookup[i * 2] = No;
2795  m_farmmapping_lookup[i * 2 + 1] = FType;
2796  }
2797  fclose(inpf);
2798 
2799  for (int i = 0; i < NoFarms; i++)
2800  {
2801  /*
2802  //If we are testing crop management, then ignore farm type from
2803  // the file and set to fixed one instead.
2804  if ( g_farm_test_crop.value() ) {
2805  FType = g_farm_test_crop_farmtype.value();
2806  }
2807  */
2808  // If we are running in fixed, sync'ed rotation mode, set all farms to
2809  // be of the requested type.
2812  }
2813 
2814  switch (m_farmmapping_lookup[i * 2 + 1]) // FType
2815  {
2816  case 0:
2817  m_farms[i] = new ConventionalCattle(this);
2818  break;
2819  case 1:
2820  m_farms[i] = new ConventionalPig(this);
2821  break;
2822  case 2:
2823  m_farms[i] = new ConventionalPlant(this);
2824  break;
2825  case 3:
2826  m_farms[i] = new OrganicCattle(this);
2827  break;
2828  case 4:
2829  m_farms[i] = new OrganicPig(this);
2830  break;
2831  case 5:
2832  m_farms[i] = new OrganicPlant(this);
2833  break;
2834  case 6:
2835  m_farms[i] = new PesticideTrialControl(this);
2836  break;
2837  case 7:
2838  m_farms[i] = new PesticideTrialToxicControl(this);
2839  break;
2840  case 8:
2841  m_farms[i] = new PesticideTrialTreatment(this);
2842  break;
2843  case 9:
2844  m_farms[i] = new ConvMarginalJord(this);
2845  break;
2846  case 10:
2847  m_farms[i] = new AgroChemIndustryCerealFarm1(this);
2848  break;
2849  case 11:
2850  m_farms[i] = new AgroChemIndustryCerealFarm2(this);
2851  break;
2852  case 12:
2853  m_farms[i] = new AgroChemIndustryCerealFarm3(this);
2854  break;
2855  case 13:
2856  m_farms[i] = new NoPesticideBaseFarm(this);
2857  break;
2858  case 14:
2859  m_farms[i] = new NoPesticideNoPFarm(this);
2860  break;
2861  case 15:
2862  m_farms[i] = new UserDefinedFarm1(this);
2863  break;
2864  case 16:
2865  m_farms[i] = new UserDefinedFarm2(this);
2866  break;
2867  case 17:
2868  m_farms[i] = new UserDefinedFarm3(this);
2869  break;
2870  case 18:
2871  m_farms[i] = new UserDefinedFarm4(this);
2872  break;
2873  case 19:
2874  m_farms[i] = new UserDefinedFarm5(this);
2875  break;
2876  case 20:
2877  m_farms[i] = new UserDefinedFarm6(this);
2878  break;
2879  case 21:
2880  m_farms[i] = new UserDefinedFarm7(this);
2881  break;
2882  case 22:
2883  m_farms[i] = new UserDefinedFarm8(this);
2884  break;
2885  case 23:
2886  m_farms[i] = new UserDefinedFarm9(this);
2887  break;
2888  case 24:
2889  m_farms[i] = new UserDefinedFarm10(this);
2890  break;
2891  case 25:
2892  m_farms[i] = new UserDefinedFarm11(this);
2893  break;
2894  case 26:
2895  m_farms[i] = new UserDefinedFarm12(this);
2896  break;
2897  case 27:
2898  m_farms[i] = new UserDefinedFarm13(this);
2899  break;
2900  case 28:
2901  m_farms[i] = new UserDefinedFarm14(this);
2902  break;
2903  case 29:
2904  m_farms[i] = new UserDefinedFarm15(this);
2905  break;
2906  case 30:
2907  m_farms[i] = new UserDefinedFarm16(this);
2908  break;
2909  case 31:
2910  m_farms[i] = new UserDefinedFarm17(this);
2911  break;
2912  // NB the user defing farms below require an extra parameter in the rotation file denoting the intensity (0 or 1 = high low)
2913  case 32:
2914  m_farms[i] = new UserDefinedFarm18("UserDefinedFarm18.rot", this);
2915  break;
2916  case 33:
2917  m_farms[i] = new UserDefinedFarm19("UserDefinedFarm19.rot", this);
2918  break;
2919  case 34:
2920  m_farms[i] = new UserDefinedFarm20("UserDefinedFarm20.rot", this);
2921  break;
2922  case 35:
2923  m_farms[i] = new UserDefinedFarm21("UserDefinedFarm21.rot", this);
2924  break;
2925  case 36:
2926  m_farms[i] = new UserDefinedFarm22("UserDefinedFarm22.rot", this);
2927  break;
2928  case 37:
2929  m_farms[i] = new UserDefinedFarm23("UserDefinedFarm23.rot", this);
2930  break;
2931  case 38:
2932  m_farms[i] = new UserDefinedFarm24("UserDefinedFarm24.rot", this);
2933  break;
2934  case 39:
2935  m_farms[i] = new UserDefinedFarm25("UserDefinedFarm25.rot", this);
2936  break;
2937  case 40:
2938  m_farms[i] = new UserDefinedFarm26("UserDefinedFarm26.rot", this);
2939  break;
2940  case 41:
2941  m_farms[i] = new UserDefinedFarm27("UserDefinedFarm27.rot", this);
2942  break;
2943  case 42:
2944  m_farms[i] = new UserDefinedFarm28("UserDefinedFarm28.rot", this);
2945  break;
2946  case 43:
2947  m_farms[i] = new UserDefinedFarm29("UserDefinedFarm29.rot", this);
2948  break;
2949  case 44:
2950  m_farms[i] = new UserDefinedFarm30("UserDefinedFarm30.rot", this);
2951  break;
2952  case 45:
2953  m_farms[i] = new UserDefinedFarm31("UserDefinedFarm31.rot", this);
2954  break;
2955  case 46:
2956  m_farms[i] = new UserDefinedFarm32("UserDefinedFarm32.rot", this);
2957  break;
2958  case 47:
2959  m_farms[i] = new UserDefinedFarm33("UserDefinedFarm33.rot", this);
2960  break;
2961  case 48:
2962  m_farms[i] = new UserDefinedFarm34("UserDefinedFarm34.rot", this);
2963  break;
2964  case 49:
2965  m_farms[i] = new UserDefinedFarm35("UserDefinedFarm35.rot", this);
2966  break;
2967  case 50: //optimising farm!
2968  if ((pm_data->Get_farmType(No)) == toof_Pig) {
2969  m_farms[i] = new OptimisingPigFarm(this, No);
2970  }
2971  else if ((pm_data->Get_farmType(No)) == toof_Cattle){
2972  m_farms[i] = new OptimisingCattleFarm(this, No);
2973  }
2974  else if ((pm_data->Get_farmType(No)) == toof_Plant){
2975  m_farms[i] = new OptimisingPlantFarm(this, No);
2976  }
2977  else if ((pm_data->Get_farmType(No)) == toof_Other){
2978  m_farms[i] = new OptimisingOtherFarm(this, No);
2979  }
2980  break;
2981 
2982  default:
2983  g_msg->Warn(WARN_FILE, "Landscape::CreateFarms(): Unknown farm type reference number: ", m_farmmapping_lookup[i * 2 + 1]);
2984  exit(1);
2985  }
2986  m_farms[i]->SetFarmNumber(i); // We use 'i' here because we renumber the farms internally. If the file did not come in this way then a dump file is created - tested in ReadPolys2
2987  }
2988 
2990  {
2991  DistributeFarmerTypes(); //added 240513
2992  }
2993 
2994  if (GetFarmNoLookup(NoFarms - 1) != NoFarms - 1) m_renumbered = false; else m_renumbered = true;
2995 }

References cfg_OptimisingFarms, DistributeFarmerTypes(), g_farm_fixed_rotation_enable, g_farm_fixed_rotation_farmtype, g_msg, DataForOptimisation::Get_farmType(), GetFarmNoLookup(), m_farmmapping_lookup, m_farms, m_renumbered, pm_data, toof_Cattle, toof_Other, toof_Pig, toof_Plant, CfgInt::value(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by FarmManager().

◆ CropDistribution()

void FarmManager::CropDistribution ( )
protected

Calculates total crop areas (at the landscape level). Includes results of the initial farm otpimisation.

Definition at line 4588 of file farm.cpp.

4588  {
4589 
4590  int no_crops = (cfg_OptimiseBedriftsmodelCrops.value())? toc_Foobar : pm_data->Get_noCrops(); //bedriftsmodel crops/almass crops
4591  m_cropTotals.resize(no_crops); //no_crops is ok for both almass and bedriftsmodel crop mode; it is taken from the input file on initial crop areas
4592 
4593  for(int i=0; i<(int)m_farms.size(); i++){
4594 
4595  OptimisingFarm * opf;
4596  int size=0;
4597  if(m_farms[i]->GetType()==tof_OptimisingFarm) { //take only optimising farms
4598  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4599  size = opf->Get_cropsSize();
4600  for(int j=0; j<size; j++) {
4601  CropOptimised *crop = opf->Get_crop(j);
4602  double area = crop->m_area_ha;
4603  m_cropTotals[j] += area;
4604  }
4605  }
4606  }
4607 }

References cfg_OptimiseBedriftsmodelCrops, OptimisingFarm::Get_crop(), OptimisingFarm::Get_cropsSize(), DataForOptimisation::Get_noCrops(), CropOptimised::m_area_ha, m_cropTotals, m_farms, pm_data, toc_Foobar, tof_OptimisingFarm, and CfgBool::value().

Referenced by OptimisationOutput().

◆ DistributeFarmerTypes()

void FarmManager::DistributeFarmerTypes ( )
protected

Randomly assigns farmer types to farms (OptimisingFarm) in proportions specified in an input file.

Definition at line 4965 of file farm.cpp.

4965  {
4966 
4967  //get the shares of certain types. Parameters in the config file.
4968  double profit_proportion = cfg_Profit_max_proportion.value();
4969  double yield_proportion = cfg_Yield_max_proportion.value();
4970  double env_proportion = cfg_Environmentalist_proportion.value();
4971 
4972  //get the number of optimising farms (count them) and make a list of opt farms and its copy
4973  int number_opt_farms=0;
4974  vector <OptimisingFarm*> opt_farms;
4975  vector <OptimisingFarm*> opt_farms_copy;
4976  for(int i=0; i<(int)m_farms.size(); i++){
4977  if(m_farms[i]->GetType()==tof_OptimisingFarm){
4978  number_opt_farms++;
4979  OptimisingFarm * opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4980  opt_farms.push_back(opf);
4981  }
4982  }
4983  opt_farms_copy = opt_farms;
4984 
4985  //find the number of farms that should be of a certain type
4986  int number_profit = (int) (profit_proportion/100 * number_opt_farms); // + 0.5); round down - to avoid having a total number of diff types higher than the number of farms
4987  int number_yield = (int) (yield_proportion/100 * number_opt_farms + 0.5);
4988  int number_env = (int) (env_proportion/100 * number_opt_farms + 0.5);
4989 
4990  //see: http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
4991  random_device rd;
4992  mt19937 gen(rd());
4993 
4994  int jj=0;
4995  int index_for_farm=0;
4996 
4997  //set farms with profit as a main goal
4998  for(int j=jj; j<number_profit; j++){
4999  distribution_type2 dis(0, number_opt_farms - j - 1); //each time we remove one farm, so '-j' and '-1' casue the last element in the list is =size-1.
5000  index_for_farm = dis(gen);
5001  opt_farms_copy[index_for_farm]->Set_main_goal(tofg_profit);
5002  opt_farms_copy.erase(opt_farms_copy.begin() + index_for_farm); //remove the farm from the list after assignign the goal
5003  jj = j;
5004  }
5005  jj++; //need to increase by one here!
5006 
5007  //set farms with yield as a main goal
5008  for(int j = jj; j<number_yield + number_profit; j++){ //start with the value of 'i' as it was after leaving the last for loop!
5009  distribution_type2 dis1(0, number_opt_farms - j - 1); //each time we remove one farm, so '-j'
5010  index_for_farm = dis1(gen);
5011  opt_farms_copy[index_for_farm]->Set_main_goal(tofg_yield);
5012  opt_farms_copy.erase(opt_farms_copy.begin() + index_for_farm); //remove the farm from the list after assignign the goal
5013  jj = j;
5014  }
5015  jj++;
5016 
5017  //set farms with environment as a main goal
5018  int loop_limit = (number_env + number_profit + number_yield > number_opt_farms)? number_opt_farms : number_env + number_profit + number_yield;
5019  for(int j=jj; j<loop_limit; j++){
5020  distribution_type2 dis2(0, number_opt_farms - j - 1); //each time we remove one farm, so '-j'
5021  index_for_farm = dis2(gen);
5022  opt_farms_copy[index_for_farm]->Set_main_goal(tofg_environment);
5023  opt_farms_copy.erase(opt_farms_copy.begin() + index_for_farm); //remove the farm from the list after assignign the goal
5024  }
5025 
5026  //check if there are any farms left without assigned goal
5027  if((int)opt_farms_copy.size()>0){ //it should be not more than 1-2
5028  for(int p=(int)opt_farms_copy.size(); p>0; p--){
5029  opt_farms_copy[p-1]->Set_main_goal(tofg_profit);
5030  }
5031  }
5032 
5033 }

References cfg_Environmentalist_proportion, cfg_Profit_max_proportion, cfg_Yield_max_proportion, m_farms, tof_OptimisingFarm, tofg_environment, tofg_profit, tofg_yield, and CfgFloat::value().

Referenced by CreateFarms().

◆ DumpFarmAreas()

void FarmManager::DumpFarmAreas ( )

Definition at line 1964 of file farm.cpp.

1964  {
1965 
1966  //create a text file with the farms
1967  ofstream ofile ("FarmTotalAreas_almass.txt", ios::out);
1968  ofile << "Farm no" << '\t' << "Area" << endl;
1969 
1970  //print each farms no and then the numbers of its neighbours
1971  for(int i=0; i<(int)m_farms.size(); i++){
1972  OptimisingFarm * opf_i;
1973  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
1974  opf_i = dynamic_cast<OptimisingFarm*>(m_farms[i]);
1975  ofile << opf_i->Get_almass_no() << '\t';
1976  ofile << opf_i->GetArea() <<'\t';
1977  ofile << endl;
1978  }
1979  }
1980 }

References OptimisingFarm::Get_almass_no(), Farm::GetArea(), and tof_OptimisingFarm.

◆ DumpFarmrefs()

void FarmManager::DumpFarmrefs ( )

dumps the farmrefs file to a standard named file

Definition at line 2997 of file farm.cpp.

2998 {
2999  ofstream opf("dump_farmrefs.txt");
3000  if (!opf.is_open())
3001  {
3002  g_msg->Warn(WARN_FILE, "Landscape::CreateFarms(): Unable to open file", "dump_farmrefs.txt");
3003  exit(1);
3004  }
3005  int NoFarms = (int) m_farms.size();
3006  opf << NoFarms << endl;
3007  for (int i = 0; i < NoFarms; i++)
3008  {
3009  opf << i << '\t' << m_farmmapping_lookup[i * 2 + 1] << endl;
3010  }
3011  opf.close();
3012 }

References g_msg, m_farmmapping_lookup, m_farms, MapErrorMsg::Warn(), and WARN_FILE.

◆ FarmManagement()

void FarmManager::FarmManagement ( )

Runs the daily farm management for each farm, but also calculates annual spilled grain and maize.

Definition at line 2707 of file farm.cpp.

2708 {
2709  for ( unsigned int i = 0; i < m_farms.size(); i++ )
2710  {
2711  m_farms[ i ]->Management();
2712  }
2713 
2714  //050214
2716  if(g_landscape_p->SupplyDayInYear() == cfg_Animals_number_test_day.value()){ //check if this is the day we want to collect data on animal numbers
2717  for ( unsigned int i = 0; i < m_farms.size(); i++ )
2718  {
2719  OptimisingFarm * opf;
2720  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
2721  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
2722  if(cfg_AnimalsThreshold.value() > 0 && opf->Get_main_goal() == tofg_environment){ //take only environmentalists and check if we are in the feedback mode (no if the config is zero)
2723  int farm_ref = opf->GetFarmNumber();
2724  int animals_no = g_landscape_p->SupplyFarmAnimalCensus(farm_ref, cfg_LifeStage.value());
2725  opf->Set_animals_no(animals_no);
2726  }
2727  }
2728  }
2729  }
2730  }
2731 }

References cfg_Animals_number_test_day, cfg_AnimalsThreshold, cfg_LifeStage, g_landscape_p, OptimisingFarm::Get_main_goal(), Farm::GetFarmNumber(), m_farms, OptimisingFarm::Set_animals_no(), Landscape::SupplyDayInYear(), Landscape::SupplyFarmAnimalCensus(), Landscape::SupplyYearNumber(), tof_OptimisingFarm, tofg_environment, CfgInt::value(), and CfgFloat::value().

◆ FindClosestFarm()

int FarmManager::FindClosestFarm ( HunterInfo  a_hinfo,
vector< int > *  a_farmlist 
)

Finds the closest farm to this co-ordinate.

Centroid calculation on farms must be called before calling this method for the first time.
a_farmlist is a pointer to a list of integers with illegal farm ref numbers. The first entry lists the number of illegal numbers.

Definition at line 3126 of file farm.cpp.

3126  {
3131  double best = 99999999999999999.0;
3132  int bestref = -1;
3133  double dist = best;
3134  for (unsigned i = 0; i < m_farms.size(); i++) {
3135  int fnum = m_farms[i]->GetFarmNumber();
3136  if (!InIllegalList(fnum, a_farmlist)) {
3137  if (!IsDuplicateRef(fnum, &a_hinfo)) {
3138  // Is possible to use this farm, so test it.
3139  APoint FPt = m_farms[i]->GetCentroids();
3140  dist = sqrt((double( FPt.m_x - a_hinfo.homeX ) * double( FPt.m_x - a_hinfo.homeX ) + double( FPt.m_y - a_hinfo.homeY ) * double( FPt.m_y - a_hinfo.homeY )));
3141  if (dist < best) {
3142  best = dist;
3143  bestref = fnum;
3144  }
3145  }
3146  }
3147  }
3148  if (bestref == -1) {
3149  g_msg->Warn( "FarmManager::FindClosestFarm - Cannot find open farm.", "" );
3150  exit( 0 );
3151  }
3152  return bestref;
3153 }

References g_msg, HunterInfo::homeX, HunterInfo::homeY, InIllegalList(), IsDuplicateRef(), m_farms, and MapErrorMsg::Warn().

◆ FindClosestFarmOpenness()

int FarmManager::FindClosestFarmOpenness ( HunterInfo  a_hinfo,
vector< int > *  a_farmlist,
int  a_openness 
)

Finds the closest farm to this co-ordinate but uses a probability distribtution for acceptance.

Finds the closest farm to this co-ordinate with openness more than a value

Definition at line 3155 of file farm.cpp.

3155  {
3156  // Centroid calculation on farms must be called before calling this method for the first time
3157  double best = 99999999999999999.0;
3158  int bestref = -1;
3159  double dist = best;
3160  for (unsigned i = 0; i < m_farms.size(); i++) {
3161  if (m_farms[ i ]->GetMaxOpenness() > a_openness) {
3162  int fref = m_farms[ i ]->GetFarmNumber();
3163  if (!InIllegalList( fref, a_farmlist )) {
3164  if (!IsDuplicateRef( fref, &a_hunterinfo )) {
3165  APoint FPt = m_farms[ i ]->GetCentroids();
3166  dist = sqrt( (double( FPt.m_x - a_hunterinfo.homeX ) * double( FPt.m_x - a_hunterinfo.homeX ) + double( FPt.m_y - a_hunterinfo.homeY ) * double( FPt.m_y - a_hunterinfo.homeY )) );
3167  if (dist < best) {
3168  best = dist;
3169  bestref = fref;
3170  }
3171  }
3172  }
3173  }
3174  }
3175  if (bestref == -1) {
3176  g_msg->Warn( "FarmManager::FindClosestFarmOpenness( ) - Cannot find open farm.", "" );
3177  exit( 0 );
3178  }
3179  return bestref;
3180 }

References g_msg, HunterInfo::homeX, HunterInfo::homeY, InIllegalList(), IsDuplicateRef(), m_farms, and MapErrorMsg::Warn().

◆ FindClosestFarmOpennessProb()

int FarmManager::FindClosestFarmOpennessProb ( HunterInfo  a_hinfo,
vector< int > *  a_farmlist,
int  a_openness 
)

Finds the closest farm to this co-ordinate with openness more than a value but uses a probability distribtution for acceptance based on closeness.

Centroid calculation on farms must be called before calling this method for the first time.
a_farmlist is a pointer to a list of integers with illegal farm ref numbers. The first entry lists the number of illegal numbers. The chance of acceptance is probability based, taking the nearest farm first then testing the next etc.. The probability is based on y = 1*EXP(-x*cfg) with cfg being a fitting parameter in cfg_ClosestFarmProbParam1

We use typedef here to create our own name for APoint - but it is just two unsigned ints. We will use 'x' for the farm num and 'y' for the distance.

We use a vector of AFarmDists to be able to sort it easily

Struct redefining operator < - used for sorting distances from smallest to largest.

Definition at line 3182 of file farm.cpp.

3182  {
3191  typedef APoint AFarmDist;
3193  vector <AFarmDist> farmdists;
3195  struct FarmDistSort {
3196  bool operator()( AFarmDist a, AFarmDist b ) {
3197  return a.m_y < b.m_y;
3198  }
3199  };
3200  for (unsigned i = 0; i < m_farms.size(); i++) {
3201  int fnum = m_farms[ i ]->GetFarmNumber();
3202  if (!InIllegalList( fnum, a_farmlist )) {
3203  if (m_farms[ i ]->GetMaxOpenness() > a_openness) {
3204  if (!IsDuplicateRef( fnum, &a_hunterinfo )) {
3205  // Is possible to use this farm, so test it.
3206  APoint FPt = m_farms[ i ]->GetCentroids();
3207  int dist = int(sqrt( (double( FPt.m_x - a_hunterinfo.homeX ) * double( FPt.m_x - a_hunterinfo.homeX ) + double( FPt.m_y - a_hunterinfo.homeY ) * double( FPt.m_y - a_hunterinfo.homeY )) ));
3208  if (dist>40000) dist = 40000;
3209  AFarmDist fd( int( fnum ), dist );
3210  farmdists.push_back( fd );
3211  }
3212  }
3213  }
3214  }
3215  // By here we have a list of farms and their distances - now we have the option to sort it or randomise it - one or other line below should be commented out.
3216  // sort(farmdists.begin(), farmdists.end(), FarmDistSort()); // Sort
3217  random_shuffle( farmdists.begin(), farmdists.end() ); // Randomise
3218  // Now the vector is sorted/randomised we loop through and test probabilities
3219  for (int ch = 1; ch < 100000; ch++) // This loop just makes sure small chances don't mess up the run by tripping out early
3220  {
3221  int sz = int( farmdists.size() );
3222  for (int i = 0; i < sz; i++) {
3223  double chance = g_rand_uni();
3224  // Uses ch from the outer loop to scale probabilities - tripping out here will occur often for farms a long way from the area otherwise
3225  double calc = cfg_ClosestFarmProbParam2.value()* exp( (cfg_ClosestFarmProbParam1.value() / double( ch ))* farmdists[ i ].m_y );
3226  if (chance <= calc) return farmdists[ i ].m_x;
3227  }
3228  }
3229  g_msg->Warn( "FarmManager::FindClosestFarmProb", "- No suitable farm found" );
3230  exit( 0 );
3231 }

References cfg_ClosestFarmProbParam1, cfg_ClosestFarmProbParam2, g_msg, g_rand_uni, HunterInfo::homeX, HunterInfo::homeY, InIllegalList(), IsDuplicateRef(), m_farms, CfgFloat::value(), and MapErrorMsg::Warn().

◆ FindClosestFarmOpennessProbNearRoostIsBest()

int FarmManager::FindClosestFarmOpennessProbNearRoostIsBest ( HunterInfo  a_hinfo,
vector< int > *  a_farmlist,
int  a_openness,
vector< APoint > *  a_farmsizelist 
)

Finds the closest farm to this co-ordinate with openness more than a value but uses a probability distribtution for acceptance based on closeness and another based on farm size.

Centroid calculation on farms must be called before calling this method for the first time.
a_farmlist is a pointer to a list of integers with illegal farm ref numbers. The first entry lists the number of illegal numbers. The chance of acceptance is probability based, taking the nearest farm first then testing the next etc.. The probability is based on y = 1*EXP(-x*cfg) with cfg being a fitting parameter in cfg_ClosestFarmProbParam1

We use typedef here to create our own name for APoint - but it is just two unsigned ints. We will use 'x' for the farm num and 'y' for the distance.

We use a vector of AFarmDists to be able to sort it easily

Struct redefining operator < - used for sorting distances from smallest to largest.

Definition at line 3289 of file farm.cpp.

3289  {
3298  typedef APoint AFarmDist;
3300  vector <AFarmDist> farmdists;
3302  struct FarmDistSort {
3303  bool operator()( AFarmDist a, AFarmDist b ) {
3304  return a.m_y < b.m_y;
3305  }
3306  };
3307  for (unsigned i = 0; i < m_farms.size(); i++) {
3308  int fnum = m_farms[ i ]->GetFarmNumber();
3309  if (!InIllegalList( fnum, a_farmlist )) {
3310  if (m_farms[ i ]->GetMaxOpenness() > a_openness) {
3311  if (!IsDuplicateRef( fnum, &a_hunterinfo )) {
3312  // Is possible to use this farm, so test it.
3313  APoint FPt = m_farms[ i ]->GetCentroids();
3314  int dist = int(sqrt( (double( FPt.m_x - a_hunterinfo.homeX ) * double( FPt.m_x - a_hunterinfo.homeX ) + double( FPt.m_y - a_hunterinfo.homeY ) * double( FPt.m_y - a_hunterinfo.homeY )) ));
3315  if (dist>40000) dist = 40000;
3316  AFarmDist fd( unsigned( fnum ), dist );
3317  farmdists.push_back( fd );
3318  }
3319  }
3320  }
3321  }
3322  // By here we have a list of farms and their distances - now we have the option to sort it or randomise it - one or other line below should be commented out.
3323  // sort(farmdists.begin(), farmdists.end(), FarmDistSort()); // Sort
3324  random_shuffle( farmdists.begin(), farmdists.end() ); // Randomise
3325  // Now the vector is sorted/randomised we loop through and test probabilities
3326  for (int ch = 1; ch < 100000; ch++) // This loop just makes sure small chances don't mess up the run by tripping out early
3327  {
3328  int sz = int( farmdists.size() );
3329  for (int i = 0; i < sz; i++) {
3330  double chance = g_rand_uni();
3331  // Uses ch from the outer loop to scale probabilities - tripping out here will occur often for farms a long way from the area otherwise
3332  double calc = cfg_ClosestFarmProbParam2.value()* exp( (cfg_ClosestFarmProbParam1.value() / double( ch ))* farmdists[ i ].m_y );
3333  if (chance <= calc) {
3334  // We passed the first test now take a second test based on roost distance
3335  chance = g_rand_uni();
3336  // Loop through each roost and find the closest to the farm - then do probability based on that distance.
3337  double dist = 10000;
3338  for (int r = 0; r < int( a_roostlist->size() ); r++) {
3339  double fdistroostx = farmdists[ i ].m_x - (*a_roostlist)[ r ].m_x;
3340  double fdistroosty = farmdists[ i ].m_y - (*a_roostlist)[ r ].m_y;
3341  double distf = sqrt( fdistroostx * fdistroostx + fdistroosty * fdistroostx );
3342  if (distf < dist) dist = distf;
3343  }
3344  calc = -0.01 + pow( dist / 10000.0, cfg_RoostDistProbParam1.value() );
3345  if (chance>calc) return farmdists[ i ].m_x;
3346  }
3347  }
3348  }
3349  g_msg->Warn( "FarmManager::FindClosestFarmProbNearRoostBest", "- No suitable farm found" );
3350  exit( 0 );
3351 }

References cfg_ClosestFarmProbParam1, cfg_ClosestFarmProbParam2, cfg_RoostDistProbParam1, g_msg, g_rand_uni, HunterInfo::homeX, HunterInfo::homeY, InIllegalList(), IsDuplicateRef(), m_farms, CfgFloat::value(), and MapErrorMsg::Warn().

◆ FindClosestFarmOpennessProbSmallIsBest()

int FarmManager::FindClosestFarmOpennessProbSmallIsBest ( HunterInfo  a_hinfo,
vector< int > *  a_farmlist,
int  a_openness,
vector< int > *  a_farmsizelist 
)

Finds the closest farm to this co-ordinate with openness more than a value but uses a probability distribtution for acceptance based on closeness and another based on farm size.

Centroid calculation on farms must be called before calling this method for the first time.
a_farmlist is a pointer to a list of integers with illegal farm ref numbers. The first entry lists the number of illegal numbers. The chance of acceptance is probability based, taking the nearest farm first then testing the next etc.. The probability is based on y = 1*EXP(-x*cfg) with cfg being a fitting parameter in cfg_ClosestFarmProbParam1

We use typedef here to create our own name for APoint - but it is just two unsigned ints. We will use 'x' for the farm num and 'y' for the distance.

We use a vector of AFarmDists to be able to sort it easily

Struct redefining operator < - used for sorting distances from smallest to largest.

Definition at line 3233 of file farm.cpp.

3233  {
3242  typedef APoint AFarmDist;
3244  vector <AFarmDist> farmdists;
3246  struct FarmDistSort {
3247  bool operator()( AFarmDist a, AFarmDist b ) {
3248  return a.m_y < b.m_y;
3249  }
3250  };
3251  for (unsigned i = 0; i < m_farms.size(); i++) {
3252  int fnum = m_farms[ i ]->GetFarmNumber();
3253  if (!InIllegalList( fnum, a_farmlist )) {
3254  if (m_farms[ i ]->GetMaxOpenness() > a_openness) {
3255  if (!IsDuplicateRef( fnum, &a_hunterinfo )) {
3256  // Is possible to use this farm, so test it.
3257  APoint FPt = m_farms[ i ]->GetCentroids();
3258  int dist = int(sqrt( (double( FPt.m_x - a_hunterinfo.homeX ) * double( FPt.m_x - a_hunterinfo.homeX ) + double( FPt.m_y - a_hunterinfo.homeY ) * double( FPt.m_y - a_hunterinfo.homeY )) ));
3259  if (dist>40000) dist = 40000;
3260  AFarmDist fd( unsigned( fnum ), dist );
3261  farmdists.push_back( fd );
3262  }
3263  }
3264  }
3265  }
3266  // By here we have a list of farms and their distances - now we have the option to sort it or randomise it - one or other line below should be commented out.
3267  // sort(farmdists.begin(), farmdists.end(), FarmDistSort()); // Sort
3268  random_shuffle( farmdists.begin(), farmdists.end() ); // Randomise
3269  // Now the vector is sorted/randomised we loop through and test probabilities
3270  for (int ch = 1; ch < 100000; ch++) // This loop just makes sure small chances don't mess up the run by tripping out early
3271  {
3272  int sz = int( farmdists.size() );
3273  for (int i = 0; i < sz; i++) {
3274  double chance = g_rand_uni();
3275  // Uses ch from the outer loop to scale probabilities - tripping out here will occur often for farms a long way from the area otherwise
3276  double calc = cfg_ClosestFarmProbParam2.value()* exp( (cfg_ClosestFarmProbParam1.value() / double( ch ))* farmdists[ i ].m_y );
3277  if (chance <= calc) {
3278  // We passed the first test now take a second test based on farm size
3279  chance = g_rand_uni();
3280  calc = pow( double( (*a_farmsizelist)[ farmdists[ i ].m_x ] / 4000.0 ), cfg_FarmSizeProbParam1.value() );
3281  if (chance>calc) return farmdists[ i ].m_x;
3282  }
3283  }
3284  }
3285  g_msg->Warn( "FarmManager::FindClosestFarmProb", "- No suitable farm found" );
3286  exit( 0 );
3287 }

References cfg_ClosestFarmProbParam1, cfg_ClosestFarmProbParam2, cfg_FarmSizeProbParam1, g_msg, g_rand_uni, HunterInfo::homeX, HunterInfo::homeY, InIllegalList(), IsDuplicateRef(), m_farms, CfgFloat::value(), and MapErrorMsg::Warn().

◆ FindFarmWithOpenness()

int FarmManager::FindFarmWithOpenness ( vector< int > *  a_farmlist,
int  a_openness 
)

Finds a farm openness more than a value not on the list.

Definition at line 3370 of file farm.cpp.

3371 {
3372  // Centroid calculation on farms must be called before calling this method for the first time
3373  int sz = (int)m_farms.size();
3374  int seed = random( sz );
3375  for (unsigned i = 0; i < m_farms.size(); i++) {
3376  int index = (i + seed) % sz;
3377  if (m_farms[ index ]->GetMaxOpenness() > a_openness)
3378  {
3379  if (!InIllegalList( m_farms[ index ]->GetFarmNumber(), a_farmlist )) return m_farms[ index ]->GetFarmNumber();
3380  }
3381  else AddToIllegalList(m_farms[ index ]->GetFarmNumber(), a_farmlist );
3382  }
3383  g_msg->Warn("FarmManager::FindFarmWithOpenness", "- No suitable farm found");
3384  exit(0);
3385 }

References AddToIllegalList(), g_msg, InIllegalList(), m_farms, and MapErrorMsg::Warn().

◆ FindFarmWithRandom()

int FarmManager::FindFarmWithRandom ( vector< int > *  a_farmlist)

Finds a farm openness more than a value not on the list.

Definition at line 3353 of file farm.cpp.

3354 {
3355  int sz= (int)m_farms.size();
3356  int f = random(sz);
3357  while (InIllegalList(m_farms[f]->GetFarmNumber(), a_farmlist))
3358  {
3359  f = random(sz);
3360  if (a_farmlist->size() >= m_farms.size())
3361  {
3362  g_msg->Warn("FarmManager::FindFarmWithRandom"," - farm density rule means all hunters cannot be placed");
3363  exit(0);
3364  }
3365  }
3366  return m_farms[f]->GetFarmNumber();
3367 
3368 }

References g_msg, InIllegalList(), m_farms, and MapErrorMsg::Warn().

◆ FindNeighbours()

void FarmManager::FindNeighbours ( )

Finds all OptimisingFarms' neighbours and saves them in the farm's OptimisingFarm::m_neighbours vector.

Definition at line 4657 of file farm.cpp.

4657  {
4658  //determine who is each farm's neighbour and save them in the farm's vector of its neighbours
4659  //and print the neighbours
4660 
4661  OptimisingFarm * opf_i;
4662  OptimisingFarm * opf_k;
4663 
4664  for(int i=0; i<(int)m_farms.size(); i++){
4665  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4666  opf_i = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4667  opf_i->Centroids(); //finds each farm's centroid
4668  }
4669  }
4670 
4671  for(int i=0; i<(int)m_farms.size(); i++){
4672  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4673  opf_i = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4674  int x = opf_i->GetFarmCentroidX();
4675  int y = opf_i->GetFarmCentroidY();
4676  int farm_no_i = opf_i->Get_almass_no();
4677 
4678  for(int k = 0; k<(int)m_farms.size(); k++) { //find neighbours of farm i
4679  if(m_farms[k]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4680  opf_k = dynamic_cast<OptimisingFarm*>(m_farms[k]);
4681  int xb = opf_k->GetFarmCentroidX();
4682  int yb = opf_k->GetFarmCentroidY();
4683  double par = 1000 * cfg_Neighbor_dist.value(); //change km to m
4684  int farm_no_k = opf_k->Get_almass_no();
4685 
4686  if(abs(x - xb) <= par && abs(y - yb) <= par && farm_no_i!=farm_no_k){ //check neighbourship (make sure it is not the same farm)
4687  //this is a neighbour
4688  opf_i->Set_Neighbour(opf_k); //add farm k to the list of neighbours of farm i
4689  }
4690  }
4691  else break;
4692  }
4693  }
4694  else break; //break the for loop -there is no more optimising farms
4695  }
4696 
4697  PrintNeighbours();
4698 
4699 }

References Farm::Centroids(), cfg_Neighbor_dist, OptimisingFarm::Get_almass_no(), OptimisingFarm::GetFarmCentroidX(), OptimisingFarm::GetFarmCentroidY(), m_farms, PrintNeighbours(), OptimisingFarm::Set_Neighbour(), tof_OptimisingFarm, and CfgFloat::value().

◆ FindOpennessFarm()

int FarmManager::FindOpennessFarm ( int  a_openness)

Finds a random farm with at least one field with openness above a_openness.

Definition at line 3387 of file farm.cpp.

3388 {
3389  int sz = (int) m_farms.size();
3390  int seed = random(sz);
3391  for (unsigned i = 0; i < m_farms.size(); i++)
3392  {
3393  int index = (i + seed) % sz;
3394  if (m_farms[index]->GetMaxOpenness() > a_openness) return m_farms[index]->GetFarmNumber();
3395  }
3396  return -1; // Should never happen but if it does we need to handle the -1 error code.
3397 }

References m_farms.

◆ Get_crops_summary_BIs_tov()

TTypesOfVegetation FarmManager::Get_crops_summary_BIs_tov ( int  i)
inline

Definition at line 1853 of file farm.h.

1853 {return m_crops_summary_BIs[i].Tov;};

References m_crops_summary_BIs.

Referenced by OptimisingFarm::ActualProfit().

◆ Get_cropTotals()

double FarmManager::Get_cropTotals ( int  i)
inline

Definition at line 1837 of file farm.h.

1837 {return m_cropTotals[i];};

References m_cropTotals.

◆ Get_cropTotals_size()

int FarmManager::Get_cropTotals_size ( )
inline

Definition at line 1840 of file farm.h.

1840 {return (int)m_cropTotals.size();};

References m_cropTotals.

◆ Get_lookup_table()

int FarmManager::Get_lookup_table ( int  index)
inline

Definition at line 1879 of file farm.h.

1879 {return m_crop_lookup_table[index];};

References m_crop_lookup_table.

Referenced by OptimisingFarm::Make_rotations(), and OptimisingFarm::Match_crop_to_field().

◆ GetDD()

double FarmManager::GetDD ( void  )
inline

Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops that are not harvested.

Definition at line 1835 of file farm.h.

1835 {return daydegrees;};

References daydegrees.

Referenced by OptimisingFarm::ActualProfit().

◆ GetFarmArableSize()

int FarmManager::GetFarmArableSize ( int  a_farmref)
inline

Returns the arable area from the farm ref num.

Definition at line 1733 of file farm.h.

1734  {
1735  return (GetFarmPtr(a_farmref)->GetArea());
1736  }

References GetFarmPtr().

◆ GetFarmAreaOpenFields()

int FarmManager::GetFarmAreaOpenFields ( int  a_farmref,
int  a_openness 
)
inline

Returns the area of fields with openness more than a_openness.

Definition at line 1760 of file farm.h.

1761  {
1762  return (GetFarmPtr(a_farmref)->GetAreaOpenFields(a_openness));
1763  }

References GetFarmPtr().

◆ GetFarmCentroid()

APoint FarmManager::GetFarmCentroid ( int  a_farmref)
inline

Gets the farm centroid as an APoint.

Definition at line 1809 of file farm.h.

1810  {
1811  for (unsigned int i = 0; i < m_farms.size(); i++)
1812  {
1813  if (a_farmref == m_farms[i]->GetFarmNumber())
1814  {
1815  return m_farms[i]->GetCentroids();
1816  }
1817  }
1818  g_msg->Warn("FarmManager::GetFarmCentroid - missing farm ref", a_farmref);
1819  exit(92);
1820  }

References g_msg, m_farms, and MapErrorMsg::Warn().

◆ GetFarmNoFields()

int FarmManager::GetFarmNoFields ( int  a_farmref)
inline

Returns the number of fields owned by a from the farm ref num.

Definition at line 1743 of file farm.h.

1744  {
1745  return (GetFarmPtr(a_farmref)->GetNoFields());
1746  }

References GetFarmPtr().

◆ GetFarmNoLookup()

int FarmManager::GetFarmNoLookup ( int  a_ref)
inline

Get a farm reference from the lookup table.

Definition at line 1882 of file farm.h.

1882 { return m_farmmapping_lookup[a_ref * 2]; }

References m_farmmapping_lookup.

Referenced by CreateFarms().

◆ GetFarmNoOpenFields()

int FarmManager::GetFarmNoOpenFields ( int  a_farmref,
int  a_openness 
)
inline

Returns the number of fields with openness more than a_openness.

Definition at line 1754 of file farm.h.

1755  {
1756  return (GetFarmPtr(a_farmref)->GetNoOpenFields(a_openness));
1757  }

References GetFarmPtr().

◆ GetFarmPtr()

Farm* FarmManager::GetFarmPtr ( int  a_owner)
inline

Returns the pointer to a farm with a specific number.

Definition at line 1766 of file farm.h.

1766  {
1767  for (unsigned int i = 0; i < m_farms.size( ); i++) {
1768  if (a_owner == m_farms[ i ]->GetFarmNumber( )) {
1769  return m_farms[ i ];
1770  }
1771  }
1772  g_msg->Warn( "FarmManager::GetFarmPtr - missing farm ref", a_owner );
1773  exit( 92 );
1774  }

References g_msg, m_farms, and MapErrorMsg::Warn().

Referenced by GetFarmArableSize(), GetFarmAreaOpenFields(), GetFarmNoFields(), GetFarmNoOpenFields(), GetFarmTotalSize(), GetFarmType(), GetFarmValidCoords(), and Landscape::SupplyFarmPtr().

◆ GetFarmPtrIndex()

Farm* FarmManager::GetFarmPtrIndex ( int  a_index)
inline

Returns the pointer to a farm with a specific index.

Definition at line 1777 of file farm.h.

1777  {
1778  return m_farms[ a_index ];
1779  }

References m_farms.

◆ GetFarmTotalSize()

int FarmManager::GetFarmTotalSize ( int  a_farmref)
inline

Returns the total farm area from the farm ref num.

Definition at line 1728 of file farm.h.

1729  {
1730  return (GetFarmPtr(a_farmref)->GetTotalArea());
1731  }

References GetFarmPtr().

◆ GetFarmType()

TTypesOfFarm FarmManager::GetFarmType ( int  a_farmref)
inline

Returns the farm type from the farm ref num.

Definition at line 1738 of file farm.h.

1739  {
1740  return (GetFarmPtr(a_farmref)->GetType());
1741  }

References GetFarmPtr().

◆ GetFarmTypeLookup()

int FarmManager::GetFarmTypeLookup ( int  a_ref)
inline

Get a farm type from the lookup table.

Definition at line 1884 of file farm.h.

1884 { return m_farmmapping_lookup[a_ref * 2 + 1]; }

References m_farmmapping_lookup.

◆ GetFarmValidCoords()

APoint FarmManager::GetFarmValidCoords ( int  a_farmref)
inline

Returns the number of fields owned by a from the farm ref num.

Definition at line 1748 of file farm.h.

1749  {
1750  return (GetFarmPtr(a_farmref)->GetValidCoords());
1751  }

References GetFarmPtr().

◆ GetIsRenumbered()

bool FarmManager::GetIsRenumbered ( )
inline

Returns the flag for renumbering.

Definition at line 1886 of file farm.h.

1886 { return m_renumbered; }

References m_renumbered.

◆ GetNoFarms()

int FarmManager::GetNoFarms ( )
inline

Definition at line 1900 of file farm.h.

1900  {
1901  return (int)m_farms.size();
1902  }

References m_farms.

Referenced by Landscape::SupplyNumberOfFarms().

◆ GetRandomFarmRefnum()

int FarmManager::GetRandomFarmRefnum ( )
inline

Returns a random farm reference number.

Definition at line 1781 of file farm.h.

1781 { return m_farms[random((int)m_farms.size())]->GetFarmNumber(); }

References m_farms.

◆ GetRenumberedFarmRef()

int FarmManager::GetRenumberedFarmRef ( int  a_farmref)
inline

Returns the farm ref index for a farmref.

Definition at line 1888 of file farm.h.

1889  {
1890  for (int i = 0; i < (int)m_farms.size(); i++)
1891  {
1892  if (m_farmmapping_lookup[i * 2] == a_farmref)
1893  {
1894  return i;
1895  }
1896  }
1897  g_msg->Warn( "FarmManager::GetRenumberedFarmRef(int a_farmref) Farm reference number not found in m_farmmapping_lookup ", a_farmref );
1898  exit( 9 );
1899  }

References g_msg, m_farmmapping_lookup, m_farms, and MapErrorMsg::Warn().

◆ GetSpilledGrain()

double FarmManager::GetSpilledGrain ( )

Returns the average amount of spilled grain in KJ/m2 this year.

Definition at line 3033 of file farm.cpp.

3034 {
3035  /*
3036  * This data is grain distributions based on 2013 & 2014 data from cereal fields in Jutland counted in September.
3037  * Counts made in squares of 0.0196 m2 and scaled up, hence the decimal numbers.
3038  * The numbers represent number of grains.
3039  */
3040  double graindist2013[26] = {
3041  29.59, 172.68, 60.59, 39.68, 51.02, 81.63, 268.71, 134.84, 57.40, 30.61, 204.08, 683.67, 108.04,
3042  141.29, 505.10, 444.61, 293.37, 355.18, 386.90, 381.83, 372.45, 377.55, 320.70, 392.46, 392.86, 435.17
3043  };
3044  double graindist2014[28] = {
3045  109.33, 382.65, 94.19, 765.31, 29.15, 70.15, 1096.94, 436.51, 309.21, 286.28, 480.44, 249.73, 784.10,
3046  688.78, 2035.45, 920.80, 341.61, 12.24, 113.38, 80.17, 178.57, 480.44, 0.00, 2.83, 1447.12, 1846.94, 1017.86,
3047  477.74
3048  };
3049  int grain_dist_value = cfg_grain_distribution.value();
3050  if (grain_dist_value == 0) // The default - random pick between the two years
3051  {
3052  if (m_SpilledGrain) return graindist2013[(int)(g_rand_uni() * 26)];
3053  else return graindist2014[(int)(g_rand_uni() * 28)];
3054  }
3055  if (grain_dist_value == 1) {
3056  return graindist2013[(int)(g_rand_uni() * 26)];
3057  }
3058  else
3059  {
3060  return graindist2014[(int)(g_rand_uni() * 28)];
3061  }
3062 }

References cfg_grain_distribution, g_rand_uni, m_SpilledGrain, and CfgInt::value().

◆ GetSpilledMaize()

double FarmManager::GetSpilledMaize ( )

Returns the average amount of spilled maize in KJ/m2 this year.

Definition at line 3064 of file farm.cpp.

3065 {
3066  /*
3067  * This data is maize distributions in kJ/m2 based on 2015, 2016 & 2017 field data from maize fields in Jutland
3068  */
3069  double maizedist[15] = {
3070  102.7905327,
3071  58.19878648,
3072  85.65877728,
3073  110.9055748,
3074  30.65682555,
3075  63.11699379,
3076  59.05947276,
3077  41.9277173,
3078  95.57716202,
3079  14.42674144,
3080  6.311699379,
3081  20.73844082,
3082  12.62339876,
3083  25.24679751,
3084  146.070757};
3085  return maizedist[(int)(g_rand_uni() * 15)];
3086 }

References g_rand_uni.

◆ InIllegalList()

bool FarmManager::InIllegalList ( int  a_farm_ref,
vector< int > *  a_farmlist 
)

Checks a list to see if a farm matches the illegal list of references.

a_farmlist is a pointer to a list of integers with illegal farm ref numbers. The first entry lists the number of illegal numbers.

Definition at line 3088 of file farm.cpp.

3088  {
3092  unsigned sz = (unsigned) a_farmlist->size();
3093  for (unsigned f = 0; f < sz; f++) {
3094  if ((*a_farmlist)[f] == a_farm_ref) return true;
3095  }
3096  return false;
3097 }

Referenced by FindClosestFarm(), FindClosestFarmOpenness(), FindClosestFarmOpennessProb(), FindClosestFarmOpennessProbNearRoostIsBest(), FindClosestFarmOpennessProbSmallIsBest(), FindFarmWithOpenness(), and FindFarmWithRandom().

◆ InitFarms()

void FarmManager::InitFarms ( )

Calls OptimisingFarm::Init for all optimising farms.

Definition at line 3014 of file farm.cpp.

3014  {
3015 
3016 
3018  Create_Output_file_for_farms(); //needed only for the OpitmisingFarms!
3019 }
3020 
3021 for(unsigned j=0; j<m_farms.size(); j++){
3022  if(m_farms[j]->GetType()==tof_OptimisingFarm){
3023  OptimisingFarm * opf = dynamic_cast<OptimisingFarm*>(m_farms[j]);
3024  opf->Init(pm_output_file);
3025  }
3026  }
3027 
3028 OptimisationOutput(); //03.05 - outputs of the optimisation
3029 
3030 }

References cfg_OptimisingFarms, Create_Output_file_for_farms(), OptimisingFarm::Init(), m_farms, OptimisationOutput(), pm_output_file, tof_OptimisingFarm, and CfgBool::value().

◆ InitiateManagement()

void FarmManager::InitiateManagement ( void  )

Definition at line 2733 of file farm.cpp.

2734 {
2735  for ( unsigned int i = 0; i < m_farms.size(); i++ )
2736  {
2737  m_farms[ i ]->InitiateManagement();
2738  }
2739 }

References m_farms.

◆ IsDuplicateRef()

bool FarmManager::IsDuplicateRef ( int  a_ref,
HunterInfo a_hinfo 
)

Checks if we already have this ref.

Definition at line 3116 of file farm.cpp.

3117 {
3118  for (int i = 0; i < int( a_hinfo->FarmHuntRef.size() ); i++)
3119  {
3120 
3121  if (a_ref == a_hinfo->FarmHuntRef[ i ]) return true;
3122  }
3123  return false;
3124 }

References HunterInfo::FarmHuntRef.

Referenced by FindClosestFarm(), FindClosestFarmOpenness(), FindClosestFarmOpennessProb(), FindClosestFarmOpennessProbNearRoostIsBest(), and FindClosestFarmOpennessProbSmallIsBest().

◆ OptimisationOutput()

void FarmManager::OptimisationOutput ( )
protected

Creates output files for all crop level variables and for landscape level crop distribution. Includes results of the initial farm otpimisation.

Definition at line 4451 of file farm.cpp.

4451  {
4452 
4453 //1. crop variables
4454  PrintOutput(tocv_AreaPercent, "AreaPercent.txt");
4455  PrintOutput(tocv_AreaHa, "AreaHa.txt");
4456  PrintOutput(tocv_N, "N.txt");
4457  PrintOutput(tocv_Nt, "Nt.txt");
4458  PrintOutput(tocv_BIHerb, "BIHerb.txt");
4459  PrintOutput(tocv_BIFi, "BIFi.txt");
4460  PrintOutput(tocv_BI, "BI.txt");
4461  PrintOutput(tocv_Grooming, "Grooming.txt");
4462  PrintOutput(tocv_Hoeing, "Hoeing.txt");
4463  PrintOutput(tocv_Weeding, "Weeding.txt");
4464  PrintOutput(tocv_TotalLoss, "TotalLoss.txt");
4465  PrintOutput(tocv_Response, "Response.txt");
4466  PrintOutput(tocv_Income, "Income.txt");
4467  PrintOutput(tocv_Costs, "Costs.txt");
4468  PrintOutput(tocv_GM, "GM.txt");
4469  PrintOutput(tocv_Savings, "Savings.txt");
4470 
4471 //2. crop total areas in ha at the landscape level
4472 
4473  CropDistribution(); //now there are total area values for each crop in the m_cropTotals vector
4474  ofstream ofile("CropDistribution.txt", ios::out);
4475 
4477  //print crop names (using vector<string>m_cropTypes)
4478  for(int c=0; c<toc_Foobar; c++) ofile << pm_data->Get_cropTypes_str(c) << '\t';
4479  ofile << endl;
4480  //print the values (total areas in ha)
4481  for(int c=0; c<toc_Foobar; c++) ofile << m_cropTotals[c] << '\t';
4482  }
4483  else{
4484  //print 'year'
4485  ofile << "Year" << '\t';
4486  //print crop names
4487  for(int c=0; c<pm_data->Get_noCrops(); c++) ofile << pm_data->Get_cropTypes_almass_str(c) << '\t';
4488  ofile << endl;
4489  //it's the first optimisation, so say the year is zero
4490  ofile << "0" << '\t';
4491  //print the values (total areas in ha)
4492  for(int c=0; c<pm_data->Get_noCrops(); c++) ofile << m_cropTotals[c] << '\t';
4493  ofile << endl;
4494  }
4495 
4496  //restart the m_cropTotals:
4497  for(int i=0; i<(int)m_cropTotals.size(); i++){
4498  m_cropTotals[i]=0;
4499  }
4500 
4501  ofile.close();
4502 }

References cfg_OptimiseBedriftsmodelCrops, CropDistribution(), DataForOptimisation::Get_cropTypes_almass_str(), DataForOptimisation::Get_cropTypes_str(), DataForOptimisation::Get_noCrops(), m_cropTotals, pm_data, PrintOutput(), toc_Foobar, tocv_AreaHa, tocv_AreaPercent, tocv_BI, tocv_BIFi, tocv_BIHerb, tocv_Costs, tocv_GM, tocv_Grooming, tocv_Hoeing, tocv_Income, tocv_N, tocv_Nt, tocv_Response, tocv_Savings, tocv_TotalLoss, tocv_Weeding, and CfgBool::value().

Referenced by InitFarms().

◆ PrintDecModes_counts()

void FarmManager::PrintDecModes_counts ( )

For each OptimizingFarm it prints the number of times each of the decision modes was used within a single simulation. See also OptimisingFarm::m_decision_mode_counters.

Definition at line 4720 of file farm.cpp.

4720  {
4721 
4722  //create a text file and make headers
4723  ofstream ofile ("Decision_modes_counts.txt", ios::out);
4724  ofile << "Farm_no\t" << "imitation\t" << "social comparison\t" << "repeat\t"<< "deliberation\t"<<endl;
4725 
4726  //print each farms no and then the content of the vector ...
4727  for(int i=0; i<(int)m_farms.size(); i++){
4728  OptimisingFarm * opf_i;
4729  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4730  opf_i = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4731  ofile << opf_i->Get_almass_no() << '\t';
4732  for(int j=0; j<4; j++){
4733  ofile << opf_i->Get_decision_mode_counters(j) <<'\t';
4734  }
4735  ofile << endl;
4736  }
4737  }
4738 
4739 }

References OptimisingFarm::Get_almass_no(), OptimisingFarm::Get_decision_mode_counters(), m_farms, and tof_OptimisingFarm.

Referenced by PrintFinalResults().

◆ PrintFinalResults()

void FarmManager::PrintFinalResults ( )

At the end of a simulation it prints results on crop distribution, pesticide and fertilizer usage.

Definition at line 4741 of file farm.cpp.

4741  {
4742 
4744 
4745  int no_years = g_date->GetYearNumber() - 21; //exclude first 9 years + one - the last one, which has just started now - it's Jan 1st//exclude first 20 (0-19) years for the wildlife runs
4746  double BIherb_sum=0;
4747  double BIfi_sum=0;
4748  double BI_sum=0;
4749  double fertilizer_sum=0;
4750  double fertilizer_trade_sum=0;
4751 
4752  totalOptFarmsArea *= 0.0001;//change to ha
4753  totalOptFarmsArea_plant *= 0.0001;
4754  totalOptFarmsArea_pig *= 0.0001;
4755  totalOptFarmsArea_cattle *= 0.0001;
4756  totalOptFarmsArea_other *= 0.0001;
4757 
4758  ofstream ofile ("CropAreasTotal_and_Average.txt", ios::out);
4759  // "This file includes summed (over all optimising farms) areas of each crop during the whole simulation, the average areas " ;
4760  //"(equal to the sum divided by the number of years the simulation was run) and areas as percentage of total optimising farms area.\t" ;
4761  ofile << "CropName\t" << "Total\t" << "Average\t" << "Area_%\t"<< endl;
4762  for(int i=0; i<(int)m_cropTotals_sum.size(); i++){
4763  ofile << pm_data->Get_cropTypes_almass_str(i) << '\t';
4764  ofile << m_cropTotals_sum[i] << '\t';
4765  ofile << m_cropTotals_sum[i]/no_years << '\t';
4766  ofile << m_cropTotals_sum[i]/no_years/totalOptFarmsArea * 100 << '%';
4767  ofile << endl;
4768  }
4769  ofile.close();
4770 
4771  //printing separate files for specific farm types - just areas in %.
4772  ofstream ofile5 ("CropAreas_plant_farms.txt", ios::out);
4773  ofile5 << "CropName\t" << "Area_%\t" << endl; //<< "Total\t" << "Average\t" <<
4774  for(int i=0; i<(int)m_cropTotals_plant_sum.size(); i++){
4775  ofile5 << pm_data->Get_cropTypes_almass_str(i) << '\t';
4776  ofile5 << m_cropTotals_plant_sum[i]/no_years/totalOptFarmsArea_plant * 100 << '%';
4777  ofile5 << endl;
4778  }
4779  ofile5.close();
4780 
4781  ofstream ofile6 ("CropAreas_pig_farms.txt", ios::out);
4782  ofile6 << "CropName\t" << "Area_%\t" << endl; //<< "Total\t" << "Average\t" <<
4783  for(int i=0; i<(int)m_cropTotals_pig_sum.size(); i++){
4784  ofile6 << pm_data->Get_cropTypes_almass_str(i) << '\t';
4785  ofile6 << m_cropTotals_pig_sum[i]/no_years/totalOptFarmsArea_pig * 100 << '%';
4786  ofile6 << endl;
4787  }
4788  ofile6.close();
4789 
4790  ofstream ofile7 ("CropAreas_cattle_farms.txt", ios::out);
4791  ofile7 << "CropName\t" << "Area_%\t" << endl; //<< "Total\t" << "Average\t" <<
4792  for(int i=0; i<(int)m_cropTotals_cattle_sum.size(); i++){
4793  ofile7 << pm_data->Get_cropTypes_almass_str(i) << '\t';
4794  ofile7 << m_cropTotals_cattle_sum[i]/no_years/totalOptFarmsArea_cattle * 100 << '%';
4795  ofile7 << endl;
4796  }
4797  ofile7.close();
4798 
4799  ofstream ofile8 ("CropAreas_other_farms.txt", ios::out);
4800  ofile8 << "CropName\t" << "Area_%\t" << endl; //<< "Total\t" << "Average\t" <<
4801  for(int i=0; i<(int)m_cropTotals_other_sum.size(); i++){
4802  ofile8 << pm_data->Get_cropTypes_almass_str(i) << '\t';
4803  ofile8 << m_cropTotals_other_sum[i]/no_years/totalOptFarmsArea_other * 100 << '%';
4804  ofile8 << endl;
4805  }
4806  ofile8.close();
4807 
4808 
4809 
4810 
4811  ofstream ofile1 ("PesticideTotals.txt", ios::out);
4812  ofile1 << "CropName\t" << "BIherb\t" << "BIfi\t" << "BI\t" ; //total values within a simulation
4813  ofile1 << "BIherb_yr\t" << "BIfi_yr\t" << "BI_yr\t"; //average values per year (total/no_years)
4814  ofile1 << "BIherb_ha\t" << "BIfi_ha\t" << "BI_ha\t"; //average values per ha (total BI/total area)
4815  ofile1 << endl;
4816  for(int i=0; i<(int)m_crops_summary_BIs.size(); i++){
4817  //ofile1 << m_crops_summary_BIs[i].Tov << '\t';
4818  ofile1 << pm_data->Get_cropTypes_almass_str(i) << '\t';
4819 
4820  ofile1 << m_crops_summary_BIs[i].BIherb << '\t';
4821  BIherb_sum += m_crops_summary_BIs[i].BIherb;
4822 
4823  ofile1 << m_crops_summary_BIs[i].BIfi << '\t';
4824  BIfi_sum += m_crops_summary_BIs[i].BIfi;
4825 
4826  ofile1 << m_crops_summary_BIs[i].BI << '\t';
4827  BI_sum += m_crops_summary_BIs[i].BI;
4828 
4829  ofile1 << m_crops_summary_BIs[i].BIherb/no_years << '\t';
4830  ofile1 << m_crops_summary_BIs[i].BIfi/no_years << '\t';
4831  ofile1 << m_crops_summary_BIs[i].BI/no_years << '\t';
4832  if(!m_cropTotals_sum[i]==0){
4833  ofile1 << m_crops_summary_BIs[i].BIherb/m_cropTotals_sum[i] << '\t';
4834  ofile1 << m_crops_summary_BIs[i].BIfi/m_cropTotals_sum[i] << '\t';
4835  ofile1 << m_crops_summary_BIs[i].BI/m_cropTotals_sum[i] << '\t';
4836  }
4837  else{
4838  ofile1 <<"0\t" << "0\t" << "0\t" ;
4839  }
4840  ofile1 << endl;
4841  }
4842  ofile1.close();
4843 
4844  ofstream ofile2 ("FertilizerTotals.txt", ios::out);
4845  ofile2 << "CropName\t" << "Fertilizer\t" << "Fertilizer_yr\t" << "Fertilizer_ha\t" << endl;
4846  for(int i=0; i<(int)m_crops_summary_BIs.size(); i++){
4847  ofile2 << pm_data->Get_cropTypes_almass_str(i) << '\t';
4848  ofile2 << m_crops_fertilizer[i] << '\t'; //total - all farms, all years
4849  fertilizer_sum += m_crops_fertilizer[i];
4850  fertilizer_trade_sum += m_crops_fertilizer_trade[i];
4851  ofile2 << m_crops_fertilizer[i]/no_years << '\t'; // average per year
4852  if(m_cropTotals_sum[i]!=0){
4853  ofile2 << m_crops_fertilizer[i]/m_cropTotals_sum[i] << '\t'; //average per ha
4854  }
4855  else{
4856  ofile2 << "0\t";
4857  }
4858  ofile2 << endl;
4859  }
4860  ofile2.close();
4861 
4862  //READ the inputs on crop areas in diff model stages
4863  ifstream ifile("crop_results_stages.txt", ios::in);
4864  //check if there is an input file
4865  if ( !ifile.is_open() ) {
4866  cout << "Cannot open input file " << "crop_results_stages.txt" << endl;
4867  char ch;
4868  cin >> ch; //so that it doesn't close immedietly
4869  exit(1);
4870  }
4871  int no_crops = pm_data->Get_noCrops();
4872  //get rid of the crop names
4873  for(int c=0; c<no_crops; c++){
4874  string type;
4875  ifile>>type;
4876  }
4877  for(int stage=0; stage<2; stage++){ //get just the results of the baseline and of the original model
4878  //stage name
4879  string stage_name;
4880  ifile>>stage_name;
4881  //save crop areas
4882  for(int a=0; a<no_crops; a++){
4883  ifile>>m_crop_areas_stages[stage * no_crops + a];
4884  }
4885  }
4886 
4887  //determine the sums of squared differences in crop areas (araes as percentages)
4888  vector<double>sums;
4889  sums.resize(2);
4890  for(int s=0; s<2; s++){
4891  sums[s]=0;
4892  }
4893 
4894  for(int st=0; st<2; st++){
4895  for(int b=0; b<no_crops; b++){
4896  double sq_diff = pow(m_cropTotals_sum[b]/no_years/totalOptFarmsArea * 100 - m_crop_areas_stages[st * no_crops + b]*100, 2);
4897  sums[st] += sq_diff;
4898  }
4899  }
4900 
4901  ofstream ofile3 ("Result_summary.txt", ios::out);
4902  ofile3 << "BIherb\t" << "BIfi\t" << "BI\t" << "Fert\t" << "Fert_trade\t" ; // sum for all crops/no_years/total_opt_farms_area
4903  ofile3 << "Sum of sq. diff: Baseline\t" << "Sum of sq. diff: Original\t"; // << "Sum of sq. diff: New opt.\t" << "Sum of sq. diff: Almass_f.area\t" << "Sum of sq. diff: Crop_choice_ev_yr\t";
4904  //ofile3 << "Sum of sq. diff: Dec.modes\t" << "Sum of sq. diff: Farmer types\t" << "Sum of sq. diff: Types+modes\t" << endl;
4905  ofile3 << BIherb_sum/totalOptFarmsArea/no_years <<'\t';
4906  ofile3 << BIfi_sum/totalOptFarmsArea/no_years <<'\t';
4907  ofile3 << BI_sum/totalOptFarmsArea/no_years <<'\t';
4908  ofile3 << fertilizer_sum/totalOptFarmsArea/no_years <<'\t';
4909  ofile3 << fertilizer_trade_sum/totalOptFarmsArea/no_years <<'\t';
4910  for(int sta=0; sta<2; sta++){
4911  ofile3 << sums[sta] << '\t';
4912  }
4913  ofile3.close();
4914 
4915  //for calibration/sensitivty analysis: comparison to baseline
4916  ofstream ofile4 ("Output.txt", ios::out);
4917  //order: 1.BI 2.BI diff%; 3. BI_abs_diff; 4.fert; 5.fert diff%; 6.fert_abs_diff 7.sum of sq. diff. compared to baseline; 8. weigthed measure
4918  double BIdiff_percent = ((BI_sum/totalOptFarmsArea/no_years/2.2) - 1) *100;//BI in the baseline = 2.2 and is the country level score!
4919  double BIdiffabs = abs(BIdiff_percent);
4920  double fert_diff_percent = ((fertilizer_sum/totalOptFarmsArea/no_years/140.07)-1) * 100;
4921  double fertdiffabs = abs(fert_diff_percent);
4922  //ofile4 << endl;
4923  ofile4 << '\t' << BI_sum/totalOptFarmsArea/no_years <<'\t' << BIdiff_percent << '\t'<< BIdiffabs <<'\t';
4924  ofile4 << fertilizer_sum/totalOptFarmsArea/no_years << '\t' << fert_diff_percent << '\t' << fertdiffabs <<'\t'; //fert in baseline = 140.07 kg/ha
4925  ofile4 << sums[0] << '\t';
4926  ofile4 << 0.2 * abs(BIdiff_percent) + 0.2 * abs(fert_diff_percent) + 0.6 * sums[0] << endl;
4927  ofile4.close();
4928 
4929  //print also areas of all crops...
4930  ofstream ofile9 ("Output_crop_areas_percent.txt", ios::out);
4931  ofile9 << '\t';
4932  for(int i=0; i<(int)m_cropTotals_sum.size(); i++){
4933  ofile9 << m_cropTotals_sum[i]/no_years/totalOptFarmsArea * 100 << '\t'; //print just areas (no crop names!)
4934  }
4935  ofile9 << endl;
4936  ofile9.close();
4937 
4938 
4939 }

References g_date, DataForOptimisation::Get_cropTypes_almass_str(), DataForOptimisation::Get_noCrops(), Calendar::GetYearNumber(), m_crop_areas_stages, m_crops_fertilizer, m_crops_fertilizer_trade, m_crops_summary_BIs, m_cropTotals_cattle_sum, m_cropTotals_other_sum, m_cropTotals_pig_sum, m_cropTotals_plant_sum, m_cropTotals_sum, pm_data, PrintDecModes_counts(), totalOptFarmsArea, totalOptFarmsArea_cattle, totalOptFarmsArea_other, totalOptFarmsArea_pig, and totalOptFarmsArea_plant.

◆ PrintNeighbours()

void FarmManager::PrintNeighbours ( )
protected

Creates an output file with a list of neighbours of each OptimisingFarm.

Definition at line 4701 of file farm.cpp.

4701  {
4702  //create a text file with the farms and their neighbours
4703  ofstream ofile ("Neighbours.txt", ios::out);
4704  ofile << "Farm no" << endl;
4705 
4706  //print each farms no and then the numbers of its neighbours
4707  for(int i=0; i<(int)m_farms.size(); i++){
4708  OptimisingFarm * opf_i;
4709  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4710  opf_i = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4711  ofile << opf_i->Get_almass_no() << '\t';
4712  for(int j=0; j<opf_i->Get_NeighboursSize(); j++){
4713  ofile << opf_i->Get_Neighbour(j)->Get_almass_no() <<'\t'; //pointer to the current, i.e. 'i' farm, takes its neighbour (j) and retrieves his almass_no
4714  }
4715  ofile << endl;
4716  }
4717  }
4718 }

References OptimisingFarm::Get_almass_no(), OptimisingFarm::Get_Neighbour(), OptimisingFarm::Get_NeighboursSize(), m_farms, and tof_OptimisingFarm.

Referenced by FindNeighbours().

◆ PrintOutput()

void FarmManager::PrintOutput ( TTypesOfCropVariables  a_var,
string  a_fileName 
)
protected

Makes an output file for one crop variable and prints its values for each crop and each OptimisingFarm. Includes results of the initial farm otpimisation.

Definition at line 4504 of file farm.cpp.

4504  {
4505 
4506  ofstream ofile (a_fileName.c_str(), ios::out);
4507  ofile << "Farm no" << '\t';
4508  //print crop names (using vector<string>m_cropTypes)
4510  for(int c=0; c<toc_Foobar; c++) ofile << pm_data->Get_cropTypes_str(c) << '\t';
4511  }
4512  else{
4513  for(int c=0; c<pm_data->Get_noCrops(); c++) ofile << pm_data->Get_cropTypes_almass_str(c) << '\t';
4514  }
4515  ofile << endl;
4516 
4517  for (int i=0; i<(int)m_farms.size(); i++){
4518  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4519  OptimisingFarm * opf;
4520  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4521  int no = opf->Get_almass_no();
4522  ofile << no << '\t';
4523  int size = opf->Get_cropsSize();
4524  for(int j = 0; j < size; j++){
4525  double var_to_print = -1;
4526  CropOptimised* crop = opf->Get_crop(j);
4527  switch (a_var){
4528  case tocv_AreaPercent:
4529  var_to_print = crop ->m_areaPercent;
4530  break;
4531  case tocv_AreaHa:
4532  var_to_print = crop ->m_area_ha;
4533  break;
4534  case tocv_N:
4535  var_to_print = crop ->m_n;
4536  break;
4537  case tocv_Nt:
4538  var_to_print = crop ->m_nt;
4539  break;
4540  case tocv_BIHerb:
4541  var_to_print = crop ->m_BIHerb;
4542  break;
4543  case tocv_BIFi:
4544  var_to_print = crop ->m_BIFi;
4545  break;
4546  case tocv_BI:
4547  var_to_print = crop ->m_BI;
4548  break;
4549  case tocv_Grooming:
4550  var_to_print = crop ->m_grooming;
4551  break;
4552  case tocv_Hoeing:
4553  var_to_print = crop ->m_hoeing;
4554  break;
4555  case tocv_Weeding:
4556  var_to_print = crop ->m_weeding;
4557  break;
4558  case tocv_TotalLoss:
4559  var_to_print = crop ->m_totalLoss;
4560  break;
4561  case tocv_Response:
4562  var_to_print = crop ->m_resp;
4563  break;
4564  case tocv_Income:
4565  var_to_print = crop ->m_income_ha;
4566  break;
4567  case tocv_Costs:
4568  var_to_print = crop ->m_costs_ha;
4569  break;
4570  case tocv_GM:
4571  var_to_print = crop ->m_GM;
4572  break;
4573  case tocv_Savings:
4574  var_to_print = crop ->m_savings;
4575  break;
4576  default:
4577  g_msg->Warn( WARN_BUG, "FarmManager::PrintOutput(): ""Unknown crop variable type! ", "" );
4578  exit( 1 );
4579  }
4580  ofile << var_to_print << '\t';
4581  }
4582  ofile << endl;
4583  }
4584  }
4585  ofile.close();
4586 }

References cfg_OptimiseBedriftsmodelCrops, g_msg, OptimisingFarm::Get_almass_no(), OptimisingFarm::Get_crop(), OptimisingFarm::Get_cropsSize(), DataForOptimisation::Get_cropTypes_almass_str(), DataForOptimisation::Get_cropTypes_str(), DataForOptimisation::Get_noCrops(), CropOptimised::m_area_ha, CropOptimised::m_areaPercent, CropOptimised::m_BI, CropOptimised::m_BIFi, CropOptimised::m_BIHerb, CropOptimised::m_costs_ha, m_farms, CropOptimised::m_GM, CropOptimised::m_grooming, CropOptimised::m_hoeing, CropOptimised::m_income_ha, CropOptimised::m_n, CropOptimised::m_nt, CropOptimised::m_resp, CropOptimised::m_savings, CropOptimised::m_totalLoss, CropOptimised::m_weeding, pm_data, toc_Foobar, tocv_AreaHa, tocv_AreaPercent, tocv_BI, tocv_BIFi, tocv_BIHerb, tocv_Costs, tocv_GM, tocv_Grooming, tocv_Hoeing, tocv_Income, tocv_N, tocv_Nt, tocv_Response, tocv_Savings, tocv_TotalLoss, tocv_Weeding, tof_OptimisingFarm, CfgBool::value(), MapErrorMsg::Warn(), and WARN_BUG.

Referenced by OptimisationOutput().

◆ ReadCropsData()

void FarmManager::ReadCropsData ( )
protected

Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector DataForOptimisation::m_cropParameters.

Definition at line 3656 of file farm.cpp.

3656  {
3657 
3658  //read the input file
3659  ifstream ifile("crop_parameters.txt", ios::in);
3660  //check if there is an input file
3661  if ( !ifile.is_open() ) {
3662  cout << "Cannot open input file " << "crop_parameters.txt" << endl;
3663  char ch;
3664  cin >> ch; //so that it doesn't close immedietly
3665  exit(1);
3666  }
3667 
3668  //get rid of the parameters names
3669  for(int p=0; p<top_Foobar; p++){
3670  string type;
3671  ifile>>type;
3672  }
3673 
3674  //loop through the crops - save values of the parameters in a vector of the DataForOptimisation class
3675  for(int c=0; c<toc_Foobar; c++){
3676  string crop; //in the first column of the input table
3677  ifile>>crop; //do nothing with it
3678  for(int p=0; p<top_Foobar; p++){
3679  double par_value;
3680  ifile>>par_value;
3681  int index=top_Foobar*c + p;
3682  pm_data->Set_cropParameter (par_value, index );
3683  }
3684  }
3685  ifile.close();
3686 }

References pm_data, DataForOptimisation::Set_cropParameter(), toc_Foobar, and top_Foobar.

Referenced by FarmManager().

◆ ReadCropsData_almass()

void FarmManager::ReadCropsData_almass ( )
protected

Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector DataForOptimisation::m_cropParameters. ALMaSS crop mode.

Definition at line 3688 of file farm.cpp.

3688  {
3689 
3690  //read the input file
3691  ifstream ifile("crop_parameters.txt", ios::in);
3692  //check if there is an input file
3693  if ( !ifile.is_open() ) {
3694  cout << "Cannot open input file " << "crop_parameters.txt" << endl;
3695  char ch;
3696  cin >> ch; //so that it doesn't close immedietly
3697  exit(1);
3698  }
3699 
3700  int noCrops=0;
3701  ifile>>noCrops;
3702 
3703  //get rid of the parameters names
3704  for(int p=0; p<top_Foobar; p++){
3705  string type;
3706  ifile>>type;
3707  }
3708 
3709  //loop through the crops - save values of the parameters in a vector of the DataForOptimisation class
3710  for(int c=0; c<noCrops; c++){
3711  string crop; //in the first column of the input table
3712  ifile>>crop; //do nothing with it
3713  for(int p=0; p<top_Foobar; p++){
3714  double par_value;
3715  ifile>>par_value;
3716  int index=top_Foobar*(pm_data->Get_cropTypes_almass(c)) + p; //Get_cropTypes_almass(c) - gives as a tov type crop at position c
3717  pm_data->Set_cropParameter (par_value, index );
3718  }
3719  }
3720  ifile.close();
3721 
3722 }

References DataForOptimisation::Get_cropTypes_almass(), pm_data, DataForOptimisation::Set_cropParameter(), and top_Foobar.

Referenced by FarmManager().

◆ ReadCropsData_perFarm_and_Soil()

void FarmManager::ReadCropsData_perFarm_and_Soil ( )
protected

Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them in a vector DataForOptimisation::m_sellingPrice.

Definition at line 4003 of file farm.cpp.

4003  {
4004 
4005  //read the input files
4006  ifstream ifile1("sellingPrice.txt", ios::in);
4007 
4008  //check if there are all input files
4009  if ( !ifile1.is_open() ) {
4010  cout << "Cannot open input file " << "sellingPrice.txt" << endl;
4011  char ch;
4012  cin >> ch; //so that it doesn't close immedietly
4013  exit(1);
4014  }
4015 
4016  //get rid off the crops names;
4017  for(int c=0; c<toc_Foobar; c++){
4018  string type;
4019  ifile1>>type;
4020  }
4021 
4022  //loop through the farm and soil types!
4023  for(int f=0; f<(toof_Foobar * tos_Foobar); f++){
4024  string farm_type;
4025  string soil_type;
4026  ifile1>>farm_type>>soil_type; //get rid off the farm type and soil type names
4027  for(int c=0; c<toc_Foobar; c++){
4028  double par_value;
4029  ifile1>>par_value;
4030  pm_data->Set_sellingPrice(par_value, toc_Foobar*f + c);
4031  }
4032  }
4033  ifile1.close();
4034 }

References pm_data, DataForOptimisation::Set_sellingPrice(), toc_Foobar, toof_Foobar, and tos_Foobar.

Referenced by FarmManager().

◆ ReadCropsData_perFarm_and_Soil_almass()

void FarmManager::ReadCropsData_perFarm_and_Soil_almass ( )
protected

Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them in a vector DataForOptimisation:m_sellingPrice. ALMaSS crop mode.

Definition at line 4036 of file farm.cpp.

4036  {
4037 
4038  //read the input files
4039  ifstream ifile1("sellingPrice.txt", ios::in);
4040 
4041  //check if there are all input files
4042  if ( !ifile1.is_open() ) {
4043  cout << "Cannot open input file " << "sellingPrice.txt" << endl;
4044  char ch;
4045  cin >> ch; //so that it doesn't close immedietly
4046  exit(1);
4047  }
4048 
4049  int noCrops=0;
4050  ifile1>>noCrops;
4051 
4052  //get rid off the crops names;
4053  for(int c=0; c<noCrops; c++){
4054  string type;
4055  ifile1>>type;
4056  }
4057 
4058  //loop through the farm and soil types!
4059  for(int f=0; f<(toof_Foobar * tos_Foobar); f++){
4060  string farm_type;
4061  string soil_type;
4062  ifile1>>farm_type>>soil_type; //get rid off the farm type and soil type names
4063  for(int c=0; c<noCrops; c++){
4064  double par_value;
4065  ifile1>>par_value;
4067  }
4068  }
4069  ifile1.close();
4070 
4071 
4072  }

References DataForOptimisation::Get_cropTypes_almass(), pm_data, DataForOptimisation::Set_sellingPrice(), toof_Foobar, tos_Foobar, and tov_Undefined.

Referenced by FarmManager().

◆ ReadCropsData_perFarm_and_Soil_and_Size()

void FarmManager::ReadCropsData_perFarm_and_Soil_and_Size ( )
protected

Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax, rotationMin) and saves them in vectors of the DataForOptimisation class.

Definition at line 4074 of file farm.cpp.

4074  {
4075 
4076  //read the input files
4077  ifstream ifile1("rotationMax.txt", ios::in);
4078  ifstream ifile2("rotationMin.txt", ios::in);
4079 
4080  //check if there are all input files
4081  if ( !ifile1.is_open() ) {
4082  cout << "Cannot open input file " << "rotationMax.txt" << endl;
4083  char ch;
4084  cin >> ch; //so that it doesn't close immedietly
4085  exit(1);
4086  } else if(!ifile2.is_open() ){
4087  cout << "Cannot open input file " << "rotationMin.txt" << endl;
4088  char ch;
4089  cin >> ch; //so that it doesn't close immedietly
4090  exit(1);
4091  }
4092 
4093  //get rid off the crops names;
4094  for(int c=0; c<toc_Foobar; c++){
4095  string type;
4096  ifile1>>type;
4097  ifile2>>type;
4098  }
4099 
4100  //loop through the farm types, soil types and farm sizes!
4101  for(int f=0; f<(toof_Foobar *tos_Foobar * tofs_Foobar); f++){
4102  string farm_type, soil_type, farm_size;
4103  ifile1>>farm_type>>soil_type>>farm_size; //get rid off the farm type, soil type ad farm size names
4104  ifile2>>farm_type>>soil_type>>farm_size;
4105  for(int c=0; c<toc_Foobar; c++){
4106  double par_value;
4107  ifile1>>par_value;
4108  pm_data->Set_rotationMax(par_value, toc_Foobar*f + c);
4109  ifile2>>par_value;
4110  pm_data->Set_rotationMin(par_value, toc_Foobar*f + c);
4111  }
4112  }
4113  ifile1.close();
4114  ifile2.close();
4115 }

References pm_data, DataForOptimisation::Set_rotationMax(), DataForOptimisation::Set_rotationMin(), toc_Foobar, tofs_Foobar, toof_Foobar, and tos_Foobar.

Referenced by FarmManager().

◆ ReadCropsData_perFarm_and_Soil_and_Size_almass()

void FarmManager::ReadCropsData_perFarm_and_Soil_and_Size_almass ( )
protected

Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax, rotationMin) and saves them in vectors of the DataForOptimisation class. ALMaSS crop mode.

Definition at line 4117 of file farm.cpp.

4117  {
4118 
4119  //read the input files
4120 
4121  string rot_max;
4122  string rot_min;
4123 
4125  rot_max = "rotationMax_almass.txt";
4126  rot_min = "rotationMin_almass.txt";
4127  }
4128  else{ //rot max and min as specified in the Original Bedriftsmodel
4129  rot_max = "rotationMax.txt";
4130  rot_min = "rotationMin.txt";
4131  }
4132 
4133  ifstream ifile1(rot_max.c_str(), ios::in);
4134  ifstream ifile2(rot_min.c_str(), ios::in);
4135 
4136 
4137 
4138  //check if there are all input files
4139  if ( !ifile1.is_open() ) {
4140  cout << "Cannot open input file with rotation max" << endl;
4141  char ch;
4142  cin >> ch; //so that it doesn't close immedietly
4143  exit(1);
4144  } else if(!ifile2.is_open() ){
4145  cout << "Cannot open input file with rotation min" << endl;
4146  char ch;
4147  cin >> ch; //so that it doesn't close immedietly
4148  exit(1);
4149  }
4150 
4151  int noCrops, noCrops1=0;
4152  ifile1>>noCrops;
4153  ifile2>>noCrops1; //should be always same number!
4154  if(noCrops!=noCrops1){
4155  g_msg->Warn( WARN_FILE, "FarmManager::ReadCropsData_perSoilType_almass():"" Numbers of crops differ between input files! ", " " );
4156  exit( 1 );
4157  }
4158 
4159  //get rid off the crops names;
4160  for(int c=0; c<noCrops; c++){
4161  string type;
4162  ifile1>>type;
4163  ifile2>>type;
4164  }
4165 
4166  //loop through the farm types, soil types and farm sizes!
4167  for(int f=0; f<(toof_Foobar *tos_Foobar * tofs_Foobar); f++){
4168  string farm_type, soil_type, farm_size;
4169  ifile1>>farm_type>>soil_type>>farm_size; //get rid off the farm type, soil type ad farm size names
4170  ifile2>>farm_type>>soil_type>>farm_size;
4171  for(int c=0; c<noCrops; c++){
4172  double par_value;
4173  ifile1>>par_value;
4175  ifile2>>par_value;
4177  }
4178  }
4179  ifile1.close();
4180  ifile2.close();
4181 
4182 }

References cfg_Areas_Based_on_Distribution, g_msg, DataForOptimisation::Get_cropTypes_almass(), pm_data, DataForOptimisation::Set_rotationMax(), DataForOptimisation::Set_rotationMin(), tofs_Foobar, toof_Foobar, tos_Foobar, tov_Undefined, CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by FarmManager().

◆ ReadCropsData_perFarmType()

void FarmManager::ReadCropsData_perFarmType ( )
protected

Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them in vectors of the DataForOptimisation class.

Definition at line 3881 of file farm.cpp.

3881  {
3882 
3883  //read the input files
3884  ifstream ifile1("fixed.txt", ios::in);
3885  ifstream ifile2("fodder.txt", ios::in);
3886  ifstream ifile3("FUKey.txt", ios::in);
3887 
3888  //check if there are all input files
3889  if ( !ifile1.is_open() ) {
3890  cout << "Cannot open input file " << "fixed.txt" << endl;
3891  char ch;
3892  cin >> ch; //so that it doesn't close immedietly
3893  exit(1);
3894  } else if(!ifile2.is_open() ){
3895  cout << "Cannot open input file " << "fodder.txt" << endl;
3896  char ch;
3897  cin >> ch; //so that it doesn't close immedietly
3898  exit(1);
3899  }
3900  else if(!ifile3.is_open() ){
3901  cout << "Cannot open input file " << "FUKey.txt" << endl;
3902  char ch;
3903  cin >> ch; //so that it doesn't close immedietly
3904  exit(1);
3905  }
3906 
3907  //get rid off the crops names;
3908  for(int c=0; c<toc_Foobar; c++){
3909  string type;
3910  ifile1>>type;
3911  ifile2>>type;
3912  ifile3>>type;
3913  }
3914 
3915  //loop through the farm types!
3916  for(int f=0; f<toof_Foobar; f++){
3917  string farm_type;
3918  ifile1>>farm_type; //get rid off the farm type name
3919  ifile2>>farm_type;
3920  ifile3>>farm_type;
3921  for(int c=0; c<toc_Foobar; c++){
3922  string par;
3923  ifile1>>par;
3924  pm_data->Set_fixed(par, toc_Foobar*f + c);
3925  ifile2>>par;
3926  pm_data->Set_fodder(par, toc_Foobar*f + c);
3927  double par_value;
3928  ifile3>>par_value;
3929  pm_data->Set_FUKey(par_value, toc_Foobar*f + c);
3930  }
3931  }
3932  ifile1.close();
3933  ifile2.close();
3934  ifile3.close();
3935 }

References pm_data, DataForOptimisation::Set_fixed(), DataForOptimisation::Set_fodder(), DataForOptimisation::Set_FUKey(), toc_Foobar, and toof_Foobar.

Referenced by FarmManager().

◆ ReadCropsData_perFarmType_almass()

void FarmManager::ReadCropsData_perFarmType_almass ( )
protected

Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them in vectors of the DataForOptimisation class. ALMaSS crop mode.

Definition at line 3937 of file farm.cpp.

3937  {
3938 
3939  //read the input files
3940  ifstream ifile1("fixed.txt", ios::in);
3941  ifstream ifile2("fodder.txt", ios::in);
3942  ifstream ifile3("FUKey.txt", ios::in);
3943 
3944  //check if there are all input files
3945  if ( !ifile1.is_open() ) {
3946  cout << "Cannot open input file " << "fixed.txt" << endl;
3947  char ch;
3948  cin >> ch; //so that it doesn't close immedietly
3949  exit(1);
3950  } else if(!ifile2.is_open() ){
3951  cout << "Cannot open input file " << "fodder.txt" << endl;
3952  char ch;
3953  cin >> ch; //so that it doesn't close immedietly
3954  exit(1);
3955  }
3956  else if(!ifile3.is_open() ){
3957  cout << "Cannot open input file " << "FUKey.txt" << endl;
3958  char ch;
3959  cin >> ch; //so that it doesn't close immedietly
3960  exit(1);
3961  }
3962 
3963  int noCrops, noCrops1, noCrops2=0;
3964  ifile1>>noCrops;
3965  ifile2>>noCrops1;
3966  ifile3>>noCrops2; //should be always same number!
3967  if(noCrops!=noCrops1 || noCrops!=noCrops2){
3968  g_msg->Warn( WARN_FILE, "FarmManager::ReadCropsData_perSoilType_almass():"" Numbers of crops differ between input files! ", " " );
3969  exit( 1 );
3970  }
3971 
3972 
3973  //get rid off the crops names;
3974  for(int c=0; c<noCrops; c++){
3975  string type;
3976  ifile1>>type;
3977  ifile2>>type;
3978  ifile3>>type;
3979  }
3980 
3981  //loop through the farm types!
3982  for(int f=0; f<toof_Foobar; f++){
3983  string farm_type;
3984  ifile1>>farm_type; //get rid off the farm type name
3985  ifile2>>farm_type;
3986  ifile3>>farm_type;
3987  for(int c=0; c<noCrops; c++){
3988  string par;
3989  ifile1>>par;
3991  ifile2>>par;
3993  double par_value;
3994  ifile3>>par_value;
3996  }
3997  }
3998  ifile1.close();
3999  ifile2.close();
4000  ifile3.close();
4001 }

References g_msg, DataForOptimisation::Get_cropTypes_almass(), pm_data, DataForOptimisation::Set_fixed(), DataForOptimisation::Set_fodder(), DataForOptimisation::Set_FUKey(), toof_Foobar, tov_Undefined, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by FarmManager().

◆ ReadCropsData_perSoilType()

void FarmManager::ReadCropsData_perSoilType ( )
protected

Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2, Nnorm) and saves them in vectors of the DataForOptimisation class.

Definition at line 3724 of file farm.cpp.

3724  {
3725 
3726  //read the input files
3727  ifstream ifile1("alfa.txt", ios::in);
3728  ifstream ifile2("beta1.txt", ios::in);
3729  ifstream ifile3("beta2.txt", ios::in);
3730  ifstream ifile4("Nnorm.txt", ios::in);
3731  //check if there are all input files
3732  if ( !ifile1.is_open() ) {
3733  cout << "Cannot open input file " << "alfa.txt" << endl;
3734  char ch;
3735  cin >> ch; //so that it doesn't close immedietly
3736  exit(1);
3737  } else if(!ifile2.is_open() ){
3738  cout << "Cannot open input file " << "beta1.txt" << endl;
3739  char ch;
3740  cin >> ch; //so that it doesn't close immedietly
3741  exit(1);
3742  }
3743  else if(!ifile3.is_open() ){
3744  cout << "Cannot open input file " << "beta2.txt" << endl;
3745  char ch;
3746  cin >> ch; //so that it doesn't close immedietly
3747  exit(1);
3748  }
3749  else if(!ifile4.is_open() ){
3750  cout << "Cannot open input file " << "Nnorm.txt" << endl;
3751  char ch;
3752  cin >> ch; //so that it doesn't close immedietly
3753  exit(1);
3754  }
3755  //get rid off the crops names;
3756  for(int c=0; c<toc_Foobar; c++){
3757  string type;
3758  ifile1>>type;
3759  ifile2>>type;
3760  ifile3>>type;
3761  ifile4>>type;
3762  }
3763 
3764  //loop through the soil types!
3765  for(int s=0; s<tos_Foobar; s++){
3766  string soil;
3767  ifile1>>soil; //get rid off the soil type name
3768  ifile2>>soil;
3769  ifile3>>soil;
3770  ifile4>>soil;
3771  for(int c=0; c<toc_Foobar; c++){
3772  double par_value;
3773  ifile1>>par_value;
3774  pm_data->Set_alfa(par_value, toc_Foobar*s + c);
3775  ifile2>>par_value;
3776  pm_data->Set_beta1(par_value, toc_Foobar*s + c);
3777  ifile3>>par_value;
3778  pm_data->Set_beta2(par_value, toc_Foobar*s + c);
3779  ifile4>>par_value;
3780  pm_data->Set_Nnorm(par_value, toc_Foobar*s + c);
3781 
3782  }
3783  }
3784  ifile1.close();
3785  ifile2.close();
3786  ifile3.close();
3787  ifile4.close();
3788 }

References pm_data, DataForOptimisation::Set_alfa(), DataForOptimisation::Set_beta1(), DataForOptimisation::Set_beta2(), DataForOptimisation::Set_Nnorm(), toc_Foobar, and tos_Foobar.

Referenced by FarmManager().

◆ ReadCropsData_perSoilType_almass()

void FarmManager::ReadCropsData_perSoilType_almass ( )
protected

Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2, Nnorm) and saves them in vectors of the DataForOptimisation class. ALMaSS crop mode.

Definition at line 3790 of file farm.cpp.

3790  {
3791 
3792  //read the input files
3793  ifstream ifile1("alfa.txt", ios::in);
3794  ifstream ifile2("beta1.txt", ios::in);
3795  ifstream ifile3("beta2.txt", ios::in);
3796  ifstream ifile4("Nnorm.txt", ios::in);
3797  ifstream ifile5("biomass_factor_almass.txt", ios::in);
3798 
3799  //check if there are all input files
3800  if ( !ifile1.is_open() ) {
3801  cout << "Cannot open input file " << "alfa.txt" << endl;
3802  char ch;
3803  cin >> ch; //so that it doesn't close immedietly
3804  exit(1);
3805  } else if(!ifile2.is_open() ){
3806  cout << "Cannot open input file " << "beta1.txt" << endl;
3807  char ch;
3808  cin >> ch; //so that it doesn't close immedietly
3809  exit(1);
3810  }
3811  else if(!ifile3.is_open() ){
3812  cout << "Cannot open input file " << "beta2.txt" << endl;
3813  char ch;
3814  cin >> ch; //so that it doesn't close immedietly
3815  exit(1);
3816  }
3817  else if(!ifile4.is_open() ){
3818  cout << "Cannot open input file " << "Nnorm.txt" << endl;
3819  char ch;
3820  cin >> ch; //so that it doesn't close immedietly
3821  exit(1);
3822  }
3823  if (!ifile5.is_open() ) {
3824  cout << "Cannot open input file " << "biomass_factor_almass.txt" << endl;
3825  char ch;
3826  cin >> ch; //so that it doesn't close immedietly
3827  exit(1);
3828  }
3829 
3830  int noCrops, noCrops1, noCrops2, noCrops3, noCrops4=0;
3831  ifile1>>noCrops;
3832  ifile2>>noCrops1;
3833  ifile3>>noCrops2;
3834  ifile4>>noCrops3;
3835  ifile5>>noCrops4; //should be always same number!
3836  if(noCrops!=noCrops1 || noCrops!=noCrops2 || noCrops!=noCrops3 || noCrops!=noCrops4){
3837  g_msg->Warn( WARN_FILE, "FarmManager::ReadCropsData_perSoilType_almass():"" Numbers of crops differ between input files! ", " " );
3838  exit( 1 );
3839  }
3840 
3841  //get rid off the crops names;
3842  for(int c=0; c<noCrops; c++){
3843  string type;
3844  ifile1>>type;
3845  ifile2>>type;
3846  ifile3>>type;
3847  ifile4>>type;
3848  ifile5>>type;
3849  }
3850 
3851  //loop through the soil types!
3852  for(int s=0; s<tos_Foobar; s++){
3853  string soil;
3854  ifile1>>soil; //get rid off the soil type name
3855  ifile2>>soil;
3856  ifile3>>soil;
3857  ifile4>>soil;
3858  ifile5>>soil;
3859  for(int c=0; c<noCrops; c++){
3860  double par_value;
3861  ifile1>>par_value;
3862  pm_data->Set_alfa(par_value, tov_Undefined*s + pm_data->Get_cropTypes_almass(c)); //Get_cropTypes_almass(c) - gives as a tov type crop at position c
3863  ifile2>>par_value;
3865  ifile3>>par_value;
3867  ifile4>>par_value;
3869  ifile5>>par_value;
3871 
3872  }
3873  }
3874  ifile1.close();
3875  ifile2.close();
3876  ifile3.close();
3877  ifile4.close();
3878  ifile5.close();
3879 }

References g_msg, DataForOptimisation::Get_cropTypes_almass(), pm_data, DataForOptimisation::Set_alfa(), DataForOptimisation::Set_beta1(), DataForOptimisation::Set_beta2(), DataForOptimisation::Set_biomass_factor(), DataForOptimisation::Set_Nnorm(), tos_Foobar, tov_Undefined, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by FarmManager().

◆ ReadEnergyMaizePrice()

void FarmManager::ReadEnergyMaizePrice ( )
protected

Definition at line 4244 of file farm.cpp.

4244  {
4245 
4246 
4247  //read the input files
4248  ifstream ifile1(l_emaize_price_file.value(), ios::in);
4249 
4250  //check if there are all input files
4251  if ( !ifile1.is_open() ) {
4252  cout << "Cannot open input file " << l_emaize_price_file.value() << endl;
4253  char ch;
4254  cin >> ch; //so that it doesn't close immedietly
4255  exit(1);
4256  }
4257  //get th enumber of years he file has data for
4258  int no_years=0;
4259  ifile1>>no_years;
4260 
4261  //loop
4262  for(int i=0; i<no_years; i++){
4263  int year;
4264  ifile1>>year; //get rid off the year number
4265  double par_value;
4266  ifile1>>par_value;
4267  pm_data->Set_emaize_price(par_value);
4268  }
4269  ifile1.close();
4270 }

References l_emaize_price_file, pm_data, DataForOptimisation::Set_emaize_price(), and CfgStr::value().

Referenced by FarmManager().

◆ ReadFarmsData()

void FarmManager::ReadFarmsData ( )
protected

Reads farm level parameters and saves them in a vector DataForOptimisation::m_farm_data.

Definition at line 3484 of file farm.cpp.

3484  {
3485 
3486  int noFarms;
3487  int noParameters=6; //farm number, farm type, soil type, farm size, real ID, soil subtype
3488 
3489  //read the input file
3490  ifstream ifile("farms_data.txt", ios::in); //change it later - so that the nme can be set in the config file
3491 
3492  //check if there is an input file
3493  if ( !ifile.is_open() ) {
3494  cout << "Cannot open input file " << "farms_data.txt" << endl;
3495  char ch;
3496  cin >> ch; //so that it doesn't close immedietly
3497  exit(1);
3498  }
3499 
3500  //get the number of farms
3501  ifile>>noFarms;
3502  //get rid off the parameters' names
3503  string rubbish=""; //put here the names of the parameters;
3504  for(int i=0; i<noParameters; i++){
3505  ifile>>rubbish;
3506  }
3507  //read the data and assign values to the farm's variables
3508  for(int f=0; f<noFarms; f++){
3509  int almass_no, realID, soilSubType;
3510  string farm_type, soil_type, farm_size;
3511  ifile >> almass_no >> farm_type >> soil_type >> farm_size >> realID >> soilSubType;
3512  TTypesOfOptFarms farmType = TranslateFarmCodes (farm_type);
3513  TTypesOfSoils soilType = TranslateSoilCodes (soil_type);
3514  TTypesOfFarmSize farmSize = TranslateFarmSizeCodes (farm_size);
3515 
3518  pm_data->m_farm_data.push_back(fd);
3519  fd->md_almass_no=almass_no;
3520  fd->md_farmType=farmType;
3521  fd->md_soilType=soilType;
3522  fd->md_farmSize=farmSize;
3523  fd->md_farmRealID=realID;
3524  fd->md_soilSubType=soilSubType;
3525  }
3526 
3527  ifile.close();
3528 }

References DataForOptimisation::m_farm_data, DataForOptimisation::FarmData::md_almass_no, DataForOptimisation::FarmData::md_farmRealID, DataForOptimisation::FarmData::md_farmSize, DataForOptimisation::FarmData::md_farmType, DataForOptimisation::FarmData::md_soilSubType, DataForOptimisation::FarmData::md_soilType, pm_data, TranslateFarmCodes(), TranslateFarmSizeCodes(), and TranslateSoilCodes().

Referenced by FarmManager().

◆ ReadFarmsData_perFarmType()

void FarmManager::ReadFarmsData_perFarmType ( )
protected

Reads the data on farms' parameters that vary with a farm type and saves them in a vector of a DataForOptimisation class.

Definition at line 4184 of file farm.cpp.

4184  {
4185 
4186  //read the input files
4187  ifstream ifile1("winterMax.txt", ios::in);
4188 
4189  //check if there are all input files
4190  if ( !ifile1.is_open() ) {
4191  cout << "Cannot open input file " << "winterMax.txt" << endl;
4192  char ch;
4193  cin >> ch; //so that it doesn't close immedietly
4194  exit(1);
4195  }
4196 
4197  //get rid off the parameter name;
4198  string type;
4199  ifile1>>type;
4200 
4201  //loop through the farm types!
4202  for(int f=0; f<toof_Foobar; f++){
4203  string farm_type;
4204  ifile1>>farm_type; //get rid off the farm type name
4205  int par_value;
4206  ifile1>>par_value;
4207  pm_data->Set_winterMax(par_value, f);
4208  }
4209  ifile1.close();
4210 }

References pm_data, DataForOptimisation::Set_winterMax(), and toof_Foobar.

Referenced by FarmManager().

◆ ReadInitialCropAreas()

void FarmManager::ReadInitialCropAreas ( )
protected

Reads the data on farms' initial crop distributions and saves them in a vector DataForOptimisation::m_cropAreas.

Definition at line 3571 of file farm.cpp.

3571  {
3572 
3573  int noFarms;
3574  //vector<TTypesOfCrops>crops_types; //vector of crops types (enums)
3575 
3576  //read the input file
3577  ifstream ifile("crop_areas.txt", ios::in);
3578  //check if there is an input file
3579  if ( !ifile.is_open() ) {
3580  cout << "Cannot open input file " << "crop_areas.txt" << endl;
3581  char ch;
3582  cin >> ch; //so that it doesn't close immedietly
3583  exit(1);
3584  }
3585 
3586  //get the number of farms /
3587  ifile>>noFarms;
3588 
3589  //put the names of the crop types to TWO vectors: one with strings, one with enums
3590  for(int c=0; c<toc_Foobar; c++){
3591  string type;
3592  ifile>>type;
3593  TTypesOfCrops type_enum = TranslateCropsCodes(type);
3594  pm_data->Set_cropTypes(type_enum);
3595  pm_data->Set_cropTypes_str(type);
3596  }
3597 
3598  //loop through the farms; create an instance of each crop type - also when the initial area is zero!
3599  for(int f=0; f<noFarms; f++){
3600  double almass_no; //in the first column of the input table
3601  ifile>>almass_no;
3602  pm_data->Set_cropArea(almass_no); //put it here so that you can search for the part of a vector - that contains numbers of a given farm
3603  for(int c=0; c<toc_Foobar; c++){
3604  double area;
3605  ifile >> area;
3606  pm_data->Set_cropArea(area);
3607  }
3608  }
3609  ifile.close();
3610 }

References pm_data, DataForOptimisation::Set_cropArea(), DataForOptimisation::Set_cropTypes(), DataForOptimisation::Set_cropTypes_str(), toc_Foobar, and TranslateCropsCodes().

Referenced by FarmManager().

◆ ReadInitialCropAreas_almass()

void FarmManager::ReadInitialCropAreas_almass ( )
protected

Reads the data on farms' initial crop distributions and saves them in a vector of a DataForOptimisation class. ALMaSS crop mode.

Definition at line 3612 of file farm.cpp.

3612  {
3613 
3614  int noFarms;
3615  int noCrops;
3616 
3617  //read the input file
3618  ifstream ifile("crop_areas.txt", ios::in);
3619  //check if there is an input file
3620  if ( !ifile.is_open() ) {
3621  cout << "Cannot open input file " << "crop_areas.txt" << endl;
3622  char ch;
3623  cin >> ch; //so that it doesn't close immedietly
3624  exit(1);
3625  }
3626 
3627  //get the number of crops
3628  ifile>>noCrops;
3629  //get the number of farms
3630  ifile>>noFarms;
3631  pm_data->Set_noCrops(noCrops);
3632 
3633  //put the names of the crop types to vector with enums and to the vector with strings - will be used for output
3634  for(int c=0; c<noCrops; c++){
3635  string type;
3636  ifile>>type;
3637  TTypesOfVegetation type_enum = TranslateCropCodes(type);
3638  pm_data->Set_cropTypes_almass(type_enum);
3640  }
3641 
3642  //loop through the farms; create an instance of each crop type - also when the initial area is zero!
3643  for(int f=0; f<noFarms; f++){
3644  double almass_no; //in the first column of the input table
3645  ifile>>almass_no;
3646  pm_data->Set_cropArea(almass_no); //put it here so that you can search for the part of a vector - that contains numbers of a given far
3647  for(int c=0; c<noCrops; c++){
3648  double area;
3649  ifile >> area;
3650  pm_data->Set_cropArea(area);
3651  }
3652  }
3653  ifile.close();
3654 }

References pm_data, DataForOptimisation::Set_cropArea(), DataForOptimisation::Set_cropTypes_almass(), DataForOptimisation::Set_cropTypes_almass_str(), DataForOptimisation::Set_noCrops(), and TranslateCropCodes().

Referenced by FarmManager().

◆ ReadLivestockData()

void FarmManager::ReadLivestockData ( )
protected

Reads the data on livestock parameters (do not vary with farm variables) and saves them in a vector DataForOptimisation::m_livestockParameters.

Definition at line 4212 of file farm.cpp.

4212  {
4213 
4214  //read the input file
4215  ifstream ifile("livestock_parameters.txt", ios::in);
4216  //check if there is an input file
4217  if ( !ifile.is_open() ) {
4218  cout << "Cannot open input file " << "livestock_parameters.txt" << endl;
4219  char ch;
4220  cin >> ch; //so that it doesn't close immedietly
4221  exit(1);
4222  }
4223 
4224  //get rid off the parameter names
4225  for(int p=0; p<tolp_Foobar; p++){
4226  string type;
4227  ifile>>type;
4228  }
4229 
4230  //loop through the livestock types - save values of the parameters in a vector of the DataForOptimisation class
4231  for(int l=0; l<toa_Foobar; l++){
4232  string livestock; //in the first column of the input table
4233  ifile>>livestock; //do nothing with it
4234  for(int p=0; p<tolp_Foobar; p++){
4235  double par_value;
4236  ifile>>par_value;
4237  pm_data->Set_livestockParameter(par_value, tolp_Foobar*l + p);
4238  }
4239  }
4240  ifile.close();
4241 }

References pm_data, DataForOptimisation::Set_livestockParameter(), toa_Foobar, and tolp_Foobar.

Referenced by FarmManager().

◆ ReadLivestockNumbers()

void FarmManager::ReadLivestockNumbers ( )
protected

Reads the data on livestock numbers and saves them in a vector DataForOptimisation::m_livestockNumbers.

Definition at line 3530 of file farm.cpp.

3530  {
3531 
3532  int noFarms;
3533  //vector<TTypesOfAnimals>livestock_types; //vector of livestock types (enums)
3534 
3535  //read the input file
3536  ifstream ifile("livestock_numbers.txt", ios::in);
3537  //check if there is an input file
3538  if ( !ifile.is_open() ) {
3539  cout << "Cannot open input file " << "livestock_numbers.txt" << endl;
3540  char ch;
3541  cin >> ch; //so that it doesn't close immedietly
3542  exit(1);
3543  }
3544 
3545  //get the number of farms //and of types of livestock
3546  ifile>>noFarms; //>>noLivestockTypes;
3547 
3548  //put the names of the livestock types to the this vector;
3549  for(int l=0; l<toa_Foobar; l++){
3550  string type;
3551  ifile>>type;
3552  //livestock_types.push_back(TranslateAnimalsCodes(type));
3554  }
3555 
3556  //loop through the farms; create an instance of each livestock type
3557  for(int f=0; f<noFarms; f++){
3558  int almass_no; //in the first column of the input table
3559  ifile>>almass_no;
3560  pm_data->Set_livestockNumber(almass_no); //put it here so that you can search for the part of a vector - that contains numbers of a given farm
3561  for(int l=0; l<toa_Foobar; l++){
3562  int number;
3563  ifile >> number;
3564  pm_data->Set_livestockNumber(number);
3565  }
3566  }
3567  ifile.close();
3568 
3569 }

References pm_data, DataForOptimisation::Set_livestockNumber(), DataForOptimisation::Set_livestockTypes(), toa_Foobar, and TranslateAnimalsCodes().

Referenced by FarmManager().

◆ ReadLookupTable()

void FarmManager::ReadLookupTable ( )
protected

Reads the lookup table with allowed/forbidden crop order from a text file and saves it into a vector m_crop_lookup_table.

Definition at line 4625 of file farm.cpp.

4625  {
4626 
4627  //read the input file
4628  ifstream ifile("crops_lookup.txt", ios::in);
4629  //check if there is an input file
4630  if ( !ifile.is_open() ) {
4631  cout << "Cannot open input file " << "crops_lookup.txt" << endl;
4632  char ch;
4633  cin >> ch; //so that it doesn't close immedietly
4634  exit(1);
4635  }
4636 
4637  //get rid of the crop tov names - first line of the input file
4638  for(int p=0; p<tov_Undefined+1; p++){
4639  string tov_type;
4640  ifile>>tov_type;
4641  }
4642 
4643  //loop through the crops - save values (-1, 0 or 1) in the vector<int>m_crop_lookup_table;
4644  for(int r=0; r<tov_Undefined+1; r++){ //rows
4645  string tov_type; //in the first column of the input table
4646  ifile>>tov_type; //do nothing with it
4647  for(int c=0; c<tov_Undefined+1; c++){ //you are at row r, go through all the columns c
4648  int value;
4649  ifile >> value;
4650  m_crop_lookup_table.push_back(value);
4651  }
4652  }
4653  ifile.close();
4654 
4655 }

References m_crop_lookup_table, and tov_Undefined.

Referenced by FarmManager().

◆ RemoveField()

void FarmManager::RemoveField ( int  a_OwnerIndex,
LE a_field 
)

Definition at line 2747 of file farm.cpp.

2748 {
2749  m_farms[ a_OwnerIndex ]->RemoveField( a_field );
2750 }

References m_farms.

◆ Save_diff_farm_types_areas()

void FarmManager::Save_diff_farm_types_areas ( )

Calculates and saves total areas of all optimising farms and specific farm types.

Definition at line 3404 of file farm.cpp.

3404  {
3405 
3406  //get farms areas and save them
3412  OptimisingFarm * opf;
3413  for(int j=0; j<(int)m_farms.size(); j++){
3414  if(m_farms[j]->GetType() == tof_OptimisingFarm){
3415  opf = dynamic_cast<OptimisingFarm*>(m_farms[j]);
3416  totalOptFarmsArea += opf->GetAreaDouble();
3417  if(opf->Get_farmType() == toof_Plant){
3419  }
3420  else if(opf->Get_farmType() == toof_Pig){
3422  }
3423  else if(opf->Get_farmType() == toof_Cattle){
3425  }
3426  else if(opf->Get_farmType() == toof_Other){
3428  }
3429  }
3430  }
3431 }

References OptimisingFarm::Get_farmType(), Farm::GetAreaDouble(), m_farms, tof_OptimisingFarm, toof_Cattle, toof_Other, toof_Pig, toof_Plant, totalOptFarmsArea, totalOptFarmsArea_cattle, totalOptFarmsArea_other, totalOptFarmsArea_pig, and totalOptFarmsArea_plant.

◆ Save_last_years_crops_for_farms()

void FarmManager::Save_last_years_crops_for_farms ( )

Calls OptimisingFarm::Save_last_years_crops for all optimising farms.

Definition at line 3456 of file farm.cpp.

3456  {
3457 
3458  for(int i=0; i<(int)m_farms.size(); i++){
3459  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
3460  OptimisingFarm * opf;
3461  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
3462  opf->Save_last_years_crops();
3463  }
3464  }
3465 }

References m_farms, OptimisingFarm::Save_last_years_crops(), and tof_OptimisingFarm.

◆ Set_crops_fertilizer()

void FarmManager::Set_crops_fertilizer ( int  i,
double  fert 
)
inline

Definition at line 1863 of file farm.h.

1863 {m_crops_fertilizer[i] += fert;};

References m_crops_fertilizer.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_crops_fertilizer_trade()

void FarmManager::Set_crops_fertilizer_trade ( int  i,
double  fert_trade 
)
inline

Definition at line 1864 of file farm.h.

1864 {m_crops_fertilizer_trade[i] += fert_trade;};

References m_crops_fertilizer_trade.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_crops_summary_BIs()

void FarmManager::Set_crops_summary_BIs ( int  i,
double  BI 
)
inline

Definition at line 1856 of file farm.h.

1856 {m_crops_summary_BIs[i].BI += BI;};

References m_crops_summary_BIs.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_crops_summary_BIs_fi()

void FarmManager::Set_crops_summary_BIs_fi ( int  i,
double  BIfi 
)
inline

Definition at line 1855 of file farm.h.

1855 {m_crops_summary_BIs[i].BIfi += BIfi;};

References m_crops_summary_BIs.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_crops_summary_BIs_herb()

void FarmManager::Set_crops_summary_BIs_herb ( int  i,
double  BIherb 
)
inline

Definition at line 1854 of file farm.h.

1854 {m_crops_summary_BIs[i].BIherb += BIherb;};

References m_crops_summary_BIs.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_cropTotals()

void FarmManager::Set_cropTotals ( int  i,
double  value 
)
inline

Definition at line 1839 of file farm.h.

1839 {m_cropTotals[i] = value;};

References m_cropTotals.

◆ Set_cropTotals_cattle_sum()

void FarmManager::Set_cropTotals_cattle_sum ( int  i,
double  crop_area 
)
inline

Definition at line 1860 of file farm.h.

1860 {m_cropTotals_cattle_sum[i] += crop_area;};

References m_cropTotals_cattle_sum.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_cropTotals_other_sum()

void FarmManager::Set_cropTotals_other_sum ( int  i,
double  crop_area 
)
inline

Definition at line 1861 of file farm.h.

1861 {m_cropTotals_other_sum[i] += crop_area;};

References m_cropTotals_other_sum.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_cropTotals_pig_sum()

void FarmManager::Set_cropTotals_pig_sum ( int  i,
double  crop_area 
)
inline

Definition at line 1859 of file farm.h.

1859 {m_cropTotals_pig_sum[i] += crop_area;};

References m_cropTotals_pig_sum.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_cropTotals_plant_sum()

void FarmManager::Set_cropTotals_plant_sum ( int  i,
double  crop_area 
)
inline

Definition at line 1858 of file farm.h.

1858 {m_cropTotals_plant_sum[i] += crop_area;};

References m_cropTotals_plant_sum.

Referenced by OptimisingFarm::ActualProfit().

◆ Set_cropTotals_sum()

void FarmManager::Set_cropTotals_sum ( int  i,
double  crop_area 
)
inline

Definition at line 1857 of file farm.h.

1857 {m_cropTotals_sum[i] += crop_area;};

References m_cropTotals_sum.

Referenced by OptimisingFarm::ActualProfit().

◆ SetDD()

void FarmManager::SetDD ( double  a_dd)
inline

Definition at line 1836 of file farm.h.

1836 {daydegrees = a_dd;};

References daydegrees.

◆ SetSpilledGrain()

void FarmManager::SetSpilledGrain ( bool  a_spilledgrain)
inline

Set m_SpilledGrain which is the flag for either 2013 (true) or 2014 (false) spilled grain distributions.

Definition at line 1828 of file farm.h.

1828  {
1829  m_SpilledGrain = a_spilledgrain;
1830  }

References m_SpilledGrain.

◆ Switch_rotation()

void FarmManager::Switch_rotation ( )

Switches OptimisingFarms Farm::m_rotation to the list of all possible rotational crops.

Definition at line 4942 of file farm.cpp.

4942  {
4943 
4944  //1. make a new rotation: include all rotational crops
4945  vector<TTypesOfVegetation> new_rotation;
4946  TTypesOfVegetation tov;
4947  for(int i=0; i<pm_data->Get_cropTypes_almass_size(); i++){
4948  tov = pm_data->Get_cropTypes_almass(i);
4951  new_rotation.push_back(tov);
4952  }
4953  }
4954 
4955  //2. assign it to each farm's m_rotation
4956  for(int i=0; i<(int)m_farms.size(); i++){
4957  OptimisingFarm * opf;
4958  if(m_farms[i]->GetType() == tof_OptimisingFarm){ //take only optimising farms
4959  opf = dynamic_cast<OptimisingFarm*>(m_farms[i]);
4960  opf->Assign_rotation(new_rotation);
4961  }
4962  }
4963 }

References Farm::Assign_rotation(), DataForOptimisation::Get_cropTypes_almass(), DataForOptimisation::Get_cropTypes_almass_size(), m_farms, pm_data, tof_OptimisingFarm, tov_OrchardCrop, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, and tov_YoungForest.

◆ TranslateAnimalsCodes()

TTypesOfAnimals FarmManager::TranslateAnimalsCodes ( string &  str)

Definition at line 4309 of file farm.cpp.

4309  {
4310  // This simply checks through the list of legal animal (livestock) types and returns
4311  // the correct animal type
4312  string str = astr;
4313  if ( str == "Horse") return toa_Horse;
4314  if ( str == "DCow") return toa_DCow;
4315  if ( str == "Suckler") return toa_Suckler;
4316  if ( str == "DCalf") return toa_DCalf;
4317  if ( str == "MCalf") return toa_MCalf;
4318  if ( str == "MCattle") return toa_MCattle;
4319  if ( str == "Sheep") return toa_Sheep;
4320  if ( str == "Goat") return toa_Goat;
4321  if ( str == "So") return toa_So;
4322  if ( str == "Finisher") return toa_Finisher;
4323  if ( str == "Piglet") return toa_Piglet;
4324  if ( str == "Deer") return toa_Deer;
4325  if ( str == "Mink") return toa_Mink;
4326  if ( str == "EHen") return toa_EHen;
4327  if ( str == "MHen") return toa_MHen;
4328  if ( str == "Turkey") return toa_Turkey;
4329  if ( str == "Goose") return toa_Goose;
4330  if ( str == "Duck") return toa_Duck;
4331  if ( str == "MDuck") return toa_MDuck;
4332  if ( str == "Ostrich") return toa_Ostrich;
4333  // No match so issue a warning and quit
4334  g_msg->Warn( WARN_FILE, "FarmManager::TranslateAnimalsCodes():"" Unknown Animal type Code ", str.c_str() );
4335  exit( 1 );
4336 }

References g_msg, toa_DCalf, toa_DCow, toa_Deer, toa_Duck, toa_EHen, toa_Finisher, toa_Goat, toa_Goose, toa_Horse, toa_MCalf, toa_MCattle, toa_MDuck, toa_MHen, toa_Mink, toa_Ostrich, toa_Piglet, toa_Sheep, toa_So, toa_Suckler, toa_Turkey, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by ReadLivestockNumbers().

◆ TranslateCropCodes()

TTypesOfVegetation FarmManager::TranslateCropCodes ( std::string &  str)
Todo:
Create a OSpringRape crop class and management
Todo:
Create a OSpringWheat crop class and management

Definition at line 1818 of file farm.cpp.

1818  { //changed to farm manager - was a Farm function, 19.03.13
1819  // This simply checks through the list of legal crop names and returns
1820  // the correct tov type
1821 
1822  string str = astr;
1823 
1824  // Unfortunately switch cannot use string so the long way:
1825  if (str == "SpringBarley") return tov_SpringBarley;
1826  if (str == "SpringBarleySpr") return tov_SpringBarleySpr;
1827  if (str == "SpringBarleyPTreatment") return tov_SpringBarleyPTreatment;
1828  if (str == "WinterBarley") return tov_WinterBarley;
1829  if (str == "SpringWheat") return tov_SpringWheat;
1830  if (str == "WinterWheat") return tov_WinterWheat;
1831  if (str == "WinterRye") return tov_WinterRye;
1832  if (str == "OrchardCrop") return tov_OrchardCrop;
1833  if (str == "Oats") return tov_Oats;
1834  if (str == "OOats") return tov_OOats;
1835  if (str == "Triticale") return tov_Triticale;
1836  if (str == "OTriticale") return tov_OTriticale;
1837  if (str == "Maize") return tov_Maize;
1838  if (str == "MaizeSilage") return tov_MaizeSilage;
1839  if (str == "SpringBarleySeed") return tov_SpringBarleySeed;
1840  if (str == "OSpringRape") return tov_SpringRape;
1841  if (str == "SpringRape") return tov_SpringRape;
1842  if (str == "WinterRape") return tov_WinterRape;
1843  if (str == "BroadBeans") return tov_BroadBeans;
1844  if (str == "FieldPeas") return tov_FieldPeas;
1845  if (str == "FieldPeasSilage") return tov_FieldPeasSilage;
1846  if (str == "Setaside") return tov_Setaside;
1847  if (str == "PermanentSetaside") return tov_PermanentSetaside;
1848  if (str == "SugarBeet") return tov_SugarBeet;
1849  if (str == "FodderBeet") return tov_FodderBeet;
1850  if (str == "OFodderBeet") return tov_OFodderBeet;
1851  if (str == "FodderGrass") return tov_FodderGrass;
1852  if (str == "CloverGrassGrazed1") return tov_CloverGrassGrazed1;
1853  if (str == "PotatoesIndustry") return tov_PotatoesIndustry;
1854  if (str == "Potatoes") return tov_Potatoes;
1855  if (str == "SeedGrass1") return tov_SeedGrass1;
1856  if (str == "OWinterBarley") return tov_OWinterBarley;
1857  if (str == "OWinterBarleyExt") return tov_OWinterBarleyExt;
1858  if (str == "SpringBarleySilage") return tov_SpringBarleySilage;
1859  if (str == "OWinterRye") return tov_OWinterRye;
1860  if (str == "OFieldPeasSilage") return tov_OFieldPeasSilage;
1861  if (str == "SpringBarleyGrass") return tov_SpringBarleyGrass;
1862  if (str == "SpringBarleyCloverGrass") return tov_SpringBarleyCloverGrass;
1863  if (str == "OBarleyPeaCloverGrass") return tov_OBarleyPeaCloverGrass;
1864  if (str == "OWinterRape") return tov_OWinterRape;
1865  if (str == "PermanentGrassGrazed") return tov_PermanentGrassGrazed;
1866  if (str == "PermanentGrassLowYield") return tov_PermanentGrassLowYield;
1867  if (str == "PermanentGrassTussocky") return tov_PermanentGrassTussocky;
1868  if (str == "CloverGrassGrazed2") return tov_CloverGrassGrazed2;
1869  if (str == "SeedGrass2") return tov_SeedGrass2;
1870  if (str == "OSpringWheat") return tov_OSpringBarley;
1871  if (str == "OSpringBarley") return tov_OSpringBarley;
1872  if (str == "OSpringBarleyExt") return tov_OSpringBarleyExt;
1873  if (str == "OWinterWheat") return tov_OWinterWheat;
1874  if (str == "OWinterWheatUndersown") return tov_OWinterWheatUndersown;
1875  if (str == "OWinterWheatUndersownExt") return tov_OWinterWheatUndersownExt;
1876  if (str == "OOats") return tov_OOats;
1877  if (str == "OFieldPeas") return tov_OFieldPeas;
1878  if (str == "OCloverGrassGrazed1") return tov_OCloverGrassGrazed1;
1879  if (str == "OGrazingPigs") return tov_OGrazingPigs;
1880  if (str == "OCarrots") return tov_OCarrots;
1881  if (str == "Carrots") return tov_Carrots;
1882  if (str == "OPotatoes") return tov_OPotatoes;
1883  if (str == "OSeedGrass1") return tov_OSeedGrass1;
1884  if (str == "OSpringBarleyGrass") return tov_OSpringBarleyGrass;
1885  if (str == "OSpringBarleyClover") return tov_OSpringBarleyClover;
1886  if (str == "OPermanentGrassGrazed") return tov_OPermanentGrassGrazed;
1887  if (str == "OCloverGrassSilage1") return tov_OCloverGrassSilage1;
1888  if (str == "OCloverGrassGrazed2") return tov_OCloverGrassGrazed2;
1889  if (str == "OSeedGrass2") return tov_OSeedGrass2;
1890  if (str == "WWheatPControl") return tov_WWheatPControl;
1891  if (str == "WWheatPToxicControl") return tov_WWheatPToxicControl;
1892  if (str == "WWheatPTreatment") return tov_WWheatPTreatment;
1893  if (str == "AgroChemIndustryCereal") return tov_AgroChemIndustryCereal;
1894  if (str == "WinterWheatShort") return tov_WinterWheatShort;
1895  if (str == "WinterWheatStrigling") return tov_WinterWheatStrigling;
1896  if (str == "WinterWheatStriglingCulm") return tov_WinterWheatStriglingCulm;
1897  if (str == "WinterWheatStriglingSgl") return tov_WinterWheatStriglingSingle;
1898  if (str == "SpringBarleyCloverGrassStrigling") return tov_SpringBarleyCloverGrassStrigling;
1899  if (str == "SpringBarleyStrigling") return tov_SpringBarleyStrigling;
1900  if (str == "SpringBarleyStriglingSingle") return tov_SpringBarleyStriglingSingle;
1901  if (str == "SpringBarleyStriglingCulm") return tov_SpringBarleyStriglingCulm;
1902  if (str == "MaizeStrigling") return tov_MaizeStrigling;
1903  if (str == "WinterRapeStrigling") return tov_WinterRapeStrigling;
1904  if (str == "WinterRyeStrigling") return tov_WinterRyeStrigling;
1905  if (str == "WinterBarleyStrigling") return tov_WinterBarleyStrigling;
1906  if (str == "FieldPeasStrigling") return tov_FieldPeasStrigling;
1907  if (str == "SpringBarleyPeaCloverGrassStrigling") return tov_SpringBarleyPeaCloverGrassStrigling;
1908  if (str == "YoungForest") return tov_YoungForest;
1909  if (str == "OMaizeSilage") return tov_OMaizeSilage;
1910  if (str == "OSpringBarleySilage") return tov_OSBarleySilage;
1911  if (str == "OSpringBarleyPigs") return tov_OSpringBarleyPigs;
1912  if (str == "NorwegianPotatoes") return tov_NorwegianPotatoes;
1913  if (str == "NorwegianOats") return tov_NorwegianOats;
1914  if (str == "NorwegianSpringBarley") return tov_NorwegianSpringBarley;
1915  if (str == "PlantNursery") return tov_PlantNursery;
1916  if (str == "PLWinterWheat") return tov_PLWinterWheat;
1917  if (str == "PLWinterRape") return tov_PLWinterRape;
1918  if (str == "PLWinterBarley") return tov_PLWinterBarley;
1919  if (str == "PLWinterTriticale") return tov_PLWinterTriticale;
1920  if (str == "PLWinterRye") return tov_PLWinterRye;
1921  if (str == "PLSpringWheat") return tov_PLSpringWheat;
1922  if (str == "PLSpringBarley") return tov_PLSpringBarley;
1923  if (str == "PLMaize") return tov_PLMaize;
1924  if (str == "PLMaizeSilage") return tov_PLMaizeSilage;
1925  if (str == "PLPotatoes") return tov_PLPotatoes;
1926  if (str == "PLBeet") return tov_PLBeet;
1927  if (str == "PLFodderLucerne1") return tov_PLFodderLucerne1;
1928  if (str == "PLFodderLucerne2") return tov_PLFodderLucerne2;
1929  if (str == "PLCarrots") return tov_PLCarrots;
1930  if (str == "PLSpringBarleySpr") return tov_PLSpringBarleySpr;
1931  if (str == "PLWinterWheatLate") return tov_PLWinterWheatLate;
1932  if (str == "PLBeetSpr") return tov_PLBeetSpr;
1933  if (str == "PLBeans") return tov_PLBeans;
1934 
1935  if (str == "NLBeet") return tov_NLBeet;
1936  if (str == "NLCarrots") return tov_NLCarrots;
1937  if (str == "NLMaize") return tov_NLMaize;
1938  if (str == "NLPotatoes") return tov_NLPotatoes;
1939  if (str == "NLSpringBarley") return tov_NLSpringBarley;
1940  if (str == "NLWinterWheat") return tov_NLWinterWheat;
1941  if (str == "NLCabbage") return tov_NLCabbage;
1942  if (str == "NLTulips") return tov_NLTulips;
1943  if (str == "NLGrassGrazed1") return tov_NLGrassGrazed1;
1944  if (str == "NLGrassGrazed1Spring") return tov_NLGrassGrazed1Spring;
1945  if (str == "NLGrassGrazed2") return tov_NLGrassGrazed2;
1946  if (str == "NLGrassGrazedLast") return tov_NLGrassGrazedLast;
1947  if (str == "NLPermanentGrassGrazed") return tov_NLPermanentGrassGrazed;
1948  if (str == "NLBeetSpring") return tov_NLBeetSpring;
1949  if (str == "NLCarrotsSpring") return tov_NLCarrotsSpring;
1950  if (str == "NLMaizeSpring") return tov_NLMaizeSpring;
1951  if (str == "NLPotatoesSpring") return tov_NLPotatoesSpring;
1952  if (str == "NLSpringBarleySpring") return tov_NLSpringBarleySpring;
1953  if (str == "NLCabbageSpring") return tov_NLCabbageSpring;
1954  if (str == "NLCatchPeaCrop") return tov_NLCatchPeaCrop;
1955 
1956  if (str == "DummyCropPestTesting") return tov_DummyCropPestTesting;
1957 
1958  // No match so issue a warning and quit
1959  g_msg->Warn( WARN_FILE, "FarmManager::TranslateCropCodes():"" Unknown Crop Code ", str.c_str() );
1960  exit( 1 );
1961 }

References g_msg, tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_DummyCropPestTesting, tov_FieldPeas, tov_FieldPeasSilage, tov_FieldPeasStrigling, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, tov_NLBeet, tov_NLBeetSpring, tov_NLCabbage, tov_NLCabbageSpring, tov_NLCarrots, tov_NLCarrotsSpring, tov_NLCatchPeaCrop, tov_NLGrassGrazed1, tov_NLGrassGrazed1Spring, tov_NLGrassGrazed2, tov_NLGrassGrazedLast, tov_NLMaize, tov_NLMaizeSpring, tov_NLPermanentGrassGrazed, tov_NLPotatoes, tov_NLPotatoesSpring, tov_NLSpringBarley, tov_NLSpringBarleySpring, tov_NLTulips, tov_NLWinterWheat, tov_NorwegianOats, tov_NorwegianPotatoes, tov_NorwegianSpringBarley, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OCarrots, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OCloverGrassSilage1, tov_OFieldPeas, tov_OFieldPeasSilage, tov_OFodderBeet, tov_OGrazingPigs, tov_OMaizeSilage, tov_OOats, tov_OPermanentGrassGrazed, tov_OPotatoes, tov_OrchardCrop, tov_OSBarleySilage, tov_OSeedGrass1, tov_OSeedGrass2, tov_OSpringBarley, tov_OSpringBarleyClover, tov_OSpringBarleyExt, tov_OSpringBarleyGrass, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterBarleyExt, tov_OWinterRape, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_OWinterWheatUndersownExt, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_PlantNursery, tov_PLBeans, tov_PLBeet, tov_PLBeetSpr, tov_PLCarrots, tov_PLFodderLucerne1, tov_PLFodderLucerne2, tov_PLMaize, tov_PLMaizeSilage, tov_PLPotatoes, tov_PLSpringBarley, tov_PLSpringBarleySpr, tov_PLSpringWheat, tov_PLWinterBarley, tov_PLWinterRape, tov_PLWinterRye, tov_PLWinterTriticale, tov_PLWinterWheat, tov_PLWinterWheatLate, tov_Potatoes, tov_PotatoesIndustry, tov_SeedGrass1, tov_SeedGrass2, tov_Setaside, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyCloverGrassStrigling, tov_SpringBarleyGrass, tov_SpringBarleyPeaCloverGrassStrigling, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySilage, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringRape, tov_SpringWheat, tov_SugarBeet, tov_Triticale, tov_WinterBarley, tov_WinterBarleyStrigling, tov_WinterRape, tov_WinterRapeStrigling, tov_WinterRye, tov_WinterRyeStrigling, tov_WinterWheat, tov_WinterWheatShort, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, tov_WWheatPTreatment, tov_YoungForest, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by OptimisingFarm::findCropByName_almass(), ReadInitialCropAreas_almass(), Farm::ReadRotation(), and UserDefinedFarm::UserDefinedFarm().

◆ TranslateCropsCodes()

TTypesOfCrops FarmManager::TranslateCropsCodes ( string &  str)

Definition at line 4338 of file farm.cpp.

4338  {
4339 // This simply checks through the list of legal crops types and returns
4340 // the correct crop type
4341  string str = astr;
4342  if ( str == "SBarley") return toc_SBarley;
4343  if ( str == "Oats") return toc_Oats;
4344  if ( str == "OSCrops") return toc_OSCrops;
4345  if ( str == "WBarley") return toc_WBarley;
4346  if ( str == "WWheat") return toc_WWheat;
4347  if ( str == "WRye") return toc_WRye;
4348  if ( str == "Triticale") return toc_Triticale;
4349  if ( str == "SRape") return toc_SRape;
4350  if ( str == "WRape") return toc_WRape;
4351  if ( str == "OOilseed") return toc_OOilseed;
4352  if ( str == "Peas") return toc_Peas;
4353  if ( str == "OLSeed") return toc_OLSeed;
4354  if ( str == "GrassSeed") return toc_GrassSeed;
4355  if ( str == "Potato") return toc_Potato;
4356  if ( str == "PotatoFood") return toc_PotatoFood;
4357  if ( str == "SugarBeet") return toc_SugarBeet;
4358  if ( str == "GrassClover") return toc_GrassClover;
4359  if ( str == "OLSeedCut") return toc_OLSeedCut;
4360  if ( str == "SCerealSil") return toc_SCerealSil;
4361  if ( str == "PeasSil") return toc_PeasSil;
4362  if ( str == "MaizeSil") return toc_MaizeSil;
4363  if ( str == "WCerealSil") return toc_WCerealSil;
4364  if ( str == "SCerealG") return toc_SCerealG;
4365  if ( str == "PerGrassLow") return toc_PerGrassLow;
4366  if ( str == "PerGrassNorm") return toc_PerGrassNorm;
4367  if ( str == "GrassEnv1") return toc_GrassEnv1;
4368  if ( str == "GrassEnv2") return toc_GrassEnv2;
4369  if ( str == "GrassRot") return toc_GrassRot;
4370  if ( str == "Setaside") return toc_Setaside;
4371  if ( str == "Uncult") return toc_Uncult;
4372  if ( str == "OUncult") return toc_OUncult;
4373  if ( str == "OFodderBeet") return toc_OFodderBeet;
4374  if ( str == "CloverGrz") return toc_CloverGrz;
4375  if ( str == "Veg") return toc_Veg;
4376  if ( str == "Fruit") return toc_Fruit;
4377  if ( str == "FruitTree") return toc_FruitTree;
4378  if ( str == "OSpecCrops") return toc_OSpecCrops;
4379  if ( str == "ChrisTree") return toc_ChrisTree;
4380  if ( str == "EnergyFor") return toc_EnergyFor;
4381  if ( str == "Other") return toc_Other;
4382  // No match so issue a warning and quit
4383  g_msg->Warn( WARN_FILE, "FarmManager::TranslateCropCodes():"" Unknown Crop type Code ", str.c_str() );
4384  exit( 1 );
4385 }

References g_msg, toc_ChrisTree, toc_CloverGrz, toc_EnergyFor, toc_Fruit, toc_FruitTree, toc_GrassClover, toc_GrassEnv1, toc_GrassEnv2, toc_GrassRot, toc_GrassSeed, toc_MaizeSil, toc_Oats, toc_OFodderBeet, toc_OLSeed, toc_OLSeedCut, toc_OOilseed, toc_OSCrops, toc_OSpecCrops, toc_Other, toc_OUncult, toc_Peas, toc_PeasSil, toc_PerGrassLow, toc_PerGrassNorm, toc_Potato, toc_PotatoFood, toc_SBarley, toc_SCerealG, toc_SCerealSil, toc_Setaside, toc_SRape, toc_SugarBeet, toc_Triticale, toc_Uncult, toc_Veg, toc_WBarley, toc_WCerealSil, toc_WRape, toc_WRye, toc_WWheat, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by OptimisingFarm::findCropByName(), and ReadInitialCropAreas().

◆ TranslateCropVariablesCodes()

TTypesOfCropVariables FarmManager::TranslateCropVariablesCodes ( string &  str)

Definition at line 4426 of file farm.cpp.

4426  {
4427  // This simply checks through the list of legal crop variables and returns the correct enum
4428  string str = astr;
4429  if ( str == "m_areaPercent" ) return tocv_AreaPercent;
4430  if ( str == "m_area_ha" ) return tocv_AreaHa;
4431  if ( str == "m_n" ) return tocv_N;
4432  if ( str == "m_nt" ) return tocv_Nt;
4433  if ( str == "m_BIHerb" ) return tocv_BIHerb;
4434  if ( str == "m_BIFi" ) return tocv_BIFi;
4435  if ( str == "m_BI" ) return tocv_BI;
4436  if ( str == "m_grooming" ) return tocv_Grooming;
4437  if ( str == "m_hoeing" ) return tocv_Hoeing;
4438  if ( str == "m_weeding" ) return tocv_Weeding;
4439  if ( str == "m_totalLoss" ) return tocv_TotalLoss;
4440  if ( str == "m_resp" ) return tocv_Response;
4441  if ( str == "m_income" ) return tocv_Income;
4442  if ( str == "m_costs" ) return tocv_Costs;
4443  if ( str == "m_GM" ) return tocv_GM;
4444  if ( str == "m_savings" ) return tocv_Savings;
4445 
4446  // No match so issue a warning and quit
4447  g_msg->Warn( WARN_FILE, "FarmManager::TTypesOfCropVariables():"" Unknown crop variable Code ", str.c_str() );
4448  exit( 1 );
4449 }

References g_msg, tocv_AreaHa, tocv_AreaPercent, tocv_BI, tocv_BIFi, tocv_BIHerb, tocv_Costs, tocv_GM, tocv_Grooming, tocv_Hoeing, tocv_Income, tocv_N, tocv_Nt, tocv_Response, tocv_Savings, tocv_TotalLoss, tocv_Weeding, MapErrorMsg::Warn(), and WARN_FILE.

◆ TranslateFarmCodes()

TTypesOfOptFarms FarmManager::TranslateFarmCodes ( string &  str)

Definition at line 4273 of file farm.cpp.

4273  {
4274  // This simply checks through the list of legal farm types and returns
4275  // the correct farm type
4276  string str = astr;
4277  if ( str == "Other" ) return toof_Other;
4278  if ( str == "Cattle" ) return toof_Cattle;
4279  if ( str == "Plant" ) return toof_Plant;
4280  if ( str == "Pig" ) return toof_Pig;
4281  // No match so issue a warning and quit
4282  g_msg->Warn( WARN_FILE, "FarmManager::TranslateFarmCodes():"" Unknown Farm type Code ", str.c_str() );
4283  exit( 1 );
4284 }

References g_msg, toof_Cattle, toof_Other, toof_Pig, toof_Plant, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by ReadFarmsData().

◆ TranslateFarmSizeCodes()

TTypesOfFarmSize FarmManager::TranslateFarmSizeCodes ( string &  str)

Definition at line 4298 of file farm.cpp.

4298  {
4299  // This simply checks through the list of legal farm sizes and returns
4300  // the correct farm size
4301  string str = astr;
4302  if ( str == "business" ) return tofs_Business;
4303  if ( str == "private" ) return tofs_Private;
4304  // No match so issue a warning and quit
4305  g_msg->Warn( WARN_FILE, "FarmManager::TranslateFarmSizeCodes():"" Unknown Farm Size Code ", str.c_str() );
4306  exit( 1 );
4307 }

References g_msg, tofs_Business, tofs_Private, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by ReadFarmsData().

◆ TranslateLivestockParametersCodes()

TTypesOfLivestockParameters FarmManager::TranslateLivestockParametersCodes ( string &  str)

Definition at line 4414 of file farm.cpp.

4414  {
4415  // This simply checks through the list of legal livestock parameters and returns the correct enum
4416  string str = astr;
4417  if ( str == "AUKey" ) return tolp_AUKey;
4418  if ( str == "Nusable" ) return tolp_Nusable;
4419  if ( str == "FUuKey" ) return tolp_FUuKey;
4420 
4421  // No match so issue a warning and quit
4422  g_msg->Warn( WARN_FILE, "FarmManager::TranslateLivestockParametersCodes():"" Unknown Livestock Parameter Code ", str.c_str() );
4423  exit( 1 );
4424 }

References g_msg, tolp_AUKey, tolp_FUuKey, tolp_Nusable, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by OptimisingFarm::findFodderDemand(), and OptimisingFarm::findTotalNanim().

◆ TranslateParametersCodes()

TTypesOfParameters FarmManager::TranslateParametersCodes ( string &  str)

Definition at line 4387 of file farm.cpp.

4387  {
4388  // This simply checks through the list of legal crop parameters (those not varying with farm type etc.)
4389  //and returns the correct enum
4390  string str = astr;
4391  if ( str == "Subsidy" ) return top_Subsidy;
4392  if ( str == "PriceLM" ) return top_PriceLM;
4393  if ( str == "PriceHerb" ) return top_PriceHerb;
4394  if ( str == "PriceFi" ) return top_PriceFi;
4395  if ( str == "PriceG" ) return top_PriceG;
4396  if ( str == "PriceH" ) return top_PriceH;
4397  if ( str == "PriceW" ) return top_PriceW;
4398  if ( str == "AlfaHerb" ) return top_AlfaHerb;
4399  if ( str == "BetaHerb" ) return top_BetaHerb;
4400  if ( str == "AlfaFi" ) return top_AlfaFi;
4401  if ( str == "BetaFi" ) return top_BetaFi;
4402  if ( str == "AlfaG" ) return top_AlfaG;
4403  if ( str == "BetaG" ) return top_BetaG;
4404  if ( str == "AlfaH" ) return top_AlfaH;
4405  if ( str == "BetaH" ) return top_BetaH;
4406  if ( str == "AlfaW" ) return top_AlfaW;
4407  if ( str == "BetaW" ) return top_BetaW;
4408 
4409  // No match so issue a warning and quit
4410  g_msg->Warn( WARN_FILE, "FarmManager::TranslateParametersCodes():"" Unknown Parameter Code ", str.c_str() );
4411  exit( 1 );
4412 }

References g_msg, top_AlfaFi, top_AlfaG, top_AlfaH, top_AlfaHerb, top_AlfaW, top_BetaFi, top_BetaG, top_BetaH, top_BetaHerb, top_BetaW, top_PriceFi, top_PriceG, top_PriceH, top_PriceHerb, top_PriceLM, top_PriceW, top_Subsidy, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by OptimisingFarm::crop_parameter().

◆ TranslateSoilCodes()

TTypesOfSoils FarmManager::TranslateSoilCodes ( string &  str)

Definition at line 4286 of file farm.cpp.

4286  {
4287  // This simply checks through the list of legal soil types and returns
4288  // the correct soil type
4289  string str = astr;
4290  if ( str == "Other" ) return tos_Other;
4291  if ( str == "Sand" ) return tos_Sand;
4292  if ( str == "Clay" ) return tos_Clay;
4293  // No match so issue a warning and quit
4294  g_msg->Warn( WARN_FILE, "FarmManager::TranslateSoilCodes():"" Unknown Soil type Code ", str.c_str() );
4295  exit( 1 );
4296 }

References g_msg, tos_Clay, tos_Other, tos_Sand, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by ReadFarmsData().

Member Data Documentation

◆ daydegrees

double FarmManager::daydegrees
protected

Daydegress for period March 1st - November 1st. Used to determine yield of crops that are not harvested (and thus do not have values of biomass at harvest).

Definition at line 1910 of file farm.h.

Referenced by GetDD(), and SetDD().

◆ m_crop_areas_stages

vector<double> FarmManager::m_crop_areas_stages
protected

Stores information on crop areas calculated in different stages of model development: for comparison in sensitivity analysis.

Definition at line 1957 of file farm.h.

Referenced by FarmManager(), and PrintFinalResults().

◆ m_crop_lookup_table

vector<int> FarmManager::m_crop_lookup_table
protected

Specifies which crop order is allowed in a rotation (i.e. if a given crop can follow another crop).

Definition at line 1939 of file farm.h.

Referenced by Get_lookup_table(), and ReadLookupTable().

◆ m_crops_fertilizer

vector<double> FarmManager::m_crops_fertilizer
protected

Stores information on aggregate (all farms) fertilizer usage for each crop.

Definition at line 1953 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_crops_fertilizer().

◆ m_crops_fertilizer_trade

vector<double> FarmManager::m_crops_fertilizer_trade
protected

Stores information on aggregate (all farms) fertilizer trade (Nt) usage for each crop.

Definition at line 1955 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_crops_fertilizer_trade().

◆ m_crops_summary_BIs

vector<PesticideData> FarmManager::m_crops_summary_BIs
protected

Stores information on aggregate (all farms)pesticide usage for each crop.

Definition at line 1951 of file farm.h.

Referenced by FarmManager(), Get_crops_summary_BIs_tov(), PrintFinalResults(), Set_crops_summary_BIs(), Set_crops_summary_BIs_fi(), and Set_crops_summary_BIs_herb().

◆ m_cropTotals

vector<double> FarmManager::m_cropTotals
protected

Stores crops areas at the landscape level per year.

Definition at line 1937 of file farm.h.

Referenced by Add_to_cropTotals(), CropDistribution(), Get_cropTotals(), Get_cropTotals_size(), OptimisationOutput(), and Set_cropTotals().

◆ m_cropTotals_cattle_sum

vector<double> FarmManager::m_cropTotals_cattle_sum
protected

Stores the sums of crops areas on cattle farms within one simulation at the landscape level.

Definition at line 1947 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_cropTotals_cattle_sum().

◆ m_cropTotals_other_sum

vector<double> FarmManager::m_cropTotals_other_sum
protected

Stores the sums of crops areas on other farms within one simulation at the landscape level.

Definition at line 1949 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_cropTotals_other_sum().

◆ m_cropTotals_pig_sum

vector<double> FarmManager::m_cropTotals_pig_sum
protected

Stores the sums of crops areas on pig farms within one simulation at the landscape level.

Definition at line 1945 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_cropTotals_pig_sum().

◆ m_cropTotals_plant_sum

vector<double> FarmManager::m_cropTotals_plant_sum
protected

Stores the sums of crops areas on plant farms within one simulation at the landscape level.

Definition at line 1943 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_cropTotals_plant_sum().

◆ m_cropTotals_sum

vector<double> FarmManager::m_cropTotals_sum
protected

Stores the sums of crops areas within one simulation at the landscape level.

Definition at line 1941 of file farm.h.

Referenced by FarmManager(), PrintFinalResults(), and Set_cropTotals_sum().

◆ m_farmmapping_lookup

int* FarmManager::m_farmmapping_lookup
protected

Used for a dynamic array of lookups converting farm references to internal renumbering.

Definition at line 1915 of file farm.h.

Referenced by CreateFarms(), DumpFarmrefs(), GetFarmNoLookup(), GetFarmTypeLookup(), and GetRenumberedFarmRef().

◆ m_farms

◆ m_population_manager

Population_Manager* FarmManager::m_population_manager
protected

Definition at line 1907 of file farm.h.

◆ m_renumbered

bool FarmManager::m_renumbered
protected

A flag to show whether renumbering was already done.

Definition at line 1917 of file farm.h.

Referenced by CreateFarms(), and GetIsRenumbered().

◆ m_SpilledGrain

bool FarmManager::m_SpilledGrain
protected

Is it 2013 (true) or 2014 (false) as far as grain goes.

Definition at line 1912 of file farm.h.

Referenced by GetSpilledGrain(), and SetSpilledGrain().

◆ pm_data

DataForOptimisation* FarmManager::pm_data

Pointer to the DataForOptimisation.

Definition at line 1876 of file farm.h.

Referenced by OptimisingFarm::ActualProfit(), OptimisingPigFarm::check_WRape_WBarley(), OptimisingCattleFarm::checkCattleRotation(), OptimisingCattleFarm::checkCattleRotation_almass(), AnimalFarm::checkWinterCrops(), NonAnimalFarm::checkWinterCrops(), AnimalFarm::checkWinterRotation1(), AnimalFarm::correctFodderDemand(), CreateFarms(), AnimalFarm::createFodderCrops(), OptimisingFarm::createVariableCrops(), OptimisingFarm::crop_parameter(), CropDistribution(), AnimalFarm::decreaseCrops(), OptimisingFarm::determineAreas(), AnimalFarm::determineFodderAreas(), AnimalFarm::determineMinFodder(), FarmManager(), OptimisingFarm::findFertilizer(), OptimisingFarm::findFodderDemand(), OptimisingFarm::findGrossMargin(), OptimisingFarm::findResponse(), OptimisingFarm::findTotalNanim(), AnimalFarm::increaseCrops(), OptimisingFarm::Initialize(), OptimisationOutput(), OptimisingFarm::optimizeCrops(), PrintFinalResults(), PrintOutput(), ReadCropsData(), ReadCropsData_almass(), ReadCropsData_perFarm_and_Soil(), ReadCropsData_perFarm_and_Soil_almass(), ReadCropsData_perFarm_and_Soil_and_Size(), ReadCropsData_perFarm_and_Soil_and_Size_almass(), ReadCropsData_perFarmType(), ReadCropsData_perFarmType_almass(), ReadCropsData_perSoilType(), ReadCropsData_perSoilType_almass(), ReadEnergyMaizePrice(), ReadFarmsData(), ReadFarmsData_perFarmType(), ReadInitialCropAreas(), ReadInitialCropAreas_almass(), ReadLivestockData(), ReadLivestockNumbers(), OptimisingCattleFarm::setCattleCropsAtMin(), Switch_rotation(), and ~FarmManager().

◆ pm_output_file

ofstream* FarmManager::pm_output_file

Definition at line 1877 of file farm.h.

Referenced by Create_Output_file_for_farms(), and InitFarms().

◆ totalOptFarmsArea

double FarmManager::totalOptFarmsArea
protected

Definition at line 1930 of file farm.h.

Referenced by PrintFinalResults(), and Save_diff_farm_types_areas().

◆ totalOptFarmsArea_cattle

double FarmManager::totalOptFarmsArea_cattle
protected

Definition at line 1933 of file farm.h.

Referenced by PrintFinalResults(), and Save_diff_farm_types_areas().

◆ totalOptFarmsArea_other

double FarmManager::totalOptFarmsArea_other
protected

Definition at line 1934 of file farm.h.

Referenced by PrintFinalResults(), and Save_diff_farm_types_areas().

◆ totalOptFarmsArea_pig

double FarmManager::totalOptFarmsArea_pig
protected

Definition at line 1932 of file farm.h.

Referenced by PrintFinalResults(), and Save_diff_farm_types_areas().

◆ totalOptFarmsArea_plant

double FarmManager::totalOptFarmsArea_plant
protected

Definition at line 1931 of file farm.h.

Referenced by PrintFinalResults(), and Save_diff_farm_types_areas().


The documentation for this class was generated from the following files:
tov_AgroChemIndustryCereal
Definition: tov_declaration.h:55
tocv_BIHerb
Definition: farm.h:404
cfg_Yield_max_proportion
CfgFloat cfg_Yield_max_proportion("YIELD_MAX_PROPORTION", CFG_CUSTOM, 0)
A parameter setting the proportion of farmers of a type yield maximiser.
FarmManager::InIllegalList
bool InIllegalList(int a_farm_ref, vector< int > *a_farmlist)
Checks a list to see if a farm matches the illegal list of references.
Definition: farm.cpp:3088
tov_OSpringBarleyClover
Definition: tov_declaration.h:46
FarmManager::DistributeFarmerTypes
void DistributeFarmerTypes()
Randomly assigns farmer types to farms (OptimisingFarm) in proportions specified in an input file.
Definition: farm.cpp:4965
tov_SpringBarleyStrigling
Definition: tov_declaration.h:58
tov_PLWinterWheatLate
Definition: tov_declaration.h:85
FarmManager::ReadLivestockData
void ReadLivestockData()
Reads the data on livestock parameters (do not vary with farm variables) and saves them in a vector D...
Definition: farm.cpp:4212
tov_PLSpringWheat
Definition: tov_declaration.h:75
OptimisingFarm::Get_farmType
TTypesOfOptFarms Get_farmType(void)
Definition: farm.h:2034
tov_NLSpringBarley
Definition: tov_declaration.h:93
toof_Pig
Definition: farm.h:282
FarmManager::ReadInitialCropAreas
void ReadInitialCropAreas()
Reads the data on farms' initial crop distributions and saves them in a vector DataForOptimisation::m...
Definition: farm.cpp:3571
DataForOptimisation::Set_cropArea
void Set_cropArea(double a_area)
Definition: farm.h:604
tov_NLMaizeSpring
Definition: tov_declaration.h:102
tov_Oats
Definition: tov_declaration.h:40
tov_OWinterBarley
Definition: tov_declaration.h:47
OrganicPig
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1148
tofg_yield
Definition: farm.h:437
toc_Oats
Definition: farm.h:325
LE::SetOwner
void SetOwner(Farm *a_owner, int a_owner_num, int a_owner_index)
Definition: elements.h:219
DataForOptimisation::Set_noCrops
void Set_noCrops(int no)
Definition: farm.h:668
OptimisingFarm::GetFarmCentroidX
int GetFarmCentroidX()
Definition: farm.h:2055
toc_PeasSil
Definition: farm.h:343
Farm::Centroids
void Centroids()
Finds farm's centroids - x and y.
Definition: farm.cpp:5334
tov_NLPotatoes
Definition: tov_declaration.h:92
CfgStr::value
const char * value(void)
Definition: configurator.h:152
UserDefinedFarm11
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1368
FarmManager::ReadCropsData_perSoilType_almass
void ReadCropsData_perSoilType_almass()
Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2,...
Definition: farm.cpp:3790
DataForOptimisation::FarmData::md_farmSize
TTypesOfFarmSize md_farmSize
Definition: farm.h:680
top_AlfaG
Definition: farm.h:383
cfg_Neighbor_dist
CfgFloat cfg_Neighbor_dist("NEIGHBOR_DIST", CFG_CUSTOM, 1.5)
A parameter setting the maximum distance from a farm to another farm that can be considred a neighbou...
CropOptimised::m_BI
double m_BI
Summary value of BI for herbicides and fung- and insecticides [BI/ha].
Definition: farm.h:1671
UserDefinedFarm13
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1386
top_Foobar
Definition: farm.h:389
tolp_Nusable
Definition: farm.h:394
toc_Other
Definition: farm.h:366
tov_OPermanentGrassGrazed
Definition: tov_declaration.h:44
DataForOptimisation
Class for storing data for optimisation.
Definition: farm.h:589
top_BetaHerb
Definition: farm.h:380
UserDefinedFarm25
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1501
tocv_Hoeing
Definition: farm.h:408
FarmManager::totalOptFarmsArea_cattle
double totalOptFarmsArea_cattle
Definition: farm.h:1933
top_AlfaFi
Definition: farm.h:381
CropOptimised::m_weeding
double m_weeding
Value of mechanical weed control for a crop - manual weeding [DKK/ha].
Definition: farm.h:1677
toc_OOilseed
Definition: farm.h:333
tov_PLSpringBarleySpr
Definition: tov_declaration.h:84
DataForOptimisation::Set_fixed
void Set_fixed(string a_value, int i)
Definition: farm.h:634
DataForOptimisation::Set_cropTypes_almass_str
void Set_cropTypes_almass_str(string crop_type)
Definition: farm.h:665
UserDefinedFarm3
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1296
FarmManager::totalOptFarmsArea_other
double totalOptFarmsArea_other
Definition: farm.h:1934
tov_OOats
Definition: tov_declaration.h:44
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: calendar.h:68
toa_Duck
Definition: farm.h:317
OptimisingFarm::GetFarmCentroidY
int GetFarmCentroidY()
Definition: farm.h:2056
FarmManager::CreateFarms
void CreateFarms(const char *a_farmfile)
Definition: farm.cpp:2772
OptimisingPigFarm
Subclass of the AnimalFarm.
Definition: farm.h:2433
TTypesOfSoils
TTypesOfSoils
Definition: farm.h:286
tov_PLMaizeSilage
Definition: tov_declaration.h:78
tov_OTriticale
Definition: tov_declaration.h:47
tos_Other
Definition: farm.h:288
FarmManager::ReadCropsData_perFarm_and_Soil_and_Size_almass
void ReadCropsData_perFarm_and_Soil_and_Size_almass()
Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax,...
Definition: farm.cpp:4117
tocv_Income
Definition: farm.h:412
tov_MaizeStrigling
Definition: tov_declaration.h:58
tof_OptimisingFarm
Definition: farm.h:273
DataForOptimisation::Set_cropTypes_str
void Set_cropTypes_str(string crop_type)
Definition: farm.h:597
DataForOptimisation::Get_noCrops
int Get_noCrops()
Definition: farm.h:669
DataForOptimisation::FarmData::md_almass_no
int md_almass_no
Definition: farm.h:677
toc_SugarBeet
Definition: farm.h:339
toc_Veg
Definition: farm.h:358
FarmManager::m_cropTotals_pig_sum
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:1945
tov_OWinterWheatUndersown
Definition: tov_declaration.h:49
UserDefinedFarm30
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1551
FarmManager::GetFarmNoLookup
int GetFarmNoLookup(int a_ref)
Get a farm reference from the lookup table.
Definition: farm.h:1882
tov_Undefined
Definition: tov_declaration.h:114
tocv_Weeding
Definition: farm.h:409
toc_GrassEnv1
Definition: farm.h:349
FarmManager::ReadCropsData_perFarmType
void ReadCropsData_perFarmType()
Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them ...
Definition: farm.cpp:3881
toc_PotatoFood
Definition: farm.h:338
tov_FieldPeasStrigling
Definition: tov_declaration.h:56
tocv_Response
Definition: farm.h:411
toc_PerGrassLow
Definition: farm.h:347
tov_WinterBarleyStrigling
Definition: tov_declaration.h:59
tov_NLBeetSpring
Definition: tov_declaration.h:100
cfg_ClosestFarmProbParam1
CfgFloat cfg_ClosestFarmProbParam1("CLOSESTFARMPROBPARAMONE", CFG_CUSTOM, 0.005)
A fitting parameter for the probability of hunter acceptance of a farm wiht distance from home - slop...
FarmManager::CropDistribution
void CropDistribution()
Calculates total crop areas (at the landscape level). Includes results of the initial farm otpimisati...
Definition: farm.cpp:4588
toc_GrassSeed
Definition: farm.h:336
tos_Clay
Definition: farm.h:289
CropOptimised::m_costs_ha
double m_costs_ha
Costs of growing 1 ha of a crop. Include costs of labour and machine (constant), pesticides (herbicid...
Definition: farm.h:1685
FarmManager::ReadCropsData_perFarmType_almass
void ReadCropsData_perFarmType_almass()
Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them ...
Definition: farm.cpp:3937
UserDefinedFarm17
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1422
tov_PLFodderLucerne1
Definition: tov_declaration.h:81
FarmManager::AddToIllegalList
void AddToIllegalList(int a_farm_ref, vector< int > *a_farmlist)
Add to a list if a farm is not already among the illegal list of references.
Definition: farm.cpp:3099
tov_WinterWheat
Definition: tov_declaration.h:55
DataForOptimisation::Set_cropParameter
void Set_cropParameter(double a_value, int i)
Definition: farm.h:621
toc_CloverGrz
Definition: farm.h:357
DataForOptimisation::Get_farmType
TTypesOfOptFarms Get_farmType(int a_almass_no)
Used by FarmManager::CreateFarms. Finds a matching almass number and returns farm's type.
Definition: farm.cpp:5086
FarmManager::ReadFarmsData
void ReadFarmsData()
Reads farm level parameters and saves them in a vector DataForOptimisation::m_farm_data.
Definition: farm.cpp:3484
toa_MHen
Definition: farm.h:314
DataForOptimisation::Set_livestockTypes
void Set_livestockTypes(TTypesOfAnimals livestock_type)
Definition: farm.h:595
tov_OCloverGrassSilage1
Definition: tov_declaration.h:43
tolp_AUKey
Definition: farm.h:393
tov_PermanentGrassTussocky
Definition: tov_declaration.h:49
UserDefinedFarm29
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1541
FarmManager::ReadCropsData_perSoilType
void ReadCropsData_perSoilType()
Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2,...
Definition: farm.cpp:3724
toc_Potato
Definition: farm.h:337
l_map_farmref_file
static CfgStr l_map_farmref_file("MAP_FARMREF_FILE", CFG_CUSTOM, "farmrefs.txt")
tov_PLWinterTriticale
Definition: tov_declaration.h:73
tocv_AreaHa
Definition: farm.h:401
top_BetaW
Definition: farm.h:388
toc_EnergyFor
Definition: farm.h:363
OptimisingFarm::Get_crop
CropOptimised * Get_crop(int i)
Definition: farm.h:2040
OptimisingFarm::Get_Neighbour
OptimisingFarm * Get_Neighbour(int i)
Definition: farm.h:2050
ConventionalPlant
Inbuilt farm type.
Definition: farm.h:1122
tov_OCloverGrassGrazed2
Definition: tov_declaration.h:43
tov_PLPotatoes
Definition: tov_declaration.h:79
tov_NLCabbage
Definition: tov_declaration.h:95
tofs_Foobar
Definition: farm.h:296
CropOptimised::m_BIHerb
double m_BIHerb
Value of BI for herbicides [BI/ha].
Definition: farm.h:1667
UserDefinedFarm7
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1332
tov_PLBeet
Definition: tov_declaration.h:80
TTypesOfOptFarms
TTypesOfOptFarms
Definition: farm.h:278
WARN_BUG
Definition: maperrormsg.h:34
tocv_BI
Definition: farm.h:406
DataForOptimisation::Set_sellingPrice
void Set_sellingPrice(double a_value, int i)
Definition: farm.h:647
tofg_environment
Definition: farm.h:438
UserDefinedFarm10
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1359
tov_PermanentSetaside
Definition: tov_declaration.h:49
OptimisingFarm::Get_main_goal
TTypeOfFarmerGoal Get_main_goal()
Definition: farm.h:2058
toa_DCalf
Definition: farm.h:303
toc_WRape
Definition: farm.h:332
toa_MCalf
Definition: farm.h:304
UserDefinedFarm22
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1471
FarmManager::ReadInitialCropAreas_almass
void ReadInitialCropAreas_almass()
Reads the data on farms' initial crop distributions and saves them in a vector of a DataForOptimisati...
Definition: farm.cpp:3612
tov_NLSpringBarleySpring
Definition: tov_declaration.h:104
tov_PLWinterRye
Definition: tov_declaration.h:74
tov_OSpringBarley
Definition: tov_declaration.h:46
cfg_grain_distribution
CfgInt cfg_grain_distribution("GOOSE_GRAIN_DISTRIBUTION", CFG_CUSTOM, 0, 0, 2)
A switch to fix the grain distribution to a specific year or make a random pick between years....
tov_Setaside
Definition: tov_declaration.h:50
toa_Turkey
Definition: farm.h:315
OptimisingFarm::Get_NeighboursSize
int Get_NeighboursSize(void)
Definition: farm.h:2049
CropOptimised::m_n
double m_n
Total amount of fertilizer applied per ha of a crop [kg N/ha].
Definition: farm.h:1656
UserDefinedFarm24
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1491
tov_OrchardCrop
Definition: tov_declaration.h:65
top_PriceHerb
Definition: farm.h:374
tov_SpringBarleySeed
Definition: tov_declaration.h:52
OptimisingCattleFarm
Subclass of the AnimalFarm.
Definition: farm.h:2448
toc_SCerealG
Definition: farm.h:346
OptimisingFarm::Get_almass_no
int Get_almass_no(void)
Definition: farm.h:2039
CropOptimised::m_GM
double m_GM
Value of gross margin for a crop (m_income_ha - m_costs_ha) [DKK/ha].
Definition: farm.h:1689
tov_WWheatPToxicControl
Definition: tov_declaration.h:55
tov_NLMaize
Definition: tov_declaration.h:91
tov_OWinterWheat
Definition: tov_declaration.h:66
UserDefinedFarm4
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1305
FarmManager::GetFarmPtr
Farm * GetFarmPtr(int a_owner)
Returns the pointer to a farm with a specific number.
Definition: farm.h:1766
tov_SpringBarleyStriglingCulm
Definition: tov_declaration.h:62
l_map_read_farmfile
static CfgBool l_map_read_farmfile("MAP_READ_FARMFILE", CFG_PRIVATE, true)
toc_WBarley
Definition: farm.h:327
tov_FieldPeasSilage
Definition: tov_declaration.h:65
toc_GrassRot
Definition: farm.h:351
tov_OCarrots
Definition: tov_declaration.h:43
tov_OWinterWheatUndersownExt
Definition: tov_declaration.h:63
FarmManager::m_farms
vector< Farm * > m_farms
Definition: farm.h:1906
CropOptimised::m_totalLoss
double m_totalLoss
Summary value of the yield loss due to the limited use of herbicides and fung- and insecticides [%].
Definition: farm.h:1683
DataForOptimisation::Get_cropTypes_almass_str
string Get_cropTypes_almass_str(int i)
Definition: farm.h:666
tov_NLGrassGrazedLast
Definition: tov_declaration.h:108
DataForOptimisation::Set_FUKey
void Set_FUKey(double a_value, int i)
Definition: farm.h:644
top_PriceG
Definition: farm.h:376
cfg_Areas_Based_on_Distribution
CfgBool cfg_Areas_Based_on_Distribution("AREAS_BASED_ON_DISTRIBUTION", CFG_CUSTOM, false)
If set to true, crops are assigned area based on their gross margin proportion in the total GM for al...
ConventionalCattle
Inbuilt farm type.
Definition: farm.h:1098
top_BetaFi
Definition: farm.h:382
tov_OBarleyPeaCloverGrass
Definition: tov_declaration.h:41
toof_Plant
Definition: farm.h:281
tos_Foobar
Definition: farm.h:290
tov_WinterWheatShort
Definition: tov_declaration.h:56
g_msg
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:41
DataForOptimisation::Set_rotationMin
void Set_rotationMin(double a_value, int i)
Definition: farm.h:654
tov_SpringBarleyGrass
Definition: tov_declaration.h:52
FarmManager::ReadLookupTable
void ReadLookupTable()
Reads the lookup table with allowed/forbidden crop order from a text file and saves it into a vector ...
Definition: farm.cpp:4625
tocv_BIFi
Definition: farm.h:405
cfg_Profit_max_proportion
CfgFloat cfg_Profit_max_proportion("PROFIT_MAX_PROPORTION", CFG_CUSTOM, 100)
A parameter setting the proportion of farmers of a type profit maximiser.
tov_NorwegianOats
Definition: tov_declaration.h:68
toc_Uncult
Definition: farm.h:353
DataForOptimisation::Set_winterMax
void Set_winterMax(int a_value, int i)
Definition: farm.h:613
tofs_Business
Definition: farm.h:294
toc_SCerealSil
Definition: farm.h:342
toc_Triticale
Definition: farm.h:330
tov_YoungForest
Definition: tov_declaration.h:60
CropOptimised
A class for storing all parameters and results of crop optimisation.
Definition: farm.h:1634
cfg_Environmentalist_proportion
CfgFloat cfg_Environmentalist_proportion("ENVIRONMENTALIST_PROPORTION", CFG_CUSTOM, 0)
A parameter setting the proportion of farmers of a type environmentalist.
tov_OWinterBarleyExt
Definition: tov_declaration.h:65
UserDefinedFarm1
Definition: farm.h:1278
tov_NorwegianSpringBarley
Definition: tov_declaration.h:68
toa_Mink
Definition: farm.h:312
toc_SBarley
Definition: farm.h:324
FarmManager::TranslateSoilCodes
TTypesOfSoils TranslateSoilCodes(string &str)
Definition: farm.cpp:4286
tov_SpringBarleySilage
Definition: tov_declaration.h:52
top_BetaH
Definition: farm.h:386
UserDefinedFarm16
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1413
tov_NLGrassGrazed1Spring
Definition: tov_declaration.h:107
DataForOptimisation::Get_cropTypes_almass
TTypesOfVegetation Get_cropTypes_almass(int i)
Definition: farm.h:663
FarmManager::TranslateCropsCodes
TTypesOfCrops TranslateCropsCodes(string &str)
Definition: farm.cpp:4338
CropOptimised::m_hoeing
double m_hoeing
Value of mechanical weed control for a crop - hoeing [DKK/ha].
Definition: farm.h:1675
Farm::GetFarmNumber
int GetFarmNumber(void)
Definition: farm.h:782
tov_DummyCropPestTesting
Definition: tov_declaration.h:112
FarmManager::m_cropTotals
vector< double > m_cropTotals
Stores crops areas at the landscape level per year.
Definition: farm.h:1937
TTypesOfVegetation
TTypesOfVegetation
Definition: tov_declaration.h:30
UserDefinedFarm28
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1531
toc_OLSeed
Definition: farm.h:335
tov_SpringRape
Definition: tov_declaration.h:53
FarmManager::PrintOutput
void PrintOutput(TTypesOfCropVariables a_var, string a_fileName)
Makes an output file for one crop variable and prints its values for each crop and each OptimisingFar...
Definition: farm.cpp:4504
PesticideTrialControl
Inbuilt special purpose farm type.
Definition: farm.h:1172
FarmManager::ReadCropsData_perFarm_and_Soil
void ReadCropsData_perFarm_and_Soil()
Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them...
Definition: farm.cpp:4003
tov_PotatoesIndustry
Definition: tov_declaration.h:50
OrganicCattle
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1160
tofs_Private
Definition: farm.h:295
DataForOptimisation::FarmData::md_farmType
TTypesOfOptFarms md_farmType
Definition: farm.h:678
toa_EHen
Definition: farm.h:313
tov_SpringBarleyPTreatment
Definition: tov_declaration.h:63
OptimisingOtherFarm
Subclass of the NonAnimalFarm.
Definition: farm.h:2504
tov_FodderGrass
Definition: tov_declaration.h:62
FarmManager::ReadCropsData_almass
void ReadCropsData_almass()
Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector D...
Definition: farm.cpp:3688
toa_Finisher
Definition: farm.h:309
FarmManager::ReadCropsData
void ReadCropsData()
Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector D...
Definition: farm.cpp:3656
tov_PLBeetSpr
Definition: tov_declaration.h:86
tov_PlantNursery
Definition: tov_declaration.h:66
tov_NLCatchPeaCrop
Definition: tov_declaration.h:106
tov_Carrots
Definition: tov_declaration.h:31
UserDefinedFarm8
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1341
toc_OFodderBeet
Definition: farm.h:356
CropOptimised::m_area_ha
double m_area_ha
Area of a crop in ha at a farm [ha].
Definition: farm.h:1699
DataForOptimisation::Set_Nnorm
void Set_Nnorm(double a_value, int i)
Definition: farm.h:630
tov_NLCarrotsSpring
Definition: tov_declaration.h:101
tocv_GM
Definition: farm.h:414
tov_NLPotatoesSpring
Definition: tov_declaration.h:103
tofg_profit
Definition: farm.h:436
cfg_FarmSizeProbParam1
CfgFloat cfg_FarmSizeProbParam1("FARMSIZEPROBPARAMONE", CFG_CUSTOM, 1.5)
A fitting parameter for the probability of hunter acceptance of a farm that is smaller.
UserDefinedFarm21
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1461
FarmManager::m_crops_fertilizer_trade
vector< double > m_crops_fertilizer_trade
Stores information on aggregate (all farms) fertilizer trade (Nt) usage for each crop.
Definition: farm.h:1955
tov_SpringBarleyCloverGrass
Definition: tov_declaration.h:52
CropOptimised::m_nt
double m_nt
Amount of purchased (and applied) fertilizer per ha of a crop [kg N/ha].
Definition: farm.h:1658
TTypesOfFarmSize
TTypesOfFarmSize
Definition: farm.h:293
tov_WinterRape
Definition: tov_declaration.h:53
FarmManager::PrintDecModes_counts
void PrintDecModes_counts()
For each OptimizingFarm it prints the number of times each of the decision modes was used within a si...
Definition: farm.cpp:4720
tov_OGrazingPigs
Definition: tov_declaration.h:44
tov_SugarBeet
Definition: tov_declaration.h:66
cfg_ClosestFarmProbParam2
CfgFloat cfg_ClosestFarmProbParam2("CLOSESTFARMPROBPARAMTWO", CFG_CUSTOM, 1.0)
A fitting parameter for the probability of hunter acceptance of a farm with distance from home - scal...
tov_NLBeet
Definition: tov_declaration.h:89
UserDefinedFarm23
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1481
tov_NorwegianPotatoes
Definition: tov_declaration.h:68
CropOptimised::m_BIFi
double m_BIFi
Value of BI for fung- and insecticides [BI/ha].
Definition: farm.h:1669
tov_OSBarleySilage
Definition: tov_declaration.h:56
top_AlfaW
Definition: farm.h:387
FarmManager::PrintNeighbours
void PrintNeighbours()
Creates an output file with a list of neighbours of each OptimisingFarm.
Definition: farm.cpp:4701
FarmManager::daydegrees
double daydegrees
Daydegress for period March 1st - November 1st. Used to determine yield of crops that are not harvest...
Definition: farm.h:1910
tov_SpringBarleyPeaCloverGrassStrigling
Definition: tov_declaration.h:60
tov_PermanentGrassGrazed
Definition: tov_declaration.h:49
cfg_MaizeEnergy
CfgBool cfg_MaizeEnergy("MAIZE_ENERGY", CFG_CUSTOM, false)
If set to true, the energy maize crop is included in the simulation.
CropOptimised::m_income_ha
double m_income_ha
Value of income per ha of a crop. Includes value of sales and subsidy [DKK/ha].
Definition: farm.h:1687
FarmManager::pm_output_file
ofstream * pm_output_file
Definition: farm.h:1877
tov_CloverGrassGrazed2
Definition: tov_declaration.h:33
UserDefinedFarm35
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1601
tov_WWheatPControl
Definition: tov_declaration.h:55
toa_DCow
Definition: farm.h:301
UserDefinedFarm5
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1314
top_Subsidy
Definition: farm.h:372
tov_PLWinterRape
Definition: tov_declaration.h:71
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
toc_OUncult
Definition: farm.h:354
tov_PLBeans
Definition: tov_declaration.h:87
tov_SpringBarleyCloverGrassStrigling
Definition: tov_declaration.h:58
tov_Potatoes
Definition: tov_declaration.h:50
top_PriceW
Definition: farm.h:378
tov_WinterRyeStrigling
Definition: tov_declaration.h:59
tov_PLWinterBarley
Definition: tov_declaration.h:72
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Definition: landscape.h:1596
toc_SRape
Definition: farm.h:331
CropOptimised::m_resp
double m_resp
Response - yield of a crop per ha [hkg/ha].
Definition: farm.h:1665
AgroChemIndustryCerealFarm1
Inbuilt special purpose farm type.
Definition: farm.h:1214
tov_WinterWheatStriglingCulm
Definition: tov_declaration.h:62
top_BetaG
Definition: farm.h:384
OptimisingFarm::Set_animals_no
void Set_animals_no(int a_number)
Definition: farm.h:2059
Farm::GetArea
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1331
tos_Sand
Definition: farm.h:287
tov_NLTulips
Definition: tov_declaration.h:96
tov_WinterRapeStrigling
Definition: tov_declaration.h:59
toc_OSpecCrops
Definition: farm.h:361
toof_Cattle
Definition: farm.h:280
OptimisingFarm::Get_cropsSize
int Get_cropsSize(void)
Definition: farm.h:2041
FarmManager::TranslateFarmSizeCodes
TTypesOfFarmSize TranslateFarmSizeCodes(string &str)
Definition: farm.cpp:4298
OptimisingPlantFarm
Subclass of the NonAnimalFarm.
Definition: farm.h:2495
Landscape::SupplyYearNumber
int SupplyYearNumber(void)
Definition: landscape.h:1616
toa_Horse
Definition: farm.h:300
toc_FruitTree
Definition: farm.h:360
DataForOptimisation::Set_fodder
void Set_fodder(string a_value, int i)
Definition: farm.h:639
PesticideTrialTreatment
Inbuilt special purpose farm type.
Definition: farm.h:1192
toc_WCerealSil
Definition: farm.h:345
tov_OMaizeSilage
Definition: tov_declaration.h:65
toa_Suckler
Definition: farm.h:302
tov_Maize
Definition: tov_declaration.h:36
UserDefinedFarm2
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1287
tocv_AreaPercent
Definition: farm.h:400
UserDefinedFarm15
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1404
tov_OWinterRape
Definition: tov_declaration.h:47
DataForOptimisation::Set_cropTypes
void Set_cropTypes(TTypesOfCrops crop_type)
Definition: farm.h:596
tov_WWheatPTreatment
Definition: tov_declaration.h:55
g_farm_fixed_rotation_enable
CfgBool g_farm_fixed_rotation_enable("FARM_FIXED_ROTATION_ENABLE", CFG_CUSTOM, false)
toa_MCattle
Definition: farm.h:305
FarmManager::Create_Output_file_for_farms
void Create_Output_file_for_farms()
Creates an output file. Prints the crop variables in the first row of the file. The file is used then...
Definition: farm.cpp:4609
CfgFloat::value
double value(void)
Definition: configurator.h:118
FarmManager::ReadCropsData_perFarm_and_Soil_and_Size
void ReadCropsData_perFarm_and_Soil_and_Size()
Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax,...
Definition: farm.cpp:4074
PesticideTrialToxicControl
Inbuilt special purpose farm type.
Definition: farm.h:1182
DataForOptimisation::Set_alfa
void Set_alfa(double a_value, int i)
Definition: farm.h:624
ConvMarginalJord
Inbuilt special purpose farm type.
Definition: farm.h:1204
toa_So
Definition: farm.h:308
cfg_OptimisingFarms
CfgBool cfg_OptimisingFarms("OPTIMISING_FARMS", CFG_CUSTOM, false)
If set to true, the farmer decision making model is active.
DataForOptimisation::Set_rotationMax
void Set_rotationMax(double a_value, int i)
Definition: farm.h:652
tov_FieldPeas
Definition: tov_declaration.h:34
tocv_Grooming
Definition: farm.h:407
UserDefinedFarm27
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1521
tov_SpringBarleyStriglingSingle
Definition: tov_declaration.h:60
tov_BroadBeans
Definition: tov_declaration.h:66
toc_GrassEnv2
Definition: farm.h:350
FarmManager::TranslateCropCodes
TTypesOfVegetation TranslateCropCodes(std::string &str)
Definition: farm.cpp:1818
CropOptimised::m_areaPercent
double m_areaPercent
Area of a crop in percent of a farm's total area [%].
Definition: farm.h:1695
tov_NLGrassGrazed1
Definition: tov_declaration.h:97
tocv_Nt
Definition: farm.h:403
tov_OSeedGrass1
Definition: tov_declaration.h:46
DataForOptimisation::Set_biomass_factor
void Set_biomass_factor(double a_value, int i)
Definition: farm.h:659
DataForOptimisation::FarmData
Class storing farm information: farm's number used in ALMaSS system, farm's soil type,...
Definition: farm.h:675
FarmManager::OptimisationOutput
void OptimisationOutput()
Creates output files for all crop level variables and for landscape level crop distribution....
Definition: farm.cpp:4451
OptimisingFarm::Set_Neighbour
void Set_Neighbour(OptimisingFarm *farm)
Definition: farm.h:2048
toa_Foobar
Definition: farm.h:320
tocv_Costs
Definition: farm.h:413
tov_OFodderBeet
Definition: tov_declaration.h:65
tov_NLWinterWheat
Definition: tov_declaration.h:94
UserDefinedFarm9
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1350
tov_PLMaize
Definition: tov_declaration.h:77
tov_OCloverGrassGrazed1
Definition: tov_declaration.h:43
FarmManager::m_cropTotals_plant_sum
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:1943
tov_OSpringBarleyPigs
Definition: tov_declaration.h:47
tov_SpringBarleySpr
Definition: tov_declaration.h:66
toc_Peas
Definition: farm.h:334
DataForOptimisation::Get_cropTypes_almass_size
int Get_cropTypes_almass_size()
Definition: farm.h:664
FarmManager::TranslateFarmCodes
TTypesOfOptFarms TranslateFarmCodes(string &str)
Definition: farm.cpp:4273
tov_PLSpringBarley
Definition: tov_declaration.h:76
DataForOptimisation::m_farm_data
vector< FarmData * > m_farm_data
Definition: farm.h:685
toc_GrassClover
Definition: farm.h:340
tov_PermanentGrassLowYield
Definition: tov_declaration.h:63
FarmManager::IsDuplicateRef
bool IsDuplicateRef(int a_ref, HunterInfo *a_hinfo)
Checks if we already have this ref.
Definition: farm.cpp:3116
UserDefinedFarm20
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1451
tov_WinterWheatStrigling
Definition: tov_declaration.h:59
ConventionalPig
Inbuilt farm type.
Definition: farm.h:1110
DataForOptimisation::FarmData::md_soilSubType
int md_soilSubType
Definition: farm.h:682
tov_WinterWheatStriglingSingle
Definition: tov_declaration.h:62
HunterInfo::homeX
int homeX
Hunter home x-coord.
Definition: farm.h:516
OptimisingFarm::Init
void Init(ofstream *ap_output_file)
Function carrying out the initial calculations at a farm level (including the initial optimisation).
Definition: farm.cpp:5294
distribution_type2
boost::random::uniform_int_distribution distribution_type2
Definition: BoostRandomGenerators.h:32
OptimisingFarm::ChooseDecisionMode
void ChooseDecisionMode()
Function determines which decision mode to use. The choice depends on the values of need satisfaction...
Definition: farm.cpp:5478
NoPesticideNoPFarm
Inbuilt special purpose farm type.
Definition: farm.h:1250
UserDefinedFarm32
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1571
HunterInfo::homeY
int homeY
Hunter home y-coord.
Definition: farm.h:518
FarmManager::m_SpilledGrain
bool m_SpilledGrain
Is it 2013 (true) or 2014 (false) as far as grain goes.
Definition: farm.h:1912
toc_PerGrassNorm
Definition: farm.h:348
tolp_Foobar
Definition: farm.h:396
WARN_FILE
Definition: maperrormsg.h:37
UserDefinedFarm34
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1591
tov_PLCarrots
Definition: tov_declaration.h:83
Farm::Assign_rotation
void Assign_rotation(vector< TTypesOfVegetation >a_new_rotation)
Definition: farm.cpp:1488
tov_WinterBarley
Definition: tov_declaration.h:53
FarmManager::m_crops_fertilizer
vector< double > m_crops_fertilizer
Stores information on aggregate (all farms) fertilizer usage for each crop.
Definition: farm.h:1953
UserDefinedFarm6
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1323
FarmManager::totalOptFarmsArea
double totalOptFarmsArea
Definition: farm.h:1930
top_PriceLM
Definition: farm.h:373
toof_Other
Definition: farm.h:279
OrganicPlant
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1135
UserDefinedFarm19
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1441
FarmManager::TranslateAnimalsCodes
TTypesOfAnimals TranslateAnimalsCodes(string &str)
Definition: farm.cpp:4309
Landscape::SupplyFarmAnimalCensus
int SupplyFarmAnimalCensus(int a_farm_ref, int a_LifeStage)
Definition: Landscape.cpp:745
tov_SeedGrass2
Definition: tov_declaration.h:50
DataForOptimisation::Set_beta2
void Set_beta2(double a_value, int i)
Definition: farm.h:628
AgroChemIndustryCerealFarm2
Inbuilt special purpose farm type.
Definition: farm.h:1223
tov_MaizeSilage
Definition: tov_declaration.h:62
toa_Piglet
Definition: farm.h:310
FarmManager::m_crop_lookup_table
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:1939
FarmManager::m_crop_areas_stages
vector< double > m_crop_areas_stages
Stores information on crop areas calculated in different stages of model development: for comparison ...
Definition: farm.h:1957
FarmManager::m_renumbered
bool m_renumbered
A flag to show whether renumbering was already done.
Definition: farm.h:1917
tov_OPotatoes
Definition: tov_declaration.h:44
toc_Foobar
Definition: farm.h:367
CfgInt::value
int value(void)
Definition: configurator.h:98
cfg_LifeStage
CfgInt cfg_LifeStage("LIFE_STAGE", CFG_CUSTOM, 0)
This parameter specifies the life stage of a species whose numbers farmers use during their decision ...
DataForOptimisation::Set_livestockNumber
void Set_livestockNumber(int a_number)
Definition: farm.h:603
DataForOptimisation::Set_livestockParameter
void Set_livestockParameter(double a_value, int i)
Definition: farm.h:617
CropOptimised::m_savings
double m_savings
Value of savings resulting from growing a fodder crop and not purchasing amount of fodder correspondi...
Definition: farm.h:1691
tov_OSeedGrass2
Definition: tov_declaration.h:46
FarmManager::m_crops_summary_BIs
vector< PesticideData > m_crops_summary_BIs
Stores information on aggregate (all farms)pesticide usage for each crop.
Definition: farm.h:1951
UserDefinedFarm12
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1377
g_farmmanager
FarmManager * g_farmmanager
Definition: farm.cpp:284
FarmManager::pm_data
DataForOptimisation * pm_data
Pointer to the DataForOptimisation.
Definition: farm.h:1876
OptimisingFarm
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:2028
toc_ChrisTree
Definition: farm.h:362
tov_NLGrassGrazed2
Definition: tov_declaration.h:98
DataForOptimisation::FarmData::md_farmRealID
int md_farmRealID
Definition: farm.h:681
FarmManager::m_farmmapping_lookup
int * m_farmmapping_lookup
Used for a dynamic array of lookups converting farm references to internal renumbering.
Definition: farm.h:1915
tov_OFieldPeasSilage
Definition: tov_declaration.h:56
top_PriceFi
Definition: farm.h:375
Farm::GetAreaDouble
double GetAreaDouble(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1350
UserDefinedFarm14
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1395
toa_MDuck
Definition: farm.h:318
tov_SpringWheat
Definition: tov_declaration.h:53
DataForOptimisation::Set_emaize_price
void Set_emaize_price(double a_value)
Definition: farm.h:671
CropOptimised::m_grooming
double m_grooming
Value of mechanical weed control for a crop - grooming [DKK/ha].
Definition: farm.h:1673
cfg_Animals_number_test_day
CfgInt cfg_Animals_number_test_day("ANIMALS_NUMBER_TEST_DAY", CFG_CUSTOM, 152)
This parameter specifies the day at which farmers observe the number of animals residing at their far...
tov_SpringBarley
Definition: tov_declaration.h:52
FarmManager::totalOptFarmsArea_plant
double totalOptFarmsArea_plant
Definition: farm.h:1931
tov_OWinterRye
Definition: tov_declaration.h:49
tov_NLCarrots
Definition: tov_declaration.h:90
toc_OLSeedCut
Definition: farm.h:341
g_date
class Calendar * g_date
Definition: calendar.cpp:38
top_PriceH
Definition: farm.h:377
AgroChemIndustryCerealFarm3
Inbuilt special purpose farm type.
Definition: farm.h:1232
toc_WRye
Definition: farm.h:329
tov_CloverGrassGrazed1
Definition: tov_declaration.h:32
UserDefinedFarm26
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1511
tov_OFieldPeas
Definition: tov_declaration.h:43
tov_FodderBeet
Definition: tov_declaration.h:35
TTypesOfCrops
TTypesOfCrops
Definition: farm.h:323
toc_OSCrops
Definition: farm.h:326
tov_WinterRye
Definition: tov_declaration.h:55
tov_PLFodderLucerne2
Definition: tov_declaration.h:82
toc_Fruit
Definition: farm.h:359
FarmManager::ReadLivestockNumbers
void ReadLivestockNumbers()
Reads the data on livestock numbers and saves them in a vector DataForOptimisation::m_livestockNumber...
Definition: farm.cpp:3530
toa_Deer
Definition: farm.h:311
FarmManager::ReadFarmsData_perFarmType
void ReadFarmsData_perFarmType()
Reads the data on farms' parameters that vary with a farm type and saves them in a vector of a DataFo...
Definition: farm.cpp:4184
tov_Triticale
Definition: tov_declaration.h:53
OptimisingFarm::Save_last_years_crops
void Save_last_years_crops()
It saves the OptimisingFarm::m_rotational_crops in a vector m_rotational_crops_visible which is acces...
Definition: farm.cpp:5472
tolp_FUuKey
Definition: farm.h:395
tov_PLWinterWheat
Definition: tov_declaration.h:70
DataForOptimisation::Set_beta1
void Set_beta1(double a_value, int i)
Definition: farm.h:626
top_AlfaH
Definition: farm.h:385
toof_Foobar
Definition: farm.h:283
tocv_Savings
Definition: farm.h:415
toa_Goose
Definition: farm.h:316
FarmManager::ReadEnergyMaizePrice
void ReadEnergyMaizePrice()
Definition: farm.cpp:4244
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
cfg_OptimiseBedriftsmodelCrops
CfgBool cfg_OptimiseBedriftsmodelCrops("OPTIMISE_BEDRIFTSMODEL_CROPS", CFG_CUSTOM, false)
If set to true, the original farm optimisation model's crop set is used in the farmer decision making...
g_farm_fixed_rotation_farmtype
CfgInt g_farm_fixed_rotation_farmtype("FARM_FIXED_ROTATION_FARMTYPE", CFG_CUSTOM, 0)
FarmManager::m_cropTotals_cattle_sum
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:1947
NoPesticideBaseFarm
Inbuilt special purpose farm type.
Definition: farm.h:1241
FarmManager::m_cropTotals_other_sum
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:1949
CfgBool::value
bool value(void)
Definition: configurator.h:135
toc_MaizeSil
Definition: farm.h:344
tov_NLPermanentGrassGrazed
Definition: tov_declaration.h:99
FarmManager::ReadCropsData_perFarm_and_Soil_almass
void ReadCropsData_perFarm_and_Soil_almass()
Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them...
Definition: farm.cpp:4036
toa_Ostrich
Definition: farm.h:319
cfg_AnimalsThreshold
CfgFloat cfg_AnimalsThreshold("ANIMALS_THRESHOLD", CFG_CUSTOM, 0)
This parameter specifies the proportion of average number of animals on a farm for previous 3 years,...
toa_Sheep
Definition: farm.h:306
top_AlfaHerb
Definition: farm.h:379
tov_SeedGrass1
Definition: tov_declaration.h:50
DataForOptimisation::FarmData::md_soilType
TTypesOfSoils md_soilType
Definition: farm.h:679
DataForOptimisation::Set_cropTypes_almass
void Set_cropTypes_almass(TTypesOfVegetation crop_type)
Definition: farm.h:662
UserDefinedFarm31
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1561
tov_OSpringBarleyGrass
Definition: tov_declaration.h:46
OptimisingFarm::ActualProfit
void ActualProfit()
Function that determines actual crop yields and profit in a given year.
Definition: farm.cpp:8806
toa_Goat
Definition: farm.h:307
FarmManager::totalOptFarmsArea_pig
double totalOptFarmsArea_pig
Definition: farm.h:1932
UserDefinedFarm33
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1581
tocv_TotalLoss
Definition: farm.h:410
OptimisingFarm::Get_decision_mode_counters
int Get_decision_mode_counters(int index)
Definition: farm.h:2060
tocv_N
Definition: farm.h:402
toc_Setaside
Definition: farm.h:352
g_landscape_p
Landscape * g_landscape_p
Definition: Landscape.cpp:258
cfg_RoostDistProbParam1
CfgFloat cfg_RoostDistProbParam1("ROOSTDISTPROBPARAMONE", CFG_CUSTOM, 1.5)
A fitting parameter for the probability of hunter acceptance of a farm with distance from roost.
toc_WWheat
Definition: farm.h:328
DataForOptimisation::Get_cropTypes_str
string Get_cropTypes_str(int i)
Definition: farm.h:599
tov_OSpringBarleyExt
Definition: tov_declaration.h:63
l_emaize_price_file
static CfgStr l_emaize_price_file("EMAIZE_PRICE_FILE", CFG_CUSTOM, "EM_price.txt")
UserDefinedFarm18
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1431
HunterInfo::FarmHuntRef
vector< int > FarmHuntRef
The hunter's is the farm reference number to where he hunts.
Definition: farm.h:520
tov_NLCabbageSpring
Definition: tov_declaration.h:105
FarmManager::m_cropTotals_sum
vector< double > m_cropTotals_sum
Stores the sums of crops areas within one simulation at the landscape level.
Definition: farm.h:1941