class_docstr: !
  @brief Local excitatory global inhibitory oscillatory network (LEGION) that uses relaxation oscillator
         based on Van der Pol model. 
         
  @details The model uses global inhibitor to de-synchronize synchronous ensembles of oscillators.
           
           CCORE option can be used to use the pyclustering core - C/C++ shared library for processing that significantly increases performance.
  
  Example:
  @code
      # Create parameters of the network
      parameters = legion_parameters();
      parameters.Wt = 4.0;
      
      # Create stimulus
      stimulus = [1, 1, 0, 0, 0, 1, 1, 1];
      
      # Create the network (use CCORE for fast solving)
      net = legion_network(len(stimulus), parameters, conn_type.GRID_FOUR, ccore = True);
      
      # Simulate network - result of simulation is output dynamic of the network
      output_dynamic = net.simulate(1000, 750, stimulus);
      
      # Draw output dynamic
      draw_dynamics(output_dynamic.time, output_dynamic.output, x_title = "Time", y_title = "x(t)");
  @endcode
class_docstr_tok: ["!","@","brief","Local","excitatory","global","inhibitory","oscillatory","network","(","LEGION",")","that","uses","relaxation","oscillator","based","on","Van","der","Pol","model",".","@","details","The","model","uses","global","inhibitor","to","de-synchronize","synchronous","ensembles","of","oscillators",".","CCORE","option","can","be","used","to","use","the","pyclustering","core","-","C\/C++","shared","library","for","processing","that","significantly","increases","performance",".","Example",":","@","code","#","Create","parameters","of","the","network","parameters","=","legion_parameters","(",")",";","parameters.Wt","=","4.0",";","#","Create","stimulus","stimulus","=","[","1",",","1",",","0",",","0",",","0",",","1",",","1",",","1","]",";","#","Create","the","network","(","use","CCORE","for","fast","solving",")","net","=","legion_network","(","len","(","stimulus",")",",","parameters",",","conn_type.GRID_FOUR",",","ccore","=","True",")",";","#","Simulate","network","-","result","of","simulation","is","output","dynamic","of","the","network","output_dynamic","=","net.simulate","(","1000",",","750",",","stimulus",")",";","#","Draw","output","dynamic","draw_dynamics","(","output_dynamic.time",",","output_dynamic.output",",","x_title","=","``","Time","''",",","y_title","=","``","x","(","t",")","''",")",";","@","endcode"]
docstr: !
  @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).
docstr_tok: ["!","@","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",")","."]
code: 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]
  
imports: import numpy
  import random
  import pyclustering.core.legion_wrapper
  from pyclustering.core.wrapper import ccore_library
  from pyclustering.nnet import *
  from pyclustering.utils import heaviside, allocate_sync_ensembles
  from scipy.integrate import odeint
label_desc: Use image node_id 10 for calling the legion_network obj's underlying member method code with example usage: obj._legion_state(inputs, t, argv) and returns: list