test(filament_group): don't assert max_group_size cap for MatchMode

The FilamentGroup property/golden harness checked a per-extruder
max_group_size cap unconditionally in check_constraints. That cap is an
invariant of the flush-partition solvers only (calc_group_by_enum /
calc_group_by_kmedoids, reached via calc_filament_group_for_flush), which
partition filaments subject to each extruder's capacity.

MatchMode (calc_filament_group_for_match) does not partition by capacity:
it maps every filament to the extruder holding the nearest-color loaded
AMS filament, and its solver capacity is the used-filament count, not
max_group_size (FilamentGroup.cpp:1067). So a legitimate MatchMode result
can place more than max_group_size filaments on one extruder.

The prop_a/b/c_mode_match specs run MatchMode, and their scenarios are
generated with std::uniform_int_distribution / std::shuffle, which are
implementation-defined. For a fixed mt19937 seed, libc++ (macOS), libstdc++
(Linux) and MSVC (Windows) draw different scenarios, so the CI failure only
surfaced on Linux/Windows while macOS passed. Verified locally: 248/600
config-A MatchMode seeds exceed the cap under libc++ — it is reachable
everywhere; seed 90400 just isn't an exceeding draw on macOS.

Gate section 3 on FGMode != MatchMode. No test case is removed or skipped:
all 57 FlushMode specs still assert the cap, MatchMode still asserts the
unprintable-filament/volume correctness constraints (which it honors), and
MatchMode grouping regressions are still caught by the golden score gate at
3% tolerance. Test-only change; slicing behavior and g-code are unaffected.
This commit is contained in:
SoftFever
2026-07-10 02:17:52 +08:00
parent b58dcf5978
commit 9e8ac03476

View File

@@ -52,12 +52,19 @@ inline bool check_constraints(const FilamentGroupContext& ctx,
}
}
// 3. max_group_size per extruder (only check when theoretically feasible)
// 3. max_group_size per extruder. This cap is an invariant of the flush-partition
// modes only: those solvers partition the filaments across extruders subject to
// each extruder's capacity. MatchMode instead maps every filament to the extruder
// holding the nearest-color loaded AMS filament and does not partition by capacity
// (its solver capacity is the filament count, not max_group_size), so a legitimate
// match may place more than max_group_size filaments on one extruder. Enforce the
// cap only for the partition modes, and only when the instance is feasible.
int total_capacity = 0;
for (auto sz : ctx.machine_info.max_group_size)
total_capacity += sz;
if (total_capacity >= (int)used_filaments.size()) {
if (ctx.group_info.mode != FGMode::MatchMode &&
total_capacity >= (int)used_filaments.size()) {
std::map<int, int> extruder_count;
for (auto fil : used_filaments) {
if (fil >= filament_map.size()) continue;