Fix SBX prob_bin parameter to control parent exchange probability
Summary
This PR fixes the prob_bin parameter in the SBX (Simulated Binary Crossover) implementation to properly control the probability of parent value exchange.
Problem
The current implementation has a semantic issue where prob_bin controls random swapping based on value magnitude rather than parent identity. This creates inconsistent behavior depending on which parent has larger/smaller values.
Solution
- Preserve parent identity during SBX crossover calculations
- Make
prob_binrepresent the probability that parents exchange values - Ensure Child 1 inherits characteristics from Parent 1 when
prob_bin=0.0 - Use cleaner
np.wheresyntax for child assignment and exchange
Behavior
With this fix:
-
prob_bin=0.0: Child1←Parent1, Child2←Parent2 (no exchange) -
prob_bin=0.25: 25% chance of exchange (Child1←Parent2, Child2←Parent1) -
prob_bin=0.5: 50% chance of exchange (equivalent to old behavior) -
prob_bin=1.0: Always exchange (Child1←Parent2, Child2←Parent1)
Backward Compatibility
The fix maintains equivalent behavior at prob_bin=0.5 (the default), ensuring backward compatibility while providing the correct semantics at other values.
Closes #673
I have checked the code and ran the test experiment from my PR; this commit successfully fixes the bias and performance discrepancy. Looks good to me!