简体   繁体   English

为什么Arc-Consistency Algorithm O(cd ^ 3)的复杂性?

[英]Why is the complexity of Arc-Consistency Algorithm O(cd^3)?

为什么Arc-Consistency Algorithm O(cd 3 )的复杂性?

I will asume that you are refering to AC-3 consistency algorithm. 我将假设您正在参考AC-3一致性算法。 This algorithm is nicely and simply described here . 这个算法在这里很好地简单描述。 I will be refering to this decsription of the algorithm. 我将参考这个算法的解释。

First, lets calculate the complexity of the method REVISE (method revises one arc between two domains). 首先,让我们计算方法REVISE的复杂性(方法修改两个域之间的一个弧)。 For each value in one domain, it is examining all the values of the second domain. 对于一个域中的每个值,它正在检查第二个域的所有值。 So the complexity of the REVISE method would be d 2 where d is maximum domain size . 因此, REVISE方法的复杂性将是d 2 ,其中d is maximum domain size

Now, how many times, at worst, will be the REVISE called? 现在,在最坏的情况下, REVISE会被召唤多少次? Initially, there are all the arcs in the queue. 最初,队列中存在所有弧。 Every time the REVISE is called, one arc is removed from the queue. 每次调用REVISE ,都会从队列中删除一个弧。 That would be e calls of the method. 这将是该方法的调用。 But we are also adding arcs back to the queue. 但我们也将弧线添加回队列。 How many times can we do that? 我们能做多少次? Well, we are adding arc back to the queue only if a value was deleted from the domain the arc is pointing to. 好吧,只有当弧从指向的域中删除了值时,我们才会将弧添加回队列。 One arc is pointing to one domain, so we can only add it as many times as the number of values in that domain. 一个弧指向一个域,因此我们只能将其添加为该域中值的数量。 So at worst, we are adding every arc back to the queue d times. 所以在最坏的情况下,我们将每个弧添加回队列d次。

REVISE is called at maximum e + ed times where e is number of arcs . REVISE在最大e + ed次调用,其中e is number of arcs

When we put it all together, we find out that the complexity of the whole algorithm is O((e+ed)d 2 ) which is O(ed 3 ). 当我们把它们放在一起时,我们发现整个算法的复杂性是O((e + ed)d 2 ),即O(ed 3 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM