Loading [MathJax]/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
OsmiaPolygonEntry Class Reference

Is the list of nests held by a polygon and associated density controls. More...

#include <Osmia_Population_Manager.h>

Public Member Functions

 OsmiaPolygonEntry ()
 The constructor for OsmiaPolygonEntry. More...
 
 OsmiaPolygonEntry (int a_index, int a_area)
 
 ~OsmiaPolygonEntry ()
 The destructor for OsmiaPolygonEntry. More...
 
bool IsOsmiaNestPossible ()
 Test to see if a nest is found. More...
 
void ReleaseOsmiaNest (Osmia_Nest *a_nest)
 Test release an Osmia nest that is no longer used. More...
 
void UpdateOsmiaNesting ()
 Recalculate the nest finding probability. More...
 
void IncOsmiaNesting (Osmia_Nest *a_nest)
 Add an occupied nest. More...
 
void SetMaxOsmiaNests (double a_noNests)
 Sets the max number of Osmia nests for this LE. More...
 
void SetAreaAttribute (int a_area)
 Sets the area attrribute. More...
 
void SetIndexAttribute (int a_index)
 Sets the area attrribute. More...
 
int GetNoNests ()
 Returns the number of current nests. More...
 
int GetMaxNoNests ()
 Returns the max number of nests. More...
 
bool SanityCheck ()
 Returns the number of current nests. More...
 
bool SanityCheck2 ()
 Checks for zero cell nests. More...
 

Protected Attributes

std::forward_list< Osmia_Nest * > m_NestList
 
double m_OsmiaNestProb
 to record the chance of osmia nesting More...
 
double m_MaxOsmiaNests
 to record the number of possible osmia nests More...
 
int m_CurrentOsmiaNests
 to record the number of actual osmia nests (only used for speed - it is the same as the size of the vector m_NestList More...
 
int m_Area
 The polygon area. More...
 
int m_Polyindex
 The polygon reference used by the Landscape and Osmia_Nest_Manager. More...
 

Detailed Description

Is the list of nests held by a polygon and associated density controls.

Constructor & Destructor Documentation

◆ OsmiaPolygonEntry() [1/2]

OsmiaPolygonEntry::OsmiaPolygonEntry ( )
inline

The constructor for OsmiaPolygonEntry.

206  {
208  m_MaxOsmiaNests = 0;
209  m_OsmiaNestProb = 0;
210  m_Polyindex = -1;
211  m_Area = -1;
212  }

References m_Area, m_CurrentOsmiaNests, m_MaxOsmiaNests, m_OsmiaNestProb, and m_Polyindex.

◆ OsmiaPolygonEntry() [2/2]

OsmiaPolygonEntry::OsmiaPolygonEntry ( int  a_index,
int  a_area 
)
inline
214  {
216  m_MaxOsmiaNests = 0;
217  m_OsmiaNestProb = 0;
218  m_Polyindex = a_index;
219  m_Area = a_area;
220  }

References m_Area, m_CurrentOsmiaNests, m_MaxOsmiaNests, m_OsmiaNestProb, and m_Polyindex.

◆ ~OsmiaPolygonEntry()

OsmiaPolygonEntry::~OsmiaPolygonEntry ( )
inline

The destructor for OsmiaPolygonEntry.

224  {
225  //for (std::vector<Osmia_Nest*>::iterator it = m_NestList.begin(); it != m_NestList.end(); ++it) {
226  for(auto it : m_NestList){
227  if(it!=NULL)
228  delete it;
229  }
230  m_NestList.clear();
231  }

References m_NestList.

Member Function Documentation

◆ GetMaxNoNests()

int OsmiaPolygonEntry::GetMaxNoNests ( )
inline

Returns the max number of nests.

283 { return m_MaxOsmiaNests; }

References m_MaxOsmiaNests.

◆ GetNoNests()

int OsmiaPolygonEntry::GetNoNests ( )
inline

Returns the number of current nests.

281 { return m_CurrentOsmiaNests; }

References m_CurrentOsmiaNests.

◆ IncOsmiaNesting()

void OsmiaPolygonEntry::IncOsmiaNesting ( Osmia_Nest a_nest)
inline

Add an occupied nest.

264  {
265  m_NestList.push_front(a_nest);
267  }

References m_CurrentOsmiaNests, and m_NestList.

◆ IsOsmiaNestPossible()

bool OsmiaPolygonEntry::IsOsmiaNestPossible ( )
inline

Test to see if a nest is found.

233  {
235  return false;
236  }

References g_rand_uni_fnc(), m_CurrentOsmiaNests, m_MaxOsmiaNests, and m_OsmiaNestProb.

◆ ReleaseOsmiaNest()

void OsmiaPolygonEntry::ReleaseOsmiaNest ( Osmia_Nest a_nest)
inline

Test release an Osmia nest that is no longer used.

238  {
240  auto prev_point = m_NestList.before_begin();
241  for (auto it = m_NestList.begin(); it!=m_NestList.end(); ++it)
242  {
243  if((*it) == a_nest)
244  {
245  //cout << "Osmia nest released" << endl;
246  m_NestList.erase_after(prev_point);
247  delete a_nest;
248  break;
249  }
250 
251  prev_point=it;
252  }
253  }

References m_CurrentOsmiaNests, and m_NestList.

◆ SanityCheck()

bool OsmiaPolygonEntry::SanityCheck ( )
inline

Returns the number of current nests.

285 { return m_CurrentOsmiaNests == std::distance(std::begin(m_NestList), std::end(m_NestList)); }

References m_CurrentOsmiaNests, and m_NestList.

◆ SanityCheck2()

bool OsmiaPolygonEntry::SanityCheck2 ( )
inline

Checks for zero cell nests.

287  {
288  for (auto it = m_NestList.begin(); it!=m_NestList.end(); ++it)
289  {
290  if((*it)->ZeroCells())
291  {
292  return false;
293  }
294  }
295 
296  return true;
297  }

References m_NestList.

◆ SetAreaAttribute()

void OsmiaPolygonEntry::SetAreaAttribute ( int  a_area)
inline

Sets the area attrribute.

277 { m_Area = a_area; }

References m_Area.

Referenced by Osmia_Nest_Manager::InitOsmiaBeeNesting().

◆ SetIndexAttribute()

void OsmiaPolygonEntry::SetIndexAttribute ( int  a_index)
inline

Sets the area attrribute.

279 { m_Polyindex = a_index; }

References m_Polyindex.

Referenced by Osmia_Nest_Manager::InitOsmiaBeeNesting().

◆ SetMaxOsmiaNests()

void OsmiaPolygonEntry::SetMaxOsmiaNests ( double  a_noNests)
inline

Sets the max number of Osmia nests for this LE.

270  {
271  double maxnests = a_noNests * m_Area;
272  if (maxnests> 2147000000 ) maxnests= 2147000000;
273  m_MaxOsmiaNests = int(maxnests);
274  if (m_MaxOsmiaNests < 1) m_MaxOsmiaNests = 0;
275  }

References m_Area, and m_MaxOsmiaNests.

◆ UpdateOsmiaNesting()

void OsmiaPolygonEntry::UpdateOsmiaNesting ( )
inline

Recalculate the nest finding probability.

256  {
257  if (m_MaxOsmiaNests <= 0) m_OsmiaNestProb = 0.0;
258  else {
260  }
261  }

References m_CurrentOsmiaNests, m_MaxOsmiaNests, and m_OsmiaNestProb.

Member Data Documentation

◆ m_Area

int OsmiaPolygonEntry::m_Area
protected

The polygon area.

Referenced by OsmiaPolygonEntry(), SetAreaAttribute(), and SetMaxOsmiaNests().

◆ m_CurrentOsmiaNests

int OsmiaPolygonEntry::m_CurrentOsmiaNests
protected

to record the number of actual osmia nests (only used for speed - it is the same as the size of the vector m_NestList

Referenced by GetNoNests(), IncOsmiaNesting(), IsOsmiaNestPossible(), OsmiaPolygonEntry(), ReleaseOsmiaNest(), SanityCheck(), and UpdateOsmiaNesting().

◆ m_MaxOsmiaNests

double OsmiaPolygonEntry::m_MaxOsmiaNests
protected

to record the number of possible osmia nests

Referenced by GetMaxNoNests(), IsOsmiaNestPossible(), OsmiaPolygonEntry(), SetMaxOsmiaNests(), and UpdateOsmiaNesting().

◆ m_NestList

std::forward_list<Osmia_Nest*> OsmiaPolygonEntry::m_NestList
protected

◆ m_OsmiaNestProb

double OsmiaPolygonEntry::m_OsmiaNestProb
protected

to record the chance of osmia nesting

Referenced by IsOsmiaNestPossible(), OsmiaPolygonEntry(), and UpdateOsmiaNesting().

◆ m_Polyindex

int OsmiaPolygonEntry::m_Polyindex
protected

The polygon reference used by the Landscape and Osmia_Nest_Manager.

Referenced by OsmiaPolygonEntry(), and SetIndexAttribute().


The documentation for this class was generated from the following file:
g_rand_uni_fnc
double g_rand_uni_fnc()
Definition: ALMaSS_Random.cpp:56
OsmiaPolygonEntry::m_MaxOsmiaNests
double m_MaxOsmiaNests
to record the number of possible osmia nests
Definition: Osmia_Population_Manager.h:196
OsmiaPolygonEntry::m_CurrentOsmiaNests
int m_CurrentOsmiaNests
to record the number of actual osmia nests (only used for speed - it is the same as the size of the v...
Definition: Osmia_Population_Manager.h:198
OsmiaPolygonEntry::m_OsmiaNestProb
double m_OsmiaNestProb
to record the chance of osmia nesting
Definition: Osmia_Population_Manager.h:194
OsmiaPolygonEntry::m_Polyindex
int m_Polyindex
The polygon reference used by the Landscape and Osmia_Nest_Manager.
Definition: Osmia_Population_Manager.h:202
OsmiaPolygonEntry::m_Area
int m_Area
The polygon area.
Definition: Osmia_Population_Manager.h:200
OsmiaPolygonEntry::m_NestList
std::forward_list< Osmia_Nest * > m_NestList
Definition: Osmia_Population_Manager.h:192