Ejemplo n.º 1
0
    def getWeights(self, format='list'):
        """
        Get synaptic weights for all connections in this Projection.
        (pyNN gather parameter not supported from the signiture
        getWeights(self, format='list', gather=True):)

        Possible formats are: a list of length equal to the number of connections
        in the projection, a 2D weight array (with NaN for non-existent
        connections). Note that for the array format, if there is more than
        one connection between two cells, the summed weight will be given.
        """
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        synapse_list = self._get_synaptic_data()
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()
            
        if format == 'list':
            weights = list()
            for row in synapse_list.get_rows():
                weights.extend(row.weights)
            return weights 
        elif format == 'array':
            weights = numpy.zeros((self.projection_edge.prevertex.atoms, 
                                   self.projection_edge.postvertex.atoms))
            rows = synapse_list.get_rows()
        for pre_atom, row in enumerate(rows):
            for post_atom, weight in zip(row.target_indices, row.weights):
                weights[pre_atom][post_atom] = weight
        return weights
Ejemplo n.º 2
0
    def getDelays(self, format='list', gather=True):
        """
        Get synaptic delays for all connections in this Projection.

        Possible formats are: a list of length equal to the number of connections
        in the projection, a 2D delay array (with NaN for non-existent
        connections).
        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        synapse_list = self._get_synaptic_data()
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()
            
        if format == 'list':
            delays = list()
            for row in synapse_list.get_rows():
                delays.extend(row.delays 
                        * (float(controller.dao.machineTimeStep) / 1000.0))
            return delays
        
        delays = numpy.zeros((self.projection_edge.prevertex.atoms, 
                self.projection_edge.postvertex.atoms))
        rows = synapse_list.get_rows()
        for pre_atom in range(len(rows)):
            row = rows[pre_atom]
            for i in len(row.target_indices):
                post_atom = row.target_indices[i]
                delay = (float(row.delays[i]) 
                        * (float(controller.dao.machineTimeStep) / 1000.0))
                delays[pre_atom][post_atom] = delay
        return delays
Ejemplo n.º 3
0
    def get_gsyn(self, gather=True, compatible_output=False):
        """
        Return a 3-column numpy array containing cell ids and synaptic conductances for recorded cells.

        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        gsyn = self.vertex.get_gsyn(controller, gather=gather, compatible_output=compatible_output)
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()
        return gsyn
Ejemplo n.º 4
0
    def getSpikes(self, compatible_output=False, gather=True):
        """
        Return a 2-column numpy array containing cell ids and spike times for
        recorded cells.   This is read directly from the memory for the board.
        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        spikes = self.vertex.getSpikes(controller, controller.dao.run_time, compatible_output)

        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()
        return spikes
Ejemplo n.º 5
0
    def get_v(self, gather=True, compatible_output=False):
        """
        Return a 3-column numpy array containing cell ids, time, and Vm for recorded cells.

        :param bool gather:
            not used - inserted to match PyNN specs
        :param bool compatible_output:
            not used - inserted to match PyNN specs
        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        v = self.vertex.get_v(controller, gather=gather, compatible_output=compatible_output)

        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()

        return v
Ejemplo n.º 6
0
    def getWeights(self, format='list'):
        """
        Get synaptic weights for all connections in this Projection.
        (pyNN gather parameter not supported from the signiture
        getWeights(self, format='list', gather=True):)

        Possible formats are: a list of length equal to the number of connections
        in the projection, a 2D weight array (with NaN for non-existent
        connections). Note that for the array format, if there is more than
        one connection between two cells, the summed weight will be given.
        """
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        synapse_list = self._get_synaptic_data()
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()

        if format == 'list':
            weights = list()
            for row in synapse_list.get_rows():
                weights.extend(row.weights)
            return weights
        elif format == 'array':
            weights = numpy.zeros((self.projection_edge.prevertex.atoms,
                                   self.projection_edge.postvertex.atoms))
            rows = synapse_list.get_rows()
        for pre_atom, row in enumerate(rows):
            for post_atom, weight in zip(row.target_indices, row.weights):
                weights[pre_atom][post_atom] = weight
        return weights
Ejemplo n.º 7
0
    def getDelays(self, format='list', gather=True):
        """
        Get synaptic delays for all connections in this Projection.

        Possible formats are: a list of length equal to the number of connections
        in the projection, a 2D delay array (with NaN for non-existent
        connections).
        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        synapse_list = self._get_synaptic_data()
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()

        if format == 'list':
            delays = list()
            for row in synapse_list.get_rows():
                delays.extend(row.delays *
                              (float(controller.dao.machineTimeStep) / 1000.0))
            return delays

        delays = numpy.zeros((self.projection_edge.prevertex.atoms,
                              self.projection_edge.postvertex.atoms))
        rows = synapse_list.get_rows()
        for pre_atom in range(len(rows)):
            row = rows[pre_atom]
            for i in len(row.target_indices):
                post_atom = row.target_indices[i]
                delay = (float(row.delays[i]) *
                         (float(controller.dao.machineTimeStep) / 1000.0))
                delays[pre_atom][post_atom] = delay
        return delays
Ejemplo n.º 8
0
    def get_gsyn(self, gather=True, compatible_output=False):
        """
        Return a 3-column numpy array containing cell ids and synaptic conductances for recorded cells.

        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        gsyn = self.vertex.get_gsyn(controller,
                                    gather=gather,
                                    compatible_output=compatible_output)
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()
        return gsyn
