-
Notifications
You must be signed in to change notification settings - Fork 14
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
Introducing random mutant-selection #31
Introducing random mutant-selection #31
Conversation
…lection: selecting a fixed number of mutants, and selecting a percentage of all the mutants. All of this with some tests
…m and percentage random, with tests
Implemented another type of random selection. |
1 to: numberOfMutants do: [ :i | | ||
operator := operators at: | ||
(random nextIntegerBetween: 1 and: operators size). | ||
[ (dict at: operator) allSatisfy: [ :each | newColl includes: each ] ] |
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.
Nice check! but it would be nice it comes with a comment :)
It's important to understand that if you already selected all the mutants in an operator, then you need to filter the operator out, otherwise this will loop forever looking for mutants (and they are all used)
whileTrue: [ | ||
operator := operators at: | ||
(random nextIntegerBetween: 1 and: operators size) ]. | ||
size := (dict at: operator) size. |
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.
This looks like the same code as above. How can we enhance it a bit and avoid the repeated code?
size := aCollection size. | ||
newColl := aCollection copyEmpty. | ||
random := Random new. | ||
numberOfMutants := size * percentageOfMutants / 100. |
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.
Cool, so you transformed a percentage into an absolute number of mutants.
Now you can reuse the code from the other class!! How could you do it? :)
dict := aCollection groupedBy: [ :e | e operator ]. | ||
operators := dict keys. | ||
1 to: numberOfMutants do: [ :i | | ||
operator := operators at: |
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.
Same here!
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.
Thanks Pol! I think the code is good, but we could do a pass before integration because there is no rush ^^
I did some refactoring.
|
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.
Better! I think there are still duplications we can remove and simplify, let's discuss them later.
Thanks @DurieuxPol !
Added a random mutant-selection decorator. It decorates a mutations-generation strategy and it randomly selects a mutant among all mutants generated.
Also added two types of concrete random mutant-selectors.
The first one randomly selects a fixed number of distinct mutants (
FixedRandomMutantSelection
), while the second one selects a percentage of them (PercentRandomMutantSelection
).An example of how to use it: