Skip to content

Commit 3c6408e

Browse files
committed
fix routing ls protocol
1 parent ba07856 commit 3c6408e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ortools/constraint_solver/constraint_solveri.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ class PathOperator : public IntVarLocalSearchOperator {
23312331
class ActivePaths {
23322332
public:
23332333
explicit ActivePaths(int num_nodes) : start_to_path_(num_nodes, -1) {}
2334-
void Clear() { is_path_pair_active_.clear(); }
2334+
void Clear() { to_reset_ = true; }
23352335
template <typename T>
23362336
void Initialize(T is_start) {
23372337
if (is_path_pair_active_.empty()) {
@@ -2343,14 +2343,15 @@ class PathOperator : public IntVarLocalSearchOperator {
23432343
++num_paths_;
23442344
}
23452345
}
2346-
is_path_pair_active_.resize(num_paths_ * num_paths_, true);
23472346
}
23482347
}
23492348
void DeactivatePathPair(int start1, int start2) {
2349+
if (to_reset_) Reset();
23502350
is_path_pair_active_[start_to_path_[start1] * num_paths_ +
23512351
start_to_path_[start2]] = false;
23522352
}
23532353
void ActivatePath(int start) {
2354+
if (to_reset_) Reset();
23542355
const int p1 = start_to_path_[start];
23552356
const int p1_block = num_paths_ * p1;
23562357
for (int p2 = 0; p2 < num_paths_; ++p2) {
@@ -2362,11 +2363,19 @@ class PathOperator : public IntVarLocalSearchOperator {
23622363
}
23632364
}
23642365
bool IsPathPairActive(int start1, int start2) const {
2366+
if (to_reset_) return true;
23652367
return is_path_pair_active_[start_to_path_[start1] * num_paths_ +
23662368
start_to_path_[start2]];
23672369
}
23682370

23692371
private:
2372+
void Reset() {
2373+
if (!to_reset_) return;
2374+
is_path_pair_active_.assign(num_paths_ * num_paths_, true);
2375+
to_reset_ = false;
2376+
}
2377+
2378+
bool to_reset_ = true;
23702379
int num_paths_ = 0;
23712380
std::vector<int64_t> start_to_path_;
23722381
std::vector<bool> is_path_pair_active_;

0 commit comments

Comments
 (0)