【问题标题】:applying the Particle swarm optimization algorithm into multi-dimentional searching space?将粒子群优化算法应用于多维搜索空间?
【发布时间】:2019-07-16 13:32:07
【问题描述】:

谁能帮我理解如何将 PSO 算法(粒子群优化)应用于 N 维搜索空间中函数的优化问题,例如,我有一个函数,它有 7 个参数,每个参数在适当的间隔 [min, max] 与不同的 步步为营!

【问题讨论】:

  • 这不清楚:默认情况下,当没有其他说明时,PSO 对一般 n 的函数 ℝⁿ → ℝ 进行操作;见e.g. Wikipedia

标签: python optimization particle-swarm


【解决方案1】:

根据我阅读 PSO 算法的理解,它已经具备处理多维空间中的函数的能力,因为它在 N 维向量上运行。

您可以将要优化的每个参数等同于向量中的不同维度,并考虑您的函数 (f) 采用 7 维向量而不是 7 个参数。

维基百科上的算法如下:

Let S be the number of particles in the swarm, each having a position xi ∈ ℝn in the search-space and a velocity vi ∈ ℝn.
Let pi be the best known position of particle i and let g be the best known position of the entire swarm. A basic PSO algorithm is then:[10]

for each particle i = 1, ..., S do
   Initialize the particle's position with a uniformly distributed random vector: x_i ~ U(b_lo, b_up)
   Initialize the particle's best known position to its initial position: p_i ← x_i
   if f(p_i) < f(g) then
       update the swarm's best known  position: g ← p_i
   Initialize the particle's velocity: vi ~ U(-|b_up-b_lo|, |b_up-b_lo|)
while a termination criterion is not met do:
   for each particle i = 1, ..., S do
      """for each dimension d = 1, ..., n do"""
         Pick random numbers: r_p, r_g ~ U(0,1)
         Update the particle's velocity: v_(i,d) ← ω v_(i,d) + φ_p r_p (p_(i,d)-x_(i,d)) + φ_g r_g (g_d-x_(i,d))
      Update the particle's position: x_i ← x_i + v_i
      if f(x_i) < f(p_i) then
         Update the particle's best known position: p_i ← x_i
         if f(p_i) < f(g) then
            Update the swarm's best known position: g ← p_i

The values b_lo and b_up represents the lower and upper boundaries of the search-space. 
The termination criterion can be the number of iterations performed, or a solution where the adequate objective function value is found.[11] 
The parameters ω, φ_p, and φ_g are selected by the practitioner and control the behaviour and efficacy of the PSO method, see below...

正如您在三引号中看到的那样,对于每个粒子,它将更新每个维度(即您的每个参数),因此您不必担心有 N 维度。

您还可以将 7 个下边界写为向量 b_lo,将 7 个上边界写为另一个向量 b_up。似乎您担心的边界仅对使用 b_lo 和 b_up 的循环的初始迭代有影响。


--OP 更新问题--

因此,间隔似乎只与b_lob_up 相关。因此,在您的情况下,b_lo 看起来像 [7, 30, ...],而 b_up 看起来像 [13, 90, ...]

对于步长,发生在这里

Update the particle's velocity: v_(i,d) ← ω v_(i,d) + φ_p r_p (p_(i,d)-x_(i,d)) + φ_g r_g (g_d-x_(i,d))
      Update the particle's position: x_i ← x_i + v_i

如果您希望每个维度中的步长保持不变,则必须在位置更新中添加条件。我不建议这样做,因为那样优化可能需要更长的时间,并且您会失去这种优化的一些优势。

所以首先是条件:

if v_(i,d) < 0:
    Update the particle's position x_i ← x_i - (step_size for that dimension)
elif v_(i,d) > 0:
    Update the particle's position x_i ← x_i + (step_size for that dimension)
else v_(i,d) is 0:
    # You can either do one of the above updates or pass and not move the particle in this dimension

您当然也可以简化更新速度,但我建议您坚持公式给出的速度。

【讨论】:

  • 非常感谢您的回复。关于在每个区间中前进的步长,例如对于第一个参数“a”,区间为 [7,13],步长为 1,第二个参数“b”为 [30,90],步长为 5,等。应该更改代码的哪一部分?提前致谢。
  • 你不需要改变代码,你只需要改变每个参数的间隔。例如,我们有 5 个参数需要优化,我们只需要用两个数组定义整个搜索空间 - 上界和下界,如下所示:lb: [7,30,15,25,30], ub: [13 ,90,20,30,45].
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多