Beispiel #1
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.

    NEURON specific extra_params:

    use_cvode - use the NEURON cvode solver. Defaults to False.

    returns: MPI rank

    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.initializer.clear()
    simulator.state.clear()
    simulator.reset()
    simulator.state.dt = timestep
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    if extra_params.has_key('use_cvode'):
        simulator.state.cvode.active(int(extra_params['use_cvode']))
        if extra_params.has_key('rtol'):
            simulator.state.cvode.rtol(float(extra_params['rtol']))
        if extra_params.has_key('atol'):
            simulator.state.cvode.atol(float(extra_params['atol']))
    if extra_params.has_key('default_maxstep'):
        simulator.state.default_maxstep = float(
            extra_params['default_maxstep'])
    return rank()
Beispiel #2
0
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):

    max_delay = extra_params.get("max_delay", DEFAULT_MAX_DELAY)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get("rank", 0)
    simulator.state.num_processes = extra_params.get("num_processes", 1)
    simulator.state.model.use_cpu = extra_params.get("use_cpu", None)

    # If a model name is specified, use that
    if "model_name" in extra_params:
        simulator.state.model.model_name = extra_params["model_name"]
    # Otherwise
    else:
        # Get the parent frame from our current frame (whatever called setup)
        calframe = inspect.getouterframes(inspect.currentframe(), 1)

        # Extract model name and path
        model_name = os.path.splitext(os.path.basename(calframe[1][1]))[0]
        model_name = sanitize_label(model_name)
        model_path = os.path.dirname(calframe[1][1])

        # Set model name and path (adding ./ if path is relative)
        simulator.state.model.model_name = model_name
        simulator.state.model_path = (model_path + os.sep
                                      if os.path.isabs(model_path) else "./" +
                                      model_path + os.sep)
    return rank()
Beispiel #3
0
def setup(timestep=1, min_delay=1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    if (timestep < 1):
        raise Exception(
            "It is not currently possible to have a timestep less than 1ms with this simulator"
        )
    if (min_delay < 1):
        raise Exception(
            "It is not currently possible to have a min_delay less than 1ms with this simulator"
        )

    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state = simulator._State(timestep, min_delay, max_delay)
    simulator.spikes_array_list = []
    simulator.recorder_list = []
    if "cpu_backend" in extra_params:
        simulator.state.conf.set_cpu_backend()
    if "cuda_backend" in extra_params:
        simulator.state.conf.set_cuda_backend(extra_params["cuda_backend"])
    print("The backend used by nemo is: ",
          simulator.state.conf.backend_description())
    return simulator.state.mpi_rank
Beispiel #4
0
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """ Set up for saving cell models and network structure to NeuroML """
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = extra_params.get('max_delay',
                                                 DEFAULT_MAX_DELAY)
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)

    logger.debug("Creating network in NeuroML document to store structure")
    nml_doc = simulator._get_nml_doc(extra_params.get('reference',
                                                      "PyNN_NeuroML2_Export"),
                                     reset=True)
    global save_format
    save_format = extra_params.get('save_format', "xml")

    # Create network
    net = neuroml.Network(id=nml_doc.id)
    nml_doc.networks.append(net)

    lems_sim = simulator._get_lems_sim(reset=True)
    lems_sim.dt = '%s' % timestep

    return rank()
Beispiel #5
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)
    return rank()
Beispiel #6
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    global tempdir

    common.setup(timestep, min_delay, max_delay, **extra_params)

    if 'verbosity' in extra_params:
        nest_verbosity = extra_params['verbosity'].upper()
    else:
        nest_verbosity = "WARNING"
    nest.sli_run("M_%s setverbosity" % nest_verbosity)

    # clear the sli stack, if this is not done --> memory leak cause the stack increases
    nest.sr('clear')

    # reset the simulation kernel
    nest.ResetKernel()

    # set tempdir
    tempdir = tempfile.mkdtemp()
    tempdirs.append(tempdir)  # append tempdir to tempdirs list
    nest.SetKernelStatus({
        'data_path': tempdir,
    })

    # set kernel RNG seeds
    num_threads = extra_params.get('threads') or 1
    if 'rng_seeds' in extra_params:
        rng_seeds = extra_params['rng_seeds']
    else:
        rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42
        rng = NumpyRNG(rng_seeds_seed)
        rng_seeds = (rng.rng.uniform(size=num_threads * num_processes()) *
                     100000).astype('int').tolist()
    logger.debug("rng_seeds = %s" % rng_seeds)
    nest.SetKernelStatus({
        'local_num_threads': num_threads,
        'rng_seeds': rng_seeds
    })

    # set resolution
    nest.SetKernelStatus({'resolution': timestep})

    # Set min_delay and max_delay for all synapse models
    for synapse_model in NEST_SYNAPSE_TYPES:
        nest.SetDefaults(synapse_model, {
            'delay': min_delay,
            'min_delay': min_delay,
            'max_delay': max_delay
        })
    simulator.reset()

    return rank()
Beispiel #7
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)
    return rank()
Beispiel #8
0
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """
    Should be called at the very beginning of a script.

    `extra_params` contains any keyword arguments that are required by a given
    simulator but not by others.

    NEST-specific extra_params:

    `spike_precision`:
        should be "off_grid" (default) or "on_grid"
    `verbosity`:
        one of: "all", "info", "deprecated", "warning", "error", "fatal"
    `recording_precision`:
        number of decimal places (OR SIGNIFICANT FIGURES?) in recorded data
    `threads`:
        number of threads to use
    `grng_seed`:
        one seed for the global random number generator of NEST
    `rng_seeds`:
        a list of seeds, one for each thread on each MPI process
    `rng_seeds_seed`:
        a single seed that will be used to generate random values for `rng_seeds`
    `t_flush`:
        extra time to run the simulation after using reset() to ensure
        the previous run does not influence the new one
    """
    max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    for key in ("threads", "verbosity", "spike_precision", "recording_precision"):
        if key in extra_params:
            setattr(simulator.state, key, extra_params[key])
    # set kernel RNG seeds
    simulator.state.num_threads = extra_params.get('threads') or 1
    if 'grng_seed' in extra_params:
        warnings.warn("The setup argument 'grng_seed' is now 'rng_seed'")
        simulator.state.rng_seed = extra_params['grng_seed']
    if 'rng_seeds' in extra_params:
        warnings.warn("The setup argument 'rng_seeds' is no longer available. Taking the first value for the global seed.")
        simulator.state.rng_seed = extra_params['rng_seeds'][0]
    if 'rng_seeds_seed' in extra_params:
        warnings.warn("The setup argument 'rng_seeds_seed' is now 'rng_seed'")
        simulator.state.rng_seed = extra_params['rng_seeds_seed']
    else:
        simulator.state.rng_seed = extra_params.get('rng_seed', 42)
    if "t_flush" in extra_params:
        # see https://github.com/nest/nest-simulator/issues/1618
        simulator.state.t_flush = extra_params["t_flush"]
    # set resolution
    simulator.state.dt = timestep
    # Set min_delay and max_delay
    simulator.state.set_delays(min_delay, max_delay)
    nest.SetDefaults('spike_generator', {'precise_times': True})
    return rank()
Beispiel #9
0
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
          max_delay=DEFAULT_MAX_DELAY, **extra_params):
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)
    return rank()
Beispiel #10
0
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY, 
          max_delay=DEFAULT_MAX_DELAY, **extra_params):
    # call superclass setup
    common.setup(timestep, min_delay, max_delay, **extra_params)
    # set up the basic functionality
    simulator.state.keep_dirs =  extra_params.get('keep_dirs', False)
    simulator.state.modelname = extra_params.get('modelname', 'GeNNmodel')
    simulator.state.float_prec = extra_params.get('float_prec', 'float')
    simulator.state.nGPU = extra_params.get('nGPU', 0)
    simulator.state.clear()
Beispiel #11
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.dt = timestep
    if not os.path.exists(temporary_directory):
        os.mkdir(temporary_directory)
    return 0
Beispiel #12
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    if 'rank' in extra_params:
        simulator.state.mpi_rank = extra_params['rank']
    if 'num_processes' in extra_params:
        simulator.state.num_processes = extra_params['num_processes']
    return rank()
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
          **extra_params):

    max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)
    return rank()
Beispiel #14
0
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          max_delay=DEFAULT_MAX_DELAY,
          **extra_params):
    # call superclass setup
    common.setup(timestep, min_delay, max_delay, **extra_params)
    # set up the basic functionality
    simulator.state.keep_dirs = extra_params.get('keep_dirs', False)
    simulator.state.modelname = extra_params.get('modelname', 'GeNNmodel')
    simulator.state.float_prec = extra_params.get('float_prec', 'float')
    simulator.state.nGPU = extra_params.get('nGPU', 0)
    simulator.state.clear()
Beispiel #15
0
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """
    Should be called at the very beginning of a script.

    `extra_params` contains any keyword arguments that are required by a given
    simulator but not by others.

    NEST-specific extra_params:

    `spike_precision`:
        should be "off_grid" (default) or "on_grid"
    `verbosity`:
        one of: "all", "info", "deprecated", "warning", "error", "fatal"
    `recording_precision`:
        number of decimal places (OR SIGNIFICANT FIGURES?) in recorded data
    `threads`:
        number of threads to use
    `grng_seed`:
        one seed for the global random number generator of NEST
    `rng_seeds`:
        a list of seeds, one for each thread on each MPI process
    `rng_seeds_seed`:
        a single seed that will be used to generate random values for `rng_seeds`
    """
    max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    for key in ("threads", "verbosity", "spike_precision",
                "recording_precision"):
        if key in extra_params:
            setattr(simulator.state, key, extra_params[key])
    # set kernel RNG seeds
    simulator.state.num_threads = extra_params.get('threads') or 1
    if 'grng_seed' in extra_params:
        simulator.state.grng_seed = extra_params['grng_seed']
    if 'rng_seeds' in extra_params:
        simulator.state.rng_seeds = extra_params['rng_seeds']
    else:
        rng = NumpyRNG(extra_params.get('rng_seeds_seed', 42))
        n = simulator.state.num_processes * simulator.state.threads
        simulator.state.rng_seeds = rng.next(n, 'uniform_int', {
            'low': 0,
            'high': 100000
        }).tolist()
    # set resolution
    simulator.state.dt = timestep
    # Set min_delay and max_delay
    simulator.state.set_delays(min_delay, max_delay)
    nest.SetDefaults('spike_generator', {'precise_times': True})
    return rank()
