-
Notifications
You must be signed in to change notification settings - Fork 97
Changes in StandardGeneticAlgorithm: Freeze targets per generation; add GASolutionSource #1347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes in StandardGeneticAlgorithm: Freeze targets per generation; add GASolutionSource #1347
Conversation
…buildSolution; support archive vs population
Changes in StandardGeneticAlgorithm: Freeze targets per generation; add GASolutionSource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fncastagna thx for this first PR ;) see my comments
| * - add: if size < maxSearchSuiteSize, sample + evaluate; add to suite (and archive GASolutionSource = ARCHIVE). | ||
| * - mod: mutate one random element; re-evaluate (or mutateAndSave if GASolutionSource = ARCHIVE). | ||
| */ | ||
| class DefaultMutationOperator : MutationOperator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name might be misleading, as mutation here is just at test suite level and not test case level, isn't it? if so, either "suite" should be in the package name, or class name, somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right it can be misleading, I'll add suite to the package name.
| private const val OP_MOD = "mod" | ||
| } | ||
|
|
||
| override fun <T : Individual> mutateIndividual( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't like the name of this function. this is doing a lot of things, and not just "mutate". name should be more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however, looking at the old code, it was named like that as well... :) but i guess it is a good time now for a name update.
| import org.evomaster.core.search.service.Sampler | ||
| import org.evomaster.core.search.service.mutator.Mutator | ||
|
|
||
| interface MutationOperator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really a mtation operator? you are also evaluating fitness, and saving to archive based on that
| score: (WtsEvalIndividual<T>) -> Double | ||
| ): WtsEvalIndividual<T> { | ||
| val selected = randomness.choose(population, tournamentSize) | ||
| return selected.maxByOrNull { score(it) } ?: randomness.choose(population) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can this be null? would that be a bug, or something that could actually happen? here, if it happens it silently handled
core/src/main/kotlin/org/evomaster/core/search/algorithms/AbstractGeneticAlgorithm.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/org/evomaster/core/search/algorithms/AbstractGeneticAlgorithm.kt
Outdated
Show resolved
Hide resolved
| /** | ||
| * Source to build the final GA solution. | ||
| * ARCHIVE: use current behavior (take tests from the archive). | ||
| * POPULATION: for GA algorithms, take the best individual from the final population. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clarify here when evolving full test suites, and not tests in isolation
|
|
||
| class StandardGeneticAlgorithmTest { | ||
|
|
||
| val injector: Injector = LifecycleInjector.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are having more than 1 test in this class, this is problematic. shared injector creates dependencies. should be recreated for each test, eg, in a @BeforeEach method
|
|
||
| val epc = injector.getInstance(ExecutionPhaseController::class.java) | ||
| if (epc.isInSearch()) { | ||
| epc.finishSearch() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed if injector is recreated per test
| val solution = standardGeneticAlgorithm.search() | ||
|
|
||
| standardGeneticAlgorithm.search() | ||
| } finally { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likely not needed if injector is recreated per test
n EMConfig
…e, translate spanish comments to english
…rithm-2 Feature/standard genetic algorithm
PR Summary
We implemented changes to the
StandardGeneticAlgorithm:We implemented changes to the
AbstractGeneticAlgorithm:Main Changes
EMConfig.GASolutionSourceandEMConfig.gaSolutionSourceto choose the source of the final solution:ARCHIVEorPOPULATION.AbstractGeneticAlgorithm(population, elitism, tournament,mutate,xover,sampleSuite).scorefunction: computes fitness using generation-frozen objectives (frozenTargets).StandardGeneticAlgorithm.searchOnce():frozenTargets = archive.notCoveredTargets().Fitness Update and Use of
frozenTargetsWhy
We align with Campos’ paper recommendation to keep objectives fixed within a generation so that all individuals compete under the same set of pending goals.
This prevents fitness drift when the objective set changes mid-generation (due to new coverages), which would make comparisons between individuals inconsistent.
How
frozenTargets = archive.notCoveredTargets().scoreof a test suite is computed only over those frozen objectives throughout the generation.Advantages