def pop_main(): filename = "test-input-3.txt" nodes = readinstance(filename) job_server = pp.Server(ncpus=7) # Create clusters of k k = 20 k_clusters = associate_points(nodes, kmeans_pp(nodes, k)) depfuncs=(wrapped_nearest_neighbor, two_opt, dist, swap_edges, nearest_neighbor, tour_length) modules=("math","itertools") jobs = [job_server.submit(parallel_two_opt_and_nearest_neighbor, (cluster,), depfuncs, modules) for cluster in k_clusters.values()] clusters = [] for cluster in jobs: clusters.append(cluster()) print "job %s has run" % id(cluster) # Cluter Gluing candr = center_f(clusters) cluster_tour = nearest_neighbor([k for k in candr],0) better = two_opt(cluster_tour) tours = glue(candr,better) tour_output(tours, filename)
def main(): filename = "test-input-1.txt" nodes = readinstance(filename) job_server = pp.Server() depfuncs=(wrapped_nearest_neighbor, two_opt, dist, swap_edges, nearest_neighbor, tour_length) modules=("math","itertools") jobs = [job_server.submit(parallel_two_opt_and_nearest_neighbor, (nodes,), depfuncs, modules)] clusters = [] for cluster in jobs: clusters.append(cluster()) print "job %s has run" % id(cluster) # Cluter Gluing candr = center_f(clusters) cluster_tour = nearest_neighbor([k for k in candr],0) better = two_opt(cluster_tour) tours = glue(candr,better) tour_output(tours, filename)
server_ui specific views """ import copy from django.conf import settings from django.http import HttpResponseRedirect from django.urls import reverse import glue import helios_auth.views as auth_views from helios.security import can_create_election from helios_auth.security import get_user from view_utils import render_template glue.glue() # actually apply glue helios.view <-> helios.signals def get_election(): return None def home(request): from helios.models import Election import heliosinstitution user = get_user(request) if user and user.user_type == 'shibboleth': return HttpResponseRedirect(reverse(heliosinstitution.views.home)) # load the featured elections