summaryrefslogtreecommitdiff
path: root/code/matlab/random_topo.m
diff options
context:
space:
mode:
Diffstat (limited to 'code/matlab/random_topo.m')
-rw-r--r--code/matlab/random_topo.m60
1 files changed, 60 insertions, 0 deletions
diff --git a/code/matlab/random_topo.m b/code/matlab/random_topo.m
new file mode 100644
index 0000000..73d94ac
--- /dev/null
+++ b/code/matlab/random_topo.m
@@ -0,0 +1,60 @@
+%% config
+% the values below should be set externally
+% num_neurons = 10;
+% connection_density = 0.5;
+% inhibitory_fraction = 0.2;
+
+min_weight = 0;
+max_weight = 0.004;
+fie = - 1;
+fei = 15 / 20;
+fii = 0;
+
+min_delay = 0.001; % >= 0.1 ms
+max_delay = 0.005; % < 2 ms
+
+
+%% init weights
+
+weights = min_weight + (max_weight - min_weight) * rand(num_neurons);
+weights = weights .* (rand(num_neurons) < connection_density);
+
+l = num_neurons - inhibitory_fraction * num_neurons + 1;
+h = num_neurons;
+
+% make incoming and outgoing weight of each inhibitory neuron proportional
+weights(1:(l-1), l:h) = weights(l:h, 1:(l-1))';
+
+% scaling weights for inhibitory connections
+weights(l:h, 1:(l-1)) = fie * weights(l:h, 1:(l-1));
+weights(l:h, l:h) = fii * weights(l:h, l:h);
+weights(1:(l-1), l:h) = fei * weights(1:(l-1), l:h);
+
+
+%% init delays
+
+delay = min_delay + (max_delay - min_delay) * rand(num_neurons);
+
+% make inhibitory delays shorter
+delay(1:(l-1), l:h) = 0.1 * delay(1:(l-1), l:h);
+delay(l:h, 1:(l-1)) = 0.1 * delay(l:h, 1:(l-1));
+
+
+%% print resulting topology config
+
+[ a, b ] = find(weights ~= 0);
+index = find(weights ~= 0);
+
+format long
+
+res = [ a, b, delay(index), weights(index) ];
+
+for i=1:length(res),
+ constness = (max(res(i,1:2)) / num_neurons >= 1 - inhibitory_fraction) % is src or dst and inhibitory neuron?
+ if (constness)
+ fprintf(2,'%d,%d,1,%f,%f\n', int32(res(i,1))-1, int32(res(i,2))-1, res(i,3), res(i,4));
+ else
+ fprintf(2,'%d,%d,0,%f,%f\n', int32(res(i,1))-1, int32(res(i,2))-1, res(i,3), res(i,4));
+ end
+end
+
contact: Jan Huwald // Impressum