piegy 1.1.5__py3-none-any.whl → 1.1.6__py3-none-any.whl
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/__version__.py +1 -0
- piegy/analysis.py +3 -3
- piegy/data_tools.py +4 -4
- piegy/figures.py +27 -27
- piegy/simulation.py +37 -37
- piegy/test_var.py +8 -8
- {piegy-1.1.5.dist-info → piegy-1.1.6.dist-info}/METADATA +1 -1
- piegy-1.1.6.dist-info/RECORD +16 -0
- piegy-1.1.5.dist-info/RECORD +0 -16
- {piegy-1.1.5.dist-info → piegy-1.1.6.dist-info}/WHEEL +0 -0
- {piegy-1.1.5.dist-info → piegy-1.1.6.dist-info}/licenses/LICENSE.txt +0 -0
- {piegy-1.1.5.dist-info → piegy-1.1.6.dist-info}/top_level.txt +0 -0
piegy/__version__.py
CHANGED
@@ -19,5 +19,6 @@ version history:
|
|
19
19
|
1.1.3: update README.
|
20
20
|
1.1.4: changed name: ``model`` module to ``simulation``, and ``model.simulation`` class to ``simulation.model``. Bug fix in videos.
|
21
21
|
1.1.5: update README.
|
22
|
+
1.1.6: change name of variables in model class -- for compatability with the new C core. 1.1.6 is the last verion of v1. From v2 on, the piegy package has C core.
|
22
23
|
|
23
24
|
'''
|
piegy/analysis.py
CHANGED
@@ -183,7 +183,7 @@ def combine_sim(mod1, mod2):
|
|
183
183
|
|
184
184
|
Returns:
|
185
185
|
|
186
|
-
- sim3: a new model object whose U, V,
|
186
|
+
- sim3: a new model object whose U, V, Upi, Vpi are weighted averages of mod1 and mod2
|
187
187
|
(weighted by sim_time).
|
188
188
|
sim3.print_pct is set to mod1's, seed set to None, sim_time set to sum of mod1's and mod2's. All other params same as mod1
|
189
189
|
'''
|
@@ -213,8 +213,8 @@ def combine_sim(mod1, mod2):
|
|
213
213
|
for k in range(sim3.max_record):
|
214
214
|
sim3.U[i][j][k] = (mod1.U[i][j][k] * mod1.sim_time + mod2.U[i][j][k] * mod2.sim_time) / combined_sim_time
|
215
215
|
sim3.V[i][j][k] = (mod1.V[i][j][k] * mod1.sim_time + mod2.V[i][j][k] * mod2.sim_time) / combined_sim_time
|
216
|
-
sim3.
|
217
|
-
sim3.
|
216
|
+
sim3.Upi[i][j][k] = (mod1.Upi[i][j][k] * mod1.sim_time + mod2.Upi[i][j][k] * mod2.sim_time) / combined_sim_time
|
217
|
+
sim3.Vpi[i][j][k] = (mod1.Vpi[i][j][k] * mod1.sim_time + mod2.Vpi[i][j][k] * mod2.sim_time) / combined_sim_time
|
218
218
|
|
219
219
|
return sim3
|
220
220
|
|
piegy/data_tools.py
CHANGED
@@ -64,9 +64,9 @@ def save_data(mod, dirs = '', print_msg = True):
|
|
64
64
|
outputs.append(mod.compress_itv)
|
65
65
|
outputs.append(mod.U.tolist())
|
66
66
|
outputs.append(mod.V.tolist())
|
67
|
-
outputs.append(mod.
|
68
|
-
outputs.append(mod.
|
69
|
-
# H&
|
67
|
+
outputs.append(mod.Upi.tolist())
|
68
|
+
outputs.append(mod.Vpi.tolist())
|
69
|
+
# H&Vpi_total are not saved, will be calculated when reading the data
|
70
70
|
data.append(outputs)
|
71
71
|
|
72
72
|
data_json = json.dumps(data)
|
@@ -119,7 +119,7 @@ def read_data(dirs):
|
|
119
119
|
# outputs
|
120
120
|
try:
|
121
121
|
mod.set_data(data_empty = False, max_record = data[2][0], compress_itv = data[2][1],
|
122
|
-
U = data[2][2], V = data[2][3],
|
122
|
+
U = data[2][2], V = data[2][3], Upi = data[2][4], Vpi = data[2][5])
|
123
123
|
except:
|
124
124
|
raise ValueError('Invalid model results saved in data')
|
125
125
|
|
piegy/figures.py
CHANGED
@@ -14,13 +14,13 @@ Plots for population:
|
|
14
14
|
|
15
15
|
|
16
16
|
Plots for payoff:
|
17
|
-
- pi_heatmap: Used for 2D space, plot distribution of
|
17
|
+
- pi_heatmap: Used for 2D space, plot distribution of Upi & Vpiwithin a specified time interval.
|
18
18
|
Average payoff over that interval is taken.
|
19
19
|
- pi_bar: Used for 1D space, counterpart of pi_heatmap.
|
20
|
-
Plot average distribution of
|
21
|
-
- pi_dyna: Plot change of total
|
22
|
-
- pi_hist: Make a histogram of
|
23
|
-
- pi_std: Plot change of standard deviation of
|
20
|
+
Plot average distribution of Upi & Vpiin a specified time interval in a bar plot.
|
21
|
+
- pi_dyna: Plot change of total Upi, Vpiovertime.
|
22
|
+
- pi_hist: Make a histogram of Upi, Vpiin a specified time interval.
|
23
|
+
- pi_std: Plot change of standard deviation of Upi, Vpiover time.
|
24
24
|
|
25
25
|
|
26
26
|
Popu-payoff correlation:
|
@@ -329,15 +329,15 @@ def pi_heatmap(mod, ax_U = None, ax_V = None, U_color = 'BuPu', V_color = 'YlGn'
|
|
329
329
|
start_index = int(mod.max_record * start)
|
330
330
|
end_index = int(mod.max_record * end)
|
331
331
|
|
332
|
-
|
333
|
-
V_pi_ave = figure_t.ave_interval(mod.
|
332
|
+
Upi_ave = figure_t.ave_interval(mod.Upi, start_index, end_index)
|
333
|
+
V_pi_ave = figure_t.ave_interval(mod.Vpi, start_index, end_index)
|
334
334
|
|
335
335
|
U_title = figure_t.gen_title('Payoff ' + r'$p_U$', start, end)
|
336
|
-
U_text = figure_t.gen_text(np.mean(
|
336
|
+
U_text = figure_t.gen_text(np.mean(Upi_ave), np.std(Upi_ave))
|
337
337
|
V_title = figure_t.gen_title('Payoff ' + r'$p_V$', start, end)
|
338
338
|
V_text = figure_t.gen_text(np.mean(V_pi_ave), np.std(V_pi_ave))
|
339
339
|
|
340
|
-
ax_U = figure_t.heatmap(
|
340
|
+
ax_U = figure_t.heatmap(Upi_ave, ax_U, U_color, annot, fmt, U_title, U_text)
|
341
341
|
ax_V = figure_t.heatmap(V_pi_ave, ax_V, V_color, annot, fmt, V_title, V_text)
|
342
342
|
|
343
343
|
return ax_U, ax_V
|
@@ -357,15 +357,15 @@ def pi_bar(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowg
|
|
357
357
|
start_index = int(mod.max_record * start)
|
358
358
|
end_index = int(mod.max_record * end)
|
359
359
|
|
360
|
-
|
361
|
-
V_pi_ave = figure_t.ave_interval_1D(mod.
|
360
|
+
Upi_ave = figure_t.ave_interval_1D(mod.Upi, start_index, end_index)
|
361
|
+
V_pi_ave = figure_t.ave_interval_1D(mod.Vpi, start_index, end_index)
|
362
362
|
|
363
363
|
U_title = figure_t.gen_title(r'$p_U$', start, end)
|
364
|
-
U_text = figure_t.gen_text(np.mean(
|
364
|
+
U_text = figure_t.gen_text(np.mean(Upi_ave), np.std(Upi_ave))
|
365
365
|
V_title = figure_t.gen_title(r'$p_V$', start, end)
|
366
366
|
V_text = figure_t.gen_text(np.mean(V_pi_ave), np.std(V_pi_ave))
|
367
367
|
|
368
|
-
ax_U = figure_t.bar(
|
368
|
+
ax_U = figure_t.bar(Upi_ave, ax_U, U_color, 'Patches', 'Payoff ' + r'$p_U$', U_title, U_text)
|
369
369
|
ax_V = figure_t.bar(V_pi_ave, ax_V, V_color, 'Patches', 'Payoff ' + r'$p_V$', V_title, V_text)
|
370
370
|
|
371
371
|
return ax_U, ax_V
|
@@ -389,8 +389,8 @@ def pi_dyna(mod, ax = None, interval = 20, grid = True):
|
|
389
389
|
interval_num = int(mod.max_record / interval)
|
390
390
|
|
391
391
|
for i in range(interval_num):
|
392
|
-
U_ave = figure_t.ave_interval(mod.
|
393
|
-
V_ave = figure_t.ave_interval(mod.
|
392
|
+
U_ave = figure_t.ave_interval(mod.Upi, i * interval, (i + 1) * interval)
|
393
|
+
V_ave = figure_t.ave_interval(mod.Vpi, i * interval, (i + 1) * interval)
|
394
394
|
|
395
395
|
U_curve.append(np.sum(U_ave))
|
396
396
|
V_curve.append(np.sum(V_ave))
|
@@ -427,8 +427,8 @@ def pi_hist(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellow
|
|
427
427
|
start_index = int(start * mod.max_record)
|
428
428
|
end_index = int(end * mod.max_record)
|
429
429
|
|
430
|
-
|
431
|
-
V_pi_ave = figure_t.ave_interval_1D(mod.
|
430
|
+
Upi_ave = figure_t.ave_interval_1D(mod.Upi, start_index, end_index)
|
431
|
+
V_pi_ave = figure_t.ave_interval_1D(mod.Vpi, start_index, end_index)
|
432
432
|
|
433
433
|
#### plot ####
|
434
434
|
|
@@ -436,7 +436,7 @@ def pi_hist(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellow
|
|
436
436
|
_, ax_U = plt.subplots()
|
437
437
|
ax_U.set_xlabel('Payoff ' + r'$p_U$')
|
438
438
|
ax_U.set_ylabel('Density')
|
439
|
-
ax_U.hist(
|
439
|
+
ax_U.hist(Upi_ave, color = U_color, density = True)
|
440
440
|
ax_U.set_title(figure_t.gen_title('Payoff ' + r'$p_U$' + ' Hist', start, end))
|
441
441
|
|
442
442
|
if ax_V == None:
|
@@ -463,23 +463,23 @@ def pi_std(mod, ax = None, interval = 20, grid = True):
|
|
463
463
|
interval = figure_t.scale_interval(interval, mod.compress_itv)
|
464
464
|
interval_num = int(mod.max_record / interval)
|
465
465
|
|
466
|
-
|
466
|
+
Upi_std = []
|
467
467
|
V_pi_std = []
|
468
468
|
|
469
469
|
for i in range(interval_num):
|
470
|
-
|
471
|
-
V_pi_ave = figure_t.ave_interval(mod.
|
470
|
+
Upi_ave = figure_t.ave_interval(mod.Upi, i * interval, (i + 1) * interval)
|
471
|
+
V_pi_ave = figure_t.ave_interval(mod.Vpi, i * interval, (i + 1) * interval)
|
472
472
|
|
473
|
-
|
473
|
+
Upi_std.append(np.std(Upi_ave))
|
474
474
|
V_pi_std.append(np.std(V_pi_ave))
|
475
475
|
|
476
476
|
#### plot ####
|
477
|
-
xaxis = np.linspace(0, mod.maxtime, len(
|
477
|
+
xaxis = np.linspace(0, mod.maxtime, len(Upi_std))
|
478
478
|
|
479
479
|
if ax == None:
|
480
480
|
_, ax = plt.subplots()
|
481
481
|
ax.grid(grid)
|
482
|
-
ax.plot(xaxis,
|
482
|
+
ax.plot(xaxis, Upi_std, CURVE_TYPE, label = r'$p_U$' + ' std')
|
483
483
|
ax.plot(xaxis, V_pi_std, CURVE_TYPE, label = r'$p_V$' + ' std')
|
484
484
|
ax.legend()
|
485
485
|
ax.set_xlabel('Time')
|
@@ -506,11 +506,11 @@ def UV_pi(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgr
|
|
506
506
|
U_ave = figure_t.ave_interval_1D(mod.U, start_index, end_index)
|
507
507
|
V_ave = figure_t.ave_interval_1D(mod.V, start_index, end_index)
|
508
508
|
|
509
|
-
|
510
|
-
V_pi_ave = figure_t.ave_interval(mod.
|
509
|
+
Upi_ave = figure_t.ave_interval(mod.Upi, start_index, end_index)
|
510
|
+
V_pi_ave = figure_t.ave_interval(mod.Vpi, start_index, end_index)
|
511
511
|
|
512
512
|
|
513
|
-
ax_U = figure_t.scatter(U_ave,
|
513
|
+
ax_U = figure_t.scatter(U_ave, Upi_ave, ax_U, U_color, alpha, xlabel = 'U', ylabel = 'Payoff ' + r'$p_U$', title = 'U - ' + r'$p_U$')
|
514
514
|
ax_V = figure_t.scatter(V_ave, V_pi_ave, ax_V, V_color, alpha, xlabel = 'V', ylabel = 'Payoff ' + r'$p_V$', title = 'V - ' + r'$p_V$')
|
515
515
|
|
516
516
|
return ax_U, ax_V
|
piegy/simulation.py
CHANGED
@@ -35,7 +35,7 @@ from timeit import default_timer as timer
|
|
35
35
|
# data type used by model.U and model.V
|
36
36
|
UV_DTYPE = 'float64'
|
37
37
|
|
38
|
-
# data type used by model.
|
38
|
+
# data type used by model.Upi and V_pi
|
39
39
|
PI_DTYPE = 'float64'
|
40
40
|
|
41
41
|
# data type for storing rates in single_test an single_init
|
@@ -63,7 +63,7 @@ class patch:
|
|
63
63
|
Set pointers to neighbors of this patch object.
|
64
64
|
|
65
65
|
update_pi:
|
66
|
-
Update
|
66
|
+
Update Upi, V_pi and payoff rates (payoff rates are the first two numbers in self.pi_death_rates).
|
67
67
|
|
68
68
|
update_k:
|
69
69
|
Update natural death rates (the last two numbers in self.pi_death_rates).
|
@@ -82,8 +82,8 @@ class patch:
|
|
82
82
|
|
83
83
|
self.U = U # int, U population. Initialized upon creating object.
|
84
84
|
self.V = V # int, V population
|
85
|
-
self.
|
86
|
-
self.
|
85
|
+
self.Upi = 0 # float, payoff
|
86
|
+
self.Vpi = 0
|
87
87
|
|
88
88
|
self.matrix = matrix # np.array or list, len = 4, payoff matrix
|
89
89
|
self.mu1 = patch_var[0] # float, how much proportion of the population migrates (U) each time
|
@@ -105,7 +105,7 @@ class patch:
|
|
105
105
|
def __str__(self):
|
106
106
|
self_str = ''
|
107
107
|
self_str += 'U, V = ' + str(self.U) + ', ' + str(self.V) + '\n'
|
108
|
-
self_str += 'pi = ' + str(self.
|
108
|
+
self_str += 'pi = ' + str(self.Upi) + ', ' + str(self.Vpi) + '\n'
|
109
109
|
self_str += 'matrix = ' + str(self.matrix) + '\n'
|
110
110
|
self_str += 'mu1, mu2 = ' + str(self.mu1) + ', ' + str(self.mu2) + '\n'
|
111
111
|
self_str += 'w1, w2 = ' + str(self.w1) + ', ' + str(self.w2) + '\n'
|
@@ -138,23 +138,23 @@ class patch:
|
|
138
138
|
|
139
139
|
if U != 0:
|
140
140
|
# no payoff if U == 0
|
141
|
-
self.
|
141
|
+
self.Upi = (U - 1) / sum_minus_1 * self.matrix[0] + V / sum_minus_1 * self.matrix[1]
|
142
142
|
else:
|
143
|
-
self.
|
143
|
+
self.Upi = 0
|
144
144
|
|
145
145
|
if V != 0:
|
146
|
-
self.
|
146
|
+
self.Vpi = U / sum_minus_1 * self.matrix[2] + (V - 1) / sum_minus_1 * self.matrix[3]
|
147
147
|
else:
|
148
|
-
self.
|
148
|
+
self.Vpi = 0
|
149
149
|
|
150
150
|
else:
|
151
151
|
# no interaction, hence no payoff, if only 1 individual
|
152
|
-
self.
|
153
|
-
self.
|
152
|
+
self.Upi = 0
|
153
|
+
self.Vpi = 0
|
154
154
|
|
155
155
|
# update payoff rates
|
156
|
-
self.pi_death_rates[0] = abs(U * self.
|
157
|
-
self.pi_death_rates[1] = abs(V * self.
|
156
|
+
self.pi_death_rates[0] = abs(U * self.Upi)
|
157
|
+
self.pi_death_rates[1] = abs(V * self.Vpi)
|
158
158
|
|
159
159
|
# update natural death rates
|
160
160
|
self.pi_death_rates[2] = self.kappa1 * U * (sum_minus_1 + 1)
|
@@ -173,8 +173,8 @@ class patch:
|
|
173
173
|
|
174
174
|
for i in range(4):
|
175
175
|
if self.nb[i] != None:
|
176
|
-
U_weight[i] = 1 + pow(math.e, self.w1 * self.nb[i].
|
177
|
-
V_weight[i] = 1 + pow(math.e, self.w2 * self.nb[i].
|
176
|
+
U_weight[i] = 1 + pow(math.e, self.w1 * self.nb[i].Upi)
|
177
|
+
V_weight[i] = 1 + pow(math.e, self.w2 * self.nb[i].Vpi)
|
178
178
|
|
179
179
|
mu1_U = self.mu1 * self.U
|
180
180
|
mu2_V = self.mu2 * self.V
|
@@ -232,7 +232,7 @@ class patch:
|
|
232
232
|
self.U -= 1
|
233
233
|
# s = 2 for natural birth / death, due to payoff
|
234
234
|
elif s == 2:
|
235
|
-
if self.
|
235
|
+
if self.Upi > 0:
|
236
236
|
self.U += 1 # natural growth due to payoff
|
237
237
|
elif self.U > 0:
|
238
238
|
self.U -= 1 # natural death due to payoff
|
@@ -244,7 +244,7 @@ class patch:
|
|
244
244
|
if self.V > 0:
|
245
245
|
self.V -= 1
|
246
246
|
else:
|
247
|
-
if self.
|
247
|
+
if self.Vpi > 0:
|
248
248
|
self.V += 1
|
249
249
|
elif self.V > 0:
|
250
250
|
self.V -= 1
|
@@ -268,7 +268,7 @@ class model:
|
|
268
268
|
Return a deep copy of self. Can choose whether to copy data as well. Default is to copy.
|
269
269
|
|
270
270
|
clear_data:
|
271
|
-
clear all data stored, set U, V,
|
271
|
+
clear all data stored, set U, V, Upi, V_pi to zero arrays
|
272
272
|
|
273
273
|
change_maxtime:
|
274
274
|
Changes maxtime of self. Update data storage as well.
|
@@ -314,8 +314,8 @@ class model:
|
|
314
314
|
# Default is 1, not to take average.
|
315
315
|
self.U = np.zeros((self.N, self.M, self.max_record), dtype = self.UV_dtype) # N x M x max_record np.array, float32, stores population of U in every patch over tiem
|
316
316
|
self.V = np.zeros((self.N, self.M, self.max_record), dtype = self.UV_dtype)
|
317
|
-
self.
|
318
|
-
self.
|
317
|
+
self.Upi = np.zeros((self.N, self.M, self.max_record), dtype = self.pi_dtype) # similar to U, but for U's payoff and float 64
|
318
|
+
self.Vpi = np.zeros((self.N, self.M, self.max_record), dtype = self.pi_dtype)
|
319
319
|
|
320
320
|
|
321
321
|
def check_valid_input(self, N, M, maxtime, record_itv, sim_time, boundary, I, X, P, print_pct):
|
@@ -449,7 +449,7 @@ class model:
|
|
449
449
|
|
450
450
|
if copy_data:
|
451
451
|
# copy data as well
|
452
|
-
sim2.set_data(self.data_empty, self.max_record, self.compress_itv, self.U, self.V, self.
|
452
|
+
sim2.set_data(self.data_empty, self.max_record, self.compress_itv, self.U, self.V, self.Upi, self.Vpi)
|
453
453
|
|
454
454
|
return sim2
|
455
455
|
|
@@ -462,8 +462,8 @@ class model:
|
|
462
462
|
for t in range(self.max_record):
|
463
463
|
self.U[i][j][t] /= self.sim_time
|
464
464
|
self.V[i][j][t] /= self.sim_time
|
465
|
-
self.
|
466
|
-
self.
|
465
|
+
self.Upi[i][j][t] /= self.sim_time
|
466
|
+
self.Vpi[i][j][t] /= self.sim_time
|
467
467
|
|
468
468
|
|
469
469
|
def change_maxtime(self, maxtime):
|
@@ -486,7 +486,7 @@ class model:
|
|
486
486
|
self.init_storage()
|
487
487
|
|
488
488
|
|
489
|
-
def set_data(self, data_empty, max_record, compress_itv, U, V,
|
489
|
+
def set_data(self, data_empty, max_record, compress_itv, U, V, Upi, V_pi):
|
490
490
|
# set data to the given data values
|
491
491
|
# copies are made
|
492
492
|
self.check_valid_data(data_empty, max_record, compress_itv)
|
@@ -496,8 +496,8 @@ class model:
|
|
496
496
|
self.compress_itv = compress_itv
|
497
497
|
self.U = np.copy(U)
|
498
498
|
self.V = np.copy(V)
|
499
|
-
self.
|
500
|
-
self.
|
499
|
+
self.Upi = np.copy(Upi)
|
500
|
+
self.Vpi = np.copy(V_pi)
|
501
501
|
|
502
502
|
|
503
503
|
def compress_data(self, compress_itv = 5):
|
@@ -515,7 +515,7 @@ class model:
|
|
515
515
|
|
516
516
|
U_reduced = np.zeros((self.N, self.M, self.max_record), dtype = self.UV_dtype)
|
517
517
|
V_reduced = np.zeros((self.N, self.M, self.max_record), dtype = self.UV_dtype)
|
518
|
-
|
518
|
+
Upi_reduced = np.zeros((self.N, self.M, self.max_record), dtype = self.pi_dtype)
|
519
519
|
V_pi_reduced = np.zeros((self.N, self.M, self.max_record), dtype = self.pi_dtype)
|
520
520
|
|
521
521
|
for i in range(self.N):
|
@@ -525,13 +525,13 @@ class model:
|
|
525
525
|
upper = lower + compress_itv
|
526
526
|
U_reduced[i][j][k] = np.mean(self.U[i, j, lower : upper])
|
527
527
|
V_reduced[i][j][k] = np.mean(self.V[i, j, lower : upper])
|
528
|
-
|
529
|
-
V_pi_reduced[i][j][k] = np.mean(self.
|
528
|
+
Upi_reduced[i][j][k] = np.mean(self.Upi[i, j, lower : upper])
|
529
|
+
V_pi_reduced[i][j][k] = np.mean(self.Vpi[i, j, lower : upper])
|
530
530
|
|
531
531
|
self.U = U_reduced
|
532
532
|
self.V = V_reduced
|
533
|
-
self.
|
534
|
-
self.
|
533
|
+
self.Upi = Upi_reduced
|
534
|
+
self.Vpi = V_pi_reduced
|
535
535
|
|
536
536
|
|
537
537
|
|
@@ -895,8 +895,8 @@ def single_init(mod, rng):
|
|
895
895
|
for k in range(record_index):
|
896
896
|
mod.U[i][j][k] += world[i][j].U
|
897
897
|
mod.V[i][j][k] += world[i][j].V
|
898
|
-
mod.
|
899
|
-
mod.
|
898
|
+
mod.Upi[i][j][k] += world[i][j].Upi
|
899
|
+
mod.Vpi[i][j][k] += world[i][j].Vpi
|
900
900
|
# we simply add to that entry, and later divide by sim_time to get the average (division in run function)
|
901
901
|
|
902
902
|
return time, world, nb_indices, patch_rates, sum_rates_by_row, sum_rates, signal
|
@@ -1037,8 +1037,8 @@ def single_test(mod, front_info, end_info, update_sum_frequency, rng):
|
|
1037
1037
|
for k in range(record_index, record_index + multi_records):
|
1038
1038
|
mod.U[i][j][k] += world[i][j].U
|
1039
1039
|
mod.V[i][j][k] += world[i][j].V
|
1040
|
-
mod.
|
1041
|
-
mod.
|
1040
|
+
mod.Upi[i][j][k] += world[i][j].Upi
|
1041
|
+
mod.Vpi[i][j][k] += world[i][j].Vpi
|
1042
1042
|
record_index += multi_records
|
1043
1043
|
else:
|
1044
1044
|
# if already exceeds maxtime
|
@@ -1047,8 +1047,8 @@ def single_test(mod, front_info, end_info, update_sum_frequency, rng):
|
|
1047
1047
|
for k in range(record_index, max_record):
|
1048
1048
|
mod.U[i][j][k] += world[i][j].U
|
1049
1049
|
mod.V[i][j][k] += world[i][j].V
|
1050
|
-
mod.
|
1051
|
-
mod.
|
1050
|
+
mod.Upi[i][j][k] += world[i][j].Upi
|
1051
|
+
mod.Vpi[i][j][k] += world[i][j].Vpi
|
1052
1052
|
|
1053
1053
|
### Large while loop ends ###
|
1054
1054
|
|
piegy/test_var.py
CHANGED
@@ -7,7 +7,7 @@ Test influence of one variable:
|
|
7
7
|
- test_var1: Test how a certain patch variable (mu, w, kappa) influences results.
|
8
8
|
Run simulations across different values of that variable and save data.
|
9
9
|
- var_UV1: Plot how U, V change across different values of a specified variable.
|
10
|
-
- var_pi1: Plot how
|
10
|
+
- var_pi1: Plot how Upi, V_pi change across different values of a specified variable.
|
11
11
|
|
12
12
|
|
13
13
|
Test influence of two variables:
|
@@ -15,7 +15,7 @@ Test influence of two variables:
|
|
15
15
|
Run simulations across different values of the two specified variables and save data.
|
16
16
|
- var_UV2: Plot how U, V change across the two variables.
|
17
17
|
x-axis is values of the variable 2, y-axis is U or V. Values of variable 1 are shown by multiple curves.
|
18
|
-
- var_pi2: Plot how
|
18
|
+
- var_pi2: Plot how Upi & V_pi change across the two variables.
|
19
19
|
|
20
20
|
|
21
21
|
Additional tools (can be called directly):
|
@@ -305,7 +305,7 @@ def var_UV2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, va
|
|
305
305
|
def var_pi1(var, values, var_dirs, ax_U = None, ax_V = None, start = 0.95, end = 1.0, U_color = 'violet', V_color = 'yellowgreen'):
|
306
306
|
'''
|
307
307
|
Plot function for test_var1. Plot influence of var on U, V's payoff.
|
308
|
-
Make
|
308
|
+
Make Upi, V_pi - var curves. y-axis is payoff, x-axis is values of var.
|
309
309
|
|
310
310
|
Inputs:
|
311
311
|
- var_dirs: return value of test_var1. A 1D list of directories where all data are stored.
|
@@ -334,8 +334,8 @@ def var_pi1(var, values, var_dirs, ax_U = None, ax_V = None, start = 0.95, end =
|
|
334
334
|
end_index = int(simk.max_record * end)
|
335
335
|
NM = int(simk.N * simk.M)
|
336
336
|
|
337
|
-
U_ave.append(np.sum(figure_t.ave_interval(simk.
|
338
|
-
V_ave.append(np.sum(figure_t.ave_interval(simk.
|
337
|
+
U_ave.append(np.sum(figure_t.ave_interval(simk.Upi, start_index, end_index)) / NM)
|
338
|
+
V_ave.append(np.sum(figure_t.ave_interval(simk.Vpi, start_index, end_index)) / NM)
|
339
339
|
|
340
340
|
del simk
|
341
341
|
|
@@ -364,7 +364,7 @@ def var_pi1(var, values, var_dirs, ax_U = None, ax_V = None, start = 0.95, end =
|
|
364
364
|
def var_pi2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, var1_on_xaxis = True, start = 0.95, end = 1.0, U_color = 'viridis', V_color = 'viridis', rgb_alpha = 1):
|
365
365
|
'''
|
366
366
|
Plot function for test_var2. Plot how var1 and var2 influence payoff.
|
367
|
-
Make
|
367
|
+
Make Upi, V_pi - var2 curves. y-axis is payoff, x-axis is values of var2,
|
368
368
|
var1 is represented by different curves. One curve corresponds to one value of var1.
|
369
369
|
|
370
370
|
Inputs:
|
@@ -398,8 +398,8 @@ def var_pi2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, va
|
|
398
398
|
end_index = int(simk.max_record * end)
|
399
399
|
NM = int(simk.N * simk.M)
|
400
400
|
|
401
|
-
U_ave[k1].append(np.sum(figure_t.ave_interval(simk.
|
402
|
-
V_ave[k1].append(np.sum(figure_t.ave_interval(simk.
|
401
|
+
U_ave[k1].append(np.sum(figure_t.ave_interval(simk.Upi, start_index, end_index)) / NM)
|
402
|
+
V_ave[k1].append(np.sum(figure_t.ave_interval(simk.Vpi, start_index, end_index)) / NM)
|
403
403
|
|
404
404
|
del simk # manually delete this large object
|
405
405
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
piegy/__init__.py,sha256=plq8y9IE9ilaKtEFIblJ_QexipAvPBXoalXhXLbs71Q,3244
|
2
|
+
piegy/__version__.py,sha256=Z8QjDLipX03j5ebaea7PhH2aJiiWo_JzOehTw_Gr8L0,1041
|
3
|
+
piegy/analysis.py,sha256=2GBsBbi7LdstSEAM0-F2bfL2kHu3MElcrw8bxZ1x6LI,8719
|
4
|
+
piegy/data_tools.py,sha256=9gCt5dPRQfMDm5HUJpzlLvCEGPtVgpa_vnCvxRfGTVM,3545
|
5
|
+
piegy/figures.py,sha256=TP9AoNnKwGZxBNmJGbplpb_ewr9US3jziBzOh1arGeY,19014
|
6
|
+
piegy/simulation.py,sha256=ezbXTm2Ri6aLM49FLD85NBGdf0eclgFyiCWvYJ-jjII,45130
|
7
|
+
piegy/test_var.py,sha256=gMyonZbtLEAS5bH1QwcFnshpvwEsq7YWGb9My0PStts,23596
|
8
|
+
piegy/videos.py,sha256=QfSpOdwfaDsrQYRoiHmZ6gowzRQHom3m8kx1P65_8sM,10218
|
9
|
+
piegy/tools/__init__.py,sha256=eYOl_HJHDonYexfrmKh3koOlxvtSo46vH6jHvCEEB4k,300
|
10
|
+
piegy/tools/figure_tools.py,sha256=54vJSJMReXidFnSPE_xFvedtgnJU3d55zQDPNBLGs98,6975
|
11
|
+
piegy/tools/file_tools.py,sha256=ncxFWeHfIE-GYLQlOrahFlhBgqPyuY3R5_93fpQeCEs,630
|
12
|
+
piegy-1.1.6.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
|
13
|
+
piegy-1.1.6.dist-info/METADATA,sha256=TSeyMPsCS6VXvZy9BiLw09bjZT1T6tXwkW0wC70BHGo,5306
|
14
|
+
piegy-1.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
+
piegy-1.1.6.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
|
16
|
+
piegy-1.1.6.dist-info/RECORD,,
|
piegy-1.1.5.dist-info/RECORD
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
piegy/__init__.py,sha256=plq8y9IE9ilaKtEFIblJ_QexipAvPBXoalXhXLbs71Q,3244
|
2
|
-
piegy/__version__.py,sha256=AAqSGH3nuhPokfBCJAiDo5lX43TPen-UUqpb0w3AMKk,878
|
3
|
-
piegy/analysis.py,sha256=5X6cpEAgFlHiRoaVmqYALlUvkep_LmrqpJHLCtQrd9Q,8727
|
4
|
-
piegy/data_tools.py,sha256=Rw1fzeCGbxAB8MqTxZNZnOkVn7FmoUGoRz21scTAvF0,3550
|
5
|
-
piegy/figures.py,sha256=bMHS7gTYtWdixUMW_wokBD6NSj_WOjQtnWp0R8VXChw,19059
|
6
|
-
piegy/simulation.py,sha256=ngyLGzXAePYlyrcRznxWA7FEvGl9Gad976Sh1gHT0hU,45178
|
7
|
-
piegy/test_var.py,sha256=g6BS_G_sewLn-8urUdTnlaVd8LYt_5GDvQQr_4bmNDU,23604
|
8
|
-
piegy/videos.py,sha256=QfSpOdwfaDsrQYRoiHmZ6gowzRQHom3m8kx1P65_8sM,10218
|
9
|
-
piegy/tools/__init__.py,sha256=eYOl_HJHDonYexfrmKh3koOlxvtSo46vH6jHvCEEB4k,300
|
10
|
-
piegy/tools/figure_tools.py,sha256=54vJSJMReXidFnSPE_xFvedtgnJU3d55zQDPNBLGs98,6975
|
11
|
-
piegy/tools/file_tools.py,sha256=ncxFWeHfIE-GYLQlOrahFlhBgqPyuY3R5_93fpQeCEs,630
|
12
|
-
piegy-1.1.5.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
|
13
|
-
piegy-1.1.5.dist-info/METADATA,sha256=Ld9BLdh-FjcVyT8wwLMeVrXa3-YwitV9JawLoaMzYd0,5306
|
14
|
-
piegy-1.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
-
piegy-1.1.5.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
|
16
|
-
piegy-1.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|