-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.h
174 lines (147 loc) · 5.23 KB
/
Cell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*----------------------------------------------------------------------------
*
* Copyright (C) 2020 Greta Bocedi, Stephen C.F. Palmer, Justin M.J. Travis, Anne-Kathleen Malchow, Damaris Zurell
*
* This file is part of RangeShifter.
*
* RangeShifter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RangeShifter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RangeShifter. If not, see <https://www.gnu.org/licenses/>.
*
--------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
RangeShifter v2.0 Cell
Implements the following classes:
Cell - Landscape cell
DistCell - Initial species distribution cell
For full details of RangeShifter, please see:
Bocedi G., Palmer S.C.F., Pe’er G., Heikkinen R.K., Matsinos Y.G., Watts K.
and Travis J.M.J. (2014). RangeShifter: a platform for modelling spatial
eco-evolutionary dynamics and species’ responses to environmental changes.
Methods in Ecology and Evolution, 5, 388-396. doi: 10.1111/2041-210X.12162
Authors: Greta Bocedi & Steve Palmer, University of Aberdeen
Last updated: 14 January 2021 by Steve Palmer
------------------------------------------------------------------------------*/
#ifndef CellH
#define CellH
#include <vector>
using namespace std;
#include "Parameters.h"
//---------------------------------------------------------------------------
struct array3x3f { float cell[3][3]; }; // neighbourhood cell array (SMS)
struct smscosts { int cost; array3x3f *effcosts; }; // cell costs for SMS
// Landscape cell
class Cell{
public:
Cell( // Constructor for habitat codes
int, // x co-ordinate
int, // y co-ordinate
intptr, // pointer (cast as integer) to the Patch to which Cell belongs
int // habitat index number
);
Cell( // Constructor for habitat % cover or habitat quality
int, // x co-ordinate
int, // y co-ordinate
intptr, // pointer (cast as integer) to the Patch to which Cell belongs
float // habitat proportion or cell quality score
);
~Cell();
void setHabIndex(
short // habitat index number
);
void changeHabIndex(
short, // landscape change number
short // habitat index number
);
int getHabIndex(
int // landscape change number
);
int nHabitats(void);
void setHabitat(
float // habitat proportions or cell quality score
);
float getHabitat( // Get habitat proportion / quality score
int // habitat index number / landscape change number
);
void setPatch(
intptr // pointer (cast as integer) to the Patch to which Cell belongs
);
intptr getPatch(void);
locn getLocn(void);
void setEnvDev(
float // local environmental deviation
);
float getEnvDev(void);
void setEnvVal(
float // environmental value
);
float getEnvVal(void);
void updateEps( // Update local environmental stochasticity (epsilon)
float, // autocorrelation coefficient
float // random adjustment
);
float getEps(void);
void setCost(
int // cost value for SMS
);
int getCost(void);
void resetCost(void);
array3x3f getEffCosts(void);
void setEffCosts(
array3x3f // 3 x 3 array of effective costs for neighbouring cells
);
void resetEffCosts(void); // Reset the effective cost, but not the cost, of the cell
void resetVisits(void);
void incrVisits(void);
unsigned long int getVisits(void);
private:
int x,y; // cell co-ordinates
intptr pPatch; // pointer (cast as integer) to the Patch to which cell belongs
// NOTE: THE FOLLOWING ENVIRONMENTAL VARIABLES COULD BE COMBINED IN A STRUCTURE
// AND ACCESSED BY A POINTER ...
float envVal; // environmental value, representing one of:
// gradient in K, r or extinction probability
float envDev; // local environmental deviation (static, in range -1.0 to +1.0)
float eps; // local environmental stochasticity (epsilon) (dynamic, from N(0,std))
unsigned long int visits; // no. of times square is visited by dispersers
smscosts *smsData;
vector <short> habIxx; // habitat indices (rasterType=0)
// NB initially, habitat codes are loaded, then converted to index nos.
// once landscape is fully loaded
vector <float> habitats; // habitat proportions (rasterType=1) or quality (rasterType=2)
};
//---------------------------------------------------------------------------
// Initial species distribution cell
class DistCell{
public:
DistCell(
int, // x co-ordinate
int // y co-ordinate
);
~DistCell();
void setCell(
bool // TRUE if cell is to be initialised, FALSE if not
);
bool toInitialise(
locn // structure holding co-ordinates of cell
);
bool selected(void);
locn getLocn(void);
private:
int x,y; // cell co-ordinates
bool initialise; // cell is to be initialised
};
#if RSDEBUG
extern void DebugGUI(string);
#endif
//---------------------------------------------------------------------------
#endif