Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Study of Graph Coloring Problems using SAT-based approach . Indira Bhusal Pandey . Graduate School of Intercultural Studies Kobe University, Japan CSPSAT meeting, March 13, 2009 Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Outline of this talk Overview Applications of GCP/B-GCP Definitions of GCP and B-GCP COP representation of GCP/B-GCP SAT problems SAT solvers and SAT-based approach SAT encoding methods Order encoding of GCP/B-GCP Developed GCP/B-GCP solver Performance evaluation Conclusion Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Overview Objective Study and implementation of a SAT-based GCP/B-GCP solver. SAT-based approach is a general method to solve difficult combinatorial problems by encoding them into SAT (Satisfiability Testing) problems and solving by using an efficient SAT solver. A (pure) Graph Coloring Problem (GCP) is a problem to find the minimum number of colors (chromatic number) such that no two adjacent vertices have the same color. A Bandwidth-GCP (B-GCP) is a generalization of GCP in which a positive minimum distance is given as the weight for each edge. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP Applications of GCP/B-GCP GCP/B-GCP are useful in variety of applications. Some of them are as follows: 1 Frequency Assignment Problems Resolving the conflicts in radio frequency assignment. 2 Time Tabling Problems Determining the minimum number of time slots needed subject to their restriction. 3 Scheduling Problems Resolving a number of pairwise restrictions on which jobs can be done simultaneously. 4 Register Allocation Problems Finding an efficient register usage in compiler systems. . . . Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP Graph Coloring Problems (GCP) . 1 Given: A graph G (V , E ) V : a set of vertices E : a set of edges 2 Objective: to find a coloring function c : V → {1, 2, 3, . . . , k} with the minimum (chromatic number) k such that colors of any two adjacent vertices must differ in at least by one. . Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP Bandwidth Graph Coloring Problems (B-GCP) . 1 Given: A weighted graph G (V , E , w ) V : a set of vertices E : a set of edges w : a weight function E → N 2 . Objective: to find a coloring function c : V → {1, 2, 3, . . . , k} with the minimum (chromatic number) k such that colors of any two adjacent vertices must differ in at least by the given weight. Note: B-GCP is a generalization of GCP. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP . Example of B-GCP 1 Given: A weighted graph G (V , E , w ) Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP . Example of B-GCP 1 Given: A weighted graph G (V , E , w ) Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP . Example of B-GCP 1 Given: A weighted graph G (V , E , w ) 2 Three is the minimum chromatic number. The following is a coloring function with the minimum chromatic number. . Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Applications GCP COP representation of GCP/B-GCP B-GCP (and also GCP) can be formulated as a constraint optimization problem (COP) on integers. G (V , E , w ) Vertex vi Edge {vi , vj } with weight c = w ({vi , vj }) COP Variable xi ∈ {1, 2, 3, . . . , k} Constraint |xi − xj | ≥ c Objective: minimize k Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion SAT Problems SAT solvers SAT encoding methods SAT Problems SAT (Satisfiability Testing) is a problem to decide whether the given propositional formula is satisfiable or unsatisfiable. The formula is given as a Conjunctive Normal Form (CNF) A CNF formula is a conjunction (AND) of clauses. A clause is a disjunction (OR) of literals. A literal is either a Boolean variable or its negation. A formula in CNF is satisfiable iff there exists an assignment for each Boolean variable so that the whole formula becomes true. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion SAT Problems SAT solvers SAT encoding methods SAT Solvers and SAT-based approach SAT solver is a program to find a solution of a SAT problem. Recent advances of SAT solver technology are remarkable. MiniSat solver (Eén and Sörensson 2003) can solve a problem with 107 literals. SAT solvers are used to solve hard problems by encoding them to SAT problems (SAT-based approach), such as Scheduling, Planning, and Software and hardware verification. There are several SAT encoding methods. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion SAT Problems SAT solvers SAT encoding methods SAT encoding methods Direct Encoding (Walsh 2000) uses a different Boolean variable p(x, a) representing x = a for each integer variable x and integer value a. p(x, a) ⇐⇒ x =a Order Encoding (Tamura et al. 2006) uses a different Boolean variable p(x, a) representing x ≤ a for each integer variable x and integer value a. p(x, a) ⇐⇒ x ≤a Direct encoding has been widely used in many applications including GCP solvers, but use of order encoding for GCP/B-GCP has not been studied. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Order Encoding Order encoding of GCP/B-GCP In this talk, we propose a new SAT encoding of GCP/B-GCP based on the order encoding. Encoding of a vertex vi , that is, encoding of a variable xi ∈ {1, 2, 3, . . . , k}. Encoding of an edge {vi , vj } with weight c, that is, encoding of a constraint |xi − xj | ≥ c (note: c = 1 for GCP). Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Order Encoding Order encoding of a variable xi ∈ {1, 2, 3, . . . , k} Variable xi ∈ {1, 2, 3, . . . , k} is encoded into the following Boolean variables and clauses. Boolean variables p(xi , 1) p(xi , 2) p(xi , 3) ... p(xi , k − 1) Clauses ¬p(xi , 1) ∨ p(xi , 2) ¬p(xi , 2) ∨ p(xi , 3) ¬p(xi , 3) ∨ p(xi , 4) ....... ¬p(xi , k − 2) ∨ p(xi , k − 1) Indira Bhusal Pandey (if (xi ≤ 1), then (xi ≤ 2)) (if (xi ≤ 2), then (xi ≤ 3)) (if (xi ≤ 3), then (xi ≤ 4)) (if (xi ≤ k − 2), then (xi ≤ k − 1)) Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Order Encoding Order encoding of a constraint |xi − xj | ≥ c The following is an example of encoding x1 ≤ x2 − 3 (x1 , x2 ∈ {1, 2, 3, . . . , 6}). (x1 ≤ x2 − 3) → (x1 ≤ 3) ∧ ¬(x2 ≤ 3) ∧ ((x1 ≤ 1) ∨ ¬(x2 ≤ 4)) ∧ ((x1 ≤ 2) ∨ ¬(x2 ≤ 5)) ↔ ¬(x1 ≥ 4) ∧ ¬(x2 ≤ 3) ∧ ¬((x1 ≥ 2) ∧ (x2 ≤ 4)) ∧ ¬((x1 ≥ 3) ∧ (x2 ≤ 5)) Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Order Encoding Order encoding of a constraint |xi − xj | ≥ c (cont.) The following is an example of encoding |x1 − x2 | ≥ 3 (x1 , x2 ∈ {1, 2, 3, . . . , 6}). |x1 − x2 | ≥ 3 → (x1 ≤ x2 − 3) ∨ (x2 ≤ x1 − 3) → (p ∨ q) ∧ (¬p ∨ (x1 ≤ x2 − 3)) ∧ (¬q ∨ (x2 ≤ x1 − 3)) → (p ∨ q) ∧(¬p ∨ (x1 ≤ 3)) ∧(¬p ∨ ¬(x2 ≤ 3)) ∧(¬p ∨ (x1 ≤ 1) ∨ ¬(x2 ≤ 4)) ∧(¬p ∨ (x1 ≤ 2) ∨ ¬(x2 ≤ 5)) ∧(¬q ∨ (x2 ≤ 3)) ∧(¬q ∨ ¬(x1 ≤ 3)) ∧(¬q ∨ (x2 ≤ 1) ∨ ¬(x1 ≤ 4)) ∧(¬q ∨ (x2 ≤ 2) ∨ ¬(x1 ≤ 5)) Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Order Encoding Order encoding of a constraint |xi − xj | ≥ c Step1 : Converting |xi − xj | ≥ c in ≤ form (xi ≤ xj − c) ∨ (xj ≤ xi − c) Step2 : Tseitin Transformation (p ∨ q) ∧ (¬p ∨ (xi ≤ xj − c)) ∧ (¬q ∨ (xj ≤ xi − c)) where p and q are new Boolean variables. Step3 : Order Encoding (p ∨ q) ∧ (¬p ∨ (xi ≤ k − c)) ∧ (¬p ∨ ¬(xj ≤ c)) ∧ k−c ^ (¬p ∨ (xi ≤ b − 1) ∨ ¬(xj ≤ c + b − 1)) b=2 ∧ (¬q ∨ (xj ≤ k − c)) ∧ (¬q ∨ ¬(xi ≤ c)) ∧ k−c ^ (¬q ∨ (xj ≤ b − 1) ∨ ¬(xi ≤ c + b − 1)) b=2 Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Order Encoding Developed GCP/B-GCP solver We developed a GCP/B-GCP solver based on the proposed method (and direct encoding for comparison purpose). MiniSat solver 2.0 is used as a SAT solver. The minimum chromatic number is searched by changing the chromatic number k with binary search method. For each of those k’s, GCP/B-GCP is encoded into a SAT problem, and solved by the MiniSat solver. In that sense, the developed solver is a complete search solver which can determine both the lower and upper bounds of the chromatic number while an incomplete search solver can determine only the upper bound. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion B-GCP Performance evaluation of the developed solver Performance of developed GCP/B-GCP solver (both order encoding and direct encoding) is compared with previous works. Three complete solvers and five incomplete solvers for GCP and Three incomplete solvers for B-GCP. 63 GCP and 33 B-GCP benchmark instances of COLOR02 symposium are chosen. Apple PowerPC G4 with 1.67GHz CPU, 2GB memory is used. Timeout is set to 30 minutes. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion B-GCP Number of solved and best results for GCP Order encoding Direct encoding CD (Caramia and Dell’Olmo, 2002) AVG (van Gelder, 2002) MZ (Mendez Diaz and Zabala, 2002) CLGA (Croitoru et al., 2002) GH2 (Galinier et al., 2002) BP (Bui and Patel, 2002) PS (Phan and Skiena, 2002) CS (Chiarandini and Stuetzle, 2002) #Solved 21 17 18 4 12 0 0 0 0 0 #Best 34 30 17 5 25 19 10 18 3 13 “#Solved” shows the number of instances for which the optimum chromatic number is determined by the solver. “#Best” shows the number of instances for which the best chromatic number is found by the solver. Order encoding solver found the optimum for 21 instances and the best for 34 instances out of 63. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion B-GCP Number of solved and best results for B-GCP Order encoding Direct encoding PS (Phan and Skiena, 2002) P02 (Prestwich, 2002) P08 (Prestwich, 2008) #Solved 25 15 0 0 0 #Best 26 17 5 22 23 Order encoding solver found the optimum for 25 instances and the best for 26 instances out of 33. Order encoding solver shows the best performance compared with direct encoding solver and three previous solvers. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Example O.E Theorem of O.E Conclusion We proposed a new SAT encoding method for GCP/B-GCP based on order encoding. We developed a GCP/B-GCP solver using the proposed method. The solver is a complete search solver which can determine both the lower and upper bounds of the chromatic number. The developed solver shows the best performance compared with the previous solvers. The developed solver found the the best for 34 instances out of The developed solver found the the best for 26 instances out of Indira Bhusal Pandey optimum for 21 instances and 63 GCP instances. optimum for 25 instances and 33 B-GCP instances. Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Example O.E Theorem of O.E Summary of the newly obtained B-GCP results Improved Benchmark Instances GEOM60b GEOM70a GEOM70b GEOM80b GEOM90a GEOM90b GEOM120 Prev. UB 43 62 48 61 64 72 60 Order encoding LB UB 41 41 61 61 47 47 60 60 63 63 69 70 59 59 Out of 33 benchmark instances, order encoding solver improved the upper bound of the chromatic number for the above 7 instances, and decided the optimum for 6 instances. Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Example O.E Theorem of O.E Example of Order encoding 1 . Encoding variables x, y ∈ {1, 2, 3, 4, 5, 6} Boolean variables px, 1 px2 px3 px4 px5 py 1 py 2 py 3 py 4 py 5 Axiom clauses ¬px2 ∨ px3 ¬px3 ∨ px4 ¬px4 ∨ px5 (similar clauses for y ) Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach Overview GCP/B-GCP SAT Encoding GCP Evaluation Conclusion Example O.E Theorem of O.E Theorem of order encoding Encoding of constraint ∧k−cy ≤ x − c(wherex, y ∈ 1, 2, 3, . . . , k) ⇐⇒ b=2 ((¬(y ≤ b − 1) ∨ ¬(x ≤ c + b − 1)) For example, in y ≤ x − 3(x, y ∈ 1, 2, 3, . . . , 6) (y ≥ 1) ∧ (x ≤ 3) . . . (y ≥ 4) ∧ (x ≤ 6)) violate the constraint ←→ ¬(y ≥ 1) ∧ (x ≤ 3) ∧ ¬(y ≥ 4) ∧ (x ≤ 6) ←→ (y ≤ 0) ∧ ¬(x ≤ 3) ∨ . . . ∨ . . . Indira Bhusal Pandey Study of Graph Coloring Problems using SAT-based approach