Beispiel #16
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.net = brian.Network()
    simulator.net.add(update_currents)  # from electrodes
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.dt = timestep
    reset()
    return rank()
Beispiel #17
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    _cleanup()
    brian.set_global_preferences(**extra_params)
    simulator.state = simulator._State(timestep, min_delay, max_delay)
    simulator.state.add(update_currents)  # from electrodes
    update_currents.clock = simulator.state.simclock
    recording.simulator = simulator
    reset()
    return rank()
Beispiel #18
0
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """
    Should be called at the very beginning of a script.

    `extra_params` contains any keyword arguments that are required by a given
    simulator but not by others.

    NEST-specific extra_params:

    `spike_precision`:
        should be "off_grid" (default) or "on_grid"
    `verbosity`:
        INSERT DESCRIPTION OF POSSIBLE VALUES
    `recording_precision`:
        number of decimal places (OR SIGNIFICANT FIGURES?) in recorded data
    `threads`:
        number of threads to use
    `grng_seed`:
        one seed for the global random number generator of NEST
    `rng_seeds`:
        a list of seeds, one for each thread on each MPI process
    `rng_seeds_seed`:
        a single seed that will be used to generate random values for `rng_seeds`
    """
    max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    for key in ("verbosity", "spike_precision", "recording_precision",
                "threads"):
        if key in extra_params:
            setattr(simulator.state, key, extra_params[key])
    # set kernel RNG seeds
    simulator.state.num_threads = extra_params.get('threads') or 1
    if 'grng_seed' in extra_params:
        simulator.state.grng_seed = extra_params['grng_seed']
    if 'rng_seeds' in extra_params:
        simulator.state.rng_seeds = extra_params['rng_seeds']
    else:
        rng = NumpyRNG(extra_params.get('rng_seeds_seed', 42))
        n = simulator.state.num_processes * simulator.state.threads
        simulator.state.rng_seeds = rng.next(n, 'uniform_int', {'low': 0, 'high': 100000}).tolist()
    # set resolution
    simulator.state.dt = timestep
    # Set min_delay and max_delay
    simulator.state.set_delays(min_delay, max_delay)
    nest.SetDefaults('spike_generator', {'precise_times': True})
    return rank()
Beispiel #19
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    For pcsim, the possible arguments are 'construct_rng_seed' and 'simulation_rng_seed'.
    """
    if simulator.state.constructRNGSeed is None:
        if extra_params.has_key("construct_rng_seed"):
            construct_rng_seed = extra_params["construct_rng_seed"]
        else:
            construct_rng_seed = datetime.today().microsecond
        simulator.state.constructRNGSeed = construct_rng_seed
    if simulator.state.simulationRNGSeed is None:
        if extra_params.has_key("simulation_rng_seed"):
            simulation_rng_seed = extra_params["simulation_rng_seed"]
        else:
            simulation_rng_seed = datetime.today().microsecond
        simulator.state.simulationRNGSeed = simulation_rng_seed
    if extra_params.has_key("threads"):
        simulator.net = pypcsim.DistributedMultiThreadNetwork(
            extra_params["threads"],
            pypcsim.SimParameter(
                pypcsim.Time.ms(timestep),
                pypcsim.Time.ms(min_delay),
                pypcsim.Time.ms(max_delay),
                simulator.state.constructRNGSeed,
                simulator.state.simulationRNGSeed,
            ),
        )
    else:
        simulator.net = pypcsim.DistributedSingleThreadNetwork(
            pypcsim.SimParameter(
                pypcsim.Time.ms(timestep),
                pypcsim.Time.ms(min_delay),
                pypcsim.Time.ms(max_delay),
                simulator.state.constructRNGSeed,
                simulator.state.simulationRNGSeed,
            )
        )

    simulator.state.t = 0
    # simulator.state.dt = timestep # seems to mess up the net object
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    common.setup(timestep, min_delay, max_delay, **extra_params)
    return simulator.net.mpi_rank()
Beispiel #20
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    brian.set_global_preferences(**extra_params)
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)
    simulator.state.network.add(update_currents)
    update_currents.clock = simulator.state.network.clock
    return rank()
Beispiel #21
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    brian.set_global_preferences(**extra_params)
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)
    simulator.state.network.add(update_currents)
    update_currents.clock = simulator.state.network.clock
    return rank()
Beispiel #22
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    brian.set_global_preferences(**extra_params)
    simulator.state = simulator._State(timestep, min_delay, max_delay)
    simulator.state.add(update_currents) # from electrodes
    update_currents.clock = simulator.state.simclock
    simulator.state.network._all_operations[0].clock = brian.Clock(t=0*ms, dt=timestep*ms)
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.dt        = timestep
    recording.simulator = simulator
    reset()
    return rank()
Beispiel #23
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.

    NEURON specific extra_params:

    use_cvode - use the NEURON cvode solver. Defaults to False.
      Optional cvode Parameters:
      -> rtol - specify relative error tolerance
      -> atol - specify absolute error tolerance

    native_rng_baseseed - added to MPI.rank to form seed for SpikeSourcePoisson, etc.
    default_maxstep - TODO

    returns: MPI rank

    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.initializer.clear()
    simulator.state.clear()
    simulator.reset()
    simulator.state.dt = timestep
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    if extra_params.has_key('use_cvode'):
        simulator.state.cvode.active(int(extra_params['use_cvode']))
        if extra_params.has_key('rtol'):
            simulator.state.cvode.rtol(float(extra_params['rtol']))
        if extra_params.has_key('atol'):
            simulator.state.cvode.atol(float(extra_params['atol']))

    if extra_params.has_key('native_rng_baseseed'):
        simulator.state.native_rng_baseseed = int(
            extra_params['native_rng_baseseed'])
    else:
        simulator.state.native_rng_baseseed = 0

    if extra_params.has_key('default_maxstep'):
        simulator.state.default_maxstep = float(
            extra_params['default_maxstep'])
    return rank()
Beispiel #24
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    brian.set_global_preferences(**extra_params)
    simulator.state = simulator._State(timestep, min_delay, max_delay)
    simulator.state.add(update_currents)  # from electrodes
    ## We need to reset the clock of the update_currents function, for the electrodes
    simulator.state.network._all_operations[0].clock = brian.Clock(
        t=0 * ms, dt=timestep * ms)
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.dt = timestep
    recording.simulator = simulator
    reset()
    return rank()
Beispiel #25
0
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """
    Should be called at the very beginning of a script.

    `extra_params` contains any keyword arguments that are required by a given
    simulator but not by others.

    NEURON specific extra_params:

    use_cvode - use the NEURON cvode solver. Defaults to False.
      Optional cvode Parameters:
      -> rtol - specify relative error tolerance
      -> atol - specify absolute error tolerance

    native_rng_baseseed - added to MPI.rank to form seed for SpikeSourcePoisson, etc.
    default_maxstep - TODO

    returns: MPI rank

    """
    common.setup(timestep, min_delay, **extra_params)
    simulator.initializer.clear()
    simulator.state.clear()
    simulator.state.dt = timestep
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = extra_params.get('max_delay',
                                                 DEFAULT_MAX_DELAY)
    if 'use_cvode' in extra_params:
        simulator.state.cvode.active(int(extra_params['use_cvode']))
        if 'rtol' in extra_params:
            simulator.state.cvode.rtol(float(extra_params['rtol']))
        if 'atol' in extra_params:
            simulator.state.cvode.atol(float(extra_params['atol']))
    if 'native_rng_baseseed' in extra_params:
        simulator.state.native_rng_baseseed = int(
            extra_params['native_rng_baseseed'])
    if 'default_maxstep' in extra_params:
        simulator.state.default_maxstep = float(
            extra_params['default_maxstep'])
    return rank()
Beispiel #26
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.

    `extra_params` contains any keyword arguments that are required by a given
    simulator but not by others.

    NEST-specific extra_params:

    `spike_precision`:
        should be "on_grid" (default) or "off_grid"
    `verbosity`:
        INSERT DESCRIPTION OF POSSIBLE VALUES
    `recording_precision`:
        number of decimal places (OR SIGNIFICANT FIGURES?) in recorded data
    `threads`:
        number of threads to use
    `rng_seeds`:
        a list of seeds, one for each thread on each MPI process
    `rng_seeds_seed`:
        a single seed that will be used to generate random values for `rng_seeds`
    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state.clear()
    for key in ("verbosity", "spike_precision", "recording_precision",
                "threads"):
        if key in extra_params:
            setattr(simulator.state, key, extra_params[key])
    # set kernel RNG seeds
    simulator.state.num_threads = extra_params.get('threads') or 1
    if 'rng_seeds' in extra_params:
        simulator.state.rng_seeds = extra_params['rng_seeds']
    else:
        rng = NumpyRNG(extra_params.get('rng_seeds_seed', 42))
        n = simulator.state.num_processes * simulator.state.threads
        simulator.state.rng_seeds = rng.next(n, 'randint', (100000, )).tolist()
    # set resolution
    simulator.state.dt = timestep
    # Set min_delay and max_delay for all synapse models
    simulator.state.set_delays(min_delay, max_delay)
    nest.SetDefaults('spike_generator', {'precise_times': True})
    return rank()
Beispiel #27
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    For pcsim, the possible arguments are 'construct_rng_seed' and 'simulation_rng_seed'.
    """
    if simulator.state.constructRNGSeed is None:
        if extra_params.has_key('construct_rng_seed'):
            construct_rng_seed = extra_params['construct_rng_seed']
        else:
            construct_rng_seed = datetime.today().microsecond
        simulator.state.constructRNGSeed = construct_rng_seed
    if simulator.state.simulationRNGSeed is None:
        if extra_params.has_key('simulation_rng_seed'):
            simulation_rng_seed = extra_params['simulation_rng_seed']
        else:
            simulation_rng_seed = datetime.today().microsecond
        simulator.state.simulationRNGSeed = simulation_rng_seed
    if extra_params.has_key('threads'):
        simulator.net = pypcsim.DistributedMultiThreadNetwork(
            extra_params['threads'],
            pypcsim.SimParameter(pypcsim.Time.ms(timestep),
                                 pypcsim.Time.ms(min_delay),
                                 pypcsim.Time.ms(max_delay),
                                 simulator.state.constructRNGSeed,
                                 simulator.state.simulationRNGSeed))
    else:
        simulator.net = pypcsim.DistributedSingleThreadNetwork(
            pypcsim.SimParameter(pypcsim.Time.ms(timestep),
                                 pypcsim.Time.ms(min_delay),
                                 pypcsim.Time.ms(max_delay),
                                 simulator.state.constructRNGSeed,
                                 simulator.state.simulationRNGSeed))

    simulator.state.t = 0
    #simulator.state.dt = timestep # seems to mess up the net object
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    common.setup(timestep, min_delay, max_delay, **extra_params)
    return simulator.net.mpi_rank()
Beispiel #28
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.

    NEURON specific extra_params:

    use_cvode - use the NEURON cvode solver. Defaults to False.
      Optional cvode Parameters:
      -> rtol - specify relative error tolerance
      -> atol - specify absolute error tolerance

    native_rng_baseseed - added to MPI.rank to form seed for SpikeSourcePoisson, etc.
    default_maxstep - TODO

    returns: MPI rank

    """
    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.initializer.clear()
    simulator.state.clear()
    simulator.reset()
    simulator.state.dt = timestep
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    if extra_params.has_key('use_cvode'):
        simulator.state.cvode.active(int(extra_params['use_cvode']))
        if extra_params.has_key('rtol'):
            simulator.state.cvode.rtol(float(extra_params['rtol']))
        if extra_params.has_key('atol'):
            simulator.state.cvode.atol(float(extra_params['atol']))

    if extra_params.has_key('native_rng_baseseed'):
        simulator.state.native_rng_baseseed=int(extra_params['native_rng_baseseed'])
    else: 
        simulator.state.native_rng_baseseed=0
        
    if extra_params.has_key('default_maxstep'):
        simulator.state.default_maxstep=float(extra_params['default_maxstep'])
    return rank()
Beispiel #29
0
def setup(timestep=1, min_delay=1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    if (timestep < 1):
        raise Exception("It is not currently possible to have a timestep less than 1ms with this simulator")
    if (min_delay < 1):
        raise Exception("It is not currently possible to have a min_delay less than 1ms with this simulator")

    common.setup(timestep, min_delay, max_delay, **extra_params)
    simulator.state = simulator._State(timestep, min_delay, max_delay)
    simulator.spikes_array_list = []
    simulator.recorder_list     = []
    if "cpu_backend" in extra_params:
        simulator.state.conf.set_cpu_backend()
    if "cuda_backend" in extra_params:
        simulator.state.conf.set_cuda_backend(extra_params["cuda_backend"])
    print("The backend used by nemo is: ", simulator.state.conf.backend_description())
    return simulator.state.mpi_rank
def setup(timestep=simulator.State.dt,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """
    Should be called at the very beginning of a script.
    :param extra_params:
        most params come from pynn.common.setup
        neuronPermutation: List providing lookup for custom pyNN neuron to
                           hardware neuron. Index: HW related population neuron
                           enumeration. Value: HW neuron enumeration. Can be
                           shorter than total HW neuron count. E.g. [2,4,5]
                           results in the first neuron of the first HXNeuron
                           population to be assigned to
                           AtomicNeuronOnDLS(Enum(2)) and so forth.
        enable_neuron_bypass: Enable neuron bypass mode: neurons forward spikes
                              arriving at the synaptic input (i.e. no leaky
                              integration is happening); defaults to False.
        injected_config: Optional user defined injected configuration.
    """

    # global instance singleton
    simulator.state = simulator.State()

    max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    enable_neuron_bypass = extra_params.get('enable_neuron_bypass', False)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    if min_delay == "auto":
        min_delay = 0
    if max_delay == "auto":
        max_delay = 0
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.enable_neuron_bypass = enable_neuron_bypass
    simulator.state.neuron_placement = simulator.NeuronPlacement(
        extra_params.get("neuronPermutation",
                         simulator.NeuronPlacement.default_permutation))
    simulator.state.injected_config = \
        extra_params.get('injected_config', InjectedConfiguration())
Beispiel #31
0
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """

    max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = max_delay
    simulator.state.mpi_rank = 0
    simulator.state.num_processes = 1

    simulator.state.network.add(
        NetworkOperation(update_currents,
                         when="start",
                         clock=simulator.state.network.clock))
    return rank()
