Skip to content

Incorrect logic in reproduction step of genetic algorihm example (knapsack problem)? #15

@fotto

Description

@fotto

children = one_point_crossover(chosen_selections[parent_index],

I know it's just an example but IMHO there are two problems with the actual implementation of the reproduction step:

the reproduce_children() function is called with 100 genes but

  • half of the parents are not used at all:
    • it combines chosen_selections[0] with chosen_selections[1]
    • then chosen_selections[1] with chosen_selections[2]
    • and so on and until chosen_selections[48] is combined with chosen_selections[49]
    • chosen_selections[50:] is not used at all
  • it forget the results of reproduction:
    • only the two children of last iteration are returned
    • all others are ignored

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions