Skip to content

Lab 9 peer review - Matteo Pietro Pillitteri s314404 #7

@Matteo-Pietro-Pillitteri

Description

Hi Luca, i have some advice for you. I hope that this review can help you.

  • I think that is very important to write a README. It could include some clarifications about:

    • the main choses that you made in your work (e.g what algorithm you implemented)
    • some motivation about the hyperparameters that you chose (e.g mutation probability, offspring size..)
    • everything that is relevant to well understanding your code
  • I immediately noticed the of_over. I think this is a form of "cheating" because you shouldn't know that fitness increases if the number of 1's in the genome increases. So, don't use it to evaluate the performance of your algorithm.

  • I see that your results are obtained using a one_cut_crossover. You can try using a two_cut _crossover to increase diversity during recombination and you may get slightly better results with just this small variation. I'll leave you my implementation for the 2-cut:

def two_cut_xover(ind1: Individual, ind2: Individual) -> Individual:

while True:
    cut_point_one = randint(0, GENOME_LENGTH -1)
    cut_point_two = randint(0, GENOME_LENGTH -1)
    if cut_point_one != cut_point_two:
        break


if cut_point_one > cut_point_two:
    temp = cut_point_one
    cut_point_one = cut_point_two
    cut_point_two = temp

offspring = Individual(
    fitness=None,
    genotype = ind1.genotype[:cut_point_one]
    + ind2.genotype[cut_point_one:cut_point_two]
    + ind1.genotype[cut_point_two:]
)

return offspring

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