Beispiel #32
0
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY, **extra_params):
    """
    Should be called at the very beginning of a script.

    `extra_params` contains any keyword arguments that are required by a given
    simulator but not by others.

    NEURON specific extra_params:

    use_cvode - use the NEURON cvode solver. Defaults to False.
      Optional cvode Parameters:
      -> rtol - specify relative error tolerance
      -> atol - specify absolute error tolerance

    native_rng_baseseed - added to MPI.rank to form seed for SpikeSourcePoisson, etc.
    default_maxstep - TODO

    returns: MPI rank

    """
    common.setup(timestep, min_delay, **extra_params)
    simulator.initializer.clear()
    simulator.state.clear()
    simulator.state.dt = timestep
    simulator.state.min_delay = min_delay
    simulator.state.max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    if 'use_cvode' in extra_params:
        simulator.state.cvode.active(int(extra_params['use_cvode']))
        if 'rtol' in extra_params:
            simulator.state.cvode.rtol(float(extra_params['rtol']))
        if 'atol' in extra_params:
            simulator.state.cvode.atol(float(extra_params['atol']))
    if 'native_rng_baseseed' in extra_params:
        simulator.state.native_rng_baseseed = int(extra_params['native_rng_baseseed'])
    if 'default_maxstep' in extra_params:
        simulator.state.default_maxstep = float(extra_params['default_maxstep'])
    return rank()
Beispiel #33
0
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    """ Set up for saving cell models and network structure to NeuroML """
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.clear()
    simulator.state.dt = timestep  # move to common.setup?
    simulator.state.min_delay = min_delay
    simulator.state.max_delay =  extra_params.get('max_delay', DEFAULT_MAX_DELAY)
    simulator.state.mpi_rank = extra_params.get('rank', 0)
    simulator.state.num_processes = extra_params.get('num_processes', 1)

    logger.debug("Creating network in NeuroML document to store structure")
    nml_doc = simulator._get_nml_doc(extra_params.get('reference', "PyNN_NeuroML2_Export"),reset=True)
    global save_format
    save_format = extra_params.get('save_format', "xml")
    
    # Create network
    net = neuroml.Network(id="network")
    nml_doc.networks.append(net)
    
    lems_sim = simulator._get_lems_sim(reset=True)
    lems_sim.dt = '%s'%timestep

    return rank()
Beispiel #34
0
def setup(timestep=_pynn_control.DEFAULT_TIMESTEP,
          min_delay=_pynn_control.DEFAULT_MIN_DELAY,
          max_delay=None,
          graph_label=None,
          database_socket_addresses=None,
          time_scale_factor=None,
          n_chips_required=None,
          n_boards_required=None,
          **extra_params):
    """ The main method needed to be called to make the PyNN 0.8 setup. Needs\
        to be called before any other function

    :param timestep:
        the time step of the simulations in micro seconds
        if None the cfg value is used
    :type timestep:
        float or None
    :param min_delay: the min delay of the simulation
    :type min_delay: float or str
    :param max_delay: Ignored and logs a warning if provided
    :type max_delay: float or str or None
    :param graph_label: the label for the graph
    :type graph_label: str or None
    :param database_socket_addresses: the sockets used by external devices
        for the database notification protocol
    :type database_socket_addresses:
        iterable(~spinn_utilities.socket_address.SocketAddress)
    :param time_scale_factor: multiplicative factor to the machine time step
        (does not affect the neuron models accuracy)
    :type time_scale_factor: int or None
    :param n_chips_required:
        Deprecated! Use n_boards_required instead.
        Must be None if n_boards_required specified.
    :type n_chips_required: int or None
    :param n_boards_required:
        if you need to be allocated a machine (for spalloc) before building
        your graph, then fill this in with a general idea of the number of
        boards you need so that the spalloc system can allocate you a machine
        big enough for your needs.
    :type n_boards_required: int or None
    :param extra_params: other keyword argumets used to configure PyNN
    :return: MPI rank (always 0 on SpiNNaker)
    :rtype: int
    :raises ConfigurationException: if both ``n_chips_required`` and
        ``n_boards_required`` are used.
    """
    # Check for "auto" values
    if timestep == "auto":
        timestep = SPYNNAKER_AUTO_TIMESTEP
    if min_delay == "auto":
        min_delay = timestep
    if max_delay:
        logger.warning(
            "max_delay is not supported by sPyNNaker so will be ignored")

    # pylint: disable=too-many-arguments, too-many-function-args
    # setup PyNN common stuff
    pynn_common.setup(timestep, min_delay, **extra_params)

    # create stuff simulator
    if globals_variables.has_simulator():
        logger.warning("Calling setup a second time causes the previous "
                       "simulator to be stopped and cleared.")
        # if already exists, kill and rebuild
        try:
            globals_variables.get_simulator().clear()
        except Exception:  # pylint: disable=broad-except
            logger.exception("Error forcing previous simulation to clear")

    # add default label if needed
    if graph_label is None:
        graph_label = "PyNN0.8_graph"

    # create the main object for all stuff related software
    SpiNNaker(database_socket_addresses=database_socket_addresses,
              time_scale_factor=time_scale_factor,
              timestep=timestep,
              min_delay=min_delay,
              graph_label=graph_label,
              n_chips_required=n_chips_required,
              n_boards_required=n_boards_required)

    # warn about kwargs arguments
    if extra_params:
        logger.warning(
            "Extra params {} have been applied to the setup "
            "command which we do not consider", extra_params)

    # get overloaded functions from PyNN in relation of our simulator object
    _create_overloaded_functions(globals_variables.get_simulator())

    return rank()
Beispiel #35
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    global tempdir
    
    common.setup(timestep, min_delay, max_delay, **extra_params)
    
    if 'verbosity' in extra_params:
        nest_verbosity = extra_params['verbosity'].upper()
    else:
        nest_verbosity = "WARNING"
    nest.sli_run("M_%s setverbosity" % nest_verbosity)
    
    if "spike_precision" in extra_params:
        simulator.state.spike_precision = extra_params["spike_precision"]
        if extra_params["spike_precision"] == 'off_grid':
            simulator.state.default_recording_precision = 15
    nest.SetKernelStatus({'off_grid_spiking': simulator.state.spike_precision=='off_grid'})
    if "recording_precision" in extra_params:
        simulator.state.default_recording_precision = extra_params["recording_precision"]
    
    
    # clear the sli stack, if this is not done --> memory leak cause the stack increases
    nest.sr('clear')
    
    # reset the simulation kernel
    nest.ResetKernel()
    
    # all NEST to erase previously written files (defaut with all the other simulators)
    nest.SetKernelStatus({'overwrite_files' : True})
    
    # set tempdir
    tempdir = tempfile.mkdtemp()
    tempdirs.append(tempdir) # append tempdir to tempdirs list
    nest.SetKernelStatus({'data_path': tempdir,})

    # set kernel RNG seeds
    num_threads = extra_params.get('threads') or 1
    if 'rng_seeds' in extra_params:
        rng_seeds = extra_params['rng_seeds']
    else:
        rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42
        rng = NumpyRNG(rng_seeds_seed)
        rng_seeds = (rng.rng.uniform(size=num_threads*num_processes())*100000).astype('int').tolist() 
    logger.debug("rng_seeds = %s" % rng_seeds)
    nest.SetKernelStatus({'local_num_threads': num_threads,
                          'rng_seeds'        : rng_seeds})

    # set resolution
    nest.SetKernelStatus({'resolution': float(timestep)})

    # Set min_delay and max_delay for all synapse models
    for synapse_model in NEST_SYNAPSE_TYPES:
        nest.SetDefaults(synapse_model, {'delay'    : float(min_delay),
                                         'min_delay': float(min_delay),
                                         'max_delay': float(max_delay)})
    simulator.reset()
    
    return rank()
