void cg_connect(ConnectionGeneratorDatum& cg, RangeSet& sources, std::vector<long>& source_gids, RangeSet& targets, std::vector<long>& target_gids, DictionaryDatum params_map, index syn) { cg_set_masks(cg, sources, targets); cg->start(); int source, target, num_parameters = cg->arity(); if (num_parameters == 0) { while (cg->next(source, target, NULL)) ConnectionGeneratorModule::get_network().connect(source_gids.at(source), target_gids.at(target), syn); } else if (num_parameters == 2) { if (!params_map->known(names::weight) || !params_map->known(names::delay)) throw BadProperty("The parameter map has to contain the indices of weight and delay."); long w_idx = (*params_map)[names::weight]; long d_idx = (*params_map)[names::delay]; std::vector<double> params(2); while (cg->next(source, target, ¶ms[0])) ConnectionGeneratorModule::get_network().connect(source_gids.at(source), target_gids.at(target), params[w_idx], params[d_idx], syn); } else { ConnectionGeneratorModule::get_network().message(SLIInterpreter::M_ERROR, "Connect", "Either two or no parameters in the Connection Set expected."); throw DimensionMismatch(); } }
void cg_connect( ConnectionGeneratorDatum& cg, RangeSet& sources, std::vector< long >& source_gids, RangeSet& targets, std::vector< long >& target_gids, DictionaryDatum params_map, index syn ) { cg_set_masks( cg, sources, targets ); cg->start(); int source, target, num_parameters = cg->arity(); if ( num_parameters == 0 ) { // connect source to target while ( cg->next( source, target, NULL ) ) { if ( kernel().node_manager.is_local_gid( target_gids.at( target ) ) ) { Node* const target_node = kernel().node_manager.get_node( target_gids.at( target ) ); const thread target_thread = target_node->get_thread(); kernel().connection_builder_manager.connect( source_gids.at( source ), target_node, target_thread, syn ); } } } else if ( num_parameters == 2 ) { if ( !params_map->known( names::weight ) || !params_map->known( names::delay ) ) throw BadProperty( "The parameter map has to contain the indices of weight and delay." ); long w_idx = ( *params_map )[ names::weight ]; long d_idx = ( *params_map )[ names::delay ]; std::vector< double > params( 2 ); // connect source to target with weight and delay while ( cg->next( source, target, ¶ms[ 0 ] ) ) { if ( kernel().node_manager.is_local_gid( target_gids.at( target ) ) ) { Node* const target_node = kernel().node_manager.get_node( target_gids.at( target ) ); const thread target_thread = target_node->get_thread(); kernel().connection_builder_manager.connect( source_gids.at( source ), target_node, target_thread, syn, params[ d_idx ], params[ w_idx ] ); } } } else { LOG( M_ERROR, "Connect", "Either two or no parameters in the Connection Set expected." ); throw DimensionMismatch(); } }
void nest::cg_set_masks( nest::ConnectionGeneratorDatum& cg, IntVectorDatum& sources, IntVectorDatum& targets ) { RangeSet source_ranges; cg_get_ranges( source_ranges, ( *sources ) ); RangeSet target_ranges; cg_get_ranges( target_ranges, ( *targets ) ); cg_set_masks( cg, source_ranges, target_ranges ); }
/* BeginDocumentation Name: cgsetmask - Call setMasks() on a ConnectionGenerator Synopsis: cg sources targets cgsetmask -> - Parameters: cg - ConnectionGenerator sources - A list of nodes used as source masks targets - A list of nodes used as target masks Description: Set masks for sources and targets on a given ConnectionGenerator cg. This is calling the setMasks() function on cg internally. Remarks: This function is part of the low-level access API for the ConnectionGenerator module. It is mainly used for debugging purposes. Usually, connections are created from a ConnectionGenerator using CGConnect. Author: Mikael Djurfeldt FirstVersion: March 2011 SeeAlso: CGParse, CGParseFile, CGConnect, CGSelectImplementation, cgstart, cgnext */ void ConnectionGeneratorModule::CGSetMask_cg_iV_iVFunction::execute( SLIInterpreter* i ) const { i->assert_stack_load( 3 ); ConnectionGeneratorDatum cg = getValue< ConnectionGeneratorDatum >( i->OStack.pick( 2 ) ); IntVectorDatum sources = getValue< IntVectorDatum >( i->OStack.pick( 1 ) ); IntVectorDatum targets = getValue< IntVectorDatum >( i->OStack.pick( 0 ) ); cg_set_masks( cg, sources, targets ); i->OStack.pop( 3 ); i->EStack.pop(); }
void cg_connect( ConnectionGeneratorDatum& cg, RangeSet& sources, index source_offset, RangeSet& targets, index target_offset, DictionaryDatum params_map, index syn ) { cg_set_masks( cg, sources, targets ); cg->start(); int source, target, num_parameters = cg->arity(); if ( num_parameters == 0 ) { // connect source to target while ( cg->next( source, target, NULL ) ) { if ( ConnectionGeneratorModule::get_network().is_local_gid( target + target_offset ) ) { Node* const target_node = ConnectionGeneratorModule::get_network().get_node( target + target_offset ); const thread target_thread = target_node->get_thread(); ConnectionGeneratorModule::get_network().connect( source + source_offset, target_node, target_thread, syn ); } } } else if ( num_parameters == 2 ) { if ( !params_map->known( names::weight ) || !params_map->known( names::delay ) ) throw BadProperty( "The parameter map has to contain the indices of weight and delay." ); long w_idx = ( *params_map )[ names::weight ]; long d_idx = ( *params_map )[ names::delay ]; std::vector< double > params( 2 ); // connect source to target with weight and delay while ( cg->next( source, target, ¶ms[ 0 ] ) ) { if ( ConnectionGeneratorModule::get_network().is_local_gid( target + target_offset ) ) { Node* const target_node = ConnectionGeneratorModule::get_network().get_node( target + target_offset ); const thread target_thread = target_node->get_thread(); ConnectionGeneratorModule::get_network().connect( source + source_offset, target_node, target_thread, syn, params[ d_idx ], params[ w_idx ] ); } } } else { ConnectionGeneratorModule::get_network().message( SLIInterpreter::M_ERROR, "Connect", "Either two or no parameters in the Connection Set expected." ); throw DimensionMismatch(); } }