-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.hpp
More file actions
247 lines (216 loc) · 6.03 KB
/
common.hpp
File metadata and controls
247 lines (216 loc) · 6.03 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#pragma once
// Common data structures for Marxan with Zones, accessed by most files/classes
#include <string>
#include <vector>
namespace marzone {
using namespace std;
// type definitions for Marxan with Zones data structures
typedef struct stringname
{
int id;
string name;
} stringname;
typedef struct zonecontribstruct
{
int zoneid;
int speciesid;
double fraction;
} zonecontribstruct;
typedef struct zonecontrib2struct
{
int zoneid;
double fraction;
} zonecontrib2struct;
typedef struct zonecontrib3struct
{
int zoneid;
int puid;
int speciesid;
double fraction;
} zonecontrib3struct;
typedef struct puzonestruct
{
int puid;
int zoneid;
} puzonestruct;
typedef struct zonespecstruct
{
double amount;
int occurrence;
} typezonespec;
typedef struct spu
{
double amount;
int clump;
int spindex;
} spu;
typedef struct spusporder
{
double amount;
int puindex;
} typepusporder;
typedef struct penaltyTerm {
double amount; // amount contributed
double cost; // cost of pu
} penaltyTerm; // used for penalty calculation sorting.
typedef struct lockedPenaltyTerm {
int lockedZoneId;
int puindex;
double amount;
} lockedPenaltyTerm;
// type definitions for original Ian Ball Marxan data structures
typedef struct spustuff
{
int id;
int status;
double xloc,yloc;
double cost;
int richness,offset;
int fPULock;
int iPULock;
int numZones;
int iPreviousStatus;
vector<double> costBreakdown;
} spustuff;
typedef struct scost
{
double total;
double connection;
int missing;
double penalty;
double cost;
double threshpen;
double shortfall;
} scost;
/* General Species information structure */
typedef struct sgenspec
{
int name; // id of species
string sname;
int type;
int targetocc;
double target;
double target2; /* Only some species need this (clumping species) */
double prop;
double spf;
} typegenspec;
// contains information about species specific to a reserve
typedef struct reservespecies {
double amount;
int occurrence;
int clumps;
} reservespecies;
typedef struct sspecies : sgenspec
{
double penalty;
int richness,offset;
double totalarea;
}sspecies;
/* Connection Structure. Fixed connection number. Should replace with link list! */
typedef struct sneighbour
{
int nbr;
double cost;
int connectionorigon;
} sneighbour;
typedef struct sconnections
{
vector<sneighbour> first;
double fixedcost;
int nbrno;
} sconnections;
struct sclumps
{
int clumpid;
double amount;
int occs;
}; /* Clump nodes for species Clump Structure */
/*** Annealing Control ****/
typedef struct sanneal
{
int Titns;
int iterations;
int Tlen;
double Tinit; /* Initial Temperature */
double Tcool; /* Cooling Factor */
double temp; /* Current Temperature */
double tempold;
int type; /* Type of annealing. 0 = none, 1 = fixed, 2 = adaptive */
double sigma; /*Used in adaptive annealing */
double sum; /* Used in adaptive annealing */
double sum2; /* used in adaptive annealing */
} sanneal; /* Annealing Control handler */
/* Input File Name Structure */
typedef struct sfname
{
string inputdir;
string outputdir;
string specname;
string puname;
string puvsprname;
string matrixspordername;
string connectionname;
string blockdefname;
string zonesname;
string costsname;
string zonecontribname;
string zonecontrib2name;
string zonecontrib3name;
string zonetargetname;
string zonetarget2name;
string zonecostname;
string pulockname;
string puzonename;
string relconnectioncostname;
string penaltyname;
string connectivityfilesname;
string savename; // generic savename prefix
int savebest;
int saverun;
int savesum;
int savesen;
int savespecies;
int savesumsoln;
int savelog;
int savesnapsteps;
int savesnapchanges;
int savesnapfrequency;
int savepenalty;
int savetotalareas;
int savesolutionsmatrix;
int solutionsmatrixheaders;
int saveannealingtrace;
int annealingtracerows;
int suppressannealzones;
int saveitimptrace;
int itimptracerows;
int savespeciesdata;
int savezoneconnectivitysum;
} sfname;
// Contains run options about which algorithms to run, as well as other run constants
typedef struct srunoptions
{
// Algorithms to run
int AnnealingOn;
int HeuristicOn;
int ItImpOn;
bool PopulationAnnealingOn; // whether population annealing is run intead of simluated annealing.
// Algorithm settings
int heurotype;
int clumptype;
int itimptype;
// Run constants
double prop;
long int iseed;
double blm; // boundary length modifier
double misslevel;
double costthresh;
double tpf1, tpf2;
int repeats, runopts, verbose;
} srunoptions;
typedef struct ZoneName
{
string name;
uint64_t index;
} ZoneName;
} // namespace marzone