[CP-SAT] improve no_overlap_2d cuts; more no_overlap_2d cuts; bugfixes; add sat/c_api subdirectory
This commit is contained in:
@@ -981,6 +981,93 @@ TEST(ReduceNumberOfBoxes, Problematic2) {
|
||||
CHECK(input == output);
|
||||
}
|
||||
|
||||
TEST(DetectDisjointRegionIn2dPackingTest, Basic) {
|
||||
// Note that the hole of size 1 is ignored since no box is small enough to
|
||||
// fit in it.
|
||||
const std::vector<Rectangle> fixed_rectangles = BuildFromAsciiArt(R"(
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
########### ############## ####
|
||||
########### ############## ####
|
||||
########### ####### ### ####
|
||||
########### ####### ### ####
|
||||
########### ############## ####
|
||||
########### ############## ####
|
||||
########### #######################
|
||||
#######################################
|
||||
#######################################
|
||||
###################### ################
|
||||
#######################################)");
|
||||
|
||||
Rectangle bb = fixed_rectangles[0];
|
||||
for (const Rectangle& r : fixed_rectangles) {
|
||||
bb.GrowToInclude(r);
|
||||
}
|
||||
const std::vector<RectangleInRange> non_fixed_rectangles = {
|
||||
{.box_index = 0, .bounding_area = bb, .x_size = 2, .y_size = 2},
|
||||
};
|
||||
|
||||
auto res = DetectDisjointRegionIn2dPacking(non_fixed_rectangles,
|
||||
fixed_rectangles, 100);
|
||||
EXPECT_THAT(res.bins.size(), 3);
|
||||
std::sort(res.bins.begin(), res.bins.end(),
|
||||
[](const Disjoint2dPackingResult::Bin& a,
|
||||
const Disjoint2dPackingResult::Bin& b) {
|
||||
return a.bin_area[0].SizeY() < b.bin_area[0].SizeY();
|
||||
});
|
||||
EXPECT_TRUE(
|
||||
RectanglesCoverSameArea(res.bins[0].fixed_boxes, BuildFromAsciiArt(R"(
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
####################### ############
|
||||
####################### ############
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################)")));
|
||||
|
||||
EXPECT_TRUE(
|
||||
RectanglesCoverSameArea(res.bins[1].fixed_boxes, BuildFromAsciiArt(R"(
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
############################## ####
|
||||
############################## ####
|
||||
############################## ####
|
||||
############################## ####
|
||||
############################## ####
|
||||
############################## ####
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################)")));
|
||||
|
||||
EXPECT_TRUE(
|
||||
RectanglesCoverSameArea(res.bins[2].fixed_boxes, BuildFromAsciiArt(R"(
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
########### #######################
|
||||
########### #######################
|
||||
########### #######################
|
||||
########### #######################
|
||||
########### #######################
|
||||
########### #######################
|
||||
########### #######################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################
|
||||
#######################################)")));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace sat
|
||||
} // namespace operations_research
|
||||
|
||||
Reference in New Issue
Block a user