[Python] Is this considered a fitness function for a genetic algorithm?

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    I start off with a population. I also have properties each individual in the population can have. If an individual DOES have the property, it’s score goes up by 5. If it DOESNT have it, it’s score increases by 0. Example code using length as a property:

    for x in individual:
    if len <5:
    score += 5
    if len >=5:
    score += 0


    Then I add up the total score and select the individuals I want to continue. Is this a fitness function?

    Continue reading...

Compartilhe esta Página