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 Performs static simulation of LEGION oscillatory network.
  
  @param[in] steps (uint): Number steps of simulations during simulation.
  @param[in] time (double): Time of simulation.
  @param[in] stimulus (list): Stimulus for oscillators, number of stimulus should be equal to number of oscillators,
             example of stimulus for 5 oscillators [0, 0, 1, 1, 0], value of stimulus is defined by parameter 'I'.
  @param[in] solution (solve_type): Method that is used for differential equation.
  @param[in] collect_dynamic (bool): If True - returns whole dynamic of oscillatory network, otherwise returns only last values of dynamics.
  
  @return (list) Dynamic of oscillatory network. If argument 'collect_dynamic' = True, than return dynamic for the whole simulation time,
          otherwise returns only last values (last step of simulation) of dynamic.
docstr_tok: ["!","@","brief","Performs","static","simulation","of","LEGION","oscillatory","network",".","@","param","[","in","]","steps","(","uint",")",":","Number","steps","of","simulations","during","simulation",".","@","param","[","in","]","time","(","double",")",":","Time","of","simulation",".","@","param","[","in","]","stimulus","(","list",")",":","Stimulus","for","oscillators",",","number","of","stimulus","should","be","equal","to","number","of","oscillators",",","example","of","stimulus","for","5","oscillators","[","0",",","0",",","1",",","1",",","0","]",",","value","of","stimulus","is","defined","by","parameter","'","I","'",".","@","param","[","in","]","solution","(","solve_type",")",":","Method","that","is","used","for","differential","equation",".","@","param","[","in","]","collect_dynamic","(","bool",")",":","If","True","-","returns","whole","dynamic","of","oscillatory","network",",","otherwise","returns","only","last","values","of","dynamics",".","@","return","(","list",")","Dynamic","of","oscillatory","network",".","If","argument","'collect_dynamic","'","=","True",",","than","return","dynamic","for","the","whole","simulation","time",",","otherwise","returns","only","last","values","(","last","step","of","simulation",")","of","dynamic","."]
code: def simulate(
      self,
      steps,
      time,
      stimulus,
      solution=solve_type.RK4,
      collect_dynamic=True,
  ):
      """!
      @brief Performs static simulation of LEGION oscillatory network.
  
      @param[in] steps (uint): Number steps of simulations during simulation.
      @param[in] time (double): Time of simulation.
      @param[in] stimulus (list): Stimulus for oscillators, number of stimulus should be equal to number of oscillators,
                 example of stimulus for 5 oscillators [0, 0, 1, 1, 0], value of stimulus is defined by parameter 'I'.
      @param[in] solution (solve_type): Method that is used for differential equation.
      @param[in] collect_dynamic (bool): If True - returns whole dynamic of oscillatory network, otherwise returns only last values of dynamics.
  
      @return (list) Dynamic of oscillatory network. If argument 'collect_dynamic' = True, than return dynamic for the whole simulation time,
              otherwise returns only last values (last step of simulation) of dynamic.
  
      """
  
      if self.__ccore_legion_pointer is not None:
          pointer_dynamic = wrapper.legion_simulate(
              self.__ccore_legion_pointer,
              steps,
              time,
              solution,
              collect_dynamic,
              stimulus,
          )
          return legion_dynamic(None, None, None, pointer_dynamic)
  
      # Check solver before simulation
      if solution == solve_type.FAST:
          raise NameError(
              "Solver FAST is not support due to low accuracy that leads to huge error."
          )
  
      elif solution == solve_type.RKF45:
          raise NameError(
              "Solver RKF45 is not support in python version. RKF45 is supported in CCORE implementation."
          )
  
      # set stimulus
      self.__create_stimulus(stimulus)
  
      # calculate dynamic weights
      self.__create_dynamic_connections()
  
      dyn_exc = None
      dyn_time = None
      dyn_ginh = None
  
      # Store only excitatory of the oscillator
      if collect_dynamic is True:
          dyn_exc = []
          dyn_time = []
          dyn_ginh = []
  
      step = time / steps
      int_step = step / 10.0
  
      for t in numpy.arange(step, time + step, step):
          # update states of oscillators
          self._calculate_states(solution, t, step, int_step)
  
          # update states of oscillators
          if collect_dynamic is True:
              dyn_exc.append(self._excitatory)
              dyn_time.append(t)
              dyn_ginh.append(self._global_inhibitor)
          else:
              dyn_exc = self._excitatory
              dyn_time = t
              dyn_ginh = self._global_inhibitor
  
      return legion_dynamic(dyn_exc, dyn_ginh, dyn_time)
  
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 6 for calling the legion_network obj's underlying member method code with example usage: obj.simulate(steps, time, stimulus, solution, collect_dynamic) and returns: legion_dynamic, legion_dynamic