Skip to content

Commit f261cf8

Browse files
committed
Shuffle presynaptic elements before assigning postsynaptic targets
1 parent f30c9ca commit f261cf8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

nestkernel/sp_manager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,13 @@ SPManager::create_synapses( std::vector< size_t >& pre_id,
647647
}
648648
else
649649
{
650+
651+
// Shuffle pre_ids (Fisher-Yates) to randomize postsynaptic assignment order
652+
for ( size_t i = pre_id_rnd.size() - 1; i > 0; --i )
653+
{
654+
size_t j = get_rank_synced_rng()->ulrand( i + 1 );
655+
std::swap( pre_id_rnd[ i ], pre_id_rnd[ j ] );
656+
}
650657
global_shuffle_spatial(
651658
pre_id_rnd, post_id_rnd, pre_ids_results, post_ids_results, sp_conn_builder->allows_autapses() );
652659
}

0 commit comments

Comments
 (0)