@@ -330,9 +330,10 @@ SPManager::build_probability_list()
330
330
throw std::runtime_error ( " Mismatch in global positions dimensionality." );
331
331
}
332
332
333
+
333
334
// Resize the probability list to accommodate all neuron pairs.
334
335
size_t total_pairs = ( num_neurons * ( num_neurons + 1 ) ) / 2 ;
335
- probability_list.resize ( total_pairs, - 1 .0 );
336
+ probability_list.resize ( total_pairs, 0 .0 );
336
337
337
338
// Calculate probabilities for connections between all pairs of neurons.
338
339
for ( size_t i = 0 ; i < num_neurons; ++i )
@@ -364,18 +365,13 @@ SPManager::build_probability_list()
364
365
continue ;
365
366
}
366
367
367
- if ( id_i == id_j )
368
- {
369
- probability_list[ index ] = 0.0 ; // Assign zero probability for self-connections
370
- }
371
- else
372
- {
373
- std::vector< double > pos_j (
374
- global_positions.begin () + pos_dim * ( id_j - 1 ), global_positions.begin () + pos_dim * id_j );
368
+
369
+ std::vector< double > pos_j (
370
+ global_positions.begin () + pos_dim * ( id_j - 1 ), global_positions.begin () + pos_dim * id_j );
375
371
376
- double prob = gaussian_kernel ( pos_i, pos_j, structural_plasticity_gaussian_kernel_sigma_ );
377
- probability_list[ index ] = prob;
378
- }
372
+ double prob = gaussian_kernel ( pos_i, pos_j, structural_plasticity_gaussian_kernel_sigma_ );
373
+ probability_list[ index ] = prob;
374
+
379
375
}
380
376
}
381
377
}
@@ -648,7 +644,8 @@ SPManager::create_synapses( std::vector< size_t >& pre_id,
648
644
}
649
645
else
650
646
{
651
- global_shuffle_spatial ( pre_id_rnd, post_id_rnd, pre_ids_results, post_ids_results );
647
+ global_shuffle_spatial (
648
+ pre_id_rnd, post_id_rnd, pre_ids_results, post_ids_results, sp_conn_builder->allows_autapses () );
652
649
}
653
650
654
651
// create synapse
893
890
SPManager::global_shuffle_spatial ( std::vector< size_t >& pre_ids,
894
891
std::vector< size_t >& post_ids,
895
892
std::vector< size_t >& pre_ids_results,
896
- std::vector< size_t >& post_ids_results )
893
+ std::vector< size_t >& post_ids_results,
894
+ bool allow_autapse )
897
895
{
898
896
size_t maxIterations = std::min ( pre_ids.size (), post_ids.size () );
899
897
@@ -912,7 +910,7 @@ SPManager::global_shuffle_spatial( std::vector< size_t >& pre_ids,
912
910
double rnd;
913
911
for ( size_t post_id : post_ids )
914
912
{
915
- if ( post_id == pre_id )
913
+ if ( post_id == pre_id && !allow_autapse )
916
914
{
917
915
continue ; // Skip self-connections
918
916
}
0 commit comments