execute

open override fun execute(candidate: BinarySolution): BinarySolution

Executes the fixed‑K swap mutation on candidate. If the candidate is not a BestSubsetSolution, it is lifted to one (bitset and objectives are copied).

Steps:

  1. Early exit if mutation does not trigger or there are no bits.

  2. Snapshot current mask into a primitive array.

  3. Collect indices with 1 and with 0.

  4. Perform:

    • Swap if both pools have elements (K preserved).

    • Repair if the mask is all‑zeros or all‑ones (K set to 1 or N‑1).

  5. Record swap/repair metadata for delta‑evaluation.

Return

the mutated BestSubsetSolution (same instance if already compatible; otherwise lifted).

Parameters

candidate

input solution (possibly a DefaultBinarySolution).