Example #1
0
    def _addDelayExtension(self, numSrcNeurons, max_delay_for_projection,
                           max_delay_per_neuron, original_connector,
                           original_synapse_list, presynaptic_population,
                           postsynaptic_population, label, synapse_dynamics):
        """
        Instantiate new delay extension component, connecting a new edge from 
        the source vertex to it and new edges from it to the target (given
        by numBlocks). 
        The outgoing edges cover each required block of delays, in groups of 
        MAX_DELAYS_PER_NEURON delay slots (currently 16).
        """
        global controller
        # If there are any connections with a delay of less than the maximum,
        # create a direct connection between the two populations only containing
        # these connections
        direct_synaptic_sublist = original_synapse_list.create_delay_sublist(
            0, max_delay_per_neuron)
        if (direct_synaptic_sublist.get_max_n_connections() != 0):
            direct_edge = ProjectionEdge(presynaptic_population.vertex,
                                         postsynaptic_population.vertex,
                                         controller.dao.machineTimeStep,
                                         synapse_list=direct_synaptic_sublist,
                                         label=label)
            controller.add_edge(direct_edge)
            self.projection_edge = direct_edge

        # Create a delay extension vertex to do the extra delays
        self.delay_vertex = presynaptic_population.vertex.delay_vertex
        if self.delay_vertex is None:
            sourceName = presynaptic_population.vertex.label
            delayName = "%s_delayed" % (sourceName)
            self.delay_vertex = DelayExtension(numSrcNeurons,
                                               max_delay_per_neuron,
                                               label=delayName)
            presynaptic_population.vertex.delay_vertex = self.delay_vertex
            #controller.add_vertex(self.delay_vertex)

        # Create a connection from the source population to the delay vertex
        new_label = "%s_to_DE" % (label)
        remaining_edge = DelayAfferentEdge(presynaptic_population.vertex,
                                           self.delay_vertex,
                                           label=new_label)
        controller.add_edge(remaining_edge)

        # Create a list of the connections with delay larger than that which
        # can be handled by the neuron itself
        remaining_synaptic_sublist = original_synapse_list.create_delay_sublist(
            max_delay_per_neuron, max_delay_for_projection)

        # Create a special DelayEdge from the delay vertex to the outgoing
        # population, with the same set of connections
        delay_label = "DE to %s" % (label)
        num_blocks = int(
            math.ceil(
                float(max_delay_for_projection) /
                float(max_delay_per_neuron))) - 1
        self.delay_edge = DelayProjectionEdge(
            self.delay_vertex,
            postsynaptic_population.vertex,
            controller.dao.machineTimeStep,
            num_blocks,
            max_delay_per_neuron,
            synapse_list=remaining_synaptic_sublist,
            synapse_dynamics=synapse_dynamics,
            label=delay_label)
        controller.add_edge(self.delay_edge)