Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Scarab 
SAT-based Constraint Programming System in Scala 
Takehide Soh1 
worked in cooperation with 
Daniel Le Berre2 Step...
Contents of Talk 
1 What is SAT? 
2 Scarab: SAT-based CP System in Scala 
3 Designing Constraint Models in Scarab 
4 Advan...
SAT (Boolean satis
ability testing) Problems 
SAT is a problem of deciding whether a given Boolean formula is 
satis
able or not. 
SAT was the
rst NP-complete problem [Cook, 1971] and is the most 
fundamental problem in Computer Science both theoretically and 
prac...
SAT (Boolean satis
ability testing) Problems 
SAT is a problem of deciding whether a given Boolean formula is 
satis
able or not. 
SAT was the
rst NP-complete problem [Cook, 1971] and is the most 
fundamental problem in Computer Science both theoretically and 
prac...
able or not? 
(a _ b _ c) ^ 
(:a _ :b) ^ 
(:a _ :c) ^ 
(:b _ :c) 
Answer: Yes. 
There is an assignment (a; b; c) = (True; ...
SAT Solvers 
There are 2n combinations for assignments. 
We cannot solve any SAT instances even for small n (e.g. n = 100)...
able (SAT) or unsatis
able (UNSAT). 
Most of all SAT solvers return a satis
able assignment when the 
instance is SAT. 
Complete SAT solvers originated in DPLL [Davis et al., 1962]. 
In particular, ...
Progress of SAT Solvers (shown by [Simon 2011]) 
1200 
1000 
800 
Results of the SAT competition/race winners on the SAT 2...
Applications of SAT Technology 
Thanks to the remarkable progress of SAT solvers, SAT-based Systems 
have been actively st...
Other News around SAT 
A SAT solver Sat4j implemented on Java has been integrated into 
Eclipse for managing plugins depen...
ability and The Art of 
Computer Programming at the International Conference on Theory 
and Applications of Satis
ability Testing 2012. 
In addition, SAT will be appeared in Volume 4b of The Art Of 
Computer Programming. 
Reference to S...
ability, volume 185 of Frontiers in Arti
cial 
Intelligence and Applications (FAIA). IOS Press. 
(in Japanese) Recent Advances in SAT Techniques, Journal of the 
J...
cial Intelligence, Special Issue, 25(1), 2010. 
8 / 60
Contents of Talk 
1 What is SAT? 
2 Scarab: SAT-based CP System in Scala 
3 Designing Constraint Models in Scarab 
4 Advan...
Motivation 
Modern fast SAT solvers have promoted the development of 
SAT-based systems for various problems. 
For an inte...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
c Language for Constraint Programming 
2 API of CSP Solver 
3 SAT encoding module 
4 API of SAT solvers 
Scarab 
DSL 
SAT ...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
c Language for Constraint Programming 
2 API of CSP Solver 
3 SAT encoding module 
4 API of SAT solvers 
Scarab 
DSL 
SAT ...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
c Language for Constraint Programming 
2 API of CSP Solver 
3 SAT encoding module 
4 API of SAT solvers 
Scarab 
Program 
...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
c Language for Constraint Programming 
2 API of CSP Solver 
3 SAT encoding module 
4 API of SAT solvers 
CSP Encoder 
Scar...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
c Language for Constraint Programming 
2 API of CSP Solver 
3 SAT encoding module 
4 API of SAT solvers 
Sat4j 
CSP Encode...
Scarab 
Scarab is a prototyping tool for developing SAT-based Constraint 
Programming (CP) systems. 
Its major design prin...
c Language for Constraint Programming 
2 API of CSP Solver 
3 SAT encoding module 
4 API of SAT solvers 
Scarab 
Program 
...
Other Features 
Eciency Scarab is ecient in the sense that it uses an optimized 
version of the order encoding for encodin...
Example of Scarab Program: GCP.scala 
Graph coloring problem (GCP) is a 
problem of
nding a coloring of the 
nodes such that colors of adjacent 
nodes are dierent. 
1 
5 2 
4 
3 
1 
Input Solution 
2 
4 3 
...
Imports 
import jp.kobe_u.scarab.csp._ 
import jp.kobe_u.scarab.solver._ 
import jp.kobe_u.scarab.sapp._ 
First 2 lines im...
nes an integer variable. 
add(c) method de
nes a constraint. 
find method searches a solution. 
solution method returns the solution. 
etc. 
20 / 60
Instance Structure 
val nodes = Seq(1,2,3,4,5) 
val edges = Seq((1,2),(1,5),(2,3),(2,4),(3,4),(4,5)) 
val colors = 3 
It de
nes the given set of nodes and edges as the sequence object in 
Scala. 
Available number of colors are de
ned as 3. 
21 / 60
De
ning CSP 
for (i - nodes) int('n(i),1,3) 
It adds an integer variable to the default CSP object by the int 
method. 
'n is...
ned in Scarab. 
for ((i,j) - edges) add('n(i) !== 'n(j)) 
It adds constraints to the default CSP object. 
The following op...
Solving CSP 
if (find) println(solution) 
The find method encodes the CSP to SAT by order encoding, and 
call Sat4j to com...
able assignment of the CSP. 
23 / 60
Contents of Talk 
1 What is SAT? 
2 Scarab: SAT-based CP System in Scala 
3 Designing Constraint Models in Scarab 
4 Advan...
Designing Constraint Models in Scarab 
Pandiagonal Latin Square PLS(n) is a problem of placing dierent n 
numbers into n  ...
alldi Model 
Pandiagonal Latin Square PLS(5) 
x11 x12 x13 x14 x15 
x21 x22 x23 x24 x25 
x31 x32 x33 x34 x35 
x41 x42 x43 x...
alldi Model 
Pandiagonal Latin Square PLS(5) 
x11 x12 x13 x14 x15 
x21 x22 x23 x24 x25 
x31 x32 x33 x34 x35 
x41 x42 x43 x...
alldi Model 
Pandiagonal Latin Square PLS(5) 
x11 x12 x13 x14 x15 
x21 x22 x23 x24 x25 
x31 x32 x33 x34 x35 
x41 x42 x43 x...
alldi Model 
Pandiagonal Latin Square PLS(5) 
x11 x12 x13 x14 x15 
x21 x22 x23 x24 x25 
x31 x32 x33 x34 x35 
x41 x42 x43 x...
alldi Model 
Pandiagonal Latin Square PLS(5) 
x11 x12 x13 x14 x15 
x21 x22 x23 x24 x25 
x31 x32 x33 x34 x35 
x41 x42 x43 x...
alldi Model 
Pandiagonal Latin Square PLS(5) 
x11 x12 x13 x14 x15 
x21 x22 x23 x24 x25 
x31 x32 x33 x34 x35 
x41 x42 x43 x...
Upcoming SlideShare
Loading in …5
×

Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラミングシステムScarabについて

2,603 views

Published on

Presentation material by Takehide Soh at ScalaMatsuri 2014
http://scalamatsuri.org/en/

Published in: Software
  • Be the first to comment

  • Be the first to like this

Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラミングシステムScarabについて

  1. 1. Scarab SAT-based Constraint Programming System in Scala Takehide Soh1 worked in cooperation with Daniel Le Berre2 Stephanie Roussel2 Mutsunori Banbara1 Naoyuki Tamura1 1Information Science and Technology Center, Kobe University 2CRIL-CNRS, UMR 8188, Universite d'Artois 2014/09/05 ScalaMatsuri 1 / 60
  2. 2. Contents of Talk 1 What is SAT? 2 Scarab: SAT-based CP System in Scala 3 Designing Constraint Models in Scarab 4 Advanced Solving Techniques using Sat4j 2 / 60
  3. 3. SAT (Boolean satis
  4. 4. ability testing) Problems SAT is a problem of deciding whether a given Boolean formula is satis
  5. 5. able or not. SAT was the
  6. 6. rst NP-complete problem [Cook, 1971] and is the most fundamental problem in Computer Science both theoretically and practically. SAT instances are given in the Conjunctive Normal Form (CNF). A CNF formula is a conjunction of clauses. A clause is a disjunction of literals. A literal is either a Boolean variable or its negation. 3 / 60
  7. 7. SAT (Boolean satis
  8. 8. ability testing) Problems SAT is a problem of deciding whether a given Boolean formula is satis
  9. 9. able or not. SAT was the
  10. 10. rst NP-complete problem [Cook, 1971] and is the most fundamental problem in Computer Science both theoretically and practically. Example of an SAT instance (in CNF) Let a; b; c 2 fTrue; Falseg be Boolean variables. Question: the following CNF formula is satis
  11. 11. able or not? (a _ b _ c) ^ (:a _ :b) ^ (:a _ :c) ^ (:b _ :c) Answer: Yes. There is an assignment (a; b; c) = (True; False; False) satisfying all clauses. 4 / 60
  12. 12. SAT Solvers There are 2n combinations for assignments. We cannot solve any SAT instances even for small n (e.g. n = 100)? Much eort on SAT solvers practically has been pushing up their limitation! SAT solver is a program of deciding whether a given SAT instance is satis
  13. 13. able (SAT) or unsatis
  14. 14. able (UNSAT). Most of all SAT solvers return a satis
  15. 15. able assignment when the instance is SAT. Complete SAT solvers originated in DPLL [Davis et al., 1962]. In particular, since around 2000, their performance is improved every year with techniques of Con ict Driven Clause Learning (CDCL), Non-chronological Backtracking, Rapid Restarts, and Variable Selection Heuristics. Modern SAT solvers can handle instances with more than 106 variables and 107 clauses. 5 / 60
  16. 16. Progress of SAT Solvers (shown by [Simon 2011]) 1200 1000 800 Results of the SAT competition/race winners on the SAT 2009 application benchmarks, 20mn timeout Limmat (2002) Zchaff (2002) Berkmin (2002) Forklift (2003) Siege (2003) Zchaff (2004) SatELite (2005) Minisat 2 (2006) Picosat (2007) Rsat (2007) Minisat 2.1 (2008) Precosat (2009) Glucose (2009) Clasp (2009) Cryptominisat (2010) Lingeling (2010) Minisat 2.2 (2010) Glucose 2 (2011) Glueminisat (2011) Contrasat (2011) CPU Time (in seconds) Number of problems solved 600 400 200 0 0 20 40 60 80 100 120 140 160 180 Cactus Plot shown by [Simon 2011] 6 / 60
  17. 17. Applications of SAT Technology Thanks to the remarkable progress of SAT solvers, SAT-based Systems have been actively studied: Planning (SATPLAN, Blackbox) [Kautz Selman 1992] Job-shop Scheduling [Crawford Baker 1994] Bounded Model Checking [Biere 1999] Term Rewriting (AProVE) [Giesl et al. 2004] Constraint Satisfaction Problem (Sugar) [Tamura et al. 2006] Others Test Case Generation, Systems Biology, Timetabling, Packing, Puzzle, and more! 7 / 60
  18. 18. Other News around SAT A SAT solver Sat4j implemented on Java has been integrated into Eclipse for managing plugins dependencies in their update manager. Donald E. Knuth gave an invited talk Satis
  19. 19. ability and The Art of Computer Programming at the International Conference on Theory and Applications of Satis
  20. 20. ability Testing 2012. In addition, SAT will be appeared in Volume 4b of The Art Of Computer Programming. Reference to SAT Biere, A., Heule, M., van Maaren, H., and Walsh, T., editors (2009). Handbook of Satis
  21. 21. ability, volume 185 of Frontiers in Arti
  22. 22. cial Intelligence and Applications (FAIA). IOS Press. (in Japanese) Recent Advances in SAT Techniques, Journal of the Japan Society for Arti
  23. 23. cial Intelligence, Special Issue, 25(1), 2010. 8 / 60
  24. 24. Contents of Talk 1 What is SAT? 2 Scarab: SAT-based CP System in Scala 3 Designing Constraint Models in Scarab 4 Advanced Solving Techniques using Sat4j 9 / 60
  25. 25. Motivation Modern fast SAT solvers have promoted the development of SAT-based systems for various problems. For an intended problem, we usually need to develop a dedicated program that encodes it into SAT. It sometimes bothers focusing on problem modeling which plays an important role in the system development process. In this talk We introduce the Scarab system, which is a prototyping tool for developing SAT-based systems. Its features are also introduced through examples of Graph Coloring and Pandiagonal Latin Square. 10 / 60
  26. 26. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. 11 / 60
  27. 27. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. It consists of the followings: 1 Scarab DSL: Domain Speci
  28. 28. c Language for Constraint Programming 2 API of CSP Solver 3 SAT encoding module 4 API of SAT solvers Scarab DSL SAT Solver API CSP Solver Encoder API 12 / 60
  29. 29. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. It consists of the followings: 1 Scarab DSL: Domain Speci
  30. 30. c Language for Constraint Programming 2 API of CSP Solver 3 SAT encoding module 4 API of SAT solvers Scarab DSL SAT Solver API CSP Solver Encoder API 800 Lines of Scala 13 / 60
  31. 31. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. It consists of the followings: 1 Scarab DSL: Domain Speci
  32. 32. c Language for Constraint Programming 2 API of CSP Solver 3 SAT encoding module 4 API of SAT solvers Scarab Program Scarab DSL SAT Solver API CSP Solver Encoder API (DSL+Scala) Encoder 14 / 60
  33. 33. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. It consists of the followings: 1 Scarab DSL: Domain Speci
  34. 34. c Language for Constraint Programming 2 API of CSP Solver 3 SAT encoding module 4 API of SAT solvers CSP Encoder Scarab Program (DSL+Scala) Scarab DSL SAT Solver API CSP Solver API Encoder 15 / 60
  35. 35. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. It consists of the followings: 1 Scarab DSL: Domain Speci
  36. 36. c Language for Constraint Programming 2 API of CSP Solver 3 SAT encoding module 4 API of SAT solvers Sat4j CSP Encoder MAP SAT Scarab Program (DSL+Scala) Scarab DSL SAT Solver API CSP Solver API Encoder 16 / 60
  37. 37. Scarab Scarab is a prototyping tool for developing SAT-based Constraint Programming (CP) systems. Its major design principle is to provide an expressive, ecient, customizable, and portable workbench for SAT-based system developers. It consists of the followings: 1 Scarab DSL: Domain Speci
  38. 38. c Language for Constraint Programming 2 API of CSP Solver 3 SAT encoding module 4 API of SAT solvers Scarab Program Sat4j CSP Scarab DSL SAT Solver API CSP Solver Encoder CSP Solution SAT SAT MAP Decoder Solution API (DSL+Scala) Encoder 17 / 60
  39. 39. Other Features Eciency Scarab is ecient in the sense that it uses an optimized version of the order encoding for encoding CSP into SAT. Portability The combination of Scarab and Sat4j enables the development of portable applications on JVM (Java Virtual Machine). Customizability Scarab is 500 lines long without comments. It allows programmers to customize their own constraints. Availability of Advanced SAT Techniques Thanks to the tight integration to Sat4j, it is available to use several SAT techniques, e.g., incremental SAT solving. 18 / 60
  40. 40. Example of Scarab Program: GCP.scala Graph coloring problem (GCP) is a problem of
  41. 41. nding a coloring of the nodes such that colors of adjacent nodes are dierent. 1 5 2 4 3 1 Input Solution 2 4 3 5 1: import jp.kobe_u.scarab.csp._ 2: import jp.kobe_u.scarab.solver._ 3: import jp.kobe_u.scarab.sapp._ 4: 5: val nodes = Seq(1,2,3,4,5) 6: val edges = Seq((1,2),(1,5),(2,3),(2,4),(3,4),(4,5)) 7: val colors = 3 8: for (i - nodes) int('n(i),1,colors) 9: for ((i,j) - edges) add('n(i) !== 'n(j)) 10: 11: if (find) println(solution) 19 / 60
  42. 42. Imports import jp.kobe_u.scarab.csp._ import jp.kobe_u.scarab.solver._ import jp.kobe_u.scarab.sapp._ First 2 lines import classes of CSP and CSP solver. Third line imports the default CSP, Encoder, SAT Solver, and CSP Solver objects. It also imports DSL methods provided by Scarab. int(x, lb, ub) method de
  43. 43. nes an integer variable. add(c) method de
  44. 44. nes a constraint. find method searches a solution. solution method returns the solution. etc. 20 / 60
  45. 45. Instance Structure val nodes = Seq(1,2,3,4,5) val edges = Seq((1,2),(1,5),(2,3),(2,4),(3,4),(4,5)) val colors = 3 It de
  46. 46. nes the given set of nodes and edges as the sequence object in Scala. Available number of colors are de
  47. 47. ned as 3. 21 / 60
  48. 48. De
  49. 49. ning CSP for (i - nodes) int('n(i),1,3) It adds an integer variable to the default CSP object by the int method. 'n is a notation of symbols in Scala. They are automatically converted integer variable (Var) objects by an implicit conversion de
  50. 50. ned in Scarab. for ((i,j) - edges) add('n(i) !== 'n(j)) It adds constraints to the default CSP object. The following operators can be used to construct constraints: logical operator: , || comparison operator: ===, !==, , =, =, arithmetic operator: +, - 22 / 60
  51. 51. Solving CSP if (find) println(solution) The find method encodes the CSP to SAT by order encoding, and call Sat4j to compute a solution. solution returns satis
  52. 52. able assignment of the CSP. 23 / 60
  53. 53. Contents of Talk 1 What is SAT? 2 Scarab: SAT-based CP System in Scala 3 Designing Constraint Models in Scarab 4 Advanced Solving Techniques using Sat4j 24 / 60
  54. 54. Designing Constraint Models in Scarab Pandiagonal Latin Square PLS(n) is a problem of placing dierent n numbers into n n matrix such that each number is occurring exactly once for each row, column, diagonally down right, and diagonally up right. alldi Model One uses alldi constraint, which is one of the best known and most studied global constraints in constraint programming. The constraint alldi(a1; : : : ; an) ensures that the values assigned to the variable a1; : : : ; an must be pairwise distinct. Boolean Cardinality Model One uses Boolean cardinality constraint. 25 / 60
  55. 55. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g 26 / 60
  56. 56. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) 27 / 60
  57. 57. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) 28 / 60
  58. 58. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) 29 / 60
  59. 59. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) 30 / 60
  60. 60. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) alldi in each pandiagonal (10 pandiagonals) 31 / 60
  61. 61. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) alldi in each pandiagonal (10 pandiagonals) 32 / 60
  62. 62. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) alldi in each pandiagonal (10 pandiagonals) 33 / 60
  63. 63. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) alldi in each pandiagonal (10 pandiagonals) 34 / 60
  64. 64. alldi Model Pandiagonal Latin Square PLS(5) x11 x12 x13 x14 x15 x21 x22 x23 x24 x25 x31 x32 x33 x34 x35 x41 x42 x43 x44 x45 x51 x52 x53 x54 x55 1 2 3 4 5 3 4 5 1 2 5 1 2 3 4 2 3 4 5 1 4 5 1 2 3 xij 2 f1; 2; 3; 4; 5g alldi in each row (5 rows) alldi in each column (5 columns) alldi in each pandiagonal (10 pandiagonals) PLS(5) is satis
  65. 65. able. 35 / 60
  66. 66. Scarab Program for alldi Model 1: import jp.kobe_u.scarab.csp._ 2: import jp.kobe_u.scarab.solver._ 3: import jp.kobe_u.scarab.sapp._ 4: 5: val n = args(0).toInt 6: 7: for (i - 1 to n; j - 1 to n) int('x(i,j),1,n) 8: for (i - 1 to n) f 9: add(alldiff((1 to n).map(j = 'x(i,j)))) 10: add(alldiff((1 to n).map(j = 'x(j,i)))) 11: add(alldiff((1 to n).map(j = 'x(j,(i+j-1)%n+1)))) 12: add(alldiff((1 to n).map(j = 'x(j,(i+(j-1)*(n-1))%n+1)))) 13: g 14: 15: if (find) println(solution) 36 / 60
  67. 67. Encoding alldi In Scarab, all we have to do for implementing global constraints is just decomposing them into simple arithmetic constraints [Bessiere et al. `09]. In the case of alldi(a1; : : : ; an), It is decomposed into pairwise not-equal constraints ^ 1ijn (ai6= aj ) . This (naive) alldi is enough to just have a feasible constraint model for PLS(n). But, one probably want to improve this :) 37 / 60
  68. 68. Extra Constraints for alldi (a1; : : : ; an) In Pandiagonal Latin Square PLS(n), all integer variables a1; : : : ; an have the same domain f1; : : : ; ng. Then, we can add the following extra constraints. Permutation constraints: ^n i=1 _n j=1 (aj = i ) It represents that one of a1; : : : ; an must be assigned to i . Pigeon hole constraint: : ^n i=1 (ai n) ^ : ^n i=1 (ai 1) It represents that mutually dierent n variables cannot be assigned within the interval of the size n

×