void nest::correlomatrix_detector::State_::get( DictionaryDatum& d ) const { ( *d )[ names::n_events ] = IntVectorDatum( new std::vector< long_t >( n_events_ ) ); ArrayDatum* C = new ArrayDatum; ArrayDatum* CountC = new ArrayDatum; for ( size_t i = 0; i < covariance_.size(); ++i ) { ArrayDatum* C_i = new ArrayDatum; ArrayDatum* CountC_i = new ArrayDatum; for ( size_t j = 0; j < covariance_[ i ].size(); ++j ) { C_i->push_back( new DoubleVectorDatum( new std::vector< double_t >( covariance_[ i ][ j ] ) ) ); CountC_i->push_back( new IntVectorDatum( new std::vector< long_t >( count_covariance_[ i ][ j ] ) ) ); } C->push_back( *C_i ); CountC->push_back( *CountC_i ); } ( *d )[ names::covariance ] = C; ( *d )[ names::count_covariance ] = CountC; }
void ModelsModule::init( SLIInterpreter* ) { register_model< iaf_neuron >( net_, "iaf_neuron" ); register_model< iaf_chs_2007 >( net_, "iaf_chs_2007" ); register_model< iaf_psc_alpha >( net_, "iaf_psc_alpha" ); register_model< iaf_psc_alpha_multisynapse >( net_, "iaf_psc_alpha_multisynapse" ); register_model< iaf_psc_delta >( net_, "iaf_psc_delta" ); register_model< iaf_psc_exp >( net_, "iaf_psc_exp" ); register_model< iaf_psc_exp_multisynapse >( net_, "iaf_psc_exp_multisynapse" ); register_model< iaf_tum_2000 >( net_, "iaf_tum_2000" ); register_model< amat2_psc_exp >( net_, "amat2_psc_exp" ); register_model< mat2_psc_exp >( net_, "mat2_psc_exp" ); register_model< parrot_neuron >( net_, "parrot_neuron" ); register_model< pp_psc_delta >( net_, "pp_psc_delta" ); register_model< pp_pop_psc_delta >( net_, "pp_pop_psc_delta" ); register_model< ac_generator >( net_, "ac_generator" ); register_model< dc_generator >( net_, "dc_generator" ); register_model< spike_generator >( net_, "spike_generator" ); register_model< poisson_generator >( net_, "poisson_generator" ); register_model< pulsepacket_generator >( net_, "pulsepacket_generator" ); register_model< noise_generator >( net_, "noise_generator" ); register_model< step_current_generator >( net_, "step_current_generator" ); register_model< mip_generator >( net_, "mip_generator" ); register_model< sinusoidal_poisson_generator >( net_, "sinusoidal_poisson_generator" ); register_model< ppd_sup_generator >( net_, "ppd_sup_generator" ); register_model< gamma_sup_generator >( net_, "gamma_sup_generator" ); register_model< sli_neuron >( net_, "sli_neuron" ); register_model< ginzburg_neuron >( net_, "ginzburg_neuron" ); register_model< mcculloch_pitts_neuron >( net_, "mcculloch_pitts_neuron" ); register_model< izhikevich >( net_, "izhikevich" ); register_model< spike_dilutor >( net_, "spike_dilutor" ); register_model< spike_detector >( net_, "spike_detector" ); register_model< spin_detector >( net_, "spin_detector" ); register_model< Multimeter >( net_, "multimeter" ); register_model< correlation_detector >( net_, "correlation_detector" ); register_model< correlomatrix_detector >( net_, "correlomatrix_detector" ); register_model< correlospinmatrix_detector >( net_, "correlospinmatrix_detector" ); register_model< volume_transmitter >( net_, "volume_transmitter" ); // Create voltmeter as a multimeter pre-configured to record V_m. /*BeginDocumentation Name: voltmeter - Device to record membrane potential from neurons. Synopsis: voltmeter Create Description: A voltmeter records the membrane potential (V_m) of connected nodes to memory, file or stdout. By default, voltmeters record values once per ms. Set the parameter /interval to change this. The recording interval cannot be smaller than the resolution. Results are returned in the /events entry of the status dictionary, which contains membrane potential as vector /V_m and pertaining times as vector /times and node GIDs as /senders, if /withtime and /withgid are set, respectively. Accumulator mode: Voltmeter can operate in accumulator mode. In this case, values for all recorded variables are added across all recorded nodes (but kept separate in time). This can be useful to record average membrane potential in a population. To activate accumulator mode, either set /to_accumulator to true, or set /record_to [ /accumulator ]. In accumulator mode, you cannot record to file, to memory, to screen, with GID or with weight. You must activate accumulator mode before simulating. Accumulator data is never written to file. You must extract it from the device using GetStatus. Remarks: - The voltmeter model is implemented as a multimeter preconfigured to record /V_m. - The set of variables to record and the recording interval must be set BEFORE the voltmeter is connected to any node, and cannot be changed afterwards. - A voltmeter cannot be frozen. - If you record with voltmeter in accumulator mode and some of the nodes you record from are frozen and others are not, data will only be collected from the unfrozen nodes. Most likely, this will lead to confusing results, so you should not use voltmeter with frozen nodes. Parameters: The following parameter can be set in the status dictionary: interval double - Recording interval in ms Examples: SLI ] /iaf_cond_alpha Create /n Set SLI ] /voltmeter Create /vm Set SLI ] vm << /interval 0.5 >> SetStatus SLI ] vm n Connect SLI ] 10 Simulate SLI ] vm /events get info -------------------------------------------------- Name Type Value -------------------------------------------------- senders intvectortype <intvectortype> times doublevectortype <doublevectortype> V_m doublevectortype <doublevectortype> -------------------------------------------------- Total number of entries: 3 Sends: DataLoggingRequest SeeAlso: Device, RecordingDevice, multimeter */ Dictionary vmdict; ArrayDatum ad; ad.push_back( LiteralDatum( names::V_m.toString() ) ); vmdict[ names::record_from ] = ad; register_preconf_model< Multimeter >( net_, "voltmeter", vmdict ); #ifdef HAVE_GSL register_model< iaf_chxk_2008 >( net_, "iaf_chxk_2008" ); register_model< iaf_cond_alpha >( net_, "iaf_cond_alpha" ); register_model< iaf_cond_exp >( net_, "iaf_cond_exp" ); register_model< iaf_cond_exp_sfa_rr >( net_, "iaf_cond_exp_sfa_rr" ); register_model< iaf_cond_alpha_mc >( net_, "iaf_cond_alpha_mc" ); register_model< hh_psc_alpha >( net_, "hh_psc_alpha" ); register_model< hh_psc_alpha_gap >( net_, "hh_psc_alpha_gap" ); register_model< hh_cond_exp_traub >( net_, "hh_cond_exp_traub" ); register_model< sinusoidal_gamma_generator >( net_, "sinusoidal_gamma_generator" ); #endif #ifdef HAVE_GSL_1_11 register_model< aeif_cond_alpha >( net_, "aeif_cond_alpha" ); register_model< aeif_cond_exp >( net_, "aeif_cond_exp" ); register_model< ht_neuron >( net_, "ht_neuron" ); #endif // This version of the AdEx model does not depend on GSL. register_model< aeif_cond_alpha_RK5 >( net_, "aeif_cond_alpha_RK5" ); register_model< aeif_cond_alpha_multisynapse >( net_, "aeif_cond_alpha_multisynapse" ); #ifdef HAVE_MUSIC //// proxies for inter-application communication using MUSIC register_model< music_event_in_proxy >( net_, "music_event_in_proxy" ); register_model< music_event_out_proxy >( net_, "music_event_out_proxy" ); register_model< music_cont_in_proxy >( net_, "music_cont_in_proxy" ); register_model< music_message_in_proxy >( net_, "music_message_in_proxy" ); #endif // register synapses /* BeginDocumentation Name: static_synapse_hpc - Variant of static_synapse with low memory consumption. Description: hpc synapses store the target neuron in form of a 2 Byte index instead of an 8 Byte pointer. This limits the number of thread local neurons to 65,536. No support for different receptor types. Otherwise identical to static_synapse. SeeAlso: synapsedict, static_synapse */ register_connection_model< StaticConnection< TargetIdentifierPtrRport > >( net_, "static_synapse" ); register_connection_model< StaticConnection< TargetIdentifierIndex > >( net_, "static_synapse_hpc" ); /* BeginDocumentation Name: static_synapse_hom_w_hpc - Variant of static_synapse_hom_w with low memory consumption. SeeAlso: synapsedict, static_synapse_hom_w, static_synapse_hpc */ register_connection_model< StaticConnectionHomW< TargetIdentifierPtrRport > >( net_, "static_synapse_hom_w" ); register_connection_model< StaticConnectionHomW< TargetIdentifierIndex > >( net_, "static_synapse_hom_w_hpc" ); /* BeginDocumentation Name: gap_junction - Connection model for gap junctions. SeeAlso: synapsedict */ register_secondary_connection_model< GapJunction< TargetIdentifierPtrRport > >( net_, "gap_junction", false ); /* BeginDocumentation Name: stdp_synapse_hpc - Variant of stdp_synapse with low memory consumption. SeeAlso: synapsedict, stdp_synapse, static_synapse_hpc */ register_connection_model< STDPConnection< TargetIdentifierPtrRport > >( net_, "stdp_synapse" ); register_connection_model< STDPConnection< TargetIdentifierIndex > >( net_, "stdp_synapse_hpc" ); /* BeginDocumentation Name: stdp_pl_synapse_hom_hpc - Variant of stdp_pl_synapse_hom with low memory consumption. SeeAlso: synapsedict, stdp_pl_synapse_hom, static_synapse_hpc */ register_connection_model< STDPPLConnectionHom< TargetIdentifierPtrRport > >( net_, "stdp_pl_synapse_hom" ); register_connection_model< STDPPLConnectionHom< TargetIdentifierIndex > >( net_, "stdp_pl_synapse_hom_hpc" ); /* BeginDocumentation Name: stdp_triplet_synapse_hpc - Variant of stdp_triplet_synapse with low memory consumption. SeeAlso: synapsedict, stdp_synapse, static_synapse_hpc */ register_connection_model< STDPTripletConnection< TargetIdentifierPtrRport > >( net_, "stdp_triplet_synapse" ); register_connection_model< STDPTripletConnection< TargetIdentifierIndex > >( net_, "stdp_triplet_synapse_hpc" ); /* BeginDocumentation Name: quantal_stp_synapse_hpc - Variant of quantal_stp_synapse with low memory consumption. SeeAlso: synapsedict, quantal_stp_synapse, static_synapse_hpc */ register_connection_model< Quantal_StpConnection< TargetIdentifierPtrRport > >( net_, "quantal_stp_synapse" ); register_connection_model< Quantal_StpConnection< TargetIdentifierIndex > >( net_, "quantal_stp_synapse_hpc" ); /* BeginDocumentation Name: stdp_synapse_hom_hpc - Variant of quantal_stp_synapse with low memory consumption. SeeAlso: synapsedict, stdp_synapse_hom, static_synapse_hpc */ register_connection_model< STDPConnectionHom< TargetIdentifierPtrRport > >( net_, "stdp_synapse_hom" ); register_connection_model< STDPConnectionHom< TargetIdentifierIndex > >( net_, "stdp_synapse_hom_hpc" ); /* BeginDocumentation Name: stdp_facetshw_synapse_hom_hpc - Variant of stdp_facetshw_synapse_hom with low memory consumption. SeeAlso: synapsedict, stdp_facetshw_synapse_hom, static_synapse_hpc */ register_connection_model< STDPFACETSHWConnectionHom< TargetIdentifierPtrRport > >( net_, "stdp_facetshw_synapse_hom" ); register_connection_model< STDPFACETSHWConnectionHom< TargetIdentifierIndex > >( net_, "stdp_facetshw_synapse_hom_hpc" ); /* BeginDocumentation Name: cont_delay_synapse_hpc - Variant of cont_delay_synapse with low memory consumption. SeeAlso: synapsedict, cont_delay_synapse, static_synapse_hpc */ register_connection_model< ContDelayConnection< TargetIdentifierPtrRport > >( net_, "cont_delay_synapse" ); register_connection_model< ContDelayConnection< TargetIdentifierIndex > >( net_, "cont_delay_synapse_hpc" ); /* BeginDocumentation Name: tsodyks_synapse_hpc - Variant of tsodyks_synapse with low memory consumption. SeeAlso: synapsedict, tsodyks_synapse, static_synapse_hpc */ register_connection_model< TsodyksConnection< TargetIdentifierPtrRport > >( net_, "tsodyks_synapse" ); register_connection_model< TsodyksConnection< TargetIdentifierIndex > >( net_, "tsodyks_synapse_hpc" ); /* BeginDocumentation Name: tsodyks_synapse_hom_hpc - Variant of tsodyks_synapse_hom with low memory consumption. SeeAlso: synapsedict, tsodyks_synapse_hom, static_synapse_hpc */ register_connection_model< TsodyksConnectionHom< TargetIdentifierPtrRport > >( net_, "tsodyks_synapse_hom" ); register_connection_model< TsodyksConnectionHom< TargetIdentifierIndex > >( net_, "tsodyks_synapse_hom_hpc" ); /* BeginDocumentation Name: tsodyks2_synapse_hpc - Variant of tsodyks2_synapse with low memory consumption. SeeAlso: synapsedict, tsodyks2_synapse, static_synapse_hpc */ register_connection_model< Tsodyks2Connection< TargetIdentifierPtrRport > >( net_, "tsodyks2_synapse" ); register_connection_model< Tsodyks2Connection< TargetIdentifierIndex > >( net_, "tsodyks2_synapse_hpc" ); /* BeginDocumentation Name: ht_synapse_hpc - Variant of ht_synapse with low memory consumption. SeeAlso: synapsedict, ht_synapse, static_synapse_hpc */ register_connection_model< HTConnection< TargetIdentifierPtrRport > >( net_, "ht_synapse" ); register_connection_model< HTConnection< TargetIdentifierIndex > >( net_, "ht_synapse_hpc" ); /* BeginDocumentation Name: stdp_dopamine_synapse_hpc - Variant of stdp_dopamine_synapse with low memory consumption. SeeAlso: synapsedict, stdp_dopamine_synapse, static_synapse_hpc */ register_connection_model< STDPDopaConnection< TargetIdentifierPtrRport > >( net_, "stdp_dopamine_synapse" ); register_connection_model< STDPDopaConnection< TargetIdentifierIndex > >( net_, "stdp_dopamine_synapse_hpc" ); /* BeginDocumentation Name: stdp_serotonine_synapse */ register_connection_model< STDPH5Connection< TargetIdentifierPtrRport > >( net_, "stdp_serotonine_synapse" ); }
void ModelsModule::init(SLIInterpreter *) { register_model<iaf_neuron>(net_, "iaf_neuron"); register_model<iaf_chs_2007>(net_, "iaf_chs_2007"); register_model<iaf_psc_alpha>(net_, "iaf_psc_alpha"); register_model<iaf_psc_alpha_multisynapse>(net_, "iaf_psc_alpha_multisynapse"); register_model<iaf_psc_delta>(net_, "iaf_psc_delta"); register_model<iaf_psc_exp>(net_, "iaf_psc_exp"); register_model<iaf_psc_exp_multisynapse>(net_, "iaf_psc_exp_multisynapse"); register_model<iaf_tum_2000>(net_, "iaf_tum_2000"); register_model<amat2_psc_exp>(net_, "amat2_psc_exp"); register_model<mat2_psc_exp>(net_, "mat2_psc_exp"); register_model<parrot_neuron>(net_, "parrot_neuron"); register_model<pp_psc_delta>(net_, "pp_psc_delta"); register_model<pp_pop_psc_delta>(net_, "pp_pop_psc_delta"); register_model<ac_generator>(net_, "ac_generator"); register_model<dc_generator>(net_, "dc_generator"); register_model<spike_generator>(net_, "spike_generator"); register_model<poisson_generator>(net_, "poisson_generator"); register_model<pulsepacket_generator>(net_, "pulsepacket_generator"); register_model<noise_generator>(net_, "noise_generator"); register_model<step_current_generator>(net_, "step_current_generator"); register_model<mip_generator>(net_, "mip_generator"); register_model<sinusoidal_poisson_generator>(net_,"sinusoidal_poisson_generator"); register_model<ppd_sup_generator>(net_, "ppd_sup_generator"); register_model<gamma_sup_generator>(net_, "gamma_sup_generator"); register_model<sli_neuron>(net_, "sli_neuron"); register_model<ginzburg_neuron>(net_, "ginzburg_neuron"); register_model<mcculloch_pitts_neuron>(net_, "mcculloch_pitts_neuron"); register_model<izhikevich>(net_, "izhikevich"); register_model<spike_detector>(net_, "spike_detector"); register_model<spin_detector>(net_, "spin_detector"); register_model<Multimeter>(net_, "multimeter"); register_model<correlation_detector>(net_, "correlation_detector"); register_model<correlomatrix_detector>(net_, "correlomatrix_detector"); register_model<volume_transmitter>(net_, "volume_transmitter"); // Create voltmeter as a multimeter pre-configured to record V_m. Dictionary vmdict; ArrayDatum ad; ad.push_back(LiteralDatum(names::V_m.toString())); vmdict[names::record_from] = ad; register_preconf_model<Multimeter>(net_, "voltmeter", vmdict); #ifdef HAVE_GSL register_model<iaf_chxk_2008>(net_, "iaf_chxk_2008"); register_model<iaf_cond_alpha>(net_, "iaf_cond_alpha"); register_model<iaf_cond_exp>(net_, "iaf_cond_exp"); register_model<iaf_cond_exp_sfa_rr>(net_, "iaf_cond_exp_sfa_rr"); register_model<iaf_cond_alpha_mc>(net_, "iaf_cond_alpha_mc"); register_model<hh_psc_alpha>(net_, "hh_psc_alpha"); register_model<hh_cond_exp_traub>(net_, "hh_cond_exp_traub"); register_model<sinusoidal_gamma_generator>(net_,"sinusoidal_gamma_generator"); #endif #ifdef HAVE_GSL_1_11 register_model<aeif_cond_alpha>(net_, "aeif_cond_alpha"); register_model<aeif_cond_exp>(net_, "aeif_cond_exp"); register_model<ht_neuron>(net_, "ht_neuron"); #endif // This version of the AdEx model does not depend on GSL. register_model<aeif_cond_alpha_RK5>(net_, "aeif_cond_alpha_RK5"); register_model<aeif_cond_alpha_multisynapse>(net_, "aeif_cond_alpha_multisynapse"); #ifdef HAVE_MUSIC //// proxies for inter-application communication using MUSIC register_model<music_event_in_proxy>(net_, "music_event_in_proxy"); register_model<music_event_out_proxy>(net_, "music_event_out_proxy"); register_model<music_cont_in_proxy>(net_, "music_cont_in_proxy"); register_model<music_message_in_proxy>(net_, "music_message_in_proxy"); #endif // register synapses /* BeginDocumentation Name: static_synapse_hpc - Variant of static_synapse with low memory consumption. Description: hpc synapses store the target neuron in form of a 2 Byte index instead of an 8 Byte pointer. This limits the number of thread local neurons to 65,536. No support for different receptor types. Otherwise identical to static_synapse. SeeAlso: synapsedict, static_synapse */ register_connection_model < StaticConnection<TargetIdentifierPtrRport> > (net_, "static_synapse"); register_connection_model < StaticConnection<TargetIdentifierIndex> > (net_, "static_synapse_hpc"); /* BeginDocumentation Name: static_synapse_hom_w_hpc - Variant of static_synapse_hom_w with low memory consumption. SeeAlso: synapsedict, static_synapse_hom_w, static_synapse_hpc */ register_connection_model < StaticConnectionHomW<TargetIdentifierPtrRport> > (net_, "static_synapse_hom_w"); register_connection_model < StaticConnectionHomW<TargetIdentifierIndex> > (net_, "static_synapse_hom_w_hpc"); /* BeginDocumentation Name: stdp_synapse_hpc - Variant of stdp_synapse with low memory consumption. SeeAlso: synapsedict, stdp_synapse, static_synapse_hpc */ register_connection_model < STDPConnection<TargetIdentifierPtrRport> > (net_, "stdp_synapse"); register_connection_model < STDPConnection<TargetIdentifierIndex> > (net_, "stdp_synapse_hpc"); /* BeginDocumentation Name: stdp_pl_synapse_hom_hpc - Variant of stdp_pl_synapse_hom with low memory consumption. SeeAlso: synapsedict, stdp_pl_synapse_hom, static_synapse_hpc */ register_connection_model < STDPPLConnectionHom<TargetIdentifierPtrRport> > (net_, "stdp_pl_synapse_hom"); register_connection_model < STDPPLConnectionHom<TargetIdentifierIndex> > (net_, "stdp_pl_synapse_hom_hpc"); /* BeginDocumentation Name: quantal_stp_synapse_hpc - Variant of quantal_stp_synapse with low memory consumption. SeeAlso: synapsedict, quantal_stp_synapse, static_synapse_hpc */ register_connection_model < Quantal_StpConnection<TargetIdentifierPtrRport> > (net_, "quantal_stp_synapse"); register_connection_model < Quantal_StpConnection<TargetIdentifierIndex> > (net_, "quantal_stp_synapse_hpc"); /* BeginDocumentation Name: stdp_synapse_hom_hpc - Variant of quantal_stp_synapse with low memory consumption. SeeAlso: synapsedict, stdp_synapse_hom, static_synapse_hpc */ register_connection_model < STDPConnectionHom<TargetIdentifierPtrRport> > (net_, "stdp_synapse_hom"); register_connection_model < STDPConnectionHom<TargetIdentifierIndex> > (net_, "stdp_synapse_hom_hpc"); /* BeginDocumentation Name: stdp_facetshw_synapse_hom_hpc - Variant of stdp_facetshw_synapse_hom with low memory consumption. SeeAlso: synapsedict, stdp_facetshw_synapse_hom, static_synapse_hpc */ register_connection_model < STDPFACETSHWConnectionHom<TargetIdentifierPtrRport> > (net_, "stdp_facetshw_synapse_hom"); register_connection_model < STDPFACETSHWConnectionHom<TargetIdentifierIndex> > (net_, "stdp_facetshw_synapse_hom_hpc"); /* BeginDocumentation Name: cont_delay_synapse_hpc - Variant of cont_delay_synapse with low memory consumption. SeeAlso: synapsedict, cont_delay_synapse, static_synapse_hpc */ register_connection_model < ContDelayConnection<TargetIdentifierPtrRport> > (net_, "cont_delay_synapse"); register_connection_model < ContDelayConnection<TargetIdentifierIndex> > (net_, "cont_delay_synapse_hpc"); /* BeginDocumentation Name: tsodyks_synapse_hpc - Variant of tsodyks_synapse with low memory consumption. SeeAlso: synapsedict, tsodyks_synapse, static_synapse_hpc */ register_connection_model < TsodyksConnection<TargetIdentifierPtrRport> > (net_, "tsodyks_synapse"); register_connection_model < TsodyksConnection<TargetIdentifierIndex> > (net_, "tsodyks_synapse_hpc"); /* BeginDocumentation Name: tsodyks2_synapse_hpc - Variant of tsodyks2_synapse with low memory consumption. SeeAlso: synapsedict, tsodyks2_synapse, static_synapse_hpc */ register_connection_model < Tsodyks2Connection<TargetIdentifierPtrRport> > (net_, "tsodyks2_synapse"); register_connection_model < Tsodyks2Connection<TargetIdentifierIndex> > (net_, "tsodyks2_synapse_hpc"); /* BeginDocumentation Name: ht_synapse_hpc - Variant of ht_synapse with low memory consumption. SeeAlso: synapsedict, ht_synapse, static_synapse_hpc */ register_connection_model < HTConnection<TargetIdentifierPtrRport> > (net_, "ht_synapse"); register_connection_model < HTConnection<TargetIdentifierIndex> > (net_, "ht_synapse_hpc"); /* BeginDocumentation Name: stdp_dopamine_synapse_hpc - Variant of stdp_dopamine_synapse with low memory consumption. SeeAlso: synapsedict, stdp_dopamine_synapse, static_synapse_hpc */ register_connection_model < STDPDopaConnection<TargetIdentifierPtrRport> > (net_, "stdp_dopamine_synapse"); register_connection_model < STDPDopaConnection<TargetIdentifierIndex> > (net_, "stdp_dopamine_synapse_hpc"); }
void nest::RNGManager::set_status( const DictionaryDatum& d ) { // have those two for later asking, whether threads have changed: long n_threads; bool n_threads_updated = updateValue< long >( d, "local_num_threads", n_threads ); // set RNGs --- MUST come after n_threads_ is updated if ( d->known( "rngs" ) ) { // this array contains pre-seeded RNGs, so they can be used // directly, no seeding required ArrayDatum* ad = dynamic_cast< ArrayDatum* >( ( *d )[ "rngs" ].datum() ); if ( ad == 0 ) throw BadProperty(); // n_threads_ is the new value after a change of the number of // threads if ( ad->size() != ( size_t )( kernel().vp_manager.get_num_virtual_processes() ) ) { LOG( M_ERROR, "RNGManager::set_status", "Number of RNGs must equal number of virtual processes " "(threads*processes). RNGs " "unchanged." ); throw DimensionMismatch( ( size_t )( kernel().vp_manager.get_num_virtual_processes() ), ad->size() ); } // delete old generators, insert new generators this code is // robust under change of thread number in this call to // set_status, as long as it comes AFTER n_threads_ has been // upated rng_.clear(); for ( index i = 0; i < ad->size(); ++i ) if ( kernel().vp_manager.is_local_vp( i ) ) rng_.push_back( getValue< librandom::RngDatum >( ( *ad )[ kernel().vp_manager.suggest_vp( i ) ] ) ); } else if ( n_threads_updated && kernel().node_manager.size() == 0 ) { LOG( M_WARNING, "RNGManager::set_status", "Equipping threads with new default RNGs" ); create_rngs_(); } if ( d->known( "rng_seeds" ) ) { ArrayDatum* ad = dynamic_cast< ArrayDatum* >( ( *d )[ "rng_seeds" ].datum() ); if ( ad == 0 ) throw BadProperty(); if ( ad->size() != ( size_t )( kernel().vp_manager.get_num_virtual_processes() ) ) { LOG( M_ERROR, "RNGManager::set_status", "Number of seeds must equal number of virtual processes " "(threads*processes). RNGs unchanged." ); throw DimensionMismatch( ( size_t )( kernel().vp_manager.get_num_virtual_processes() ), ad->size() ); } // check if seeds are unique std::set< ulong_t > seedset; for ( index i = 0; i < ad->size(); ++i ) { long s = ( *ad )[ i ]; // SLI has no ulong tokens if ( !seedset.insert( s ).second ) { LOG( M_WARNING, "RNGManager::set_status", "Seeds are not unique across threads!" ); break; } } // now apply seeds, resets generators automatically for ( index i = 0; i < ad->size(); ++i ) { long s = ( *ad )[ i ]; if ( kernel().vp_manager.is_local_vp( i ) ) rng_[ kernel().vp_manager.vp_to_thread( kernel().vp_manager.suggest_vp( i ) ) ]->seed( s ); rng_seeds_[ i ] = s; } } // if rng_seeds // set GRNG if ( d->known( "grng" ) ) { // pre-seeded grng that can be used directly, no seeding required updateValue< librandom::RngDatum >( d, "grng", grng_ ); } else if ( n_threads_updated && kernel().node_manager.size() == 0 ) { LOG( M_WARNING, "RNGManager::set_status", "Equipping threads with new default GRNG" ); create_grng_(); } if ( d->known( "grng_seed" ) ) { const long gseed = getValue< long >( d, "grng_seed" ); // check if grng seed is unique with respect to rng seeds // if grng_seed and rng_seeds given in one SetStatus call std::set< ulong_t > seedset; seedset.insert( gseed ); if ( d->known( "rng_seeds" ) ) { ArrayDatum* ad_rngseeds = dynamic_cast< ArrayDatum* >( ( *d )[ "rng_seeds" ].datum() ); if ( ad_rngseeds == 0 ) throw BadProperty(); for ( index i = 0; i < ad_rngseeds->size(); ++i ) { const long vpseed = ( *ad_rngseeds )[ i ]; // SLI has no ulong tokens if ( !seedset.insert( vpseed ).second ) { LOG( M_WARNING, "RNGManager::set_status", "Seeds are not unique across threads!" ); break; } } } // now apply seed, resets generator automatically grng_seed_ = gseed; grng_->seed( gseed ); } // if grng_seed }
index AbstractLayer::create_layer(const DictionaryDatum & layer_dict) { index length = 0; const char *layer_model_name = 0; std::vector<long_t> element_ids; std::string element_name; Token element_model; const Token& t = layer_dict->lookup(names::elements); ArrayDatum* ad = dynamic_cast<ArrayDatum *>(t.datum()); if (ad) { for (Token* tp = ad->begin(); tp != ad->end(); ++tp) { element_name = std::string(*tp); element_model = net_->get_modeldict().lookup(element_name); if ( element_model.empty() ) throw UnknownModelName(element_name); // Creates several nodes if the next element in // the elements variable is a number. if ((tp+1 != ad->end()) && dynamic_cast<IntegerDatum*>((tp+1)->datum())) { // Select how many nodes that should be created. const long_t number = getValue<long_t>(*(++tp)); for(long_t i=0;i<number;++i) element_ids.push_back(static_cast<long>(element_model)); } else { element_ids.push_back(static_cast<long>(element_model)); } } } else { element_name = getValue<std::string>(layer_dict, names::elements); element_model = net_->get_modeldict().lookup(element_name); if ( element_model.empty() ) throw UnknownModelName(element_name); element_ids.push_back(static_cast<long>(element_model)); } if (layer_dict->known(names::positions)) { if (layer_dict->known(names::rows) or layer_dict->known(names::columns) or layer_dict->known(names::layers)) throw BadProperty("Can not specify both positions and rows or columns."); TokenArray positions = getValue<TokenArray>(layer_dict, names::positions); if (positions.size() == 0) { throw BadProperty("Empty positions array."); } std::vector<double_t> pos = getValue<std::vector<double_t> >(positions[0]); if (pos.size() == 2) layer_model_name = "topology_layer_free"; else if (pos.size() == 3) layer_model_name = "topology_layer_free_3d"; else throw BadProperty("Positions must have 2 or 3 coordinates."); length = positions.size(); } else if (layer_dict->known(names::columns)) { if (not layer_dict->known(names::rows)) { throw BadProperty("Both columns and rows must be given."); } length=getValue<long_t>(layer_dict, names::columns) * getValue<long_t>(layer_dict, names::rows); if (layer_dict->known(names::layers)) { layer_model_name = "topology_layer_grid_3d"; length *= getValue<long_t>(layer_dict, names::layers); } else { layer_model_name = "topology_layer_grid"; } } else { throw BadProperty("Unknown layer type."); } assert(layer_model_name != 0); Token layer_model = net_->get_modeldict().lookup(layer_model_name); if ( layer_model.empty() ) throw UnknownModelName(layer_model_name); index layer_node = net_->add_node(layer_model); // Remember original subnet const index cwnode = net_->get_cwn()->get_gid(); net_->go_to(layer_node); // Create layer nodes. for ( size_t i = 0 ; i < element_ids.size() ; ++i ) { for ( index n = 0 ; n < length ; ++n ) { net_->add_node(element_ids[i]); } } // Return to original subnet net_->go_to(cwnode); //Set layer parameters according to input dictionary. AbstractLayer *layer = dynamic_cast<AbstractLayer *>(net_->get_node(layer_node)); layer->depth_ = element_ids.size(); layer->set_status(layer_dict); return layer_node; }