@@ -2331,7 +2331,7 @@ class PathOperator : public IntVarLocalSearchOperator {
2331
2331
class ActivePaths {
2332
2332
public:
2333
2333
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 ; }
2335
2335
template <typename T>
2336
2336
void Initialize (T is_start) {
2337
2337
if (is_path_pair_active_.empty ()) {
@@ -2343,14 +2343,15 @@ class PathOperator : public IntVarLocalSearchOperator {
2343
2343
++num_paths_;
2344
2344
}
2345
2345
}
2346
- is_path_pair_active_.resize (num_paths_ * num_paths_, true );
2347
2346
}
2348
2347
}
2349
2348
void DeactivatePathPair (int start1, int start2) {
2349
+ if (to_reset_) Reset ();
2350
2350
is_path_pair_active_[start_to_path_[start1] * num_paths_ +
2351
2351
start_to_path_[start2]] = false ;
2352
2352
}
2353
2353
void ActivatePath (int start) {
2354
+ if (to_reset_) Reset ();
2354
2355
const int p1 = start_to_path_[start];
2355
2356
const int p1_block = num_paths_ * p1;
2356
2357
for (int p2 = 0 ; p2 < num_paths_; ++p2) {
@@ -2362,11 +2363,19 @@ class PathOperator : public IntVarLocalSearchOperator {
2362
2363
}
2363
2364
}
2364
2365
bool IsPathPairActive (int start1, int start2) const {
2366
+ if (to_reset_) return true ;
2365
2367
return is_path_pair_active_[start_to_path_[start1] * num_paths_ +
2366
2368
start_to_path_[start2]];
2367
2369
}
2368
2370
2369
2371
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 ;
2370
2379
int num_paths_ = 0 ;
2371
2380
std::vector<int64_t > start_to_path_;
2372
2381
std::vector<bool > is_path_pair_active_;
0 commit comments