piegy 2.3.2__tar.gz → 2.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {piegy-2.3.2/src/piegy.egg-info → piegy-2.3.3}/PKG-INFO +1 -1
- {piegy-2.3.2 → piegy-2.3.3}/pyproject.toml +1 -1
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/runner.c +5 -5
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/sim_funcs.c +16 -23
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/sim_funcs.h +26 -25
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/__version__.py +2 -1
- {piegy-2.3.2 → piegy-2.3.3/src/piegy.egg-info}/PKG-INFO +1 -1
- {piegy-2.3.2 → piegy-2.3.3}/LICENSE.txt +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/MANIFEST.in +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/README.md +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/setup.cfg +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/setup.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/Makefile +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/model.c +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/model.h +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/patch.c +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/C_core/patch.h +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/__init__.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/analysis.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/build_info.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/data_tools.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/figures.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/simulation.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/simulation_py.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/test_var.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/tools/__init__.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/tools/figure_tools.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/tools/file_tools.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/tools/find_C.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy/videos.py +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy.egg-info/SOURCES.txt +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy.egg-info/dependency_links.txt +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy.egg-info/requires.txt +0 -0
- {piegy-2.3.2 → piegy-2.3.3}/src/piegy.egg-info/top_level.txt +0 -0
@@ -11,14 +11,14 @@
|
|
11
11
|
int main() {
|
12
12
|
size_t N = 1;
|
13
13
|
size_t M = 100;
|
14
|
-
double maxtime =
|
14
|
+
double maxtime = 600;
|
15
15
|
double record_itv = 0.1;
|
16
|
-
size_t sim_time =
|
16
|
+
size_t sim_time = 1;
|
17
17
|
bool boundary = true;
|
18
|
-
uint32_t I_single[2] = {
|
18
|
+
uint32_t I_single[2] = {440, 220};
|
19
19
|
double X_single[4] = {-1, 4, 0, 2};
|
20
|
-
double P_single[6] = {0.5, 0.5,
|
21
|
-
int32_t print_pct =
|
20
|
+
double P_single[6] = {0.5, 0.5, 100, 100, 0.001, 0.001};
|
21
|
+
int32_t print_pct = 1;
|
22
22
|
int32_t seed = 36; // -1 for None
|
23
23
|
|
24
24
|
uint32_t I[N * M * 2];
|
@@ -303,25 +303,21 @@ static uint8_t single_test(model_t* restrict mod, uint32_t update_sum_freq, char
|
|
303
303
|
uint8_t rela_loc = signal.rela_loc;
|
304
304
|
if (rela_loc == NO_MIG) {
|
305
305
|
// if only one
|
306
|
-
|
307
|
-
|
308
|
-
sum_rates -= picked_rate;
|
306
|
+
sum_rates_by_row[si1] -= patch_rates[sij1];
|
307
|
+
sum_rates -= patch_rates[sij1];
|
309
308
|
|
310
309
|
update_pi_k(&world[sij1], &(mod->X[sij1 * 4]), &(mod->P[sij1 * 6]));
|
311
|
-
|
310
|
+
init_mig(&world[sij1], &(mod->P[sij1 * 6]));
|
312
311
|
|
313
|
-
|
314
|
-
patch_rates[sij1]
|
315
|
-
|
316
|
-
sum_rates += picked_rate;
|
312
|
+
patch_rates[sij1] = world[sij1].sum_pi_death_rates + world[sij1].sum_mig_rates;
|
313
|
+
sum_rates_by_row[si1] += patch_rates[sij1];
|
314
|
+
sum_rates += patch_rates[sij1];
|
317
315
|
} else {
|
318
316
|
// two
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
sum_rates -= picked_rate1;
|
324
|
-
sum_rates -= picked_rate2;
|
317
|
+
sum_rates_by_row[si1] -= patch_rates[sij1];
|
318
|
+
sum_rates_by_row[si2] -= patch_rates[sij2];
|
319
|
+
sum_rates -= patch_rates[sij1];
|
320
|
+
sum_rates -= patch_rates[sij2];
|
325
321
|
|
326
322
|
update_pi_k(&world[sij1], &(mod->X[sij1 * 4]), &(mod->P[sij1 * 6])); // update both patches' payoffs first
|
327
323
|
update_pi_k(&world[sij2], &(mod->X[sij2 * 4]), &(mod->P[sij2 * 6]));
|
@@ -335,15 +331,12 @@ static uint8_t single_test(model_t* restrict mod, uint32_t update_sum_freq, char
|
|
335
331
|
return SIM_OVERFLOW;
|
336
332
|
}
|
337
333
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
patch_rates[
|
343
|
-
|
344
|
-
sum_rates_by_row[si2] += picked_rate2;
|
345
|
-
sum_rates += picked_rate1;
|
346
|
-
sum_rates += picked_rate2;
|
334
|
+
patch_rates[sij1] = world[sij1].sum_pi_death_rates + world[sij1].sum_mig_rates;
|
335
|
+
patch_rates[sij2] = world[sij2].sum_pi_death_rates + world[sij2].sum_mig_rates;
|
336
|
+
sum_rates_by_row[si1] += patch_rates[sij1];
|
337
|
+
sum_rates_by_row[si2] += patch_rates[sij2];
|
338
|
+
sum_rates += patch_rates[sij1];
|
339
|
+
sum_rates += patch_rates[sij2];
|
347
340
|
}
|
348
341
|
|
349
342
|
// update neighbors of last-changed patches
|
@@ -36,7 +36,7 @@
|
|
36
36
|
#define SMALL_MAXTIME 2
|
37
37
|
#define SIM_OVERFLOW 3
|
38
38
|
|
39
|
-
// where exp(x) is considered overflow
|
39
|
+
// where 1 + exp(x) is considered overflow
|
40
40
|
// below the actual bound (709) because the large numbers will be computed with close-to-0 ones (payoff rates), so higher accuracy is needed
|
41
41
|
#define EXP_OVERFLOW_BOUND 500
|
42
42
|
|
@@ -116,19 +116,19 @@ static inline void update_pi_k(patch_t* restrict p, const double* restrict M_sta
|
|
116
116
|
|
117
117
|
double U = (double) p->U;
|
118
118
|
double V = (double) p->V;
|
119
|
-
double sum = U + V;
|
119
|
+
double sum = U + V - 1;
|
120
|
+
//double U_ratio = U / sum;
|
121
|
+
//double V_ratio = V / sum;
|
120
122
|
|
121
123
|
if (sum > 0) {
|
122
|
-
if (U
|
123
|
-
p->U_pi = (U / sum
|
124
|
-
(V / sum) * M_start[1];
|
124
|
+
if (U > 0) {
|
125
|
+
p->U_pi = (U - 1) / sum * M_start[0] + V / sum * M_start[1];
|
125
126
|
} else {
|
126
127
|
p->U_pi = 0.0;
|
127
128
|
}
|
128
129
|
|
129
|
-
if (V
|
130
|
-
p->V_pi =
|
131
|
-
(V / sum) * M_start[3];
|
130
|
+
if (V > 0) {
|
131
|
+
p->V_pi = U / sum * M_start[2] + (V - 1) / sum * M_start[3];
|
132
132
|
} else {
|
133
133
|
p->V_pi = 0.0;
|
134
134
|
}
|
@@ -141,8 +141,8 @@ static inline void update_pi_k(patch_t* restrict p, const double* restrict M_sta
|
|
141
141
|
p->pi_death_rates[0] = fabs(U * p->U_pi);
|
142
142
|
p->pi_death_rates[1] = fabs(V * p->V_pi);
|
143
143
|
|
144
|
-
p->pi_death_rates[2] = P_start[4] * U * sum;
|
145
|
-
p->pi_death_rates[3] = P_start[5] * V * sum;
|
144
|
+
p->pi_death_rates[2] = P_start[4] * U * (sum + 1);
|
145
|
+
p->pi_death_rates[3] = P_start[5] * V * (sum + 1);
|
146
146
|
|
147
147
|
p->sum_pi_death_rates = 0.0;
|
148
148
|
for (size_t i = 0; i < 4; i++) {
|
@@ -154,12 +154,14 @@ static inline void update_pi_k(patch_t* restrict p, const double* restrict M_sta
|
|
154
154
|
|
155
155
|
static inline void update_mig_just_rate(patch_t* restrict p, const double* restrict P_start) {
|
156
156
|
// update migration weight for patch p, in location loc. Only rate is updated
|
157
|
-
// used by
|
157
|
+
// used by last-changed patch, when there is only one last-changed patch
|
158
158
|
double* p_U_weight = p->U_weight;
|
159
159
|
double* p_V_weight = p->V_weight;
|
160
160
|
|
161
161
|
double mu1_U = P_start[0] * (double)p->U;
|
162
162
|
double mu2_V = P_start[1] * (double)p->V;
|
163
|
+
p->sum_mig_rates = mu1_U + mu2_V;
|
164
|
+
|
163
165
|
double mu1_U_divide_sum = mu1_U / p->sum_U_weight;
|
164
166
|
double mu2_V_divide_sum = mu2_V / p->sum_V_weight;
|
165
167
|
|
@@ -167,14 +169,13 @@ static inline void update_mig_just_rate(patch_t* restrict p, const double* restr
|
|
167
169
|
p->mig_rates[i] = mu1_U_divide_sum * p_U_weight[i];
|
168
170
|
p->mig_rates[i + 4] = mu2_V_divide_sum * p_V_weight[i];
|
169
171
|
}
|
170
|
-
p->sum_mig_rates = mu1_U + mu2_V;
|
171
172
|
}
|
172
173
|
|
173
174
|
|
174
175
|
static inline uint8_t update_mig_weight_rate(patch_t* restrict p, const double* P_start, uint8_t loc) {
|
175
176
|
// update migration weight as well as rates, in one direction
|
176
177
|
// used by neighbors of last-changed patches
|
177
|
-
// also used by last-changed patches themselve, when there
|
178
|
+
// also used by last-changed patches themselve, when there are two patch changed, to update mig rates of in each other's direction
|
178
179
|
|
179
180
|
double* p_U_weight = p->U_weight;
|
180
181
|
double* p_V_weight = p->V_weight;
|
@@ -194,20 +195,20 @@ static inline uint8_t update_mig_weight_rate(patch_t* restrict p, const double*
|
|
194
195
|
|
195
196
|
switch(loc) {
|
196
197
|
case MIG_UP:
|
197
|
-
p_U_weight[MIG_UP] = exp(w1_Upi);
|
198
|
-
p_V_weight[MIG_UP] = exp(w2_Vpi);
|
198
|
+
p_U_weight[MIG_UP] = 1 + exp(w1_Upi);
|
199
|
+
p_V_weight[MIG_UP] = 1 + exp(w2_Vpi);
|
199
200
|
break;
|
200
201
|
case MIG_DOWN:
|
201
|
-
p_U_weight[MIG_DOWN] = exp(w1_Upi);
|
202
|
-
p_V_weight[MIG_DOWN] = exp(w2_Vpi);
|
202
|
+
p_U_weight[MIG_DOWN] = 1 + exp(w1_Upi);
|
203
|
+
p_V_weight[MIG_DOWN] = 1 + exp(w2_Vpi);
|
203
204
|
break;
|
204
205
|
case MIG_LEFT:
|
205
|
-
p_U_weight[MIG_LEFT] = exp(w1_Upi);
|
206
|
-
p_V_weight[MIG_LEFT] = exp(w2_Vpi);
|
206
|
+
p_U_weight[MIG_LEFT] = 1 + exp(w1_Upi);
|
207
|
+
p_V_weight[MIG_LEFT] = 1 + exp(w2_Vpi);
|
207
208
|
break;
|
208
209
|
default:
|
209
|
-
p_U_weight[MIG_RIGHT] = exp(w1_Upi);
|
210
|
-
p_V_weight[MIG_RIGHT] = exp(w2_Vpi);
|
210
|
+
p_U_weight[MIG_RIGHT] = 1 + exp(w1_Upi);
|
211
|
+
p_V_weight[MIG_RIGHT] = 1 + exp(w2_Vpi);
|
211
212
|
break;
|
212
213
|
}
|
213
214
|
p->sum_U_weight += p_U_weight[loc];
|
@@ -254,8 +255,8 @@ static inline uint8_t init_mig(patch_t* restrict p, const double* restrict P_sta
|
|
254
255
|
if (w2_Vpi > EXP_OVERFLOW_BOUND) {
|
255
256
|
return SIM_OVERFLOW;
|
256
257
|
}
|
257
|
-
p_U_weight[i] = exp(w1_Upi);
|
258
|
-
p_V_weight[i] = exp(w2_Vpi);
|
258
|
+
p_U_weight[i] = 1 + exp(w1_Upi);
|
259
|
+
p_V_weight[i] = 1 + exp(w2_Vpi);
|
259
260
|
|
260
261
|
p->sum_U_weight += p_U_weight[i];
|
261
262
|
p->sum_V_weight += p_V_weight[i];
|
@@ -321,7 +322,7 @@ static inline void change_popu(patch_t* restrict p, uint8_t s) {
|
|
321
322
|
return;
|
322
323
|
case 2:
|
323
324
|
// Natural birth/death for U due to payoff
|
324
|
-
if (p->U_pi > 0
|
325
|
+
if (p->U_pi > 0) {
|
325
326
|
p->U += 1;
|
326
327
|
} else if (p->U > 0) {
|
327
328
|
p->U -= 1;
|
@@ -337,7 +338,7 @@ static inline void change_popu(patch_t* restrict p, uint8_t s) {
|
|
337
338
|
return;
|
338
339
|
default:
|
339
340
|
// Natural birth/death for V due to payoff
|
340
|
-
if (p->V_pi > 0
|
341
|
+
if (p->V_pi > 0) {
|
341
342
|
p->V += 1;
|
342
343
|
} else if (p->V > 0) {
|
343
344
|
p->V -= 1;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__ = '2.3.
|
1
|
+
__version__ = '2.3.3'
|
2
2
|
|
3
3
|
'''
|
4
4
|
version history:
|
@@ -39,4 +39,5 @@ version history:
|
|
39
39
|
Add video_fig function to figures module, which plots change of patch popu/payoff overtime in a 2D figure. Add auto-sorting for values passed to test_var plot functions.
|
40
40
|
2.3.2: allow play-with-self in payoff calculation. Changed migration function to e^(w*pi) (removed "1+" term).
|
41
41
|
Simplified update-migration functions, improve speed by ~10%. Add -march=native flag to Makefile.
|
42
|
+
2.3.3: fix error in calculation of migration rates.
|
42
43
|
'''
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|