【问题标题】:How to implement simulated annealing to find longest path in graph如何实现模拟退火以找到图中的最长路径
【发布时间】:2019-04-10 13:58:42
【问题描述】:

我找到了一段伪代码,它解释了最长路径问题的模拟退火,但有一些我不明白的细节。

目前我已经实现了一个表示图的结构,以及在图中生成随机图和随机路径的方法 - 两者都是统一的。

这是模拟退火的伪代码:

Procedure Anneal(G, s, t, P)
P = RandomPath(s, t, G)
temp = TEMP0
itermax = ITER0
while temp > TEMPF do
  while iteration  < itermax do
    S = RandomNeighbor(P, G)
    delta = S.len - P.len
    if delta > 0 then
       P = S
    else
      x = random01
      if x < exp(delta / temp) then
        P = S
      endif
    endif
    iteration = iteration + 1
  enddo
  temp = Alpha(temp)
  itermax = Beta(itermax)
enddo

我觉得不够清楚理解的细节是:

RandomNeighbor(P, G)

阿尔法(温度)

itermax = Beta(itermax)

这些方法应该做什么?

【问题讨论】:

标签: pseudocode simulated-annealing longest-path


【解决方案1】:

RandomNeighbor(P, G):这可能是从您当前的解决方案(邻居是随机选择的)创建新解决方案(或新的相邻解决方案)的函数。

Alpha(temp):就是降低温度的函数(可能是temp *= alpha

itermax = Beta(itermax):我只能假设这个计数器正在更改(很可能是重置)迭代时的计数器,因为它被用于内部while。因此,当您的迭代计数器达到最大值时,它会被重置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-01
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多