Hi Guillaume,
thanks, I now get a somewhat clearer idea of what you want to do.
Unfortunately, neither the shared variable approach that you tried
earlier (that would have *one* weight for all synapses), nor
storing it in the post-synaptic NeuronGroup (that would give you
the same weights for all incoming spikes at a particular neuron)
will work here. What you'd need is linked variables in the
Synapses object, but this is something we don't allow currently.
We will eventually, it's not in there because linking variables
assumes a constant mapping between two groups, but the size of a
Synapses object can change with the addition of synapses.
This all said, I think you *can* do what you want, but you have to
use an internal Brian mechanism that bypasses most checks, i.e.
you can shoot yourself in the foot if you use it incorrectly.
Here's the idea (untested...):
In addition to your group neurons1, you create a NeuronGroup (that
is not really about neurons) as a container for your shared
weights:
shared_weights = NeuronGroup(n_shared, 'w : 1')
In your Synapses object, you remove the 'w : 1' from the
equations, but add an indexing state variable 'w_index : integer'.
After you've created the Synapses object, you reference the
variable w in the shared_weights group and tell Brian to use
w_index as an index for it (this is the part of Brian that a user
normally wouldn't use directly):
S1.variables.add_reference(shared_weights, 'w',
index='w_index')
Now, whenever Brian executes code such as ge += w for a synapse,
it will use the w of the shared_weights group, indexed with the
value of w_index of that synapse. Expressed in a pseudo-Pythonic
way, if the synapse number "syn" receives a spike for target
neuron number "target", it will translate 'ge += w' into:
neuron1.ge[target] += shared_weights.w[w_index[syn]]
Now, all you have to do is to set w_index for every synapse so
that it points to the correct shared weight. If your connection
pattern is like the one in the link you sent (under "shared
weights"), this is actually quite easy, for the connections
(source -- target) 0 -- 0, 1 -- 1, 2 -- 2, you use shared weight
0, for 1 -- 0, 2 -- 1, 3 --1 you use shared weight 1, etc., i.e.
you can simply write
S1.w_index = 'i - j ' # i is the source index, j the target
index
As I said, I did not actually test this but it should work, let us
know how it goes! Best
Marcel