forked from pena-rodrigo/net_cortex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genMatAdj.cpp
174 lines (147 loc) · 5.16 KB
/
genMatAdj.cpp
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
# include <iostream>
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <sys/time.h>
# include <ctime>
# include <time.h>
# define NN 4000
double randun() {
return (double)rand() / (double)RAND_MAX;
}
using namespace std;
int main() {
//system("clear");
srand (time(NULL)*10000000);
clock_t startTime = clock();
int nsyn = 0,
r = 0,
c = 0;
if(1){ // turn on to Potdjans and Diesmann network
double table[8][8] =
{
{ 0.101, 0.169, 0.044, 0.082, 0.032, 0.0, 0.008, 0.0 },
{ 0.135, 0.137, 0.032, 0.052, 0.075, 0.0, 0.004, 0.0 },
{ 0.008, 0.006, 0.050, 0.135, 0.007, 0.0003, 0.045, 0.0 },
{ 0.069, 0.003, 0.079, 0.160, 0.003, 0.0, 0.106, 0.0 },
{ 0.100, 0.062, 0.051, 0.006, 0.083, 0.373, 0.020, 0.0 },
{ 0.055, 0.027, 0.026, 0.002, 0.060, 0.316, 0.009, 0.0 },
{ 0.016, 0.007, 0.021, 0.017, 0.057, 0.020, 0.040, 0.225 },
{ 0.036, 0.001, 0.003, 0.001, 0.028, 0.008, 0.066, 0.144 },
};
cout << "Gerando matriz de adjacência... ";
FILE *raster;
raster = fopen("ma4k.dat","w");
for(int i = 0; i < NN; i++) {
if(i >= 0 && i < round(268.0/1000 * NN)) {
c = 0;
}
if(i >= round(268.0/1000 * NN) && i < round(344.0/1000 * NN)) {
c = 1;
}
if(i >= round(344.0/1000 *NN) && i < round(628.0/1000 * NN)) {
c = 2;
}
if(i >= round(628.0/1000 * NN) && i < round(700.0/1000 * NN)){
c = 3;
}
if(i >= round(700.0/1000 * NN) && i < round(763.0/1000 * NN)) {
c = 4;
}
if(i >= round(763.0/1000 * NN) && i < round(777.0/1000 * NN)) {
c = 5;
}
if(i >= round(777.0/1000 * NN) && i < round(963.0/1000 * NN)) {
c = 6;
}
if(i >= round(963.0/1000 * NN) && i < round(1000.0 / 1000 * NN)) {
c = 7;
}
for(int j = 0; j < NN; j++) {
if(j >= 0 && j < round(268.0/1000 * NN)) {
if(randun() < table[0][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(268.0/1000 * NN) && j < round(344.0/1000 * NN)) {
if(randun() < table[1][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(344.0/1000 *NN) && j < round(628.0/1000 * NN)) {
if(randun() < table[2][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(628.0/1000 * NN) && j < round(700.0/1000 * NN)){
if(randun() < table[3][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(700.0/1000 * NN) && j < round(763.0/1000 * NN)) {
if(randun() < table[4][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(763.0/1000 * NN) && j < round(777.0/1000 * NN)) {
if(randun() < table[5][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(777.0/1000 * NN) && j < round(963.0/1000 * NN)) {
if(randun() < table[6][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
if(j >= round(963.0/1000 * NN) && j < round(1000.0 / 1000 * NN)) {
if(randun() < table[7][c]) {
fprintf(raster,"%d\t%d\n", i, j);
nsyn++;
}
}
}
}
cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " s.\n\n" << endl;
cout << "NN : " << NN << " Nsyns : " << nsyn << "\n";
}else{ // here homogeneous random network
//cout << "Gerando matriz de adjacência... ";
FILE *raster;
raster = fopen("random.dat","w");
int Ce=1000, sort; //excitatory and inhibitory inputs per neuron
float gama=0.25;
int Ni = (int) round(NN*gama);
int Ci = (int) round(Ce*gama);
for (int i = 0; i < (NN+Ni); i++) { //exc
for (int j = 0; j < Ce; j++) {
sort = round(randun()*((NN)-1));
while (sort==i){
sort = round(randun()*((NN)-1));
}
fprintf(raster,"%d\t%d\n", sort, i);
nsyn++;
}
}
for (int i = 0; i < (NN+Ni); i++) { //inh
for (int j = 0; j < Ci; j++) {
sort = round(randun()*Ni+NN);
while (sort==i){
sort = round(randun()*Ni+NN);
}
fprintf(raster,"%d\t%d\n", sort, i);
nsyn++;
}
}
cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " s.\n\n" << endl;
cout << "Ne + Ni : " << (NN+Ni) << " Nsyns : " << nsyn << "\n";
fclose(raster);
// cout << round(randun()*NN) << endl;
}
return 0;
}