1
|
|
|
"""!
|
2
|
|
|
|
3
|
|
|
@brief CCORE Wrapper for oscillatory neural network based on Kuramoto model.
|
4
|
|
|
|
5
|
|
|
@authors Andrei Novikov ([email protected])
|
6
|
|
|
@date 2014-2017
|
7
|
|
|
@copyright GNU Public License
|
8
|
|
|
|
9
|
|
|
@cond GNU_PUBLIC_LICENSE
|
10
|
|
|
PyClustering is free software: you can redistribute it and/or modify
|
11
|
|
|
it under the terms of the GNU General Public License as published by
|
12
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
13
|
|
|
(at your option) any later version.
|
14
|
|
|
|
15
|
|
|
PyClustering is distributed in the hope that it will be useful,
|
16
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
|
|
GNU General Public License for more details.
|
19
|
|
|
|
20
|
|
|
You should have received a copy of the GNU General Public License
|
21
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
22
|
|
|
@endcond
|
23
|
|
|
|
24
|
|
|
"""
|
25
|
|
|
|
26
|
|
|
|
27
|
|
|
from pyclustering.core.wrapper import *;
|
|
|
|
|
28
|
|
|
from pyclustering.core.pyclustering_package import pyclustering_package, package_extractor;
|
29
|
|
|
|
30
|
|
|
|
31
|
|
|
def sync_create_network(num_osc, weight, frequency, type_conn, initial_phases):
|
32
|
|
|
ccore = load_core();
|
33
|
|
|
|
34
|
|
|
ccore.sync_create_network.restype = POINTER(c_void_p);
|
35
|
|
|
pointer_network = ccore.sync_create_network(c_uint(num_osc), c_double(weight), c_double(frequency), c_uint(type_conn), c_uint(initial_phases));
|
36
|
|
|
|
37
|
|
|
return pointer_network;
|
38
|
|
|
|
39
|
|
|
|
40
|
|
|
def sync_get_size(pointer_network):
|
41
|
|
|
ccore = load_core();
|
42
|
|
|
ccore.sync_get_size.restype = c_size_t;
|
43
|
|
|
return ccore.sync_get_size(pointer_network);
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
def sync_destroy_network(pointer_network):
|
47
|
|
|
ccore = load_core();
|
48
|
|
|
ccore.sync_destroy_network(pointer_network);
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
def sync_simulate_static(pointer_network, steps, time, solution, collect_dynamic):
|
52
|
|
|
ccore = load_core();
|
53
|
|
|
ccore.sync_simulate_static.restype = POINTER(c_void_p);
|
54
|
|
|
return ccore.sync_simulate_static(pointer_network, c_uint(steps), c_double(time), c_uint(solution), c_bool(collect_dynamic));
|
55
|
|
|
|
56
|
|
|
|
57
|
|
|
def sync_simulate_dynamic(pointer_network, order, solution, collect_dynamic, step, int_step, threshold_changes):
|
58
|
|
|
ccore = load_core();
|
59
|
|
|
ccore.sync_simulate_dynamic.restype = POINTER(c_void_p);
|
60
|
|
|
return ccore.sync_simulate_dynamic(pointer_network, c_double(order), c_uint(solution), c_bool(collect_dynamic), c_double(step), c_double(int_step), c_double(threshold_changes));
|
61
|
|
|
|
62
|
|
|
|
63
|
|
|
def sync_order(pointer_network):
|
64
|
|
|
ccore = load_core();
|
65
|
|
|
ccore.sync_order.restype = c_double;
|
66
|
|
|
|
67
|
|
|
return ccore.sync_order(pointer_network);
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
def sync_local_order(pointer_network):
|
71
|
|
|
ccore = load_core();
|
72
|
|
|
ccore.sync_local_order.restype = c_double;
|
73
|
|
|
|
74
|
|
|
return ccore.sync_local_order(pointer_network);
|
75
|
|
|
|
76
|
|
|
|
77
|
|
|
def sync_connectivity_matrix(pointer_network):
|
78
|
|
|
ccore = load_core();
|
79
|
|
|
ccore.sync_connectivity_matrix.restype = POINTER(pyclustering_package);
|
80
|
|
|
|
81
|
|
|
package = ccore.sync_connectivity_matrix(pointer_network);
|
82
|
|
|
|
83
|
|
|
connectivity_matrix = package_extractor(package).extract();
|
84
|
|
|
ccore.free_pyclustering_package(package);
|
85
|
|
|
|
86
|
|
|
return connectivity_matrix;
|
87
|
|
|
|
88
|
|
|
|
89
|
|
|
def sync_dynamic_get_size(pointer_dynamic):
|
90
|
|
|
ccore = load_core();
|
91
|
|
|
ccore.sync_dynamic_get_time.restype = c_size_t;
|
92
|
|
|
return ccore.sync_dynamic_get_size(pointer_dynamic);
|
93
|
|
|
|
94
|
|
|
|
95
|
|
|
def sync_dynamic_destroy(pointer_dynamic):
|
96
|
|
|
ccore = load_core();
|
97
|
|
|
ccore.sync_dynamic_destroy(pointer_dynamic);
|
98
|
|
|
|
99
|
|
|
|
100
|
|
|
def sync_dynamic_allocate_sync_ensembles(pointer_dynamic, tolerance, iteration):
|
101
|
|
|
if (iteration is None):
|
102
|
|
|
iteration = sync_dynamic_get_size(pointer_dynamic) - 1;
|
103
|
|
|
|
104
|
|
|
ccore = load_core();
|
105
|
|
|
|
106
|
|
|
ccore.sync_dynamic_allocate_sync_ensembles.restype = POINTER(pyclustering_package);
|
107
|
|
|
package = ccore.sync_dynamic_allocate_sync_ensembles(pointer_dynamic, c_double(tolerance), c_size_t(iteration));
|
108
|
|
|
|
109
|
|
|
result = package_extractor(package).extract();
|
110
|
|
|
ccore.free_pyclustering_package(package);
|
111
|
|
|
|
112
|
|
|
return result;
|
113
|
|
|
|
114
|
|
|
|
115
|
|
|
def sync_dynamic_allocate_correlation_matrix(pointer_dynamic, iteration):
|
116
|
|
|
analyse_iteration = iteration;
|
117
|
|
|
if (analyse_iteration is None):
|
118
|
|
|
analyse_iteration = sync_dynamic_get_size(pointer_dynamic) - 1;
|
119
|
|
|
|
120
|
|
|
ccore = load_core();
|
121
|
|
|
|
122
|
|
|
ccore.sync_dynamic_allocate_correlation_matrix.restype = POINTER(pyclustering_package);
|
123
|
|
|
package = ccore.sync_dynamic_allocate_correlation_matrix(pointer_dynamic, c_uint(analyse_iteration));
|
124
|
|
|
|
125
|
|
|
result = package_extractor(package).extract();
|
126
|
|
|
ccore.free_pyclustering_package(package);
|
127
|
|
|
|
128
|
|
|
return result;
|
129
|
|
|
|
130
|
|
|
|
131
|
|
|
def sync_dynamic_get_output(pointer_dynamic):
|
132
|
|
|
ccore = load_core();
|
133
|
|
|
|
134
|
|
|
ccore.sync_dynamic_get_output.restype = POINTER(pyclustering_package);
|
135
|
|
|
package = ccore.sync_dynamic_get_output(pointer_dynamic);
|
136
|
|
|
|
137
|
|
|
result = package_extractor(package).extract();
|
138
|
|
|
ccore.free_pyclustering_package(package);
|
139
|
|
|
|
140
|
|
|
return result;
|
141
|
|
|
|
142
|
|
|
|
143
|
|
|
def sync_dynamic_get_time(pointer_dynamic):
|
144
|
|
|
ccore = load_core();
|
145
|
|
|
|
146
|
|
|
ccore.sync_dynamic_get_time.restype = POINTER(pyclustering_package);
|
147
|
|
|
package = ccore.sync_dynamic_get_time(pointer_dynamic);
|
148
|
|
|
|
149
|
|
|
result = package_extractor(package).extract();
|
150
|
|
|
ccore.free_pyclustering_package(package);
|
151
|
|
|
|
152
|
|
|
return result;
|
153
|
|
|
|