Created
June 20, 2019 17:56
-
-
Save jtrussell/fbf67717e919763a4b9d2bc3708b1dbe to your computer and use it in GitHub Desktop.
Pseudo-ish code for service area fitness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_fitness(individual): | |
# Award a baseline score based on total volume | |
percent_volume = get_percent_volume(individual) | |
score = min(percent_volume, 0.75) * max_volume_score | |
if percent_volume >= 0.75: | |
# Award additional points for contiguity if we've met | |
# the volume threshold. | |
num_contiguous_blocks = get_num_contiguous_blocks(individual) | |
contiguous_bonus = get_contiguous_bonus(num_contiguous_blocks) | |
score = score + contiguous_bonus | |
if num_contiguous_blocks is 1: | |
# Once we achieve contiguity, start whittling away | |
# unnecessary ZIP Codes. | |
num_codes_in_area = get_num_codes_in_area(individual) | |
fewest_codes_bonus = get_fewest_codes_bonus(num_codes_in_area) | |
score = score + fewest_codes_bonus | |
return score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment