private void merge_groups(cluster A, cluster B) { groups.Remove(B); foreach (cluster each in groups) { if (each.Equals(A)) { //foreach(location a in A) //{ //a.hebing = true; //} each.add_range(B.get_cluster()); } } }
private location find_closest_location(cluster target_cluster, cluster adjacent_cluster) { double d = 9999; location target = null; foreach (location each in target_cluster.get_cluster()) { cluster c = new cluster(each); if (c.distance_to(adjacent_cluster) < d) { d = c.distance_to(adjacent_cluster); target = each; } } return(target); }
public double distance_to(cluster B) { double total = 0; foreach (location a in group) { double ave_d = 0; foreach (location b in B.get_cluster()) { ave_d += a.distance_to(b); } ave_d /= B.get_size(); total += ave_d; } total /= size; return(total); }
private void fill_vehicle_with_appropriate_kids(vehicle proper_car, cluster most_distant_cluster, cluster closest_cluster) { List <location> left_kids = new List <location>(); //List<location> selected_kids = new List<location>(); int extra_kids = most_distant_cluster.get_size() - proper_car.getCapacity(); while (extra_kids > 0) { location closest = find_closest_location(most_distant_cluster, closest_cluster); left_kids.Add(closest); most_distant_cluster.remove(closest); extra_kids--; } proper_car.fill_kids(most_distant_cluster.get_cluster()); most_distant_cluster.remove_all(); most_distant_cluster.add_range(left_kids); }
private void fill_vehicle_with_all_kids_in_cluster(vehicle proper_car, cluster most_distant_cluster) { proper_car.fill_kids(most_distant_cluster.get_cluster()); groups.Remove(most_distant_cluster); }