Dijkstra 的自稳定算法是如何工作的?

发布于 2024-11-16 17:03:06 字数 238 浏览 2 评论 0原文

我读过他的开创性论文,尽管采用分布式控制,但仍具有自稳定系统。然而,我不太明白自稳定算法是如何工作的。我对他的 k 状态机“解决方案”最感兴趣。纸张的密度相当大,我无法理解它的意义。这个算法用简单的英语来说是如何工作的?

I have read his seminal paper, Self-stabilizing systems in spite of distributed control. However, I don't quite get how the self-stabilizing algorithm works. I am most interested in his, 'solution' of k-state machines. The density of the paper is quite intense and I can't make much sense of it. How does this algorithm work in plain English?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瑕疵 2024-11-23 17:03:06

我可以尝试用简单的英语解释它......

首先你应该看看 链接< /a> 让-弗朗索瓦·科贝特 (Jean-Francois Corbett) 发表评论。

定义

(来自维基百科)

系统是自稳定的当且仅当:

  • 从任何状态开始,都保证系统最终会达到正确的状态(收敛)。
  • 鉴于系统处于正确状态,只要不发生故障(关闭),就保证保持正确状态。

符号

与研讨会论文中的相同

自稳定系统

在他的论文中,Dijkstra 定义了一个自稳定系统如下:

考虑一个具有 N+1 个节点的圆图。 (从0到N+1)

每个节点可以处于不同的状态。

每个节点可以有不同的权限。 (例如 xS = xR 可以是一种特权)

在每一步中,如果在一个节点中存在特权,我们将应用某种规则:

if privilege then "what to do" endif 

合法状态

他将合法状态定义为仅存在一种特权的状态。

结论

如果您将 Dijkstra 论文中的不同规则应用于所描述的系统,您将得到一个自稳定系统。 (参见定义。)

即,从具有 n 个特权的任何状态(即使一个节点具有多个特权),您将在有限数量的状态中达到仅存在一个特权的状态,并在此状态之后保持合法状态。你将能够达到任何合法的状态。

你可以自己尝试一个简单的例子。

4 状态解决方案的示例

让我们只采用一个底部节点和一个顶部节点:

starting point: (upT,xT) = (0,0) and
                (upB,xB) = (1,0)

state1: (upT,xT) = (0,0) and
        (upB,xB) = (1,1)
    only one privilege present on B => legitimate
state2: (upT,xT) = (0,1) and
        (upB,xB) = (1,1)
    only one privilege present on T => legitimate
state3: (upT,xT) = (0,1) and
        (upB,xB) = (1,0)
    only one privilege present on B => legitimate
state4: (upT,xT) = (0,0) and
        (upB,xB) = (1,0)
    only one privilege present on T => legitimate

这是 3 个节点的结果: 底部 (0) 中间 (1) 顶部 (2):我以 2 个权限开始(不是合法状态,然后一旦我进入合法状态,我就会停留在其中):

{0: [True, False], 1: [False, False], 2: [False, True]}
privilege in bottom
privilege in top
================================
{0: [True, True], 1: [False, False], 2: [False, False]}
first privilege in middle
================================
{0: [True, True], 1: [True, True], 2: [False, False]}
privilege in top
================================
{0: [True, True], 1: [True, True], 2: [False, True]}
second privilege in middle
================================
{0: [True, True], 1: [False, True], 2: [False, True]}
privilege in bottom
================================
{0: [True, False], 1: [False, True], 2: [False, True]}
first privilege in middle
================================
{0: [True, False], 1: [True, False], 2: [False, True]}
privilege in top
================================
{0: [True, False], 1: [True, False], 2: [False, False]}
second privilege in middle
================================
{0: [True, False], 1: [False, False], 2: [False, False]}
privilege in bottom
... etc

这是一个小的Python [<=2.7]代码(我不太擅长Python,所以它可能很难看),用于使用 n 的系统测试 4 种状态方法节点,它停止时你会发现所有合法的状态:

from copy import deepcopy
import random

n=int(raw_input("number of elements in the graph:"))-1
L=[]
D={}
D[0]=[True,random.choice([True,False])]
for i in range(1,n):
    D[i]=[random.choice([True,False]),random.choice([True,False])]
D[n]=[False,random.choice([True,False])]
L.append(D)

D1=deepcopy(D)

def nextStep(G):
    N=len(G)-1
    print G
    Temp=deepcopy(G)
    privilege=0
    if G[0][1] == G[1][1] and (not G[1][0]):
        Temp[0][1]=(not Temp[0][1])
        privilege+=1
        print "privilege in bottom"
    if G[N][1] != G[N-1][1]:
        Temp[N][1]=(not Temp[N][1])
        privilege+=1
        print "privilege in top"
    for i in range(1,N):
        if G[i][1] != G[i-1][1]:
            Temp[i][1]=(not Temp[i][1])
            Temp[i][0]=True
            print "first privilege in ", i
            privilege+=1
        if G[i][1] == G[i+1][1] and G[i][0] and (not G[i+1][0]):
            Temp[i][0]=False
            print "second privilege in ", i
            privilege+=1
    print "number of privilege used :", privilege
    print '================================'
    return Temp

D=nextStep(D)
while(not (D in L) ):
    L.append(D)
    D=nextStep(D)

I can try to explain it in plain English...

First you should have a look at the link Jean-Francois Corbett wrote as a comment.

Definition

(from Wikipedia)

A system is self-stabilizing if and only if:

  • Starting from any state, it is guaranteed that the system will eventually reach a correct state (convergence).
  • Given that the system is in a correct state, it is guaranteed to stay in a correct state, provided that no fault happens (closure).

Notations

Same as the one on the seminar paper

Self Stabilizing system

In his paper Dijkstra defines a self stabilizing system as follow:

Consider a circle graph with N+1 nodes. (From 0 to N+1)

Each node can be in different states.

Each node can have different privilege. (for example xS = xR can be a privilege)

At each step if in one node a privilege is present we will apply a certain rule :

if privilege then "what to do" endif 

Legitimate States

He defines a legitimate state to be a state with only one privilege present.

Conclusion

If you apply the different rules in Dijkstra's paper for the described system you will get a self-stabilizing system. (cf definition.)

i.e. from any state with n privilege presents (even with multiple privileges for one node) you will reach in a finite number of states a state with only one privilege present, and stay in legitimate states after this state. And you will be able to reach any legitimate state.

You can try yourself with a simple example.

Example for the 4 states solution

Let's take only a bottom node and a top node:

starting point: (upT,xT) = (0,0) and
                (upB,xB) = (1,0)

state1: (upT,xT) = (0,0) and
        (upB,xB) = (1,1)
    only one privilege present on B => legitimate
state2: (upT,xT) = (0,1) and
        (upB,xB) = (1,1)
    only one privilege present on T => legitimate
state3: (upT,xT) = (0,1) and
        (upB,xB) = (1,0)
    only one privilege present on B => legitimate
state4: (upT,xT) = (0,0) and
        (upB,xB) = (1,0)
    only one privilege present on T => legitimate

and here is a result for 3 nodes: bottom (0) middle (1) top (2): I start with 2 privileges (not legitimate state, then once I get into a legitimate state I stay in it):

{0: [True, False], 1: [False, False], 2: [False, True]}
privilege in bottom
privilege in top
================================
{0: [True, True], 1: [False, False], 2: [False, False]}
first privilege in middle
================================
{0: [True, True], 1: [True, True], 2: [False, False]}
privilege in top
================================
{0: [True, True], 1: [True, True], 2: [False, True]}
second privilege in middle
================================
{0: [True, True], 1: [False, True], 2: [False, True]}
privilege in bottom
================================
{0: [True, False], 1: [False, True], 2: [False, True]}
first privilege in middle
================================
{0: [True, False], 1: [True, False], 2: [False, True]}
privilege in top
================================
{0: [True, False], 1: [True, False], 2: [False, False]}
second privilege in middle
================================
{0: [True, False], 1: [False, False], 2: [False, False]}
privilege in bottom
... etc

Here is a small Python [<=2.7] code (I am not very good at python so it's may be ugly) to test the 4 states methods with a system of n nodes, it stops when you find all the legitimate states:

from copy import deepcopy
import random

n=int(raw_input("number of elements in the graph:"))-1
L=[]
D={}
D[0]=[True,random.choice([True,False])]
for i in range(1,n):
    D[i]=[random.choice([True,False]),random.choice([True,False])]
D[n]=[False,random.choice([True,False])]
L.append(D)

D1=deepcopy(D)

def nextStep(G):
    N=len(G)-1
    print G
    Temp=deepcopy(G)
    privilege=0
    if G[0][1] == G[1][1] and (not G[1][0]):
        Temp[0][1]=(not Temp[0][1])
        privilege+=1
        print "privilege in bottom"
    if G[N][1] != G[N-1][1]:
        Temp[N][1]=(not Temp[N][1])
        privilege+=1
        print "privilege in top"
    for i in range(1,N):
        if G[i][1] != G[i-1][1]:
            Temp[i][1]=(not Temp[i][1])
            Temp[i][0]=True
            print "first privilege in ", i
            privilege+=1
        if G[i][1] == G[i+1][1] and G[i][0] and (not G[i+1][0]):
            Temp[i][0]=False
            print "second privilege in ", i
            privilege+=1
    print "number of privilege used :", privilege
    print '================================'
    return Temp

D=nextStep(D)
while(not (D in L) ):
    L.append(D)
    D=nextStep(D)
你怎么敢 2024-11-23 17:03:06

这是一个经过实战测试的自稳定库(具有非常异步的设计):

https://github.com/hpc/libcircle

有关如何将 Dijkstra 的自稳定环纳入此库(工作队列分割技术)的更多信息,请访问:http://dl.acm.org/itation.cfm?id=2389114

如果您不想阅读本文,该代码也有很好的注释。例如,请查看: https://github.com/hpc /libcircle/blob/master/libcircle/token.c

免责声明:我是该库和论文的作者。

Here's a battle tested self-stabilization library (with a very asynchronous design):

https://github.com/hpc/libcircle

More information on how Dijkstra's self-stabilizing ring has been incorporated into this library (work queue splitting techniques) can be found at: http://dl.acm.org/citation.cfm?id=2389114.

The code is also commented fairly well if you don't feel like working through the paper. For example, take a look at: https://github.com/hpc/libcircle/blob/master/libcircle/token.c

Disclaimer: I'm an author of the library and paper.

孤独难免 2024-11-23 17:03:06

对于Dijkstra自稳定环算法,可以将每个不可区分过程的动作划分为闭合动作和收敛动作。特异进程P0的动作是关闭动作。收敛动作不参与非进展循环。对于包括P0在内的关闭动作,只能形成单个权限循环的死循环。如果碰巧您拥有多个特权,则关闭操作无法使它们保持循环。换句话说,当经过P0:杰出进程时,特权数量不断减少。

除了 Dijkstra 在 1986 年的证明之外,以下两篇出版物特别有趣:
1- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.976&rep=rep1&type=pdf
2- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.27.4320&rep=rep1&type=pdf

For Dijkstra's self-stabilizing ring algorithm, you can partition the actions of each non-distinguishable process into closure actions and convergence actions. The action of the distinguished process P0 are closure actions. The convergence actions do not participate into non-progress cycles. As to the closure actions including those of P0, they can only form an infinite loop of a single privilege circulating. If it happens that you have more than one privilege, there is no way that the closure actions keep them circulating. In other words, the number of privileges keep decreasing as they pass through P0: the distinguished process.

The following two publications are particularly interesting, besides Dijkstra's proof in 1986:
1- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.976&rep=rep1&type=pdf
2- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.27.4320&rep=rep1&type=pdf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文