[CP-SAT] more spans; one more case of preserving hints during presolve; new packing LNS; propagate objective in LNS

This commit is contained in:
Laurent Perron
2024-12-02 17:17:42 +01:00
parent 79e3fc9cf5
commit dbe123f225
23 changed files with 789 additions and 1179 deletions

View File

@@ -120,6 +120,28 @@ inline IntegerValue Rectangle::IntersectArea(const Rectangle& other) const {
}
}
// Returns the L2 distance between the centers of the two rectangles.
inline double CenterToCenterL2Distance(const Rectangle& a, const Rectangle& b) {
const double diff_x =
(static_cast<double>(a.x_min.value()) + a.x_max.value()) / 2.0 -
(static_cast<double>(b.x_min.value()) + b.x_max.value()) / 2.0;
const double diff_y =
(static_cast<double>(a.y_min.value()) + a.y_max.value()) / 2.0 -
(static_cast<double>(b.y_min.value()) + b.y_max.value()) / 2.0;
return std::sqrt(diff_x * diff_x + diff_y * diff_y);
}
inline double CenterToCenterLInfinityDistance(const Rectangle& a,
const Rectangle& b) {
const double diff_x =
(static_cast<double>(a.x_min.value()) + a.x_max.value()) / 2.0 -
(static_cast<double>(b.x_min.value()) + b.x_max.value()) / 2.0;
const double diff_y =
(static_cast<double>(a.y_min.value()) + a.y_max.value()) / 2.0 -
(static_cast<double>(b.y_min.value()) + b.y_max.value()) / 2.0;
return std::max(std::abs(diff_x), std::abs(diff_y));
}
// Creates a graph when two nodes are connected iff their rectangles overlap.
// Then partition into connected components.
//