import numpy as np
import pandas as pd

class Initializer:

    def __init__(self, n, a, b):
        self.n = n
        self.a = a
        self.b = b

    def generate_nodes_and_weight_matrix(self):

        n = self.n
        a = self.a
        b = self.b
        
        np.random.seed(100*a + b)

        x = (np.random.rand(n) - 0.5) * 50
        y = (np.random.rand(n) - 0.5) * 50

        weight_matrix = np.zeros([n, n])
        for i in range(n):
            for j in range(i+1, n):
                weight_matrix[i, j] = (x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2
                weight_matrix[j, i] = weight_matrix[i, j]

        return x, y, weight_matrix

for i in range(2,16):                        ### Here, (2,16) could be replaced with the some other range of no. of locations you want.
    for j in range(10):                      ### Here, (10) could be replaced with some other number of instcnces you want to generate for a particular no. of locations.
        initializer = Initializer(i, i, j)
        x,y,weight_matrix = initializer.generate_nodes_and_weight_matrix()
        df_x = pd.DataFrame(x)
        df_y = pd.DataFrame(y)
        df_wm = pd.DataFrame(weight_matrix)
        with open ("dataset.csv", 'a') as f:
            df = pd.concat([df_x, df_y, df_wm], keys = ["x_" + str(i) + '_' + str(j), "y_" + str(i) + '_' + str(j), "wm_" + str(i) + '_' + str(j)])
            df.to_csv(f)