from sympy.utilities.iterables import multiset_permutations
#constructing all 60 permutations for a combination
count = 0
M = [1, 2, 3, 4, 5]
premutationn = np.zeros((60, 6))
for a1 in range(4):
    for a5 in range(a1 + 1, 5):
        M_copy = M.copy()
        del M_copy[a1]
        del M_copy[a5 - 1]
        for p in multiset_permutations(M_copy):
            premutationn[count, :] = [0] + [M[a1]] + p + [M[a5]]
            count += 1

salesman = traveling_salesman(num_cities=50)

N = [0, 1, 2, 3, 4, 5, 49, 49, 49, 49]
old_fitness = 100000000

for n in range(15890700 - 1):  #50!/(6!*44!)=15890700

    N[0] = (N[1] + N[2] + N[3] + N[4] + N[5] == 45 + 46 + 47 + 48 + 49) + N[0]
    N[1] = ((N[2] + N[3] + N[4] + N[5] == 46 + 47 + 48 + 49) +
            N[1]) * (N[1] + N[2] + N[3] + N[4] + N[5] != 45 + 46 + 47 + 48 +
                     49) + (N[0] + 1) * (N[1] + N[2] + N[3] + N[4] + N[5]
                                         == 45 + 46 + 47 + 48 + 49)
    N[2] = ((N[3] + N[4] + N[5] == 47 + 48 + 49) +
            N[2]) * (N[2] + N[3] + N[4] + N[5] != 46 + 47 + 48 + 49) + (
                N[1] + 1) * (N[2] + N[3] + N[4] + N[5] == 46 + 47 + 48 + 49)
    N[3] = ((N[4] + N[5] == 48 + 49) + N[3]) * (
from Traveling_Salesman import traveling_salesman
import matplotlib.pyplot as plt
import numpy as np

salesman = traveling_salesman(
    num_cities=50)  # initialize the TS's world with 50 cities

random_initial_tour = salesman.random_tour(
    num_stops=6
)  # create a random tour for the TS, plot and calculate length of tour
plt.figure()
salesman.plot()
print("length of first tour: ", salesman.tour_length())

salesman.new_tour(tour=np.arange(
    6).tolist())  # assign a new tour to the TS, plot and calculate length
plt.figure()
salesman.plot()
print("length of first tour: ", salesman.tour_length())

salesman.new_tour(
    tour=[1, 6, 7, 28, 42,
          9])  # assign a new tour to the TS, plot and calculate length
plt.figure()
salesman.plot()
print("length of first tour: ", salesman.tour_length())