def _legion_state(self, inputs, t, argv): """! @brief Returns new values of excitatory and inhibitory parts of oscillator and potential of oscillator. @param[in] inputs (list): Initial values (current) of oscillator [excitatory, inhibitory, potential]. @param[in] t (double): Current time of simulation. @param[in] argv (uint): Extra arguments that are not used for integration - index of oscillator. @return (list) New values of excitatoty and inhibitory part of oscillator and new value of potential (not assign). """ index = argv; x = inputs[0]; # excitatory y = inputs[1]; # inhibitory p = inputs[2]; # potential potential_influence = heaviside(p + math.exp(-self._params.alpha * t) - self._params.teta); dx = 3.0 * x - x ** 3.0 + 2.0 - y + self._stimulus[index] * potential_influence + self._coupling_term[index] + self._noise[index]; dy = self._params.eps * (self._params.gamma * (1.0 + math.tanh(x / self._params.betta)) - y); neighbors = self.get_neighbors(index); potential = 0.0; for index_neighbor in neighbors: potential += self._params.T * heaviside(self._excitatory[index_neighbor] - self._params.teta_x); dp = self._params.lamda * (1.0 - p) * heaviside(potential - self._params.teta_p) - self._params.mu * p; return [dx, dy, dp];
def _calculate_states(self, solution, t, step, int_step): """! @brief Calculates new state of each oscillator in the network. @param[in] solution (solve_type): Type solver of the differential equation. @param[in] t (double): Current time of simulation. @param[in] step (double): Step of solution at the end of which states of oscillators should be calculated. @param[in] int_step (double): Step differentiation that is used for solving differential equation. """ next_excitatory = [0.0] * self._num_osc; next_inhibitory = [0.0] * self._num_osc; next_potential = []; if (self._params.ENABLE_POTENTIONAL is True): next_potential = [0.0] * self._num_osc; # Update states of oscillators for index in range (0, self._num_osc, 1): if (self._params.ENABLE_POTENTIONAL is True): result = odeint(self._legion_state, [self._excitatory[index], self._inhibitory[index], self._potential[index]], numpy.arange(t - step, t, int_step), (index , )); [ next_excitatory[index], next_inhibitory[index], next_potential[index] ] = result[len(result) - 1][0:3]; else: result = odeint(self._legion_state_simplify, [self._excitatory[index], self._inhibitory[index] ], numpy.arange(t - step, t, int_step), (index , )); [ next_excitatory[index], next_inhibitory[index] ] = result[len(result) - 1][0:2]; # Update coupling term neighbors = self.get_neighbors(index); coupling = 0 for index_neighbor in neighbors: coupling += self._dynamic_coupling[index][index_neighbor] * heaviside(self._excitatory[index_neighbor] - self._params.teta_x); self._buffer_coupling_term[index] = coupling - self._params.Wz * heaviside(self._global_inhibitor - self._params.teta_xz); # Update state of global inhibitory result = odeint(self._global_inhibitor_state, self._global_inhibitor, numpy.arange(t - step, t, int_step), (None, )); self._global_inhibitor = result[len(result) - 1][0]; self._noise = [random.random() * self._params.ro for i in range(self._num_osc)]; self._coupling_term = self._buffer_coupling_term[:]; self._inhibitory = next_inhibitory[:]; self._excitatory = next_excitatory[:]; if (self._params.ENABLE_POTENTIONAL is True): self._potential = next_potential[:];
def _legion_state_simplify(self, inputs, t, argv): """! @brief Returns new values of excitatory and inhibitory parts of oscillator of oscillator. @details Simplify model doesn't consider oscillator potential. @param[in] inputs (list): Initial values (current) of oscillator [excitatory, inhibitory]. @param[in] t (double): Current time of simulation. @param[in] argv (uint): Extra arguments that are not used for integration - index of oscillator. @return (list) New values of excitatoty and inhibitory part of oscillator (not assign). """ index = argv x = inputs[0] # excitatory y = inputs[1] # inhibitory dx = 3.0 * x - x**3.0 + 2.0 - y + self._stimulus[ index] + self._coupling_term[index] + self._noise[index] dy = self._params.eps * (self._params.gamma * (1.0 + math.tanh(x / self._params.betta)) - y) neighbors = self.get_neighbors(index) potential = 0.0 for index_neighbor in neighbors: potential += self._params.T * heaviside( self._excitatory[index_neighbor] - self._params.teta_x) return [dx, dy]
def _legion_state_simplify(self, inputs, t, argv): """! @brief Returns new values of excitatory and inhibitory parts of oscillator of oscillator. @details Simplify model doesn't consider oscillator potential. @param[in] inputs (list): Initial values (current) of oscillator [excitatory, inhibitory]. @param[in] t (double): Current time of simulation. @param[in] argv (uint): Extra arguments that are not used for integration - index of oscillator. @return (list) New values of excitatoty and inhibitory part of oscillator (not assign). """ index = argv; x = inputs[0]; # excitatory y = inputs[1]; # inhibitory dx = 3.0 * x - x ** 3.0 + 2.0 - y + self._stimulus[index] + self._coupling_term[index] + self._noise[index]; dy = self._params.eps * (self._params.gamma * (1.0 + math.tanh(x / self._params.betta)) - y); neighbors = self.get_neighbors(index); potential = 0.0; for index_neighbor in neighbors: potential += self._params.T * heaviside(self._excitatory[index_neighbor] - self._params.teta_x); return [dx, dy];
def __allocate_neuron_patterns(self, start_iteration, stop_iteration): """! @brief Allocates observation transposed matrix of neurons that is limited by specified periods of simulation. @details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each iteration. @return (list) Transposed observation matrix that is limited by specified periods of simulation. """ pattern_matrix = [] for index_neuron in range(len(self.output[0])): pattern_neuron = [] for iteration in range(start_iteration, stop_iteration): pattern_neuron.append(heaviside(self.output[iteration][index_neuron])) pattern_matrix.append(pattern_neuron) return pattern_matrix
def allocate_observation_matrix(self): """! @brief Allocates observation matrix in line with output dynamic of the network. @details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each iteration. @return (list) Observation matrix of the network dynamic. """ number_neurons = len(self.output[0]) observation_matrix = [] for iteration in range(len(self.output)): obervation_column = [] for index_neuron in range(number_neurons): obervation_column.append(heaviside(self.output[iteration][index_neuron])) observation_matrix.append(obervation_column) return observation_matrix