Skip to content

Commit

Permalink
sync routing code; fix #3975
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Nov 9, 2023
1 parent 35684c9 commit 0557eae
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 259 deletions.
22 changes: 17 additions & 5 deletions ortools/constraint_solver/constraint_solveri.h
Original file line number Diff line number Diff line change
Expand Up @@ -1683,20 +1683,26 @@ class LocalSearchState {
class Variable;
// Adds a variable to this state, return a handler to the new variable.
int AddVariable(int64_t initial_min, int64_t initial_max);
void ChangeInitialVariableBounds(int variable_index, int64_t min,
void ChangeRelaxedVariableBounds(int variable_index, int64_t min,
int64_t max);
// Makes an object with restricted operations on the variable identified by
// variable_index: only Relax, Tighten and read operations are available.
Variable MakeVariable(int variable_index);
void Commit();
void Revert();
bool StateIsValid() const { return state_is_valid_; }
bool StateIsFeasible() const {
return state_all_variable_bounds_are_correct_ &&
num_committed_empty_domains_ == 0;
}

private:
struct Bounds {
int64_t min;
int64_t max;
};
bool BoundsIntersectionIsEmpty(const Bounds& b1, const Bounds& b2) const {
return b1.max < b2.min || b2.max < b1.min;
}

void RelaxVariableBounds(int variable_index);
bool TightenVariableMin(int variable_index, int64_t value);
Expand All @@ -1705,11 +1711,17 @@ class LocalSearchState {
int64_t VariableMax(int variable_index) const;

// TODO(user): turn these into strong vectors.
std::vector<Bounds> initial_variable_bounds_;
std::vector<Bounds> relaxed_variable_bounds_;
std::vector<Bounds> variable_bounds_;
std::vector<std::pair<Bounds, int>> saved_variable_bounds_trail_;
std::vector<std::pair<Bounds, int>> trailed_variable_bounds_;
std::vector<bool> variable_is_relaxed_;
bool state_is_valid_ = true;
// True iff all variable have their variable_bounds_ min <= max.
bool state_all_variable_bounds_are_correct_ = true;
bool state_has_relaxed_variables_ = false;
// Number of variables v for which the intersection of
// variable_bounds_[v] and relaxed_variable_bounds_[v] is empty.
int num_committed_empty_domains_ = 0;
int trailed_num_committed_empty_domains_ = 0;
};

// A LocalSearchVariable can only be created by a LocalSearchState, then it is
Expand Down
1 change: 0 additions & 1 deletion ortools/constraint_solver/docs/routing_svg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Copyright 2010-2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 0557eae

Please sign in to comment.