Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
Fauna::GetForageDemands Class Reference

Function object to calculate forage demands for a herbivore. More...

#include <get_forage_demands.h>

Public Member Functions

 GetForageDemands (std::shared_ptr< const Hft > hft, const Sex sex)
 Constructor. More...
 
void add_eaten (ForageMass eaten_forage)
 Register ingested forage so that less forage will be demanded. More...
 
void init_today (const int day, const HabitatForage &available_forage, const ForageEnergyContent &energy_content, const double bodymass)
 Initialize foraging for another day. More...
 
bool is_day_initialized (const int day) const
 Whether the given day has been initialized with init_today(). More...
 
ForageMass operator() (const double energy_needs)
 Calculate current forage demands. More...
 

Static Public Member Functions

static ForageMass get_max_intake_as_total_mass (const ForageFraction &mj_proportions, const ForageEnergyContent &mj_per_kg, const double kg_total)
 Get maximum intake for each forage type limited by total mass. More...
 

Private Member Functions

double get_bodymass_adult () const
 Adult herbivore body mass [kg/ind]. More...
 
const Hftget_hft () const
 The herbivore functional type. More...
 
ForageFraction get_diet_composition () const
 Get energy-wise preferences for forage types. More...
 
ForageMass get_max_digestion () const
 Maximum forage [kgDM/ind/day] that could be potentially digested. More...
 
ForageMass get_max_foraging () const
 
int get_today () const
 Current day of the year, as set in init_today(). More...
 

Private Attributes

const std::shared_ptr< const Hfthft
 
const Sex sex
 
HabitatForage available_forage
 
double bodymass
 
ForageFraction diet_composition
 [kg/ind] More...
 
Digestibility digestibility
 [frac.] sum = 1.0 More...
 
ForageEnergyContent energy_content
 [frac.] More...
 
double energy_needs
 [MJ/kgDM] More...
 
ForageMass max_intake
 [MJ/ind] More...
 
int today
 [kgDM/ind/day] More...
 

Detailed Description

Function object to calculate forage demands for a herbivore.

See also
HerbivoreInterface::get_forage_demands()

Constructor & Destructor Documentation

◆ GetForageDemands()

GetForageDemands::GetForageDemands ( std::shared_ptr< const Hft hft,
const Sex  sex 
)

Constructor.

Parameters
hftHerbivore functional type.
sexThe sex of the herbivore cohort.
Exceptions
std::invalid_argumentIf hft==NULL.

Member Function Documentation

◆ add_eaten()

void GetForageDemands::add_eaten ( ForageMass  eaten_forage)

Register ingested forage so that less forage will be demanded.

Parameters
eaten_forageIngested plant material [kgDM/ind].
Exceptions
std::logic_errorIf eaten_forage exceeds the maximum intake of today.

◆ get_bodymass_adult()

double GetForageDemands::get_bodymass_adult ( ) const
private

Adult herbivore body mass [kg/ind].

◆ get_diet_composition()

ForageFraction GetForageDemands::get_diet_composition ( ) const
private

Get energy-wise preferences for forage types.

To what fractions the different forage types are eaten (in sum the fractions must be 1.0).

Hft::foraging_diet_composer defines the algorithm used to put together the fractions of different forage types in the preferred diet for each day. Note that this function may be called several times a day in cases of food scarcity, when the available forage needs to be split among herbivores according to their needs (see DistributeForage). This allows for switching to another, less preferred, forage type if the first choice is not available anymore.

This is the ad-libidum diet according to the preferences of the HFT. The fractions refer to energy, not mass. The composition is set, i.e. that the demanded forage will be put together accordingly. In case of forage shortage in the habitat, there is the chance to switch to other forage types when the demands are queried again in the same day. (⇒ see Fauna::DistributeForage).

Returns
Energy fractions of forage types composing current diet; the sum is 1.0.
Exceptions
std::logic_errorIf the Hft::foraging_diet_composer is not implemented.
std::logic_errorIf the selected algorithm does not produce a sum of fractions that equals 1.0 (100%).

◆ get_hft()

const Hft & Fauna::GetForageDemands::get_hft ( ) const
inlineprivate

The herbivore functional type.

◆ get_max_digestion()

ForageMass GetForageDemands::get_max_digestion ( ) const
private

Maximum forage [kgDM/ind/day] that could be potentially digested.

