Changeset 1015
- Timestamp:
- 11/25/11 14:53:10 (6 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
examples/VAbenchmarks2-csa.py (modified) (1 diff)
-
src/connectors.py (modified) (4 diffs)
-
src/nest/connectors.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/VAbenchmarks2-csa.py
r998 r1015 126 126 inh_cells = all_cells[n_exc:] 127 127 if benchmark == "COBA": 128 ext_stim = Population(20, SpikeSourcePoisson, {'rate' : rate, 'duration' : stim_dur},"expoisson")128 ext_stim = Population(20, SpikeSourcePoisson, {'rate' : rate, 'duration' : stim_dur}, label="expoisson") 129 129 rconn = 0.01 130 130 ext_conn = FixedProbabilityConnector(rconn, weights=0.1) 131 131 132 132 print "%s Initialising membrane potential to random values..." % node_id 133 rng = NumpyRNG(seed=rngseed, parallel_safe=parallel_safe s)133 rng = NumpyRNG(seed=rngseed, parallel_safe=parallel_safe) 134 134 uniformDistr = RandomDistribution('uniform', [v_reset,v_thresh], rng=rng) 135 135 all_cells.initialize('v', uniformDistr) -
trunk/src/connectors.py
r1003 r1015 898 898 Connector.__init__(self, None, None, safe=safe, verbose=verbose) 899 899 self.cset = cset 900 if cs et.arity== 0:900 if csa.arity(cset) == 0: 901 901 #assert weights is not None and delays is not None, \ 902 902 # 'must specify weights and delays in addition to a CSA mask' … … 906 906 self.delays = delays 907 907 else: 908 assert cs et.arity== 2, 'must specify mask or connection-set with arity 2'908 assert csa.arity(cset) == 2, 'must specify mask or connection-set with arity 2' 909 909 assert weights is None and delays is None, \ 910 910 "weights or delays specified both in connection-set and as CSAConnector argument" … … 926 926 if self.delays is None: 927 927 self.delays = projection._simulator.state.min_delay 928 i0 = projection.pre.first_id 929 size1 = projection.pre.last_id - i0 930 j0 = projection.post.first_id 931 targets = [j - j0 for j in projection.post] 932 933 # Cut out finite part and shift to global ids 934 c = csa.shift (i0, j0) * csa.cross ((0, size1), targets) * self.cset 935 936 if csa.arity (self.cset) == 2: 928 # Cut out finite part 929 c = csa.cross((0, projection.pre.size-1), (0, projection.post.size-1)) * self.cset 930 931 if csa.arity(self.cset) == 2: 937 932 # Connection-set with arity 2 938 933 for (i, j, weight, delay) in c: 939 projection._divergent_connect (i, [j], weight, delay)934 projection._divergent_connect(projection.pre[i], [projection.post[j]], weight, delay) 940 935 elif CSAConnector.isConstant (self.weights) \ 941 936 and CSAConnector.isConstant (self.delays): 942 937 # Mask with constant weights and delays 943 938 for (i, j) in c: 944 projection._divergent_connect ( i, [j], self.weights, self.delays)939 projection._divergent_connect (projection.pre[i], [projection.post[j]], self.weights, self.delays) 945 940 else: 946 941 # Mask with weights and/or delays iterable … … 952 947 delays = CSAConnector.constantIterator (delays) 953 948 for (i, j), weight, delay in zip (c, weights, delays): 954 projection._divergent_connect ( i, [j], weight, delay)949 projection._divergent_connect (projection.pre[i], [projection.post[j]], weight, delay) -
trunk/src/nest/connectors.py
r1013 r1015 16 16 import numpy 17 17 from pyNN.space import Space 18 19 20 18 from pyNN.common.populations import Population 19 try: 20 import csa 21 have_csa = True 22 except ImportError: 23 have_csa = False 24 import nest 21 25 22 26 class FastProbabilisticConnector(Connector): … … 209 213 connector._probabilistic_connect(tgt, proba, self.n_connections, self.rewiring) 210 214 self.progression(count, projection._simulator.state.mpi_rank) 215 216 217 class CSAConnector(CSAConnector): 218 219 def connect(self, projection): 220 """Connect-up a Projection.""" 221 if self.delays is None: 222 self.delays = projection._simulator.state.min_delay 223 224 def connect_csa(cset, pre, post, syn_type): 225 print "connecting using cset" 226 if isinstance(pre, Population) and isinstance(post, Population): 227 # contiguous IDs, so just pass first_id and size 228 nest.sli_func("Connect_cg_i_i_i_i_D_l", 229 self.cset, 230 pre.first_id, pre.size, 231 post.first_id, post.size, 232 {'weight': 0, 'delay': 1}, # ignored if arity==0 233 syn_type) 234 else: # PopulationViews or Assemblies 235 # IDs may be non-contiguous, so need to pass entire arrays 236 nest.sli_func("Connect_cg_a_a_D_l", 237 self.cset, 238 pre.all_cells, 239 post.all_cells, 240 {'weight': 0, 'delay': 1}, # ignored if arity==0 241 syn_type) 242 # TODO: fix weights units 243 if csa.arity(self.cset) == 2: 244 # Connection-set with arity 2 245 connect_csa(self.cset, projection.pre, 246 projection.post, projection.synapse_model) 247 elif CSAConnector.isConstant(self.weights) \ 248 and CSAConnector.isConstant(self.delays): 249 # Mask with constant weights and delays 250 assert csa.arity(self.cset) == 0 251 nest.SetDefaults(projection.synapse_model, {'weight': self.weights, 'delay': self.delays}) 252 connect_csa(self.cset, projection.pre, 253 projection.post, projection.synapse_model) 254 projection._sources = projection.pre.all_cells