Beispiel #36
0
def setup(timestep=_pynn_control.DEFAULT_TIMESTEP,
          min_delay=_pynn_control.DEFAULT_MIN_DELAY,
          max_delay=_pynn_control.DEFAULT_MAX_DELAY,
          graph_label=None,
          database_socket_addresses=None,
          extra_algorithm_xml_paths=None,
          extra_mapping_inputs=None,
          extra_mapping_algorithms=None,
          extra_pre_run_algorithms=None,
          extra_post_run_algorithms=None,
          extra_load_algorithms=None,
          time_scale_factor=None,
          n_chips_required=None,
          n_boards_required=None,
          **extra_params):
    """ The main method needed to be called to make the PyNN 0.8 setup. Needs\
        to be called before any other function

    :param timestep: the time step of the simulations
    :param min_delay: the min delay of the simulation
    :param max_delay: the max delay of the simulation
    :param graph_label: the label for the graph
    :param database_socket_addresses: the sockets used by external devices\
        for the database notification protocol
    :param extra_algorithm_xml_paths: \
        list of paths to where other XML are located
    :param extra_mapping_inputs: other inputs used by the mapping process
    :param extra_mapping_algorithms: \
        other algorithms to be used by the mapping process
    :param extra_pre_run_algorithms: extra algorithms to use before a run
    :param extra_post_run_algorithms: extra algorithms to use after a run
    :param extra_load_algorithms: \
        extra algorithms to use within the loading phase
    :param time_scale_factor: multiplicative factor to the machine time step\
        (does not affect the neuron models accuracy)
    :param n_chips_required:\
        Deprecated! Use n_boards_required instead.
        Must be None if n_boards_required specified.
    :type n_chips_required: int or None
    :param n_boards_required:\
        if you need to be allocated a machine (for spalloc) before building\
        your graph, then fill this in with a general idea of the number of
        boards you need so that the spalloc system can allocate you a machine\
        big enough for your needs.
    :param extra_params: other stuff
    :return: rank thing
    :raises ConfigurationException if both n_chips_required and
        n_boards_required are used.
    """
    # pylint: disable=too-many-arguments, too-many-function-args
    if pynn8_syntax:
        # setup PyNN common stuff
        pynn_common.setup(timestep, min_delay, max_delay, **extra_params)
    else:
        # setup PyNN common stuff
        pynn_common.setup(timestep, min_delay, **extra_params)

    # create stuff simulator
    if globals_variables.has_simulator():
        # if already exists, kill and rebuild
        globals_variables.get_simulator().clear()

    # add default label if needed
    if graph_label is None:
        graph_label = "PyNN0.8_graph"

    # create the main object for all stuff related software
    SpiNNaker(database_socket_addresses=database_socket_addresses,
              extra_algorithm_xml_paths=extra_algorithm_xml_paths,
              extra_mapping_inputs=extra_mapping_inputs,
              extra_mapping_algorithms=extra_mapping_algorithms,
              extra_pre_run_algorithms=extra_pre_run_algorithms,
              extra_post_run_algorithms=extra_post_run_algorithms,
              extra_load_algorithms=extra_load_algorithms,
              time_scale_factor=time_scale_factor,
              timestep=timestep,
              min_delay=min_delay,
              max_delay=max_delay,
              graph_label=graph_label,
              n_chips_required=n_chips_required,
              n_boards_required=n_boards_required)

    # warn about kwargs arguments
    if extra_params:
        logger.warning(
            "Extra params {} have been applied to the setup "
            "command which we do not consider", extra_params)

    # get overloaded functions from PyNN in relation of our simulator object
    _create_overloaded_functions(globals_variables.get_simulator())

    return rank()
def setup(timestep=DEFAULT_TIMESTEP,
          min_delay=DEFAULT_MIN_DELAY,
          **extra_params):
    common.setup(timestep, min_delay, **extra_params)
    simulator.state.set_params_and_init(extra_params)
Beispiel #38
0
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    global tempdir

    common.setup(timestep, min_delay, max_delay, **extra_params)
    # clear the sli stack, if this is not done --> memory leak cause the stack increases
    nest.sr('clear')

    # reset the simulation kernel
    nest.ResetKernel()

    if 'verbosity' in extra_params:
        nest_verbosity = extra_params['verbosity'].upper()
    else:
        nest_verbosity = "WARNING"
    nest.sli_run("M_%s setverbosity" % nest_verbosity)

    if "spike_precision" in extra_params:
        simulator.state.spike_precision = extra_params["spike_precision"]
        if extra_params["spike_precision"] == 'off_grid':
            simulator.state.default_recording_precision = 15
    nest.SetKernelStatus(
        {'off_grid_spiking': simulator.state.spike_precision == 'off_grid'})
    if "recording_precision" in extra_params:
        simulator.state.default_recording_precision = extra_params[
            "recording_precision"]

    # all NEST to erase previously written files (defaut with all the other simulators)
    nest.SetKernelStatus({'overwrite_files': True})

    # set tempdir
    tempdir = tempfile.mkdtemp()
    tempdirs.append(tempdir)  # append tempdir to tempdirs list
    nest.SetKernelStatus({
        'data_path': tempdir,
    })

    # set kernel RNG seeds
    num_threads = extra_params.get('threads') or 1
    if 'rng_seeds' in extra_params:
        rng_seeds = extra_params['rng_seeds']
    else:
        rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42
        rng = NumpyRNG(rng_seeds_seed)
        rng_seeds = (rng.rng.uniform(size=num_threads * num_processes()) *
                     100000).astype('int').tolist()
    logger.debug("rng_seeds = %s" % rng_seeds)
    nest.SetKernelStatus({
        'local_num_threads': num_threads,
        'rng_seeds': rng_seeds
    })

    # set resolution
    nest.SetKernelStatus({'resolution': timestep})

    if 'allow_offgrid_spikes' in nest.GetDefaults('spike_generator'):
        nest.SetDefaults('spike_generator', {'allow_offgrid_spikes': True})

    # Set min_delay and max_delay for all synapse models
    NEST_SYNAPSE_TYPES = nest.Models(
        mtype='synapses')  # need to rebuild after ResetKernel
    for synapse_model in NEST_SYNAPSE_TYPES:
        nest.SetDefaults(synapse_model, {
            'delay': min_delay,
            'min_delay': min_delay,
            'max_delay': max_delay
        })
    simulator.connection_managers = []
    simulator.populations = []
    simulator.reset()

    return rank()