/* * test_getrng_Vmset.sli * * This file is part of NEST. * * Copyright (C) 2004 The NEST Initiative * * NEST is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * NEST is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NEST. If not, see <http://www.gnu.org/licenses/>. * */ /* BeginDocumentation Name: testsuite::test_getrng_Vmset - test whether Vm can consistently be set to random value Synopsis: nest_indirect test_getrng_Vmset -> - Description: The script demonstrates two methods of supplying nodes with random numbers independent of the number of jobs used to carry out the simulation. Both methods loop over all nodes in the network and would therefore constitute a serial component of run time. The test was developed in the context of ticket $336. Author: Plesser, September 2010, Diesmann SeeAlso: */ /unittest (9715) require /unittest using [1 2 4] { % Method 1 ResetKernel 0 << /total_num_virtual_procs 4 >> SetStatus % obtain global RNG /rng GetGlobalRNG def % create four neurons /n /iaf_neuron 4 Create def % initialize membrane potential randomly from global RNG. % The SetStatus is ignored for non-local neurons but still the random number are drawn. % Therefore, each neuron receives a well defined random number. 0 GetGlobalLeaves { << /V_m rng drand >> SetStatus } forall % get membrane potential of the local nodes 0 GetGlobalLeaves { /local get } Select { [[/global_id /V_m]] get } Map Transpose % Method 2 ResetKernel 0 << /total_num_virtual_procs 4 >> SetStatus /n /iaf_neuron 4 Create def % initialize membrane potential using the RNG assigned to the virtual process the % neuron lives on. Also with this method each neuron receives a well defined random % number. 0 GetGlobalLeaves { dup /local get { dup GetVpRNG /rng Set << /V_m rng drand >> SetStatus } {pop} ifelse } forall % get membrane potential of the local nodes 0 GetGlobalLeaves { /local get } Select { [[/global_id /V_m]] get } Map Transpose % combine the results of the two variants and remove duplicate occurence of gids join [3] Drop Transpose % format: [ [gid Vm1 Vm2], ... ] } distributed_process_invariant_collect_assert_or_die