File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1247,7 +1247,7 @@ double NeighborhoodGenerator::GetUCBScore(int64_t total_num_calls) const {
12471247 return current_average_ + sqrt ((2 * log (total_num_calls)) / num_calls_);
12481248}
12491249
1250- double NeighborhoodGenerator::Synchronize () {
1250+ absl::Span< const double > NeighborhoodGenerator::Synchronize () {
12511251 absl::MutexLock mutex_lock (&generator_mutex_);
12521252
12531253 // To make the whole update process deterministic, we currently sort the
@@ -1258,7 +1258,7 @@ double NeighborhoodGenerator::Synchronize() {
12581258 int num_fully_solved_in_batch = 0 ;
12591259 int num_not_fully_solved_in_batch = 0 ;
12601260
1261- double total_dtime = 0.0 ;
1261+ tmp_dtimes_. clear () ;
12621262 for (const SolveData& data : solve_data_) {
12631263 ++num_calls_;
12641264
@@ -1304,7 +1304,7 @@ double NeighborhoodGenerator::Synchronize() {
13041304 current_average_ = 0.9 * current_average_ + 0.1 * gain_per_time_unit;
13051305 }
13061306
1307- total_dtime += data.deterministic_time ;
1307+ tmp_dtimes_. push_back ( data.deterministic_time ) ;
13081308 }
13091309
13101310 // Update the difficulty.
@@ -1327,7 +1327,7 @@ double NeighborhoodGenerator::Synchronize() {
13271327 }
13281328
13291329 solve_data_.clear ();
1330- return total_dtime ;
1330+ return tmp_dtimes_ ;
13311331}
13321332
13331333std::vector<int >
Original file line number Diff line number Diff line change @@ -475,9 +475,9 @@ class NeighborhoodGenerator {
475475 }
476476
477477 // Process all the recently added solve data and update this generator
478- // score and difficulty. This returns the sum of the deterministic time of
478+ // score and difficulty. This returns list of the deterministic time of
479479 // each SolveData.
480- double Synchronize ();
480+ absl::Span< const double > Synchronize ();
481481
482482 // Returns a short description of the generator.
483483 std::string name () const { return name_; }
@@ -528,6 +528,7 @@ class NeighborhoodGenerator {
528528
529529 private:
530530 std::vector<SolveData> solve_data_;
531+ std::vector<double > tmp_dtimes_;
531532
532533 // Current parameters to be used when generating/solving a neighborhood with
533534 // this generator. Only updated on Synchronize().
Original file line number Diff line number Diff line change @@ -1721,9 +1721,13 @@ class LnsSolver : public SubSolver {
17211721 }
17221722
17231723 void Synchronize () override {
1724- const double dtime = generator_->Synchronize ();
1725- AddTaskDeterministicDuration (dtime);
1726- shared_->time_limit ->AdvanceDeterministicTime (dtime);
1724+ double sum = 0.0 ;
1725+ const absl::Span<const double > dtimes = generator_->Synchronize ();
1726+ for (const double dtime : dtimes) {
1727+ sum += dtime;
1728+ AddTaskDeterministicDuration (dtime);
1729+ }
1730+ shared_->time_limit ->AdvanceDeterministicTime (sum);
17271731 }
17281732
17291733 private:
You can’t perform that action at this time.
0 commit comments