Skip to content

Instantly share code, notes, and snippets.

@NicolleLouis
Created November 27, 2017 17:18
Show Gist options
  • Save NicolleLouis/6faa8156645da6e3308e5e9272b22770 to your computer and use it in GitHub Desktop.
Save NicolleLouis/6faa8156645da6e3308e5e9272b22770 to your computer and use it in GitHub Desktop.
Fitness Knapsack
def fitness(individual, item_set):
Knapsack_Capacity = round(total_weight_of_item_set(item_set) / 2)
result = 0
if (weight_of_individual(individual, item_set) <= Knapsack_Capacity):
result = 2 * value_of_individual(individual, item_set) - weight_of_individual(individual, item_set)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment