Exemple #1
0
    def __init__(self,
                 num_osc,
                 parameters=None,
                 type_conn=conn_type.ALL_TO_ALL,
                 type_conn_represent=conn_represent.MATRIX,
                 height=None,
                 width=None,
                 ccore=False):
        """!
        @brief Constructor of oscillatory network is based on Kuramoto model.
        
        @param[in] num_osc (uint): Number of oscillators in the network.
        @param[in] parameters (pcnn_parameters): Parameters of the network.
        @param[in] type_conn (conn_type): Type of connection between oscillators in the network (all-to-all, grid, bidirectional list, etc.).
        @param[in] type_conn_represent (conn_represent): Internal representation of connection in the network: matrix or list.
        @param[in] height (uint): Number of oscillators in column of the network, this argument is used 
                    only for network with grid structure (GRID_FOUR, GRID_EIGHT), for other types this argument is ignored.
        @param[in] width (uint): Number of oscillotors in row of the network, this argument is used only 
                    for network with grid structure (GRID_FOUR, GRID_EIGHT), for other types this argument is ignored.
        @param[in] ccore (bool): If True then all interaction with object will be performed via CCORE library (C++ implementation of pyclustering).
        
        """

        # set parameters of the network
        if (parameters is not None):
            self._params = parameters
        else:
            self._params = pcnn_parameters()

        if (ccore is True):
            network_height = height
            network_width = width

            if ((type_conn == conn_type.GRID_FOUR)
                    or (type_conn == conn_type.GRID_EIGHT)):
                if ((network_height is None) or (network_width is None)):
                    side_size = num_osc**(0.5)
                    if (side_size - math.floor(side_size) > 0):
                        raise NameError(
                            'Invalid number of oscillators in the network in case of grid structure'
                        )

                    network_height = int(side_size)
                    network_width = int(side_size)
            else:
                network_height = 0
                network_width = 0

            self.__ccore_pcnn_pointer = wrapper.pcnn_create(
                num_osc, type_conn, network_height, network_width,
                self._params)
        else:
            super().__init__(num_osc, type_conn, type_conn_represent, height,
                             width)

            self._outputs = [0.0] * self._num_osc

            self._feeding = [0.0] * self._num_osc
            self._linking = [0.0] * self._num_osc
            self._threshold = [random.random() for i in range(self._num_osc)]
Exemple #2
0
 def __init__(self, num_osc, parameters = None, type_conn = conn_type.ALL_TO_ALL, type_conn_represent = conn_represent.MATRIX, ccore = False):
     """!
     @brief Constructor of oscillatory network is based on Kuramoto model.
     
     @param[in] num_osc (uint): Number of oscillators in the network.
     @param[in] parameters (pcnn_parameters): Parameters of the network.
     @param[in] type_conn (conn_type): Type of connection between oscillators in the network (all-to-all, grid, bidirectional list, etc.).
     @param[in] type_conn_represent (conn_represent): Internal representation of connection in the network: matrix or list.
     @param[in] ccore (bool): If True then all interaction with object will be performed via CCORE library (C++ implementation of pyclustering).
     
     """
     
     # set parameters of the network
     if (parameters is not None):
         self._params = parameters;
     else:
         self._params = pcnn_parameters();
     
     if (ccore is True):
         self.__ccore_pcnn_pointer = wrapper.pcnn_create(num_osc, type_conn, self._params);
     else:
         super().__init__(num_osc, type_conn, type_conn_represent);
         
         self._outputs = [0.0] * self._num_osc;
         
         self._feeding = [0.0] * self._num_osc;    
         self._linking = [0.0] * self._num_osc;        
         self._threshold = [ random.random() for i in range(self._num_osc) ];
Exemple #3
0
    def __init__(self,
                 num_osc,
                 parameters=None,
                 type_conn=conn_type.ALL_TO_ALL,
                 type_conn_represent=conn_represent.MATRIX,
                 ccore=False):
        """!
        @brief Constructor of oscillatory network is based on Kuramoto model.
        
        @param[in] num_osc (uint): Number of oscillators in the network.
        @param[in] parameters (pcnn_parameters): Parameters of the network.
        @param[in] type_conn (conn_type): Type of connection between oscillators in the network (all-to-all, grid, bidirectional list, etc.).
        @param[in] type_conn_represent (conn_represent): Internal representation of connection in the network: matrix or list.
        @param[in] ccore (bool): If True then all interaction with object will be performed via CCORE library (C++ implementation of pyclustering).
        
        """

        # set parameters of the network
        if (parameters is not None):
            self._params = parameters
        else:
            self._params = pcnn_parameters()

        if (ccore is True):
            self.__ccore_pcnn_pointer = wrapper.pcnn_create(
                num_osc, type_conn, self._params)
        else:
            super().__init__(num_osc, type_conn, type_conn_represent)

            self._outputs = [0.0] * self._num_osc

            self._feeding = [0.0] * self._num_osc
            self._linking = [0.0] * self._num_osc
            self._threshold = [random.random() for i in range(self._num_osc)]
Exemple #4
0
 def __init__(self, num_osc, parameters=None, type_conn=conn_type.ALL_TO_ALL, type_conn_represent=conn_represent.MATRIX, height=None, width=None, ccore=True):
     """!
     @brief Constructor of oscillatory network is based on Kuramoto model.
     
     @param[in] num_osc (uint): Number of oscillators in the network.
     @param[in] parameters (pcnn_parameters): Parameters of the network.
     @param[in] type_conn (conn_type): Type of connection between oscillators in the network (all-to-all, grid, bidirectional list, etc.).
     @param[in] type_conn_represent (conn_represent): Internal representation of connection in the network: matrix or list.
     @param[in] height (uint): Number of oscillators in column of the network, this argument is used 
                 only for network with grid structure (GRID_FOUR, GRID_EIGHT), for other types this argument is ignored.
     @param[in] width (uint): Number of oscillotors in row of the network, this argument is used only 
                 for network with grid structure (GRID_FOUR, GRID_EIGHT), for other types this argument is ignored.
     @param[in] ccore (bool): If True then all interaction with object will be performed via CCORE library (C++ implementation of pyclustering).
     
     """
     
     self._outputs = None            # list of outputs of oscillators.
 
     self._feeding = None            # feeding compartment of each oscillator.
     self._linking = None            # linking compartment of each oscillator.
     self._threshold = None          # threshold of each oscillator.
     
     self._params = None
     
     self.__ccore_pcnn_pointer = None
     
     # set parameters of the network
     if parameters is not None:
         self._params = parameters
     else:
         self._params = pcnn_parameters()
     
     if (ccore is True) and ccore_library.workable():
         network_height = height
         network_width = width
         
         if (type_conn == conn_type.GRID_FOUR) or (type_conn == conn_type.GRID_EIGHT):
             if (network_height is None) or (network_width is None):
                 side_size = num_osc ** (0.5)
                 if side_size - math.floor(side_size) > 0:
                     raise NameError('Invalid number of oscillators in the network in case of grid structure')
             
                 network_height = int(side_size)
                 network_width = int(side_size)
         else:
             network_height = 0
             network_width = 0
             
         self.__ccore_pcnn_pointer = wrapper.pcnn_create(num_osc, type_conn, network_height, network_width, self._params)
     else:
         super().__init__(num_osc, type_conn, type_conn_represent, height, width)
         
         self._outputs = [0.0] * self._num_osc
         
         self._feeding = [0.0] * self._num_osc
         self._linking = [0.0] * self._num_osc
         self._threshold = [ random.random() for i in range(self._num_osc) ]