Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
We implemented the Chemical Reaction Optimization (CRO) algorithm and added comprehensive tests.
Pseudocode:
Source: https://www.researchgate.net/publication/327166354_An_Empirical_Evaluation_of_Evolutionary_Algorithms_for_Unit_Test_Suite_Generation
Main Changes
New Algorithm (
CroAlgorithm):WtsEvalIndividual), modeling each suite as a molecule with potential energy (−fitness) and kinetic energy.numCollisions).croMolecularCollisionRate): either synthesis (both molecules eligible by KE threshold) or inter-molecular ineffective collision.mutateandxoverare reused; potential is defined as-calculateCombinedFitness().croInitialKineticEnergy; tracks collisions per molecule to gate decomposition.Reactor (
CroReactor):EnergyContext(container); provides:onWallIneffectiveCollision: mutate copy; accept if energy surplus ≥ 0; split surplus between KE and container using retained-fraction ∈ [croKineticEnergyLossRate, 1].decomposition: create two mutated offspring; if deficit, attempt borrow from container (random fractional product of container); split net KE between offspring.intermolecularIneffectiveCollision: mutate both; accept if net surplus ≥ 0; split KE between the two.synthesis: crossover two offspring, pick the fitter fused; accept if net surplus ≥ 0; assign KE=surplus, reset collisions; otherwise increment parents’ collisions.computeEnergySurplus(totalBeforePotential, totalBeforeKinetic, totalAfterPotential).Molecule model (
CroMolecule):suite,kineticEnergy,numCollisions.Config (
EMConfig):CROtoEMConfig.Algorithm.croMolecularCollisionRate(0.2): probability of binary reactions (0–1).croKineticEnergyLossRate(0.2): lower bound of KE retained on on-wall (0–1).croInitialKineticEnergy(1000.0): initial KE per molecule (≥ 0).croDecompositionThreshold(500): min collisions before allowing decomposition (≥ 0).croSynthesisThreshold(10.0): synthesis allowed if KE ≤ threshold (≥ 0).Integration (
Main.kt):EMConfig.Algorithm.CROtoCroAlgorithm<RestIndividual>in algorithm selection.Docs (
docs/options.md):Tests
Algorithm-level tests added (
CroAlgorithmTest.kt):testCroAlgorithmFindsOptimum).Reactor unit tests added (
CroReactorTest.kt):computeEnergySurplusreturns positive/zero/negative as expected.