<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Overview
Kunci utama dari Efisiensi pengiriman adalah customer harus terassign ke kitchen yang terdekat dulu.
Kami melakukannya dengan menSort customer dari jarak yang paling jauh dari titik pusat customer (sum/total lat long).
Solusi tersebut belum optimal,tapi mendekati.
Solusi optimal = Sort dari Outermost customer.
Customer kemudian di assign ke kitchen terdekatnya, apabila sudah full maka diassign ke kitchen kedua terdekat, dst.
Sehingga bisa didapat group berupa customer yang terassign ke suatu kitchen.
Driver kemudian di assign per group berdasarkan degree dan jarak.
Di assign tidak hanya berdasarkan jarak untuk mengoptimalkan waktu pengiriman selama 1 jam.
Grouping customer to the best kitchen
Step1:  Assign driver in group based on degree and distance
<ASSISTANT_TASK:>
Python Code:
# Find center point of customer, buat nyari
# long
long_centroid = sum(customer['long'])/len(customer)
# lat
lat_centroid = sum(customer['lat'])/len(customer)
# Find distance from customer point to central customer point
customer['distSort'] = np.sqrt( (customer.long-long_centroid)**2 + (customer.lat-lat_centroid)**2)
# Sort by longest distance
customer = data.sort_values(['distSort'], ascending=False)
# Data already sorted from outermost customer 
# For each row in the column,assign customer to the the nearest kitchen, 
# if the kitchen already full, assign customer to the second nearest kitchen and so on.
# BELUM SELESAI YANG INI
clusters = []
for row in customer['distSort']:
    #clusters.append(cluster)
    
data['cluster'] = clusters
# Data visulization customer assigned to its kitchen
def visualize(data):
    x = data['long']
    y = data['lat']
    Cluster = data['cluster'] 
    fig = plt.figure()
    ax = fig.add_subplot(111)
    scatter = ax.scatter(x,y,c=Cluster, cmap=plt.cm.Paired, s=10, label='customer')
    ax.scatter(kitchen['long'],kitchen['lat'], s=10, c='r', marker="x", label='second')
    ax.set_xlabel('longitude')
    ax.set_ylabel('latitude')
    plt.colorbar(scatter)
    fig.show()
# Visualization Example customer assigned to kitchen (without following constraint)
# THIS IS ONLY EXAMPLE
y = kitchen['kitchenName']
X = pd.DataFrame(kitchen.drop('kitchenName', axis=1))
clf = NearestCentroid()
clf.fit(X, y)
pred = clf.predict(customer)
customer1['cluster'] = pd.Series(pred, index=customer1.index)
customer['cluster'] = pd.Series(pred, index=customer.index)
visualize(customer)
# Count customer order assigned to Kitchen
dapurMiji = (customer1.where(customer1['cluster'] == 0))['qtyOrdered'].sum()
dapurNusantara = (customer1.where(customer1['cluster'] == 1))['qtyOrdered'].sum()
familiaCatering = (customer1.where(customer1['cluster'] == 2))['qtyOrdered'].sum()
pondokRawon = (customer1.where(customer1['cluster'] == 3))['qtyOrdered'].sum()
roseCatering = (customer1.where(customer1['cluster'] == 4))['qtyOrdered'].sum()
tigaKitchenCatering = (customer1.where(customer1['cluster'] == 5))['qtyOrdered'].sum()
ummuUwais = (customer1.where(customer1['cluster'] == 6))['qtyOrdered'].sum()
d = {'Dapur Miji': dapurMiji , 'Dapur Nusantara': dapurNusantara, 'Familia Catering': familiaCatering, 'Pondok Rawon': pondokRawon,'Rose Catering': roseCatering, 'Tiga Kitchen Catering': tigaKitchenCatering, 'Ummu Uwais': ummuUwais}
# print(customer.cluster.value_counts())
# Print sum of assigned
print(d) 
Explanation: Overview
Kunci utama dari Efisiensi pengiriman adalah customer harus terassign ke kitchen yang terdekat dulu.
Kami melakukannya dengan menSort customer dari jarak yang paling jauh dari titik pusat customer (sum/total lat long).
Solusi tersebut belum optimal,tapi mendekati.
Solusi optimal = Sort dari Outermost customer.
Customer kemudian di assign ke kitchen terdekatnya, apabila sudah full maka diassign ke kitchen kedua terdekat, dst.
Sehingga bisa didapat group berupa customer yang terassign ke suatu kitchen.
Driver kemudian di assign per group berdasarkan degree dan jarak.
Di assign tidak hanya berdasarkan jarak untuk mengoptimalkan waktu pengiriman selama 1 jam.
Grouping customer to the best kitchen
End of explanation
# Get degree for each customer in the cluster
def getDegree(data):
    # distance
    # center long lat (start of routing)
    center_latitude = #Tiap Kitchen
    center_longitude = #Tiap Kitchen
    degrees = []
    degree = 0
    # For each row in the column,
    for row in data['longitude']:
        degrees = np.rint(np.rad2deg(np.arctan2((data['latitude']-center_latitude),(data['longitude']-center_longitude))))
       #center di pulogadung
    data['degrees'] = degrees
    return data
# Assign driver dari kitchen ke customer berdasarkan degree dan jarak
# Priority utama berdasarkan degree jadi gaada driver yang deket doang
# Tapi belum dipikir gimana bisa optimize waktu harus satu jam max, tapi seenggaknya driver udah agak rata jaraknya
# Kasus khusus apabila yg degree nya kecil jaraknya jauh banget, dia driver baru.
# BELUM SELESAI YANG INI
Explanation: Assign driver in group based on degree and distance
End of explanation
<END_TASK>