The algorithm selected by Hft::digestion_limit is employed. Note that this is only the digestion-limited maximum intake. It does not consider metabolic needs (“hunger”, compare FatmassEnergyBudget::get_energy_needs()) nor foraging capabilities (get_max_foraging()) nor actual available forage.

Returns
Maximum digestible dry matter today with given forage composition [kgDM/ind/day].
Exceptions
std::logic_errorIf the Hft::digestion_limit is not implemented.

◆ get_max_foraging()

ForageMass GetForageDemands::get_max_foraging ( ) const
private

Get the amount of forage the herbivore would be able to harvest [kgDM/day/ind]. The relative amount of each forage type is prescribed, and the absolute mass that the herbivore could potentially ingest is returned. This does not consider digestive limits or actual metabolic needs (“hunger”), but only considers the harvesting efficiency of the herbivore this day.

Each forage type is calculated separately and independently.

Returns
Maximum potentially harvested dry matter mass of each forage type [kgDM/day/ind].
Exceptions
std::logic_errorIf one of Hft::foraging_limits is not implemented.

◆ get_max_intake_as_total_mass()

ForageMass GetForageDemands::get_max_intake_as_total_mass ( const ForageFraction mj_proportions,
const ForageEnergyContent mj_per_kg,
const double  kg_total 
)
static

Get maximum intake for each forage type limited by total mass.

Parameters
mj_proportionsDiet composition in energy proportions [MJ/MJ].
mj_per_kgEnergy content of forage [MJ/kgDM].
kg_totalThe maximum total intake [kgDM/day].
Returns
The maximum intake for each forage type [kgDM/day] while retaining the given relative energy proportions.
Exceptions
std::invalid_argumentIf kg_total < 0.0.
std::invalid_argumentIf mj_proportions.sum() != 1.0.
See also
DigestiveLimit::Allometric

◆ get_today()

int GetForageDemands::get_today ( ) const
private

Current day of the year, as set in init_today().

Exceptions
std::logic_errorIf current day not yet set by an initial call to init_today().

◆ init_today()

void GetForageDemands::init_today ( const int  day,
const HabitatForage available_forage,
const ForageEnergyContent energy_content,
const double  bodymass 
)

Initialize foraging for another day.

  • Calculate the diet composition with different forage types.
  • Set max_intake to the minimum of digestive and foraging constraints.
    Parameters
    available_forageThe forage in the habitat.
    dayCurrent day of year, 0=Jan. 1st.
    bodymassCurrent live weight body mass [kg/ind].
    energy_contentNet energy content of the available forage [MJ/kgDM].
    Exceptions
    std::invalid_argumentIf day not in [0,364] or if bodymass<=0.

◆ is_day_initialized()

bool GetForageDemands::is_day_initialized ( const int  day) const

Whether the given day has been initialized with init_today().

Exceptions
std::invalid_argumentIf day<0 || day>364.

◆ operator()()

ForageMass GetForageDemands::operator() ( const double  energy_needs)

Calculate current forage demands.

Call this only after init_today().

Returns
Forage [kgDM/ind/day] demanded by the herbivore today. This will not exceed the available forage in the patch.
Exceptions
std::logic_errorIf init_today() hasn’t been called yet.
std::invalid_argumentIf energy_needs < 0.0.

Member Data Documentation

◆ available_forage

HabitatForage Fauna::GetForageDemands::available_forage
private

◆ bodymass

double Fauna::GetForageDemands::bodymass
private

◆ diet_composition

ForageFraction Fauna::GetForageDemands::diet_composition
private

[kg/ind]

◆ digestibility

Digestibility Fauna::GetForageDemands::digestibility
private

[frac.] sum = 1.0

◆ energy_content

ForageEnergyContent Fauna::GetForageDemands::energy_content
private

[frac.]

◆ energy_needs

double Fauna::GetForageDemands::energy_needs
private

[MJ/kgDM]

◆ hft

const std::shared_ptr<const Hft> Fauna::GetForageDemands::hft
private

◆ max_intake

ForageMass Fauna::GetForageDemands::max_intake
private

[MJ/ind]

◆ sex

const Sex Fauna::GetForageDemands::sex
private

◆ today

int Fauna::GetForageDemands::today
private

[kgDM/ind/day]


The documentation for this class was generated from the following files: