@@ -344,7 +344,6 @@ namespace grb {
344344 best_energy = energies[j];
345345 best_state = states[j];
346346 }
347- if ( goal < -1 && best_energy <= goal ) break ;
348347 } // n_replicas
349348
350349 // TODO: find a better way than this, to avoid a sync at each iteration
@@ -423,10 +422,20 @@ namespace grb {
423422 grb::resize ( w, n );
424423
425424 std::minstd_rand rng ( seed );
426- std::uniform_real_distribution< AType > rand ( 0.1 , 2.0 );
427425
426+ // random shuffle w
427+ // const auto w_raw = grb::internal::getRaw( w );
428428 for ( size_t i = 0 ; i < n ; ++i ){
429- rc = rc ? rc : grb::setElement ( w, rand ( rng ), i );
429+ rc = rc ? rc : grb::setElement ( w, i+1 , i );
430+ }
431+ for ( size_t i = 0 ; i < n ; ++i ){
432+ std::uniform_int_distribution< size_t > rand ( i, n-1 );
433+ const auto j = rand (rng);
434+ const auto a = w[i];
435+ const auto b = w[j];
436+ rc = rc ? rc : grb::setElement ( w, b, i );
437+ rc = rc ? rc : grb::setElement ( w, a, j );
438+ // std::swap( w_raw[i], w_raw[j] );
430439 }
431440
432441 const grb::Semiring<
@@ -512,6 +521,7 @@ namespace grb {
512521 * @param[in,out] betas Inverse temperature of each state.
513522 * @param[in] n_sweeps Number of Simulated Annealing iterations.
514523 * @param[in] use_pt Whether to use Parallel Tampering or not.
524+ * @param[in] seed Seed to use for internal randomization (must be the same for all processees);
515525 *
516526 * @tparam StateType The state variable type.
517527 * @tparam QType The matrix values' type.
0 commit comments