ALMaSS Rabbit ODdox
1.00
The rabbit model description following ODdox protocol
|
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... | |
Farm * | GetFarmPtr (int a_owner) |
Returns the pointer to a farm with a specific number. More... | |
Farm * | GetFarmPtrIndex (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 | |
DataForOptimisation * | pm_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_Manager * | m_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< PesticideData > | m_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... | |
FarmManager::FarmManager | ( | ) |
Farm manager constructor.
Definition at line 2177 of file farm.cpp.
References cfg_MaizeEnergy, cfg_OptimiseBedriftsmodelCrops, cfg_OptimisingFarms, l_map_farmref_file, l_map_read_farmfile, CfgBool::value(), and CfgStr::value().
FarmManager::~FarmManager | ( | ) |
Farm manager destructor.
Definition at line 2250 of file farm.cpp.
References cfg_OptimisingFarms, and CfgBool::value().
void FarmManager::ActualProfit | ( | ) |
Calls OptimisingFarm::ActualProfit for all optimising farms.
Definition at line 2956 of file farm.cpp.
References OptimisingFarm::ActualProfit(), Farm::GetType(), and tof_OptimisingFarm.
|
inline |
Definition at line 1695 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
void FarmManager::AddField | ( | int | a_OwnerIndex, |
LE * | a_newland, | ||
int | a_Owner | ||
) |
Definition at line 2292 of file farm.cpp.
References LE::SetOwner().
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.
|
inline |
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 2922 of file farm.cpp.
References Farm::GetMaxOpenness().
void FarmManager::ChooseDecisionMode_for_farms | ( | ) |
Calls OptimisingFarm::ChooseDecisionMode for all optimising farms.
Definition at line 2967 of file farm.cpp.
References OptimisingFarm::ChooseDecisionMode(), Farm::GetType(), and tof_OptimisingFarm.
int FarmManager::ConnectFarm | ( | int | a_owner | ) |
Definition at line 2303 of file farm.cpp.
References g_msg, Farm::GetFarmNumber(), MapErrorMsg::Warn(), and WARN_FILE.
|
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.
|
protected |
Definition at line 2323 of file farm.cpp.
References cfg_OptimisingFarms, g_farm_fixed_rotation_enable, g_farm_fixed_rotation_farmtype, g_msg, toof_Cattle, toof_Other, toof_Pig, toof_Plant, UserDefinedFarm35::UserDefinedFarm35(), CfgInt::value(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.
|
protected |
Calculates total crop areas (at the landscape level). Includes results of the initial farm otpimisation.
Definition at line 4111 of file farm.cpp.
References cfg_OptimiseBedriftsmodelCrops, OptimisingFarm::Get_crop(), OptimisingFarm::Get_cropsSize(), Farm::GetType(), CropOptimised::m_area_ha, toc_Foobar, tof_OptimisingFarm, and CfgBool::value().
|
protected |
Randomly assigns farmer types to farms (OptimisingFarm) in proportions specified in an input file.
Definition at line 4488 of file farm.cpp.
References cfg_Environmentalist_proportion, cfg_Profit_max_proportion, cfg_Yield_max_proportion, Farm::GetType(), tof_OptimisingFarm, tofg_environment, tofg_profit, tofg_yield, and CfgFloat::value().
void FarmManager::DumpFarmAreas | ( | ) |
Definition at line 1536 of file farm.cpp.
References OptimisingFarm::Get_almass_no(), Farm::GetArea(), and tof_OptimisingFarm.
void FarmManager::DumpFarmrefs | ( | ) |
dumps the farmrefs file to a standard named file
Definition at line 2548 of file farm.cpp.
References g_msg, MapErrorMsg::Warn(), and WARN_FILE.
void FarmManager::FarmManagement | ( | ) |
Runs the daily farm management for each farm, but also calculates annual spilled grain and maize.
Definition at line 2258 of file farm.cpp.
References cfg_Animals_number_test_day, cfg_AnimalsThreshold, cfg_LifeStage, OptimisingFarm::Get_main_goal(), Farm::GetFarmNumber(), Farm::GetType(), OptimisingFarm::Set_animals_no(), Landscape::SupplyDayInYear(), Landscape::SupplyFarmAnimalCensus(), Landscape::SupplyYearNumber(), tof_OptimisingFarm, tofg_environment, CfgInt::value(), and CfgFloat::value().
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 2649 of file farm.cpp.
References g_msg, HunterInfo::homeX, HunterInfo::homeY, and MapErrorMsg::Warn().
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 2678 of file farm.cpp.
References g_msg, Farm::GetMaxOpenness(), HunterInfo::homeX, HunterInfo::homeY, and MapErrorMsg::Warn().
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 2705 of file farm.cpp.
References cfg_ClosestFarmProbParam1, cfg_ClosestFarmProbParam2, g_msg, g_rand_uni, Farm::GetMaxOpenness(), HunterInfo::homeX, HunterInfo::homeY, CfgFloat::value(), and MapErrorMsg::Warn().
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 2812 of file farm.cpp.
References cfg_ClosestFarmProbParam1, cfg_ClosestFarmProbParam2, cfg_RoostDistProbParam1, g_msg, g_rand_uni, Farm::GetMaxOpenness(), HunterInfo::homeX, HunterInfo::homeY, CfgFloat::value(), and MapErrorMsg::Warn().
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 2756 of file farm.cpp.
References cfg_ClosestFarmProbParam1, cfg_ClosestFarmProbParam2, cfg_FarmSizeProbParam1, g_msg, g_rand_uni, Farm::GetMaxOpenness(), HunterInfo::homeX, HunterInfo::homeY, CfgFloat::value(), and MapErrorMsg::Warn().
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 2893 of file farm.cpp.
References g_msg, Farm::GetFarmNumber(), Farm::GetMaxOpenness(), and MapErrorMsg::Warn().
int FarmManager::FindFarmWithRandom | ( | vector< int > * | a_farmlist | ) |
Finds a farm openness more than a value not on the list.
Definition at line 2876 of file farm.cpp.
References g_msg, Farm::GetFarmNumber(), and MapErrorMsg::Warn().
void FarmManager::FindNeighbours | ( | ) |
Finds all OptimisingFarms' neighbours and saves them in the farm's OptimisingFarm::m_neighbours vector.
Definition at line 4180 of file farm.cpp.
References Farm::Centroids(), cfg_Neighbor_dist, OptimisingFarm::Get_almass_no(), OptimisingFarm::GetFarmCentroidX(), OptimisingFarm::GetFarmCentroidY(), Farm::GetType(), OptimisingFarm::Set_Neighbour(), tof_OptimisingFarm, and CfgFloat::value().
int FarmManager::FindOpennessFarm | ( | int | a_openness | ) |
Finds a random farm with at least one field with openness above a_openness.
Definition at line 2910 of file farm.cpp.
References Farm::GetFarmNumber(), and Farm::GetMaxOpenness().
|
inline |
Definition at line 1710 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1694 of file farm.h.
|
inline |
Definition at line 1697 of file farm.h.
|
inline |
Definition at line 1736 of file farm.h.
Referenced by OptimisingFarm::Make_rotations(), and OptimisingFarm::Match_crop_to_field().
|
inline |
Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops that are not harvested.
Definition at line 1692 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Returns the arable area from the farm ref num.
Definition at line 1590 of file farm.h.
|
inline |
Returns the area of fields with openness more than a_openness.
Definition at line 1617 of file farm.h.
|
inline |
Gets the farm centroid as an APoint.
Definition at line 1666 of file farm.h.
References g_msg, and MapErrorMsg::Warn().
|
inline |
Returns the number of fields owned by a from the farm ref num.
Definition at line 1600 of file farm.h.
|
inline |
Get a farm reference from the lookup table.
Definition at line 1739 of file farm.h.
|
inline |
Returns the number of fields with openness more than a_openness.
Definition at line 1611 of file farm.h.
|
inline |
Returns the pointer to a farm with a specific number.
Definition at line 1623 of file farm.h.
References g_msg, and MapErrorMsg::Warn().
Referenced by Landscape::SupplyFarmPtr().
|
inline |
|
inline |
Returns the total farm area from the farm ref num.
Definition at line 1585 of file farm.h.
|
inline |
Returns the farm type from the farm ref num.
Definition at line 1595 of file farm.h.
|
inline |
Get a farm type from the lookup table.
Definition at line 1741 of file farm.h.
|
inline |
Returns the number of fields owned by a from the farm ref num.
Definition at line 1605 of file farm.h.
|
inline |
Returns the flag for renumbering.
Definition at line 1743 of file farm.h.
|
inline |
|
inline |
Returns the farm ref index for a farmref.
Definition at line 1745 of file farm.h.
References g_msg, and MapErrorMsg::Warn().
double FarmManager::GetSpilledGrain | ( | ) |
Returns the average amount of spilled grain in KJ/m2 this year.
Definition at line 2584 of file farm.cpp.
References g_rand_uni.
double FarmManager::GetSpilledMaize | ( | ) |
Returns the average amount of spilled maize in KJ/m2 this year.
Definition at line 2601 of file farm.cpp.
References g_rand_uni.
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.
void FarmManager::InitFarms | ( | ) |
Calls OptimisingFarm::Init for all optimising farms.
Definition at line 2565 of file farm.cpp.
References cfg_OptimisingFarms, Farm::GetType(), OptimisingFarm::Init(), tof_OptimisingFarm, and CfgBool::value().
bool FarmManager::IsDuplicateRef | ( | int | a_ref, |
HunterInfo * | a_hinfo | ||
) |
Checks if we already have this ref.
Definition at line 2639 of file farm.cpp.
References HunterInfo::FarmHuntRef.
|
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 3974 of file farm.cpp.
References cfg_OptimiseBedriftsmodelCrops, 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().
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 4243 of file farm.cpp.
References OptimisingFarm::Get_almass_no(), OptimisingFarm::Get_decision_mode_counters(), Farm::GetType(), and tof_OptimisingFarm.
void FarmManager::PrintFinalResults | ( | ) |
At the end of a simulation it prints results on crop distribution, pesticide and fertilizer usage.
Definition at line 4264 of file farm.cpp.
References g_date, and Calendar::GetYearNumber().
|
protected |
Creates an output file with a list of neighbours of each OptimisingFarm.
Definition at line 4224 of file farm.cpp.
References OptimisingFarm::Get_almass_no(), OptimisingFarm::Get_Neighbour(), OptimisingFarm::Get_NeighboursSize(), Farm::GetType(), and tof_OptimisingFarm.
|
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 4027 of file farm.cpp.
References cfg_OptimiseBedriftsmodelCrops, g_msg, OptimisingFarm::Get_almass_no(), OptimisingFarm::Get_crop(), OptimisingFarm::Get_cropsSize(), Farm::GetType(), CropOptimised::m_area_ha, CropOptimised::m_areaPercent, CropOptimised::m_BI, CropOptimised::m_BIFi, CropOptimised::m_BIHerb, CropOptimised::m_costs_ha, 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, 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.
|
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 3179 of file farm.cpp.
References toc_Foobar, and top_Foobar.
|
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 3211 of file farm.cpp.
References top_Foobar.
|
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 3526 of file farm.cpp.
References toc_Foobar, toof_Foobar, and tos_Foobar.
|
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 3559 of file farm.cpp.
References toof_Foobar, tos_Foobar, and tov_Undefined.
|
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 3597 of file farm.cpp.
References toc_Foobar, tofs_Foobar, toof_Foobar, and tos_Foobar.
|
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 3640 of file farm.cpp.
References cfg_Areas_Based_on_Distribution, g_msg, tofs_Foobar, toof_Foobar, tos_Foobar, tov_Undefined, CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.
|
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 3404 of file farm.cpp.
References toc_Foobar, and toof_Foobar.
|
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 3460 of file farm.cpp.
References g_msg, toof_Foobar, tov_Undefined, MapErrorMsg::Warn(), and WARN_FILE.
|
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 3247 of file farm.cpp.
References toc_Foobar, and tos_Foobar.
|
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 3313 of file farm.cpp.
References g_msg, tos_Foobar, tov_Undefined, MapErrorMsg::Warn(), and WARN_FILE.
|
protected |
Definition at line 3767 of file farm.cpp.
References l_emaize_price_file, and CfgStr::value().
|
protected |
Reads farm level parameters and saves them in a vector DataForOptimisation::m_farm_data.
Definition at line 3007 of file farm.cpp.
References DataForOptimisation::FarmData::md_almass_no, DataForOptimisation::FarmData::md_farmRealID, DataForOptimisation::FarmData::md_farmSize, DataForOptimisation::FarmData::md_farmType, DataForOptimisation::FarmData::md_soilSubType, and DataForOptimisation::FarmData::md_soilType.
|
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 3707 of file farm.cpp.
References toof_Foobar.
|
protected |
Reads the data on farms' initial crop distributions and saves them in a vector DataForOptimisation::m_cropAreas.
Definition at line 3094 of file farm.cpp.
References toc_Foobar.
|
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 3135 of file farm.cpp.
|
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 3735 of file farm.cpp.
References toa_Foobar, and tolp_Foobar.
|
protected |
Reads the data on livestock numbers and saves them in a vector DataForOptimisation::m_livestockNumbers.
Definition at line 3053 of file farm.cpp.
References toa_Foobar.
|
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 4148 of file farm.cpp.
References tov_Undefined.
void FarmManager::RemoveField | ( | int | a_OwnerIndex, |
LE * | a_field | ||
) |
void FarmManager::Save_diff_farm_types_areas | ( | ) |
Calculates and saves total areas of all optimising farms and specific farm types.
Definition at line 2927 of file farm.cpp.
References OptimisingFarm::Get_farmType(), Farm::GetAreaDouble(), Farm::GetType(), tof_OptimisingFarm, toof_Cattle, toof_Other, toof_Pig, and toof_Plant.
void FarmManager::Save_last_years_crops_for_farms | ( | ) |
Calls OptimisingFarm::Save_last_years_crops for all optimising farms.
Definition at line 2979 of file farm.cpp.
References Farm::GetType(), OptimisingFarm::Save_last_years_crops(), and tof_OptimisingFarm.
|
inline |
Definition at line 1720 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1721 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1713 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1712 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1711 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1696 of file farm.h.
|
inline |
Definition at line 1717 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1718 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1716 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1715 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1714 of file farm.h.
Referenced by OptimisingFarm::ActualProfit().
|
inline |
Definition at line 1693 of file farm.h.
|
inline |
Set m_SpilledGrain which is the flag for either 2013 (true) or 2014 (false) spilled grain distributions.
Definition at line 1685 of file farm.h.
void FarmManager::Switch_rotation | ( | ) |
Switches OptimisingFarms Farm::m_rotation to the list of all possible rotational crops.
Definition at line 4465 of file farm.cpp.
References Farm::Assign_rotation(), Farm::GetType(), tof_OptimisingFarm, tov_OrchardCrop, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, and tov_YoungForest.
TTypesOfAnimals FarmManager::TranslateAnimalsCodes | ( | string & | str | ) |
Definition at line 3832 of file farm.cpp.
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.
TTypesOfVegetation FarmManager::TranslateCropCodes | ( | std::string & | str | ) |
Definition at line 1435 of file farm.cpp.
References g_msg, tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_FieldPeas, tov_FieldPeasSilage, tov_FieldPeasStrigling, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, 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_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(), Farm::ReadRotation(), and UserDefinedFarm::UserDefinedFarm().
TTypesOfCrops FarmManager::TranslateCropsCodes | ( | string & | str | ) |
Definition at line 3861 of file farm.cpp.
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().
TTypesOfCropVariables FarmManager::TranslateCropVariablesCodes | ( | string & | str | ) |
Definition at line 3949 of file farm.cpp.
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.
TTypesOfOptFarms FarmManager::TranslateFarmCodes | ( | string & | str | ) |
Definition at line 3796 of file farm.cpp.
References g_msg, toof_Cattle, toof_Other, toof_Pig, toof_Plant, MapErrorMsg::Warn(), and WARN_FILE.
TTypesOfFarmSize FarmManager::TranslateFarmSizeCodes | ( | string & | str | ) |
Definition at line 3821 of file farm.cpp.
References g_msg, tofs_Business, tofs_Private, MapErrorMsg::Warn(), and WARN_FILE.
TTypesOfLivestockParameters FarmManager::TranslateLivestockParametersCodes | ( | string & | str | ) |
Definition at line 3937 of file farm.cpp.
References g_msg, tolp_AUKey, tolp_FUuKey, tolp_Nusable, MapErrorMsg::Warn(), and WARN_FILE.
Referenced by OptimisingFarm::findFodderDemand(), and OptimisingFarm::findTotalNanim().
TTypesOfParameters FarmManager::TranslateParametersCodes | ( | string & | str | ) |
Definition at line 3910 of file farm.cpp.
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().
TTypesOfSoils FarmManager::TranslateSoilCodes | ( | string & | str | ) |
Definition at line 3809 of file farm.cpp.
References g_msg, tos_Clay, tos_Other, tos_Sand, MapErrorMsg::Warn(), and WARN_FILE.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
DataForOptimisation* FarmManager::pm_data |
Pointer to the DataForOptimisation.
Definition at line 1733 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(), AnimalFarm::createFodderCrops(), OptimisingFarm::createVariableCrops(), OptimisingFarm::crop_parameter(), AnimalFarm::decreaseCrops(), OptimisingFarm::determineAreas(), AnimalFarm::determineFodderAreas(), AnimalFarm::determineMinFodder(), OptimisingFarm::findFertilizer(), OptimisingFarm::findFodderDemand(), OptimisingFarm::findGrossMargin(), OptimisingFarm::findResponse(), OptimisingFarm::findTotalNanim(), AnimalFarm::increaseCrops(), OptimisingFarm::Initialize(), OptimisingFarm::optimizeCrops(), and OptimisingCattleFarm::setCattleCropsAtMin().