Abstract
Bidirectional singleton arc consistency (BiSAC) which is an extended singleton arc consistency (SAC) has been proposed recently. The first contribution of this paper is to propose and prove two theorems of BiSAC theoretically (one is a property of BiSAC and the other is the property of allowing the deletion of some BiSACinconsistent values). Secondly, based on these properties we present two algorithms, denoted by BiSACDF and BiSACDP, to enforce BiSAC. Also, we prove their correctness and analyze the space and time complexity of them in detail. Besides, for special circumstances, we show that BiSACDF admits a worstcase time complexity in and a best one in when the problem is an already BiSAC, while BiSACDP also has the same best one when the tightness is small. Finally, experiments on a wide range of CSP instances show BiSACDF and BiSACDP are usually around one order of magnitude faster than the existing BiSAC1. For some special instances, BiSACDP is about two orders of magnitude efficient.
1. Introduction
Constraint satisfaction problem (CSP) is an important researching area in artificial intelligence. Many combinatorial problems can be solved by modeling as CSP. However, it is the NPcomplete task of determining whether a given CSP instance has a solution. Fortunately, consistency techniques can reduce the search space and speed up solving process by removing the inconsistent values [1]. Many notions and algorithms of consistency have been proposed to achieve these goals so far. Among these techniques, arc consistency (AC) [2] is the oldest and most wellknown way of filtering domain. This is indeed very simple and natural. More importantly, it is an effective technique to solve CSP instances. Now there are many algorithms to enforce it. For example AC3 [3], AC4 [4], and AC2001 [5] are all very efficient methods and they are very easy to implement. Besides, nowadays singleton arc consistency (SAC) [6] has been focused on widely. It can remove redundant values like arc consistency and path consistency [7], but the power of pruning the inconsistent values is stronger than that of AC. In fact, it ensures that the problem is also arc consistent after assigning any value to any variable. Debruyne and Bessière proposed a straightforward algorithm SAC1 [6], and Prosser studied SAC again [8]. Consiquently, the second algorithm SAC2 [9] has been proposed by Bartok. It is based on AC4 and uses external data structures to avoid invoking the AC procedure to test SAC condition more times than SAC1. Bessière and Debruyne presented the algorithms SACOPT [10] and SACSDS [11]. SACOPT has the optimal time complexity with a high space complexity. SACSDS has a better space complexity though it is not optimal in time. However, it tries to avoid redundant work. Lecoutre proposed the first depthfirst greedy algorithm SAC3 [12]. Bessière and Debruyne (2008) studied the comprehensive theoretical of SAC and proposed a new local consistency—bidirectional singleton arc consistency (BiSAC) [13] by extending the SAC. They have also proved BiSAC is stronger than SAC and presented the first algorithm BiSAC1 to enforce it. Zhang et al. proposed the algorithms BiSACDF and BiSACDP (Algorithms 4 and 5), both of them were the enforced algorithms of BiSAC.
In this paper, we firstly propose two properties of BiSAC and then prove their correctness. Based on them, we present two algorithms to enforce BiSAC, denoted by BiSACDF and BiSACDP. BiSACDF is inspired by algorithm SAC3 proposed by Lecoutre, and it is also a depthfirst greedy algorithm. The BiSACDP also uses the previous properties as a theoretical foundation and combines domain partition and divideandconquer strategy. Besides, we propose operator on subdomain to improve the efficiency of it. Also we prove their correctness and analyze their complexity. Finally, in our experiments on random CSPs, classical problems, and benchmarks, the results show that our algorithms perform better than the BiSAC1.
In terms of complexity, BiSACDF and BiSACDP have a space complexity in and a worstcase time complexity in , where is the number of variables, is the greatest domain size, and is the number of constraints. In particular, when applied to an already bidirectional singleton arc consistent problem, BiSACDF admits the worstcase time complexity in and a best one in . BiSACDP has a bestcase time if the tightness of the problem is relatively small. Notice that it does not mean the problem is BiSAC if the tightness of it is small. Actually, the problem which is an already BiSAC may have a high tightness.
2. Preliminaries
A constraint satisfaction problem , where is a finite set of variables, is a finite set of domains for every variable, and is a finite set of constraints. For each variable , its domain is denoted by . will denote the size of the greatest domain. We can use the label to represent the domain set of the problem . Each has an associated relation denoted by which represents the set of tuples allowed for the variables involved in . We can say the tightness of is small if is large enough for , respectively. Problem is a subproblem of if , and , . A solution of a constraint satisfaction problem is an assignment of value from its domain to each variable such that every constraint is satisfied. A problem is said to be satisfiable if it admits at least one solution. We denote if there is a variable of and wipes out.
A constraint satisfaction problem can be characterized by properties called partial consistency. It always removes some inconsistent values and some inconsistent pairs of values. There are many methods to do this. Now, we introduce several important notions. In this paper, we focused on binary CSP.
Definition 1. The value of variable is arc consistent (AC) if and only if, for each variable connected by the constraint , there exists a value of such that . The CSP is arc consistent if and only if every value of every variable is arc consistent.
We use to represent the problem which is obtained after enforcing AC on a given problem . If there is a variable with an empty domain in , denote .
Definition 2. The value of variable is singleton arc consistent (SAC) if and only if the problem restricted to is arc consistent . The CSP is singleton arc consistent if and only if every value of every variable is singleton arc consistent.
From the definition of AC and SAC, we can clearly see SAC is stronger than AC. In 2008, Bessière extended SAC to a stronger level of local consistency and proposed a new technique—bidirectional SAC (BiSAC) [13]. Now we introduce BiSAC below.
Definition 3. The value of variable is bidirectional singleton arc consistent (BiSAC) if and only if , , where . The CSP is bidirectional singleton arc consistent if and only if every value of every variable is bidirectional singleton arc consistent.
In [13] Bessière proposed a straightforward algorithm BiSAC1 to enforce bidirectional singleton arc consistency. Its correctness and its space and time complexity are and , respectively (see Algorithm 1).

