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

Function object to simulate one day in one habitat. More...

#include <simulate_day.h>

Public Member Functions

 SimulateDay (const int day_of_year, SimulationUnit &simulation_unit, const FeedHerbivores &feed_herbivores)
 Constructor. More...
 
void operator() (const bool do_herbivores, const bool establish_as_needed)
 Simulate one day. More...
 

Private Member Functions

void create_offspring ()
 Create the offspring counted in total_offspring. More...
 
void simulate_herbivores ()
 Iterate over all herbivores and let them do their simulation. More...
 

Static Private Member Functions

static HabitatForage get_corrected_forage (const Habitat &)
 Read available forage and set it to zero if it is very low. More...
 
static std::map< PopulationInterface *, HerbivoreVectorget_herbivores (const PopulationList &)
 Get references to all herbivores in the list of populations. More...
 

Private Attributes

const int day_of_year
 Julian day of year (0 = Jan 1st). More...
 
const HabitatEnvironment environment
 The current abiotic conditions. More...
 
const FeedHerbivoresfeed_herbivores
 Function object doing the feeding. More...
 
std::map< PopulationInterface *, HerbivoreVectorherbivores
 Pointers to all herbivores in the habitat. More...
 
std::map< PopulationInterface *, double > total_offspring
 All offspring for each population today [ind/km²]. More...
 
SimulationUnitsimulation_unit
 Reference to the simulation unit. More...
 

Detailed Description

Function object to simulate one day in one habitat.

This class is very high in the framework hierarchy and should therefore be kept as slim as possible. It should only call well encapsulated other functions and classes.

Constructor & Destructor Documentation

◆ SimulateDay()

SimulateDay::SimulateDay ( const int  day_of_year,
SimulationUnit simulation_unit,
const FeedHerbivores feed_herbivores 
)

Constructor.

Parameters
day_of_yearCurrent day of year (0 = Jan 1st)
simulation_unitThe habitat and herbivores to simulate.
feed_herbivoresFunction object used to give forage to the herbivores.
Exceptions
std::invalid_argumentIf day_of_year not in [0,364].

Member Function Documentation

◆ create_offspring()

void SimulateDay::create_offspring ( )
private

Create the offspring counted in total_offspring.

For each HFT, let the PopulationInterface object create herbivores. These new herbivores will be counted in the output next simulation cycle.

◆ get_corrected_forage()

HabitatForage SimulateDay::get_corrected_forage ( const Habitat habitat)
staticprivate

Read available forage and set it to zero if it is very low.

Set any marginally small values to zero in order to avoid errors caused by rounding inaccuracy. This is done here and not in Habitat for the sake of decoupling: The Habitat shouldn’t be concerned with the herbivore feeding.

◆ get_herbivores()

std::map< PopulationInterface *, HerbivoreVector > SimulateDay::get_herbivores ( const PopulationList pop_list)
staticprivate

Get references to all herbivores in the list of populations.

◆ operator()()

void SimulateDay::operator() ( const bool  do_herbivores,
const bool  establish_as_needed 
)

Simulate one day.

  1. Initialize habitat.
  2. Simulate herbivores.
  3. Feed herbivores.
  4. Create potential offspring.
  5. Delete dead herbivores.
Parameters
do_herbivoresWhether the herbivore objects shall be simulated. Otherwise only the habitat is initialized.
establish_as_neededWhether to (re-)establish herbivores in those populations that are empty. This only has effect if also do_herbivores==true

◆ simulate_herbivores()

void SimulateDay::simulate_herbivores ( )
private

Iterate over all herbivores and let them do their simulation.

Call HerbivoreInterface::simulate_day() in each alive herbivore object. Also collect offspring.

Member Data Documentation

◆ day_of_year

const int Fauna::SimulateDay::day_of_year
private

Julian day of year (0 = Jan 1st).

◆ environment

const HabitatEnvironment Fauna::SimulateDay::environment
private

The current abiotic conditions.

◆ feed_herbivores

const FeedHerbivores& Fauna::SimulateDay::feed_herbivores
private

Function object doing the feeding.

◆ herbivores

std::map<PopulationInterface*, HerbivoreVector> Fauna::SimulateDay::herbivores
private

Pointers to all herbivores in the habitat.

◆ simulation_unit

SimulationUnit& Fauna::SimulateDay::simulation_unit
private

Reference to the simulation unit.

◆ total_offspring

std::map<PopulationInterface*, double> Fauna::SimulateDay::total_offspring
private

All offspring for each population today [ind/km²].


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