def main():
    initial = np.array(list(product([0, 1, -1], [0, 1, -1])))[1:]
    initial = normalize(initial)
    initial = np.hstack((initial, np.zeros((initial.shape[0], 1))))
    filename = "smooth_transition.html"
    figure = animate_init_(initial, filename)
    final = shear(initial)
    generation = 1
    figure = animate_next_(final, figure, filename, generation)
    complete = False
    while not complete:
        center = np.average(final, axis=0)
        final, complete = rotate_toward(center, np.array([1, 1, 1]), final)
        figure = animate_next_(final, figure, filename, generation)
        generation = generation + 1
    complete = False
    while not complete:
        center = np.average(final, axis=0)
        final, complete = rotate_toward(center, np.array([1, 0, 1]), final)
        figure = animate_next_(final, figure, filename, generation)
        generation = generation + 1
    complete = False
    while not complete:
        center = np.average(final, axis=0)
        final, complete = rotate_toward(center, np.array([0, 0, 1]), final)
        figure = animate_next_(final, figure, filename, generation)
        generation = generation + 1
    complete = False
    while not complete:
        center = np.average(final, axis=0)
        final, complete = rotate_toward(center, np.array([1, 0, 0]), final)
        figure = animate_next_(final, figure, filename, generation)
        generation = generation + 1
Пример #2
0
 def plot_init_(self):
     """Initialize animation object. Return figure"""
     obj = self.objectives
     self.figure = animate_init_(obj, self.filename + ".html")
     return self.figure
Пример #3
0
               K1[j]=K[0] # The index of the solution with the minimal ASF value
               K2[j]=asf_sort[0] # The ASF value related to the K1 index
          
          no_redun_sol = list(dict.fromkeys(K1)) # Remove the redundant solutions (the solutions chosen several times for different weights) from the list K1

          # Select pop_size solutions for next generation
          if len(no_redun_sol) > pop_size:
               no_redun_sol=no_redun_sol[0:pop_size]

          ## Sorting the individuals and original objective functions based on their ASF values
          for i in range(pop_size):
               objectives1 = np.vstack((objectives1, objectives[int(no_redun_sol[i])]))
               individuals1 = np.vstack((individuals1, individuals[int(no_redun_sol[i])]))
     
          if gen==0:
               figure = animate_init_(objectives1, filename + ".html")
               #figure= animate_next_(objectives1, figure, filename + ".html",gen) 
          else:
               figure= animate_next_(objectives1, figure, filename + ".html",gen) 
               # if gen==20
               



     # k-mean cluster Ns solutions

     k_means = KMeans(NS)
     solution_points = objectives1
     k_means.fit(solution_points)

     # Closest solutions to the center of each class are selected