Skip to content
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

feat: random permutation population generator #200

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

co012
Copy link
Collaborator

@co012 co012 commented Nov 27, 2022

Description

Added random permutation population generator

Linked issues

Closes #148

Important implementation details

Generator doesn't promises uniquids of generated individuals, it is possible to implement but it will generate a lot of overhead

@co012 co012 self-assigned this Nov 27, 2022
@co012 co012 requested a review from kkafar November 27, 2022 18:10
Copy link
Collaborator

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've come to settlement with myself and decided that we can go with this kind of implementation for now (in this stage of the library development). However we should consider providing:

  1. Much more efficient solution
  2. Generating permutations only from integers 1, ..., n

}
}

impl<GeneT: Copy + Debug + Sync + Send> PopulationGenerator<Vec<GeneT>> for RandomPermutations<GeneT> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
impl<GeneT: Copy + Debug + Sync + Send> PopulationGenerator<Vec<GeneT>> for RandomPermutations<GeneT> {
impl<GeneT: Copy> PopulationGenerator<Vec<GeneT>> for RandomPermutations<GeneT> {

Is there a particular reason for these three trait bounds: Debug, Sync, Send?

Particularly the last two should be auto-implemented (you don't need to do it manually AFAIK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't work without them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Could you give more specific info? Only method I see here, that could potentially require it is shuffle, but there are no trait bounds there. Maybe I'm missing something.

src/ga/population.rs Show resolved Hide resolved
src/ga/population.rs Show resolved Hide resolved
@kkafar kkafar added this to the Release 0.1.0-beta.1 milestone Nov 30, 2022
@co012 co012 merged commit cc08760 into main Dec 14, 2022
@co012 co012 deleted the @co012/population-permutation branch December 14, 2022 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GA] Population - permutation
2 participants