Fixed KSwap Mutation
Mutation operator that preserves subset cardinality K by swapping one 1 → 0 and one 0 → 1.
Intent:
Pick one index from the 1‑pool (selected topics) and set it to
false(swap OUT).Pick one index from the 0‑pool (unselected topics) and set it to
true(swap IN).
Robustness:
jMetal may occasionally pass DefaultBinarySolution instances. This operator lifts any BinarySolution into a BestSubsetSolution view before mutating (cloning bitset/objectives and synthesizing labels as needed).
Guarantees:
If both pools are non‑empty, K is preserved exactly.
Degenerate masks are repaired safely:
all‑zeros → flip one random bit to
true(K becomes 1)all‑ones → flip one random bit to
false(K becomes N‑1)Operates in‑place on the (adapted) BestSubsetSolution.
Delta‑evaluation hook:
On a true swap or repair, sets:
BestSubsetSolution.lastMutationWasFixedKSwap =
trueso thatBestSubsetProblem.evaluate(...)can update cached per‑system sums in O(S).
Determinism:
All randomness goes through jMetal’s singleton RNG, so external seeding works.
Complexity:
O(N) to collect indices + O(1) updates.
Parameters
Per‑candidate mutation probability in (0.0..1.0]. When the random draw is ≥ probability, the operator is a no‑op.
Functions
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).
jMetal 6.x mutation API: returns the configured per‑candidate mutation probability.