solver: prune unplaceable large squares

A skyline may retain enough total empty area while no longer containing a box for its largest remaining square. Scan for the required consecutive low columns and reject such monotonic dead states.

Keep each pruning combination independently measurable and record the small public-path gain, the direct-order-9 regression, and the rejected periodic schedule.

Tests: Debug CTest (13 passed)

Tests: ASan+UBSan CTest (13 passed)

Refs: #15
This commit was merged in pull request #27.
This commit is contained in:
Codex instance
2026-07-31 08:25:36 +01:00
parent e27427d231
commit 220cec06a9
6 changed files with 264 additions and 43 deletions
+29 -8
View File
@@ -92,13 +92,24 @@ namespace {
}
auto boolean(bool value) -> char const * { return value ? "true" : "false"; }
auto pruning_name(Pruning const pruning) -> char const * {
switch (pruning) {
case Pruning::all: return "all";
case Pruning::valley_capacity: return "valley-capacity";
case Pruning::large_square: return "large-square";
case Pruning::disabled: return "none";
}
assert(false);
return "none";
}
}
int main(int argc, char **argv) {
if (argc < 3 || argc > 7) {
std::cerr << "usage: partridge_benchmark ORDER counters|plain "
"[ascending|descending|best-fit] [public|direct] "
"[d4|none] [valley-capacity|none]\n";
"[d4|none] [all|valley-capacity|large-square|none]\n";
return 2;
}
auto const order = static_cast<std::uint64_t>(std::strtoull(argv[1], nullptr, 10));
@@ -136,12 +147,19 @@ int main(int argc, char **argv) {
return 2;
}
auto const pruning =
argc < 7 || std::string_view(argv[6]) == "valley-capacity"
? Pruning::valley_capacity
: Pruning::disabled;
if (argc == 7 && std::string_view(argv[6]) != "valley-capacity" &&
argc < 7 || std::string_view(argv[6]) == "all"
? Pruning::all
: std::string_view(argv[6]) == "valley-capacity"
? Pruning::valley_capacity
: std::string_view(argv[6]) == "large-square"
? Pruning::large_square
: Pruning::disabled;
if (argc == 7 && std::string_view(argv[6]) != "all" &&
std::string_view(argv[6]) != "valley-capacity" &&
std::string_view(argv[6]) != "large-square" &&
std::string_view(argv[6]) != "none") {
std::cerr << "pruning mode must be valley-capacity or none\n";
std::cerr << "pruning mode must be all, valley-capacity, "
"large-square, or none\n";
return 2;
}
@@ -177,8 +195,7 @@ int main(int argc, char **argv) {
<< (symmetry == SymmetryBreaking::d4_unit_square ? "d4" : "none")
<< "\""
<< ",\"pruning\":\""
<< (pruning == Pruning::valley_capacity ? "valley-capacity" : "none")
<< "\""
<< pruning_name(pruning) << "\""
<< ",\"solved\":" << boolean(!timed.result.squares().empty())
<< ",\"valid\":" << boolean(validation_ok)
<< ",\"timing_seconds\":{\"solve\":" << timed.search_seconds
@@ -195,6 +212,10 @@ int main(int argc, char **argv) {
<< counters.valley_capacity_checks
<< ",\"valley_capacity_prunes\":"
<< counters.valley_capacity_prunes
<< ",\"large_square_checks\":"
<< counters.large_square_checks
<< ",\"large_square_prunes\":"
<< counters.large_square_prunes
<< ",\"generated_tasks\":" << counters.generated_tasks
<< ",\"completed_tasks\":" << counters.completed_tasks << "}}\n";
return validation_ok ? 0 : 1;