FixedKSwapMutation

class FixedKSwapMutation(probability: Double) : MutationOperator<BinarySolution>

Mutation operator that preserves subset cardinality K by swapping one 10 and one 01.

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:

Determinism:

  • All randomness goes through jMetal’s singleton RNG, so external seeding works.

Complexity:

  • O(N) to collect indices + O(1) updates.

Parameters

probability

Per‑candidate mutation probability in (0.0..1.0]. When the random draw is ≥ probability, the operator is a no‑op.

Constructors

Link copied to clipboard
constructor(probability: Double)

Functions

Link copied to clipboard
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).

Link copied to clipboard
open override fun mutationProbability(): Double

jMetal 6.x mutation API: returns the configured per‑candidate mutation probability.