Ejemplo n.º 9
0
    def getSpikes(self, compatible_output=False, gather=True):
        """
        Return a 2-column numpy array containing cell ids and spike times for
        recorded cells.   This is read directly from the memory for the board.
        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        spikes = self.vertex.getSpikes(controller, controller.dao.run_time,
                                       compatible_output)

        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()
        return spikes
Ejemplo n.º 10
0
    def get_v(self, gather=True, compatible_output=False):
        """
        Return a 3-column numpy array containing cell ids, time, and Vm for recorded cells.

        :param bool gather:
            not used - inserted to match PyNN specs
        :param bool compatible_output:
            not used - inserted to match PyNN specs
        """
        global controller
        timer = None
        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer = Timer()
            timer.start_timing()
        v = self.vertex.get_v(controller,
                              gather=gather,
                              compatible_output=compatible_output)

        if conf.config.getboolean("Reports", "outputTimesForSections"):
            timer.take_sample()

        return v
Ejemplo n.º 11
0
def run(run_time=None, do_load=None, do_run=None):
    """
    Run the simulation for run_time ms.

    :param int run_time:
        simulation length (in ms)

    On run the following :py:class:`pacman103.core.control.Controller` functions are called:
     - :py:mod:`pacman103.core.control.Controller.map_model`
     - :py:mod:`pacman103.core.control.Controller.specify_output`
     - :py:mod:`pacman103.core.control.Controller.generate_output`
     - :py:mod:`pacman103.core.control.Controller.load_executables`
     - :py:mod:`pacman103.core.control.Controller.run`
    """
    global controller
    do_timing = conf.config.getboolean("Reports", "outputTimesForSections")

    if do_timing:
        timer = Timer()
    if do_load == None:
        do_load = True
        if conf.config.has_option("Execute", "load"):
            do_load = conf.config.getboolean("Execute", "load")

    if do_run == None:
        do_run = True
        if conf.config.has_option("Execute", "run"):
            do_run = conf.config.getboolean("Execute", "run")

    controller.dao.run_time = run_time
    logger.info("*** Running Mapper *** ")
    if do_timing:
        timer.start_timing()
    controller.map_model()
    if do_timing:
        timer.take_sample()

    if do_timing:
        timer.start_timing()
    logger.info("*** Generating Output *** ")
    logger.debug("")
    controller.generate_output()
    if do_timing:
        timer.take_sample()

    controller.start_visualiser()

    if do_timing:
        timer.start_timing()
    if (conf.config.getboolean("Execute", "run_simulation")):
        if do_load == True:
            logger.info("*** Loading data ***")
            controller.load_targets()
            controller.load_write_mem()
        if do_timing:
            timer.take_sample()

        if do_run == True:
            logger.info("*** Running simulation... *** ")
            controller.run(controller.dao.app_id)
    else:
        logger.info("*** No simulation requested: Stopping. ***")
    return run_time
Ejemplo n.º 12
0
def run(run_time = None, do_load = None, do_run = None):
    """
    Run the simulation for run_time ms.

    :param int run_time:
        simulation length (in ms)

    On run the following :py:class:`pacman103.core.control.Controller` functions are called:
     - :py:mod:`pacman103.core.control.Controller.map_model`
     - :py:mod:`pacman103.core.control.Controller.specify_output`
     - :py:mod:`pacman103.core.control.Controller.generate_output`
     - :py:mod:`pacman103.core.control.Controller.load_executables`
     - :py:mod:`pacman103.core.control.Controller.run`
    """
    global controller
    do_timing = conf.config.getboolean("Reports", "outputTimesForSections")

    if do_timing:
        timer = Timer()
    if do_load == None:
        do_load = True
        if conf.config.has_option("Execute", "load"):
            do_load = conf.config.getboolean("Execute", "load")
    
    if do_run == None:
        do_run = True
        if conf.config.has_option("Execute", "run"):
            do_run = conf.config.getboolean("Execute", "run")

    controller.dao.run_time = run_time
    logger.info("*** Running Mapper *** ")
    if do_timing:
        timer.start_timing()
    controller.map_model()
    if do_timing:
        timer.take_sample()

    if do_timing:
        timer.start_timing()
    logger.info("*** Generating Output *** ")
    logger.debug("")
    controller.generate_output()
    if do_timing:
        timer.take_sample()
    
    controller.start_visualiser()

    if do_timing:
        timer.start_timing()
    if(conf.config.getboolean("Execute", "run_simulation")):
        if do_load == True:
            logger.info("*** Loading data ***")
            controller.load_targets()
            controller.load_write_mem()
        if do_timing:
            timer.take_sample()
        
        if do_run == True:
            logger.info("*** Running simulation... *** ")
            controller.run(controller.dao.app_id)
    else:
        logger.info("*** No simulation requested: Stopping. ***")
    return run_time