Monday, February 6, 2017

Voting Districts Day 6: Voting District Draft

Next up, we are going to go through our starting points where each will take turns choosing a voting district that is closest to them. This draft of sorts is intended to cluster the voting districts together to build our congressional districts.

To do this, we are going to continually pick the closest voting district for each point until there are no more voting districts left to pick. As voting districts are picked, we will associate the voting district to the point by appending the point and its distance to the voting district to our big list consisting of each voting district and their center points (the value we used to measure the distance to the starting point). We'll also take the voting district away as an option by replacing the distance value in the matrix from the measure to 'xxxxx.' We'll know when we are done when all the values in one of the matrix rows consists of all 'xxxxx' values.

Here's the code I wrote with the usual verbose comments:

#Our list to iterate through the points, giving each a turn to get its closest voting district.
point_list = list()

#Next, until all the voting districts are picked, round robin through the points, designating the closest available voting
#district and removing that voting district as an option for the next pick.  For the ones already found, mark out with xxxxx, which will also eliminate it from being
#found as the minimum for the next point check.  Do this until all the voting districts equal xxxxx, which means they've all been designated to a point.  

#we need a variable that'll be used to hold how many voting districts haven't been chosen.  
choices_left = 1

#while there are still voting districts unspoken for...
while (choices_left > 0):
    #I want to pull an item from a list of the points using pop, but make the pop or the list random...
    #can do this with random.shuffle, then pop the last one out!
    
    #when the list is empty, fill it back up with the number of points and shuffle that list.
    if (len(point_list) == 0):
        for e in range(0,len(start_points)): point_list.append(e)
        random.shuffle(point_list)
    point_choice = point_list.pop() #pull a point.
    min_distance = min(matrix[point_choice]) #get the least distance found between a voting district and that point.
    dist_loc = matrix[point_choice].index(min_distance) #figure out which voting district has that minimum distance.
    coords[dist_loc].append([point_choice, min_distance]) #and apply the point and distance to that district as the points choice.
    #then mark that voting district as chosen by changing the distance values corresponding to that district to xxxxx.
    for f in range(0, len(matrix)):
        matrix[f][dist_loc] = 'xxxxx'

    #figure out how many voting districts have yet to be spoken for by counting how many in one line of the matrix do not equal xxxxx.   
    choices_left = len([g for g in matrix[0] if g != 'xxxxx'])
    #print(str(point_choice) + ' ' + str(min_distance) + '  ' + str(dist_loc) + '  ' + str(choices_left))

Next, we've got to figure out what to do with this data. It would be great to build a map with it to see what it looks like, but I'm not sure exactly how to pull that off.

It looks like javascript and leaflet.js may be a nice option, but there's definitely a learning curve there for me. I'll research and see what I can do.

1 comment:

terry james said...

I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..










I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..









I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..