Fix clang-format in examples/
This commit is contained in:
@@ -160,12 +160,13 @@ void LocationContainer::AddRandomLocation(int64_t x_max, int64_t y_max,
|
||||
}
|
||||
}
|
||||
|
||||
int64_t LocationContainer::ManhattanDistance(NodeIndex from, NodeIndex to) const {
|
||||
int64_t LocationContainer::ManhattanDistance(NodeIndex from,
|
||||
NodeIndex to) const {
|
||||
return locations_[from].DistanceTo(locations_[to]);
|
||||
}
|
||||
|
||||
int64_t LocationContainer::NegManhattanDistance(NodeIndex from,
|
||||
NodeIndex to) const {
|
||||
NodeIndex to) const {
|
||||
return -ManhattanDistance(from, to);
|
||||
}
|
||||
|
||||
@@ -179,7 +180,8 @@ bool LocationContainer::SameLocation(NodeIndex node1, NodeIndex node2) const {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int64_t LocationContainer::SameLocationFromIndex(int64_t node1, int64_t node2) const {
|
||||
int64_t LocationContainer::SameLocationFromIndex(int64_t node1,
|
||||
int64_t node2) const {
|
||||
// The direct conversion from constraint model indices to routing model
|
||||
// nodes is correct because the depot is node 0.
|
||||
// TODO(user): Fetch proper indices from routing model.
|
||||
@@ -190,7 +192,8 @@ LocationContainer::Location::Location() : x_(0), y_(0) {}
|
||||
|
||||
LocationContainer::Location::Location(int64_t x, int64_t y) : x_(x), y_(y) {}
|
||||
|
||||
int64_t LocationContainer::Location::DistanceTo(const Location& location) const {
|
||||
int64_t LocationContainer::Location::DistanceTo(
|
||||
const Location& location) const {
|
||||
return Abs(x_ - location.x_) + Abs(y_ - location.y_);
|
||||
}
|
||||
|
||||
@@ -220,8 +223,8 @@ void RandomDemand::Initialize() {
|
||||
if (order == depot_) {
|
||||
demand_[order] = 0;
|
||||
} else {
|
||||
demand_[order] =
|
||||
kDemandMin + absl::Uniform(randomizer, 0, kDemandMax - kDemandMin + 1);
|
||||
demand_[order] = kDemandMin + absl::Uniform(randomizer, 0,
|
||||
kDemandMax - kDemandMin + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,7 +252,7 @@ StopServiceTimePlusTransition::StopServiceTimePlusTransition(
|
||||
transition_time_(std::move(transition_time)) {}
|
||||
|
||||
int64_t StopServiceTimePlusTransition::Compute(NodeIndex from,
|
||||
NodeIndex to) const {
|
||||
NodeIndex to) const {
|
||||
return location_container_.SameLocation(from, to)
|
||||
? 0
|
||||
: stop_time_ + transition_time_(from, to);
|
||||
|
||||
@@ -68,7 +68,7 @@ int32_t GetSeed() {
|
||||
|
||||
// Sample function.
|
||||
int64_t MyDistance(RoutingIndexManager::NodeIndex from,
|
||||
RoutingIndexManager::NodeIndex to) {
|
||||
RoutingIndexManager::NodeIndex to) {
|
||||
// Put your distance code here.
|
||||
return (from + to).value(); // for instance
|
||||
}
|
||||
@@ -84,7 +84,8 @@ class RandomMatrix {
|
||||
for (RoutingIndexManager::NodeIndex from(0); from < size_; ++from) {
|
||||
for (RoutingIndexManager::NodeIndex to(0); to < size_; ++to) {
|
||||
if (to != from) {
|
||||
matrix_[MatrixIndex(from, to)] = absl::Uniform(randomizer, 0, kDistanceMax);
|
||||
matrix_[MatrixIndex(from, to)] =
|
||||
absl::Uniform(randomizer, 0, kDistanceMax);
|
||||
} else {
|
||||
matrix_[MatrixIndex(from, to)] = 0LL;
|
||||
}
|
||||
@@ -92,13 +93,13 @@ class RandomMatrix {
|
||||
}
|
||||
}
|
||||
int64_t Distance(RoutingIndexManager::NodeIndex from,
|
||||
RoutingIndexManager::NodeIndex to) const {
|
||||
RoutingIndexManager::NodeIndex to) const {
|
||||
return matrix_[MatrixIndex(from, to)];
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t MatrixIndex(RoutingIndexManager::NodeIndex from,
|
||||
RoutingIndexManager::NodeIndex to) const {
|
||||
RoutingIndexManager::NodeIndex to) const {
|
||||
return (from * size_ + to).value();
|
||||
}
|
||||
std::unique_ptr<int64_t[]> matrix_;
|
||||
@@ -144,9 +145,10 @@ void Tsp() {
|
||||
int64_t forbidden_connections = 0;
|
||||
while (forbidden_connections <
|
||||
absl::GetFlag(FLAGS_tsp_random_forbidden_connections)) {
|
||||
const int64_t from = absl::Uniform(randomizer, 0, absl::GetFlag(FLAGS_tsp_size) - 1);
|
||||
const int64_t from =
|
||||
absl::Uniform(randomizer, 0, absl::GetFlag(FLAGS_tsp_size) - 1);
|
||||
const int64_t to =
|
||||
absl::Uniform(randomizer, 0 , absl::GetFlag(FLAGS_tsp_size) - 1) + 1;
|
||||
absl::Uniform(randomizer, 0, absl::GetFlag(FLAGS_tsp_size) - 1) + 1;
|
||||
if (routing.NextVar(from)->Contains(to)) {
|
||||
LOG(INFO) << "Forbidding connection " << from << " -> " << to;
|
||||
routing.NextVar(from)->RemoveValue(to);
|
||||
|
||||
@@ -143,7 +143,8 @@ static void UncapacitatedFacilityLocation(
|
||||
// Set options and solve
|
||||
if (optimization_problem_type != MPSolver::SCIP_MIXED_INTEGER_PROGRAMMING) {
|
||||
if (!solver.SetNumThreads(8).ok()) {
|
||||
LOG(INFO) << "Could not set parallelism for " << optimization_problem_type;
|
||||
LOG(INFO) << "Could not set parallelism for "
|
||||
<< optimization_problem_type;
|
||||
}
|
||||
}
|
||||
solver.EnableOutput();
|
||||
|
||||
Reference in New Issue
Block a user