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 Constructor of oscillatory network LEGION (local excitatory global inhibitory oscillatory network).
  
  @param[in] num_osc (uint): Number of oscillators in the network.
  @param[in] parameters (legion_parameters): Parameters of the network that are defined by structure 'legion_parameters'.
  @param[in] type_conn (conn_type): Type of connection between oscillators in the network.
  @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).
docstr_tok: ["!","@","brief","Constructor","of","oscillatory","network","LEGION","(","local","excitatory","global","inhibitory","oscillatory","network",")",".","@","param","[","in","]","num_osc","(","uint",")",":","Number","of","oscillators","in","the","network",".","@","param","[","in","]","parameters","(","legion_parameters",")",":","Parameters","of","the","network","that","are","defined","by","structure","'legion_parameters","'",".","@","param","[","in","]","type_conn","(","conn_type",")",":","Type","of","connection","between","oscillators","in","the","network",".","@","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",")","."]
code: def __init__(
      self,
      num_osc,
      parameters=None,
      type_conn=conn_type.ALL_TO_ALL,
      type_conn_represent=conn_represent.MATRIX,
      ccore=True,
  ):
      """!
      @brief Constructor of oscillatory network LEGION (local excitatory global inhibitory oscillatory network).
  
      @param[in] num_osc (uint): Number of oscillators in the network.
      @param[in] parameters (legion_parameters): Parameters of the network that are defined by structure 'legion_parameters'.
      @param[in] type_conn (conn_type): Type of connection between oscillators in the network.
      @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).
  
      """
  
      self._params = None
      # parameters of the network
  
      self.__ccore_legion_pointer = None
      self._params = parameters
  
      # set parameters of the network
      if self._params is None:
          self._params = legion_parameters()
  
      if (ccore is True) and ccore_library.workable():
          self.__ccore_legion_pointer = wrapper.legion_create(
              num_osc, type_conn, self._params
          )
  
      else:
          super().__init__(num_osc, type_conn, type_conn_represent)
  
          # initial states
          self._excitatory = [
              random.random() for _ in range(self._num_osc)
          ]
          self._inhibitory = [0.0] * self._num_osc
          self._potential = [0.0] * self._num_osc
  
          self._coupling_term = None
          # coupling term of each oscillator
          self._global_inhibitor = 0
          # value of global inhibitory
          self._stimulus = None
          # stimulus of each oscillator
  
          self._dynamic_coupling = None
          # dynamic connection between oscillators
          self._coupling_term = [0.0] * self._num_osc
          self._buffer_coupling_term = [0.0] * self._num_osc
  
          # generate first noises
          self._noise = [
              random.random() * self._params.ro
              for i in range(self._num_osc)
          ]
  
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 1 to create a new legion_network object from inherited base classes: network with example: obj = legion_network(num_osc, parameters, type_conn, type_conn_represent, ccore)