File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MRR_Data Class Reference

Class for running mark-release-recapture experiments. More...

#include <Hare_All.h>

Public Member Functions

 MRR_Data ()
 
void AddEntry (int a_RefNum)
 
void OutputToFile ()
 
void IncTrapping ()
 

Protected Attributes

int m_currenttrapping
 
vector< MRR_Entrym_Entries
 

Detailed Description

Class for running mark-release-recapture experiments.

Constructor & Destructor Documentation

◆ MRR_Data()

MRR_Data::MRR_Data ( )

Constructor for MRR_Data

3999  {
4000  m_currenttrapping = 0;
4001  m_Entries.resize(0);
4002 }

References m_currenttrapping, and m_Entries.

Member Function Documentation

◆ AddEntry()

void MRR_Data::AddEntry ( int  a_RefNum)

Adds a new entry to the Mark Release Recapture data vector

4007  {
4008  // First do we have this RefNum in the vector?
4009  auto current = m_Entries.begin();
4010  auto found = m_Entries.end();
4011  bool flag = false;
4012  while (current != found)
4013  {
4014  if ((*current).m_HareRefNum == a_RefNum)
4015  {
4016  found = current;
4017  flag = true;
4018  }
4019  else ++current;
4020  }
4021  MRR_Entry mre;
4022  if (flag)
4023  {
4024  // Get the entry out to mre
4025  // mre=(*found);
4026  if (m_currenttrapping < 32)
4027  {
4028  unsigned int mask = 0x01 << m_currenttrapping;
4029  (*found).m_trappings1 += mask;
4030  }
4031  else
4032  {
4033  unsigned int mask = 0x01 << (m_currenttrapping - 32);
4034  (*found).m_trappings2 += mask;
4035  }
4036  }
4037  else
4038  {
4039  mre.m_HareRefNum = a_RefNum;
4040  mre.m_trappings1 = 0;
4041  mre.m_trappings2 = 0;
4042  if (m_currenttrapping < 32)
4043  {
4044  unsigned int mask = 0x01 << m_currenttrapping;
4045  mre.m_trappings1 += mask;
4046  }
4047  else
4048  {
4049  unsigned int mask = 0x01 << (m_currenttrapping - 32);
4050  mre.m_trappings2 += mask;
4051  }
4052  m_Entries.insert(m_Entries.begin(), mre);
4053  // Put at the beginning because this is the one most likely found next time
4054  }
4055 }

References m_currenttrapping, m_Entries, MRR_Entry::m_HareRefNum, MRR_Entry::m_trappings1, and MRR_Entry::m_trappings2.

Referenced by THare_Population_Manager::MRROutputs().

◆ IncTrapping()

void MRR_Data::IncTrapping ( )
inline

◆ OutputToFile()

void MRR_Data::OutputToFile ( )

Produces a file output for the Mark Release Recapture data

4061  {
4062  FILE* MRROut = fopen("MRR_Hare.txt", "w");
4063  if (!MRROut)
4064  {
4065  // something wrong if the program gets to here
4066  g_land->Warn("THare_Population_Manager::MRROutputs - MRR_Hare.txt can't be opened", nullptr);
4067  exit(1);
4068  }
4069  auto current = m_Entries.begin();
4070  for (auto i = m_Entries.begin(); i < m_Entries.end(); ++i)
4071  {
4072  MRR_Entry mre = *i;
4073  unsigned int mask = 0x01;
4074  for (int j = 0; j < 32; j++)
4075  {
4076  if ((mask & mre.m_trappings1) > 0) { fprintf(MRROut, "%d\t", 1); }
4077  else fprintf(MRROut, "%d\t", 0);
4078  mask = mask << 1;
4079  }
4080  mask = 0;
4081  for (int j = 0; j < 32; j++)
4082  {
4083  if ((mask & mre.m_trappings2) > 0) { fprintf(MRROut, "%d\t", 1); }
4084  else fprintf(MRROut, "%d\t", 0);
4085  mask = mask << 1;
4086  }
4087  fprintf(MRROut, "%d\n", mre.m_HareRefNum);
4088  }
4089  fclose(MRROut);
4090 }

References g_land, m_Entries, MRR_Entry::m_HareRefNum, MRR_Entry::m_trappings1, MRR_Entry::m_trappings2, and Landscape::Warn().

Referenced by THare_Population_Manager::MRROutputs().

Member Data Documentation

◆ m_currenttrapping

int MRR_Data::m_currenttrapping
protected

Referenced by AddEntry(), IncTrapping(), and MRR_Data().

◆ m_Entries

vector<MRR_Entry> MRR_Data::m_Entries
protected

Referenced by AddEntry(), MRR_Data(), and OutputToFile().


The documentation for this class was generated from the following files:
g_land
Landscape * g_land
Definition: skylarks_all.cpp:44
MRR_Entry::m_trappings2
int m_trappings2
Definition: Hare_All.h:112
MRR_Data::m_Entries
vector< MRR_Entry > m_Entries
Definition: Hare_All.h:129
MRR_Entry::m_HareRefNum
int m_HareRefNum
Definition: Hare_All.h:110
MRR_Data::m_currenttrapping
int m_currenttrapping
Definition: Hare_All.h:128
MRR_Entry
Data entry for mark release recapture data MRR_Data.
Definition: Hare_All.h:109
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Wrapper for the g_msg Warn function.
Definition: Landscape.h:2250
MRR_Entry::m_trappings1
int m_trappings1
Definition: Hare_All.h:111