code: def __init__(
      self,
      func,
      n_dim,
      size_pop=50,
      max_iter=300,
      max_try_num=100,
      step=0.5,
      visual=0.3,
      q=0.98,
      delta=0.5,
  ):
      self.func = func
      self.n_dim = n_dim
      self.size_pop = size_pop
      self.max_iter = max_iter
      self.max_try_num = max_try_num  # 最大尝试捕食次数
      self.step = step  # 每一步的最大位移比例
      self.visual = visual  # 鱼的最大感知范围
      self.q = q  # 鱼的感知范围衰减系数
      self.delta = delta  # 拥挤度阈值，越大越容易聚群和追尾
  
      self.X = np.random.rand(self.size_pop, self.n_dim)
      self.Y = np.array([self.func(x) for x in self.X])
  
      best_idx = self.Y.argmin()
      self.best_x, self.best_y = self.X[best_idx, :], self.Y[best_idx]
      self.best_X, self.best_Y = self.best_x, self.best_y
  
file_path: scikit-opt/sko/AFSA.py
imports: import numpy
  from scipy import spatial
label_desc: Use image node_id 1 to create a new AFSA object  with example: obj = AFSA(func, n_dim, size_pop, max_iter, max_try_num, step, visual, q, delta)