Skip to content

Commit

Permalink
fix race and subsequent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Aug 3, 2023
1 parent ae1f0ea commit 8d44f5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions ortools/sat/cp_model_lns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2028,21 +2028,19 @@ Neighborhood SchedulingTimeWindowNeighborhoodGenerator::Generate(
Neighborhood SchedulingResourceWindowsNeighborhoodGenerator::Generate(
const CpSolverResponse& initial_solution, double difficulty,
absl::BitGenRef random) {
intervals_to_relax_.clear();
std::vector<int> intervals_to_relax;
for (const std::vector<int>& intervals : intervals_in_constraints_) {
const std::vector<int> selected_indices = SelectIndicesInRandomTimeWindow(
intervals, helper_.ModelProto(), initial_solution, difficulty, random);
for (const int index : selected_indices) {
intervals_to_relax_.insert(intervals[index]);
intervals_to_relax.push_back(intervals[index]);
}
}

if (intervals_to_relax_.empty()) return helper_.FullNeighborhood();

const std::vector<int> intervals(
{intervals_to_relax_.begin(), intervals_to_relax_.end()});
if (intervals_to_relax.empty()) return helper_.FullNeighborhood();
gtl::STLSortAndRemoveDuplicates(&intervals_to_relax);
return GenerateSchedulingNeighborhoodFromRelaxedIntervals(
intervals, initial_solution, random, helper_);
intervals_to_relax, initial_solution, random, helper_);
}

Neighborhood RandomRectanglesPackingNeighborhoodGenerator::Generate(
Expand Down
1 change: 0 additions & 1 deletion ortools/sat/cp_model_lns.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ class SchedulingResourceWindowsNeighborhoodGenerator

private:
const std::vector<std::vector<int>> intervals_in_constraints_;
absl::flat_hash_set<int> intervals_to_relax_;
};

// Only make sense for problems with no_overlap_2d constraints. This select a
Expand Down

0 comments on commit 8d44f5f

Please sign in to comment.