3. New Algorithms to Enforce BiSAC
In this paper, we propose two algorithms to enforce BiSAC. Before describing them, we need to present two important theorems of BiSAC. They not only provide a theoretical basis for correctness of our algorithms, but also can improve efficiency for our algorithms.
3.1. Theoretical Analysis of BiSAC
Theorem 4. Let be a CSP and let be a subproblem of . Given ,(1) is bidirectional singleton arc consistent in , if is bidirectional singleton arc consistent in ; (2) is bidirectional singleton arc consistent in , if , where , .
Proof. (1) Let , where . Because is BiSAC in , thus is clearly concluded by the definition of BiSAC. For every , the fact that is a subproblem of can produce . Moreover, according to the correctness of AC procedure, for , if , then . Above all, it implies , where . Let ; hence, is a subproblem of the problem . According to the correctness of AC procedure again, implies . So is also bidirectional singleton arc consistent in by the definition of BiSAC.
(2) Let , where . Thus, is a subproblem of . Now, using the correctness of AC and the fact that , is deduced correspondingly. Hence conclusion (2) is obtained by the definition of BiSAC.
Actually conclusion (1) exploits BiSAC of the subproblem to ensure that is BiSAC in . So it can avoid revoking the redundant AC procedure (see Definition 3). Conclusion (2) can be a similar result through a combination of definition of BiSAC and subproblem . It is not enough although Theorem 4 as a property of BiSAC can conclude that is BiSAC in . We also need another property to ensure is bidirectional singleton arc inconsistent in .
Theorem 5. Let be a CSP and .(1) is bidirectional singleton arc inconsistent in , if .(2) is bidirectional singleton arc inconsistent in , if and , where , .
Proof. (1) Let , where and . It means that and for every s.t. . Thus, according to the correctness of AC, can lead to . Therefore, () is bidirectional singleton arc inconsistent in by the definition of BiSAC.
(2) Let ; it means that every value in is arc inconsistent when the problem is restricted to . Besides, let where, . It implies and for every in and . Thus every element in must be in , so and is a subproblem of . However, every value in is arc inconsistent in by the correctness of AC. Again, this correctness and will lead to . Thus is bidirectional singleton arc inconsistent in . So, conclusion (2) is obtained.
Theorem 5 is a property of bidirectional singleton arc inconsistency. Conclusion (1) of it, using the fact that problem restricted to is arc inconsistent, can infer is bidirectional singleton arc inconsistent in . Another conclusion also can tell us is bidirectional singleton arc inconsistent in through arc inconsistency of a special subproblem. Actually, these theorems together provide a theoretical basis for soundness and completeness of our algorithms. More importantly, they are also approaches to speed up the efficiency of consistency technique.
Now, we propose two algorithms to enforce BiSAC, denoted by BiSACDF and BiSACDP, which rely on Theorems 4 and 5.
3.2. BiSACDF Algorithm
The first algorithm BiSACDF is inspired by SAC3, which is also depthfirst greedy approach. Moreover the above theorems can improve efficiency and ensure correctness of BiSACDF. The function BiSACDF firstly puts all variablevalue pairs in the structure Queue and then calls the function JudgeDF to establish BiSAC. If the JudgeDF returns , it means there exists a domain that wipes out. So the BiSAC returns false. Otherwise, this processing continues until a fixpoint is reached.
The function JudgeDF performs a depthfirst search in order to instantiate variables, but it does not have a backtrack mechanism when dead ends occur. As long as, the current branch, no inconsistency is found, we try to extend it. In other words, the current problem is restricted to and then arc consistency is maintained. So a subproblem is generated correspondingly. The other value pairs will be judged whether they are BiSAC on this current subproblem. Theorem 4 concludes that is BiSAC in if it is BiSAC in subproblem or (line 15 and line 25). In particular, it maybe finds a lucky solution (line 18). For bidirectional singleton arc inconsistency, a dead end must occur. In that case, Theorem 5 can tell us that is bidirectional singleton arc inconsistent in if the structure occur is null (line 6 and line 14). Therefore, the value should be removed from the domain of the variable . If this domain wipes out, the algorithm terminates and returns (line 23). Otherwise, we cannot judge whether is BiSAC or not. So, it needs further propagations.
Theorem 6. BiSACDF is a correct algorithm to enforce bidirectional singleton arc consistency.
Proof. Consider the following.
Soundness. Suppose is the first BiSAC value removed by BiSACDF. It is necessarily removed in line 22 of the function JudgeDF. It means that the structure occur is , and at this time it goes to line 22 only from line 6 or line 14. Hence, if it jumps from line 6, it implies . The main loop in JudgeDF was executed only once because the structure occur is , so . Therefore, is bidirectional singleton arc inconsistent in according to conclusion (1) of Theorem 5. Jumping from line 14, it is implied that and ; conclusion (2) of Theorem 5 admits that is also bidirectional singleton arc inconsistent in . Therefore, this contradicts the assumption that is the first BiSAC value removed by BiSACDF. So, BiSACDF is sound.
Completeness. When the BiSACDF terminated, for every , is removed from Queue if the clause repeat (in JudgeDF) is executed for the first time. It means , where , . According to the definition of BiSAC, is bidirectional singleton arc consistent in . Otherwise, it is concluded that , where , . Theorem 4 can ensure that is also bidirectional singleton arc consistent in . Thus, BiSACDF is complete.
Theorem 7. BiSACDF admits a space complexity in and a worstcase time complexity in .
Proof. The additional data structure in BiSACDF is Queue and , while the space of them is also , so the overall space complexity of BiSACDF is .The worstcase of running BiSACDF is that there is exactly one value removed from its domain when the loop (see line 5 in Algorithm 2) terminates. In that case, the number of elements in Queue is when the loop repeat is executed times. Notice that the number of variablevalue pairs in is also . Let be the total times of calling JudgeDF at iterative times in the loop repeat (in BiSACDF), and let be the number of elements removed from Queue at times of calling JudgeDF. From the function JudgeDF, it is easily concluded that the times of calling AC are at most when a value is removed from Queue. Thus, at iterative times in the loop repeat (in BiSACDF), the total number of calling AC is Therefore, the times of AC called by BiSACDF are . If an optimal AC is used, then the time complexity is , such as AC2001. So, the worstcase time complexity of BiSACDF is , namely, .

