SlideShare una empresa de Scribd logo
1 de 60
Descargar para leer sin conexión
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
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
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 
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
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 
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
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
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
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, 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
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
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
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
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 SAT 
Biere, A., Heule, M., van Maaren, H., and Walsh, T., editors (2009). 
Handbook of Satis
ability, volume 185 of Frontiers in Arti
cial 
Intelligence and Applications (FAIA). IOS Press. 
(in Japanese) Recent Advances in SAT Techniques, Journal of the 
Japan Society for Arti
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 Advanced Solving Techniques using Sat4j 
9 / 60
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 
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
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
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 a notation of symbols in Scala. 
They are automatically converted integer variable (Var) objects by an 
implicit conversion de
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
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
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 Advanced Solving Techniques using Sat4j 
24 / 60
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
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
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
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
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
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
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

Más contenido relacionado

La actualidad más candente

ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
Vyacheslav Lapin
 
Neo4 + Grails
Neo4 + GrailsNeo4 + Grails
Neo4 + Grails
stasimus
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
Roman Elizarov
 

La actualidad más candente (20)

How Scala code is expressed in the JVM
How Scala code is expressed in the JVMHow Scala code is expressed in the JVM
How Scala code is expressed in the JVM
 
Scala profiling
Scala profilingScala profiling
Scala profiling
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Introduction of failsafe
Introduction of failsafeIntroduction of failsafe
Introduction of failsafe
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentation
 
Apache Spark: The Analytics Operating System
Apache Spark: The Analytics Operating SystemApache Spark: The Analytics Operating System
Apache Spark: The Analytics Operating System
 
Neo4 + Grails
Neo4 + GrailsNeo4 + Grails
Neo4 + Grails
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overview
 
Scala in a wild enterprise
Scala in a wild enterpriseScala in a wild enterprise
Scala in a wild enterprise
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
 
The State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila SzegediThe State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila Szegedi
 
Scaling software with akka
Scaling software with akkaScaling software with akka
Scaling software with akka
 
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
 
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
 

Destacado

GitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by ScalaGitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by Scala
takezoe
 
芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜
芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜
芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜
scalaconfjp
 
Scala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jsScala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.js
takezoe
 

Destacado (16)

[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
 
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
Scalable Generator: Using Scala in SIer Business (ScalaMatsuri)
 
GitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by ScalaGitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by Scala
 
sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜
芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜
芸者東京とScala〜おみせやさんから脳トレクエストまでの軌跡〜
 
Scala が支える医療系ウェブサービス #jissenscala
Scala が支える医療系ウェブサービス #jissenscalaScala が支える医療系ウェブサービス #jissenscala
Scala が支える医療系ウェブサービス #jissenscala
 
Scala@SmartNews_20150221
Scala@SmartNews_20150221Scala@SmartNews_20150221
Scala@SmartNews_20150221
 
Scala@SmartNews AdFrontend を Scala で書いた話
Scala@SmartNews AdFrontend を Scala で書いた話Scala@SmartNews AdFrontend を Scala で書いた話
Scala@SmartNews AdFrontend を Scala で書いた話
 
ビズリーチの新サービスをScalaで作ってみた 〜マイクロサービスの裏側 #jissenscala
ビズリーチの新サービスをScalaで作ってみた 〜マイクロサービスの裏側 #jissenscalaビズリーチの新サービスをScalaで作ってみた 〜マイクロサービスの裏側 #jissenscala
ビズリーチの新サービスをScalaで作ってみた 〜マイクロサービスの裏側 #jissenscala
 
あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Scala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jsScala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.js
 

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

How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
ESUG
 
Tech Days 2015: User Presentation Vermont Technical College
Tech Days 2015: User Presentation Vermont Technical CollegeTech Days 2015: User Presentation Vermont Technical College
Tech Days 2015: User Presentation Vermont Technical College
AdaCore
 
Punit_Shah_resume
Punit_Shah_resumePunit_Shah_resume
Punit_Shah_resume
Punit Shah
 
Punit_Shah_resume
Punit_Shah_resumePunit_Shah_resume
Punit_Shah_resume
Punit Shah
 
Punit_Shah_resume
Punit_Shah_resumePunit_Shah_resume
Punit_Shah_resume
Punit Shah
 
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
inside-BigData.com
 
Ankita Gloria Kerketta (3)
Ankita Gloria Kerketta (3)Ankita Gloria Kerketta (3)
Ankita Gloria Kerketta (3)
rbvrfbv fbv gf
 
Full resume dr_russell_john_childs_2013
Full resume dr_russell_john_childs_2013Full resume dr_russell_john_childs_2013
Full resume dr_russell_john_childs_2013
Russell Childs
 

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

Large scale logistic regression and linear support vector machines using spark
Large scale logistic regression and linear support vector machines using sparkLarge scale logistic regression and linear support vector machines using spark
Large scale logistic regression and linear support vector machines using spark
 
SCA Next Part 1 - Software Defined Radio (SDR) Webcast Slides
SCA Next Part 1 - Software Defined Radio (SDR) Webcast SlidesSCA Next Part 1 - Software Defined Radio (SDR) Webcast Slides
SCA Next Part 1 - Software Defined Radio (SDR) Webcast Slides
 
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
 
OpenPOWER Webinar from University of Delaware - Title :OpenMP (offloading) o...
OpenPOWER Webinar from University of Delaware  - Title :OpenMP (offloading) o...OpenPOWER Webinar from University of Delaware  - Title :OpenMP (offloading) o...
OpenPOWER Webinar from University of Delaware - Title :OpenMP (offloading) o...
 
Introduction to Apache Hivemall v0.5.0
Introduction to Apache Hivemall v0.5.0Introduction to Apache Hivemall v0.5.0
Introduction to Apache Hivemall v0.5.0
 
External Aerodynamic Optimization Using ANSYS Mesh Morphing
External Aerodynamic Optimization Using ANSYS Mesh MorphingExternal Aerodynamic Optimization Using ANSYS Mesh Morphing
External Aerodynamic Optimization Using ANSYS Mesh Morphing
 
Tech Days 2015: User Presentation Vermont Technical College
Tech Days 2015: User Presentation Vermont Technical CollegeTech Days 2015: User Presentation Vermont Technical College
Tech Days 2015: User Presentation Vermont Technical College
 
Punit_Shah_resume
Punit_Shah_resumePunit_Shah_resume
Punit_Shah_resume
 
Punit_Shah_resume
Punit_Shah_resumePunit_Shah_resume
Punit_Shah_resume
 
Punit_Shah_resume
Punit_Shah_resumePunit_Shah_resume
Punit_Shah_resume
 
C044061518
C044061518C044061518
C044061518
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
 
Lear unified env_paper-1
Lear unified env_paper-1Lear unified env_paper-1
Lear unified env_paper-1
 
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
 
Ankita Gloria Kerketta (3)
Ankita Gloria Kerketta (3)Ankita Gloria Kerketta (3)
Ankita Gloria Kerketta (3)
 
Full resume dr_russell_john_childs_2013
Full resume dr_russell_john_childs_2013Full resume dr_russell_john_childs_2013
Full resume dr_russell_john_childs_2013
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM Stack
 
santhosh popshetwar
santhosh popshetwarsanthosh popshetwar
santhosh popshetwar
 

Más de scalaconfjp

Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメントScalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
scalaconfjp
 

Más de scalaconfjp (20)

脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
 
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
 
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
 
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
 
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan GoyeauScala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
 
Scala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio BrasilScala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio Brasil
 
Introduction to GraphQL in Scala
Introduction to GraphQL in ScalaIntroduction to GraphQL in Scala
Introduction to GraphQL in Scala
 
Safety Beyond Types
Safety Beyond TypesSafety Beyond Types
Safety Beyond Types
 
Reactive Kafka with Akka Streams
Reactive Kafka with Akka StreamsReactive Kafka with Akka Streams
Reactive Kafka with Akka Streams
 
Reactive microservices with play and akka
Reactive microservices with play and akkaReactive microservices with play and akka
Reactive microservices with play and akka
 
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメントScalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
 
DWANGO by ドワンゴ
DWANGO by ドワンゴDWANGO by ドワンゴ
DWANGO by ドワンゴ
 
OCTOPARTS by M3, Inc.
OCTOPARTS by M3, Inc.OCTOPARTS by M3, Inc.
OCTOPARTS by M3, Inc.
 
Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.
 
統計をとって高速化する
Scala開発 by CyberZ,Inc.
統計をとって高速化する
Scala開発 by CyberZ,Inc.統計をとって高速化する
Scala開発 by CyberZ,Inc.
統計をとって高速化する
Scala開発 by CyberZ,Inc.
 
Short Introduction of Implicit Conversion by TIS, Inc.
Short Introduction of Implicit Conversion by TIS, Inc.Short Introduction of Implicit Conversion by TIS, Inc.
Short Introduction of Implicit Conversion by TIS, Inc.
 
ビズリーチ x ScalaMatsuri by BIZREACH, Inc.
ビズリーチ x ScalaMatsuri  by BIZREACH, Inc.ビズリーチ x ScalaMatsuri  by BIZREACH, Inc.
ビズリーチ x ScalaMatsuri by BIZREACH, Inc.
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
 

Último

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Último (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

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

  • 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. 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
  • 4. ability testing) Problems SAT is a problem of deciding whether a given Boolean formula is satis
  • 5. able or not. SAT was the
  • 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
  • 8. ability testing) Problems SAT is a problem of deciding whether a given Boolean formula is satis
  • 9. able or not. SAT was the
  • 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. 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. 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. able (SAT) or unsatis
  • 14. able (UNSAT). Most of all SAT solvers return a satis
  • 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. 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. 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. 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. ability and The Art of Computer Programming at the International Conference on Theory and Applications of Satis
  • 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. ability, volume 185 of Frontiers in Arti
  • 22. cial Intelligence and Applications (FAIA). IOS Press. (in Japanese) Recent Advances in SAT Techniques, Journal of the Japan Society for Arti
  • 23. cial Intelligence, Special Issue, 25(1), 2010. 8 / 60
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Example of Scarab Program: GCP.scala Graph coloring problem (GCP) is a problem of
  • 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. 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. nes an integer variable. add(c) method de
  • 44. nes a constraint. find method searches a solution. solution method returns the solution. etc. 20 / 60
  • 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. nes the given set of nodes and edges as the sequence object in Scala. Available number of colors are de
  • 47. ned as 3. 21 / 60
  • 48. De
  • 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. 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. 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. able assignment of the CSP. 23 / 60
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  • 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. 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. 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 1. 38 / 60
  • 69. alldi (naive) def alldiff(xs: Seq[Var]) = And(for (Seq(x, y) - xs.combinations(2)) yield x !== y) 39 / 60
  • 70. alldi (optimized) def alldiff(xs: Seq[Var]) = f val lb = for (x - xs) yield csp.dom(x).lb val ub = for (x - xs) yield csp.dom(x).ub == pigeon hole val ph = And(Or(for (x - xs) yield !(x lb.min+xs.size-1)), Or(for (x - xs) yield !(x ub.max-xs.size+1))) == permutation def perm = And(for (num - lb.min to ub.max) yield Or(for (x - xs) yield x === num)) val extra = if (ub.max-lb.min+1 == xs.size) And(ph,perm) else ph And(And(for (Seq(x, y) - xs.combinations(2)) yield x !== y),extra) g 40 / 60
  • 71. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) 41 / 60
  • 72. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 42 / 60
  • 73. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 43 / 60
  • 74. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 44 / 60
  • 75. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 45 / 60
  • 76. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 for each pandiagonal (10 pandiagonals) y11k + y22k + y33k + y44k + y55k = 1 46 / 60
  • 77. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 for each pandiagonal (10 pandiagonals) y11k + y22k + y33k + y44k + y55k = 1 47 / 60
  • 78. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 for each pandiagonal (10 pandiagonals) y11k + y22k + y33k + y44k + y55k = 1 48 / 60
  • 79. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 for each pandiagonal (10 pandiagonals) y11k + y22k + y33k + y44k + y55k = 1 49 / 60
  • 80. Boolean Cardinality Model y11k y12k y13k y14k y15k y21k y22k y23k y24k y25k y31k y32k y33k y34k y35k y41k y42k y43k y44k y45k y51k y52k y53k y54k y55k wgh0 wgh/ wgh2 wgh1 wgh3 yijk 2 f0; 1g yijk = 1 , k is placed at (i ; j) for each value (5 values) for each row (5 rows) yi1k + yi2k + yi3k + yi4k + yi5k = 1 for each column (5 columns) y1jk + y2jk + y3jk + y4jk + y5jk = 1 for each pandiagonal (10 pandiagonals) y11k + y22k + y33k + y44k + y55k = 1 for each (i ; j) position (25 positions) yij1 + yij2 + yij3 + yij4 + yij5 = 1 50 / 60
  • 81. Scarab Program for Boolean Cardinality Model 1: import jp.kobe_u.scarab.csp._ 2: import jp.kobe_u.scarab.solver._ 3: import jp.kobe_u.scarab.sapp._ 4: 5: for (i - 1 to n; j - 1 to n; num - 1 to n) 6: int('y(i,j,num),0,1) 7: 8: for (num - 1 to n) f 9: for (i - 1 to n) f 10: add(BC((1 to n).map(j = 'y(i,j,num)))===1) 11: add(BC((1 to n).map(j = 'y(j,i,num)))===1) 12: add(BC((1 to n).map(j = 'y(j,(i+j-1)%n+1,num))) === 1) 13: add(BC((1 to n).map(j = 'y(j,(i+(j-1)*(n-1))%n+1,num))) === 1) 14: g 15: g 16: 17: for (i - 1 to n; j - 1 to n) 18: add(BC((1 to n).map(k = 'y(i,j,k))) === 1) 19: 20: if (find) println(solution) 51 / 60
  • 82. SAT Encoding of Boolean Cardinality in Scarab There are several ways for encoding Boolean cardinality. In Scarab, we can easily write the following encoding methods by de
  • 83. ning your own BC methods. Pairwise Totalizer [Bailleux `03] Sequential Counter [Sinz `05] In total, 3 variants of Boolean cardinality model are obtained. BC1: Pairwise (implemented by 2 lines) BC2: Totalizer [Bailleux `03] (implemented by 15 lines) BC3: Sequential Counter [Sinz `05] (implemented by 7 lines) Good point to use Scarab is that we can test those models without writing dedicated programs. 52 / 60
  • 84. Experiments Comparison on Solving Pandiagonal Latin Square To show the dierences in performance, we compared the following 5 models. 1 AD1: naive alldi 2 AD2: optimized alldi 3 BC1: Pairwise 4 BC2: [Bailleux `03] 5 BC3: [Sinz `05] Benchmark and Experimental Environment Benchmark: Pandiagonal Latin Square (n = 7 to n = 16) CPU: 2.93GHz, Mem: 2GB, Time Limit: 3600 seconds 53 / 60
  • 85. Results (CPU Time in Seconds) n SAT/UNSAT AD1 AD2 BC1 BC2 BC3 7 SAT 0.2 0.2 0.2 0.3 0.3 8 UNSAT T.O. 0.5 0.3 0.3 0.3 9 UNSAT T.O. 0.3 0.5 0.3 0.2 10 UNSAT T.O. 0.4 1.0 0.3 0.3 11 SAT 0.3 0.3 2.3 0.5 0.4 12 UNSAT T.O. 1.0 5.3 0.8 0.8 13 SAT T.O. 0.5 T.O. T.O. T.O. 14 UNSAT T.O. 9.7 32.4 8.2 6.8 15 UNSAT T.O. 388.9 322.7 194.6 155.8 16 UNSAT T.O. 457.1 546.6 300.7 414.8 Only optimized version of alldi model (AD2) solved all instances. Modeling and encoding have an important role in developing SAT-based systems. Scarab helps users to focus on them ;) 54 / 60
  • 86. 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 55 / 60
  • 87. Advanced Solving Techniques using Sat4j Thanks to the tight integration to Sat4j, Scarab provides the functions: Incremental solving and CSP solving with assumptions. We explain it using the following program. 1: int('x, 1, 3) 2: int('y, 1, 3) 3: add('x === 'y) 4: find // first call of find 5: add('x !== 3) 6: find // second call of find 7: 8: find('y === 3) // with assumption y = 3 9: find('x === 1) // with assumption x = 1 56 / 60
  • 88. Incremental SAT Solving int('x, 1, 3) int('y, 1, 3) add('x === 'y) find // first call of find add('x !== 3) find // second call of find In the
  • 89. rst call of find method, the whole CSP is encoded and generated SAT clauses are added to Sat4j, then it computes a solution. In the second call of find method, only the extra constraint x6= 3 is encoded and added to Sat4j, then it computes a solution. The learned clauses obtained by the
  • 90. rst find are kept at the second call. 57 / 60
  • 91. CSP Solving under Assumption find('y === 3) // with assumption y = 3 find('x === 1) // with assumption x = 1 find(assumption: Constraint) method provides CSP solving under assumption given by the speci
  • 92. ed constraint. The constraint of assumption should be encoded to a conjunction of literals (otherwise an exception is raised). Then, the literals are passed to Sat4j, then it computes a solution under assumption. We can utilize those techniques for optimization and enumeration problems. 58 / 60
  • 93. Conclusion Introducing Architecture and Features of Scarab Using Scarab, we can write various constraint models without developing dedicated encoders, which allows us to focus on problem modeling and encoding. Future Work Introducing more features from Sat4j Sat4j has various functions of
  • 94. nding MUS, optimization, solution enumeration, handling natively cardinality and pseudo-Boolean constraints. URL of Scarab http://kix.istc.kobe-u.ac.jp/~soh/scarab/ 59 / 60
  • 95. References I Biere, A., Heule, M., van Maaren, H., and Walsh, T., editors (2009). Handbook of Satis
  • 96. ability, volume 185 of Frontiers in Arti
  • 97. cial Intelligence and Applications (FAIA). IOS Press. Cook, S. A. (1971). The complexity of theorem-proving procedures. In Proceedings of the 3rd Annual ACM Symposium on Theory of Computing (STOC 1971), pages 151{158. Davis, M., Logemann, G., and Loveland, D. W. (1962). A machine program for theorem-proving. Communications of the ACM, 5(7):394{397. 60 / 60