Theorem 8. Applied to a constraint network which is BiSAC, the worstcase time complexity of BiSACDF is and the bestcase time complexity is .
Proof. When it is applied to a BiSAC network, there will be no value removed. It implies that the loop repeat (in Algorithm 2) is executed only once. During this procedure, the number of elements in Queue is . For every element in Queue, in the worstcase, it needs call AC times and the total is . Thus, worstcase time complexity is . For the best case, it only executes JudgeDF exactly once (finding a lucky solution). So the number of calling AC is at iterative times in the loop repeat (in Algorithm 3). Note that the number of elements in is . Thus, the total of calling AC is So the bestcase time complexity is .



3.3. BiSACDP Algorithm
Another algorithm BiSACDP is also based on the previous propositions, but it is not depthfirst greedy approach. So it cannot find a lucky solution. However, it combines domain partition technique and uses the operator presented by us to find a special subproblem so that it saves lots of redundant work. Now we propose operator : let ; operator must remove every value from the domain of every variable connected with by the constraint , where the value s.t. such that . During removing values, if a domain wipes out, operator returns ; otherwise, it returns the new problem. From the definition, we know operator can run in at worst without additional data structure. Actually, if , the function of operator is the same as forward checking (FC). For , it can be considered as the extended forward checking. Note that the operator is only used to improve efficiency through finding an appropriate special subproblem. However when ; we cannot say that the current problem has no solutions. Actually, in that case all values in are also necessary to be propagated for BiSAC. So, a “good” domain for is very important for efficiency of our algorithm. Therefore, we introduce divideconquer strategy to automatically find an appropriate subdomain.
The function BiSACDP partitions the domain of every variable into two subdomains firstly and then calls the function JudgeDP to establish the BiSAC. This process terminates until the fixpoint is reached. It means that every value in the current subdomain is bidirectional singleton arc consistent when function JudgeDP returns true. Otherwise, it means that a domain has wiped out when it returns .
The main function of JudgeDP is to determine whether all values in subdomain are BiSAC in the special subproblem. If they are all BiSAC, then they return true; otherwise it needs to partition the current subdomain. Firstly, JudgeDP uses operator to find the special subproblem. If (line 4), the function would go to label L. Otherwise, JudgeDP calls the AC. It would still go to L if AC returns too. Otherwise, it enforces BiSAC on this current problem (line 6–line 10). Theorem 4 can ensure that it is BiSAC in if it is BiSAC in the current subproblem for every value in subdomain (line 10). However, if not, it also needs to go to L for further processing. In label L, according to the definition of BiSAC, if , the single value in is bidirectional singleton arc inconsistent, so it must be removed (line 13). However, if , the current subdomain needs to be partitioned further (line 18).
Theorem 9. BiSACDP is a correct algorithm to enforce bidirectional singleton arc consistency.
Proof. Consider the following.
Soundness. Suppose is the first BiSAC value removed by BiSACDP. It is necessarily removed in line 13 of the function JudgeDP. It implies that the subdomain only contains one value . From the JudgeDP, it goes to line 13 only through line 4, line 5, or line 10 (in this case, ). If it goes through line 5, then and . So conclusion (1) of Theorem 5 admits is bidirectional singleton arc inconsistent in . Through line 4, and can also be concluded because and . So the same result can be obtained. Otherwise, from line 10 and , in this case, according to conclusion (2) in Theorem 5, is also bidirectional singleton arc inconsistent in . Above all, this contradicts the assumption. So, BiSACDP is sound.
Completeness. When the BiSACDP terminated, for every , is checked or is checked for BiSAC, where is subdomain of and . If is checked, then is BiSAC in by Theorem 4. Otherwise, the same result is also obtained by the definition of operator and Theorem 4. Thus, BiSACDP is complete.
Theorem 10. BiSACDP admits a space complexity in and a time complexity in , where denotes the number of partitions built by the BiSACDP.
Proof. The BiSACDP has only the additional data structure and the space complexity of it is . So the space complexity of BiSACDP is . From the function partition, we can see that the number of calling AC is when the JudgeDP (from lines 1 to 10) is executed only once. So, the time complexity of BiSACDP is .
Corollary 11. The worstcase time complexity of BiSACDP is , and the bestcase time complexity is .
Proof. The worstcase of running BiSACDP is that there is exactly one value removed from its domain when the loop (see line 3 in BiSACDP) terminates. So it calls the function JudgeDP times. The number of partitions produced by calling the function JudgeDP once is at most , where . Consequently, . Thus the worstcase time complexity is . However the best case is . The bestcase time complexity is obtained.
From the above proofs, the time complexity of the algorithm BiSACDP is when . In that case, the tightness of problem must be small enough. For another algorithm BiSACDF, it has the same time complexity if it can find a solution in an already BiSAC constraint network. Note that a problem whose tightness is small may not be a bidirectional singleton arc consistent. In other words a bidirectional singleton arc consistent problem may have a big tightness.
4. Experiments
To compare the different algorithms mentioned in this paper, we have performed experimentation with respect to random CSPs, classical problems, and benchmarks. Performances have been measured in terms of the CPU time in seconds and the number of checks performed by BiSAC. All algorithms have been implemented in C++ and embedded into the constraint solving platform “Ming Yue” [14–16] designed by us. In this platform, we use dom/deg variable ordering and choose the AC with heuristic information [17] because it is easy to implement and very efficient. The experiments were carried out on a DELL Intel PIV 3.0 GHz CPU/512 MB RAM with Windows XP Professional SP2/Visual C++6.0.
Random constraint satisfaction problems have become a standard for testing constraint satisfaction algorithms and heuristic algorithms because of their randomness [18]. A binary random constraint satisfaction problem (http://www.lirmm.fr/~bessiere/generator.html) is specified by four parameters , where defines a number of variables, defines the size of domains, (density) defines how many constraints appear in the problem, and (tightness) defines how many pairs of values are inconsistent in a constraint. This paper chooses , while and range from 0.05 to 0.95 (interval is 0.05). Figure 1 shows the difference of running times for BiSAC1 and BiSACDF and a ratio BiSAC1/BiSACDF. From Figure 1(a) we can see that the average running time required by BiSACDF is much less than that of BiSAC1. Actually, from the right graph of Figure 1, we can know that BiSACDF is around 2–5 times faster the BiSAC1 for small tightness. When the tightness is relatively big, BiSACDF is about 10–25 times than BiSAC1. For some special combination of the density and tightness, BiSACDF can reach about 30 times the BiSAC1. All of them can be explained by the fact that the times of revoking AC procedure of BiSACDF are much less than BiSAC1, and BiSACDF can determine whether is BiSAC earlier than BiSAC1. Figure 2 tells us that the number of checks performed by BiSACDF is also much smaller than BiSAC1. For the other algorithm BiSACDP, the running time is also less than BiSAC1. In fact, it is less than BiSACDF too (see Figure 3). For small tightness BiSACDP is about 2–20 times the BiSAC1 because the BiSACDP can find the appropriate subproblem earlier and more easily so that lots of values can be inferred BiSAC without more BiSAC checks. For the other tightness, BiSACDP is on average 40–60 times the BiSAC. BiSACDP is around 100 times faster than BiSAC1 when density ranges from 0.5 to 0.6, and tightness is set to about 0.7, which is not surprising since BiSACDP not only uses the operator to find a good subproblem successfully, but also avoids much redundant work at testing BiSAC checks. Figure 4 also shows that BiSACDP performs a visibly smaller number of checks than BiSAC1.
(a)
(b)
(a)
(b)
(a)
(b)
(a)
(b)
Besides random CSPs, we have made our algorithms apply to classical problems like Queens, Pigeons, and Color problems. From Table 1, we can see BiSACDF and BiSACDP also outperform BiSAC1 on range of CSP instances. On average, the efficiency of BiSACDF is about 3 times that of BiSAC1, and BiSACDP is around 8–20 times faster than BiSAC1.
Table 2, built from other instances (http://cpai.ucc.ie/05/Benchmarks.html), shows that our algorithms also have a better performance than BiSAC1. Especially, BiSACDP and BiSACDP are about 1000 times more efficient than BiSAC1 for the instances—“qk.” For frb and Lsq_dg, our algorithms are 23 times more efficient than BiSAC1. However, BiSACDF is slower than BiSAC1. Maybe this is because that the procedure of depthfirst instantiating variables delays the time of finding the domain which has been wiped out.
5. Conclusion
In this paper, we made a study of bidirectional singleton arc consistency and then proposed two properties. Based on these properties, two algorithms (BiSACDF and BiSACDP) were proposed. Besides, we theoretically prove that these algorithms have the same space complexity and worstcase time complexity . For different cases, they also have the same bestcase time complexity . Because our algorithms do not invoke the AC procedure to test the BiSAC condition more times than the original BiSAC1, so they avoid lots of redundant works and have a better performance. Our experimental results also show that our approaches significantly outperform BiSAC1 on range of CSP instances, and it will be applied to solve large scale real life problems coming from the scheduling and configuration areas.
Acknowledgments
The authors of this paper express sincere gratitude to all the anonymous reviewers for their hard work. This work was supported in part by NSFC under Grant nos. 61170314, 61272208, and 61373052.