SlideShare a Scribd company logo
Constraint Satisfaction Problems (CSP)
Constraint satisfaction problem
A constraint satisfaction problem (CSP) requires a value, selected
from a given finite domain, to be assigned to each variable in
the problem, so that all constraints relating the variables are satisfied.
Many combinatorial problems in operational research, such as
scheduling and timetabling, can be formulated as CSPs.
2
Constraint satisfaction problem
CSP is one of the standard search problem where instead of saying state
is black box, we say state is defined by variables and values.
• CSP:
• state is defined by variables Xi with values from domain Di
• goal test is a set of constraints specifying allowable combinations
of values for subsets of variables
Allows useful general-purpose algorithms with more power than
standard search algorithms
3
Varieties of CSPs
 Discrete variables
• Finite domains:
• n variables, domain size d  O(d n) complete assignments
• e.g., 3-SAT (NP-complete)
• Infinite domains:
• integers, strings, etc.
• e.g., job scheduling, variables are start/end days for each job
• need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3
 Continuous variables
• e.g., start/end times for Hubble Space Telescope observations
• linear constraints solvable in polynomial time by linear programming
4
Varieties of constraints
• Unary constraints involve a single variable,
• e.g., SA ≠ green
• Binary constraints involve pairs of variables,
• e.g., SA ≠ WA
• Higher-order constraints involve 3 or more variables,
• e.g., SA ≠ WA ≠ NT
Preferences (Soft Constraints): e.g. red is better than green. Need not be satisfied but
you get credit for satisfying them.
Constraint Optimization Problems.
5
Real-world CSPs
 Assignment problems
 e.g., who teaches what class
 Timetabling problems
 e.g., which class is offered when and where?
 Transportation scheduling
 Factory scheduling
 Hardware configuration
 Floor planning
Notice that many real-world problems involve real-valued variables.
6
Examples of CSPs
1. Graph/ Map Coloring
2. Sudoku Problems
3. Cryptarithmetic Problems
4. 4- Queen Problems
5. Puzzles etc.
7
Example: Cryptarithmetic
Cryptarithmetic: is a type of constraint satisfaction problem in which
each alphabet and symbol is associated with unique digit.
Rules:
1. Each alphabet has unique digit
2. Digit ranges from 0- 9
3. Only one carry should be found
4. Can be solved from both sides.
8
Example: Cryptarithmetic
+
S E N D
M O R E
M O N E Y
9
Constraints
1. Every letter must have a digit.
2. Each letter must have different digit
𝑉𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠, 𝑋 = 0 {𝑆, 𝐸, 𝑁, 𝐷, 𝑀, 𝑂, 𝑅, 𝑌0}
𝐷𝑜𝑚𝑎𝑖𝑛𝑠, 𝐷 (𝑒𝑥𝑐𝑒𝑝𝑡 𝑆 & 𝑀) = {0,1, 2, 3, 4, 5, 6, 7, 8, 9}
𝐶𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠: 𝐴𝑙𝑙𝑑𝑖𝑓(𝑆, 𝐸, 𝑁, 𝐷, 𝑀, 𝑂, 𝑅, 𝑌)0
𝐷𝑜𝑚𝑎𝑖𝑛𝑠, 𝐷 (𝑆 & 𝑀) = {1, 2, 3, 4, 5, 6, 7, 8, 9}
Example: Cryptarithmetic
10
+
+
S E N D
M O R E
M O N E Y
Character Code
S
E
N
D
M
O
R
Y
11
+
1
+
S E N D
M O R E
M O N E Y
Character Code
S
E
N
D
M
O
R
Y
12
+ 1
1
+
S E N D
M O R E
M O N E Y
Character Code
S
E
N
D
M 1
O
R
Y
13
+
9
1
1 0
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O
R
Y
14
+
9
1 0
1 0
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O 0
R
Y
15
+
9 ?
1 0
1 0 N
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O 0
R
Y
E + 0 = N
16
+
9 E
1 0
1 0 N
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O 0
R
Y
1 CARRY FROM HERE
Expression: E + 1 = N ( N & E differ by 1 )
17
+
9 E
1 0
1 0 N
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O 0
R
Y
1
Expression:
1. E + 1 = N [ N & E differ by 1 ]
2. N + R (+1) = E + 10 [ (+1) will be considered only if needed ]
18
+
9 E
1 0
1 0 N
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O 0
R 8
Y
1
Expression:
1. E + 1 = N [ N & E differ by 1 ]
2. N + R (+1) = E + 10 [ (+1) will be considered only if needed ]
Substituting the values:
E + 1 + R (+1) = E + 10
Hence, R (+1) = 9
If we do not consider carry then
R must be 9 but which is not
possible because 9 has already
taken, so R might be 8.
19
+
9 E
1 0 8
1 0 N
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E
N
D
M 1
O 0
R 8
Y
1 1
Now D+E= Y, has to be such that generates carry, D+E should be
sum up to more than 11 because Y can not be 0 or 1 as they have
already been taken, so to get that, the possibilities are 7+5 or 7+6 and
so on.
So, if we take D = 7, E = 5, Hence Y = 2
20
+
9 5 7
1 0 8 5
1 0 N 2
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E 5
N
D 7
M 1
O 0
R 8
Y 2
1 1
Expression:
1. E + 1 = N
21
+
9 5 6 7
1 0 8 5
1 0 6 4 2
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E 5
N 6
D 7
M 1
O 0
R 8
Y 2
1 1
Hence N = 6
22
+
9 5 6 7
1 0 8 5
1 0 6 4 2
+
S E N D
M O R E
M O N E Y
Character Code
S 9
E 5
N 6
D 7
M 1
O 0
R 8
Y 2
Example: Sudoku
𝑋1 𝑋2 𝑋3
𝑋4 𝑋5 𝑋6
𝑋7 𝑋8 𝑋9
23
Constraints
• Each box contains only unique values
• Same values can not be on multiple place on
sudoku box
𝑉𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠 ∶ 𝑋𝑖 = {𝑋1, 𝑋2, 𝑋3, 𝑋4, 𝑋5, 𝑋6, 𝑋7, 𝑋8, 𝑋9}
𝐷𝑜𝑚𝑎𝑖𝑛𝑠: 𝐷𝑖 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
Solution of this CSP is : {𝑋𝑖} = {𝐷𝑖}
𝐶𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠: 𝐴𝑙𝑙𝑑𝑖𝑓(1, 2, 3, 4, 5, 6, 7, 8, 9)0
Example: 4-Queens
• States: 4 queens in 4 columns (44 = 256 states)
• Actions: move queen in column
• Goal test: no attacks
• Evaluation: h(n) = number of attacks
24
Example: Map-Coloring
25
Variables WA, NT, Q, NSW, V, SA, T
Domains Di = {red, green, blue}
Constraints: adjacent regions must have different colors. e.g., WA ≠ NT
Example: Map-Coloring
26
Solutions are complete and consistent assignments, e.g., WA = red,
NT = green, Q = red, NSW = green, V = red, SA = blue, T = green
Thank You
27

More Related Content

What's hot

Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
Mohammad Imam Hossain
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
Harini Balamurugan
 
Problem Formulation
Problem FormulationProblem Formulation
Problem Formulation
Adri Jovin
 
Automata theory
Automata theoryAutomata theory
Automata theory
Pardeep Vats
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
N queen problem
N queen problemN queen problem
N queen problem
Ridhima Chowdhury
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
Amey Kerkar
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
BMS Institute of Technology and Management
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Machine learning
Machine learningMachine learning
Machine learning
Amit Kumar Rathi
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
manika kumari
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
Sujata Pardeshi
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Hinal Lunagariya
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
Neha Kulkarni
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
V.V.Vanniaperumal College for Women
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
sandeep54552
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
5 csp
5 csp5 csp
5 csp
Mhd Sb
 

What's hot (20)

Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
 
Problem Formulation
Problem FormulationProblem Formulation
Problem Formulation
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
N queen problem
N queen problemN queen problem
N queen problem
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Machine learning
Machine learningMachine learning
Machine learning
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
5 csp
5 csp5 csp
5 csp
 

Similar to Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Queen, Sudoku

Number system
Number systemNumber system
Number system
Diksha Shivpure
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
SrinivasaReddyPolamR
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematics
Mark Simon
 
factoring
factoringfactoring
factoring
Harish Sahu
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
ssuser01e301
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata Theory
Mark Simon
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
sajinis3
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
KarthikeyaLanka1
 
Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.
Thato Barry
 
Ebook 1
Ebook 1Ebook 1
Ebook 1
thato barry
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2
Gopi Saiteja
 
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
DebiPrasadSen
 
Combinatorics.ppt
Combinatorics.pptCombinatorics.ppt
Combinatorics.ppt
ssuserdc5a3d
 
Proof Techniques
Proof TechniquesProof Techniques
Proof Techniques
CHANDANKUMARMANDAL5
 
Derivada aplicada en la carrera de electrónica y automatización.
Derivada aplicada en la carrera de electrónica y automatización.Derivada aplicada en la carrera de electrónica y automatización.
Derivada aplicada en la carrera de electrónica y automatización.
DANIELAXIOMARAANDRAN
 
presentation on artificial intelligence autosaved
presentation on artificial intelligence autosavedpresentation on artificial intelligence autosaved
presentation on artificial intelligence autosaved
Divya Somashekar
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
AmayJaiswal4
 
Lecture slides week14-15
Lecture slides week14-15Lecture slides week14-15
Lecture slides week14-15
Shani729
 
Reed solomon Encoder and Decoder
Reed solomon Encoder and DecoderReed solomon Encoder and Decoder
Reed solomon Encoder and Decoder
Ameer H Ali
 

Similar to Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Queen, Sudoku (20)

Number system
Number systemNumber system
Number system
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematics
 
factoring
factoringfactoring
factoring
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata Theory
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Sequence function
Sequence functionSequence function
Sequence function
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
 
Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.
 
Ebook 1
Ebook 1Ebook 1
Ebook 1
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2
 
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
 
Combinatorics.ppt
Combinatorics.pptCombinatorics.ppt
Combinatorics.ppt
 
Proof Techniques
Proof TechniquesProof Techniques
Proof Techniques
 
Derivada aplicada en la carrera de electrónica y automatización.
Derivada aplicada en la carrera de electrónica y automatización.Derivada aplicada en la carrera de electrónica y automatización.
Derivada aplicada en la carrera de electrónica y automatización.
 
presentation on artificial intelligence autosaved
presentation on artificial intelligence autosavedpresentation on artificial intelligence autosaved
presentation on artificial intelligence autosaved
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
 
Lecture slides week14-15
Lecture slides week14-15Lecture slides week14-15
Lecture slides week14-15
 
Reed solomon Encoder and Decoder
Reed solomon Encoder and DecoderReed solomon Encoder and Decoder
Reed solomon Encoder and Decoder
 

More from Mahbubur Rahman

Randomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced AlgorithmRandomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced Algorithm
Mahbubur Rahman
 
Cloudonomics in Advanced Cloud Computing
Cloudonomics in Advanced Cloud ComputingCloudonomics in Advanced Cloud Computing
Cloudonomics in Advanced Cloud Computing
Mahbubur Rahman
 
Geographic Routing in WSN
Geographic Routing in WSNGeographic Routing in WSN
Geographic Routing in WSN
Mahbubur Rahman
 
Streaming Stored Video- Computer Networking
Streaming Stored Video- Computer Networking  Streaming Stored Video- Computer Networking
Streaming Stored Video- Computer Networking
Mahbubur Rahman
 
Random Oracle Model & Hashing - Cryptography & Network Security
Random Oracle Model & Hashing - Cryptography & Network SecurityRandom Oracle Model & Hashing - Cryptography & Network Security
Random Oracle Model & Hashing - Cryptography & Network Security
Mahbubur Rahman
 
Modern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key CipherModern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key Cipher
Mahbubur Rahman
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
Mahbubur Rahman
 
Web Server And Database Server
Web Server And Database ServerWeb Server And Database Server
Web Server And Database Server
Mahbubur Rahman
 
LEX & YACC
LEX & YACCLEX & YACC
LEX & YACC
Mahbubur Rahman
 

More from Mahbubur Rahman (9)

Randomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced AlgorithmRandomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced Algorithm
 
Cloudonomics in Advanced Cloud Computing
Cloudonomics in Advanced Cloud ComputingCloudonomics in Advanced Cloud Computing
Cloudonomics in Advanced Cloud Computing
 
Geographic Routing in WSN
Geographic Routing in WSNGeographic Routing in WSN
Geographic Routing in WSN
 
Streaming Stored Video- Computer Networking
Streaming Stored Video- Computer Networking  Streaming Stored Video- Computer Networking
Streaming Stored Video- Computer Networking
 
Random Oracle Model & Hashing - Cryptography & Network Security
Random Oracle Model & Hashing - Cryptography & Network SecurityRandom Oracle Model & Hashing - Cryptography & Network Security
Random Oracle Model & Hashing - Cryptography & Network Security
 
Modern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key CipherModern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key Cipher
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
 
Web Server And Database Server
Web Server And Database ServerWeb Server And Database Server
Web Server And Database Server
 
LEX & YACC
LEX & YACCLEX & YACC
LEX & YACC
 

Recently uploaded

Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 

Recently uploaded (20)

Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 

Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Queen, Sudoku

  • 2. Constraint satisfaction problem A constraint satisfaction problem (CSP) requires a value, selected from a given finite domain, to be assigned to each variable in the problem, so that all constraints relating the variables are satisfied. Many combinatorial problems in operational research, such as scheduling and timetabling, can be formulated as CSPs. 2
  • 3. Constraint satisfaction problem CSP is one of the standard search problem where instead of saying state is black box, we say state is defined by variables and values. • CSP: • state is defined by variables Xi with values from domain Di • goal test is a set of constraints specifying allowable combinations of values for subsets of variables Allows useful general-purpose algorithms with more power than standard search algorithms 3
  • 4. Varieties of CSPs  Discrete variables • Finite domains: • n variables, domain size d  O(d n) complete assignments • e.g., 3-SAT (NP-complete) • Infinite domains: • integers, strings, etc. • e.g., job scheduling, variables are start/end days for each job • need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3  Continuous variables • e.g., start/end times for Hubble Space Telescope observations • linear constraints solvable in polynomial time by linear programming 4
  • 5. Varieties of constraints • Unary constraints involve a single variable, • e.g., SA ≠ green • Binary constraints involve pairs of variables, • e.g., SA ≠ WA • Higher-order constraints involve 3 or more variables, • e.g., SA ≠ WA ≠ NT Preferences (Soft Constraints): e.g. red is better than green. Need not be satisfied but you get credit for satisfying them. Constraint Optimization Problems. 5
  • 6. Real-world CSPs  Assignment problems  e.g., who teaches what class  Timetabling problems  e.g., which class is offered when and where?  Transportation scheduling  Factory scheduling  Hardware configuration  Floor planning Notice that many real-world problems involve real-valued variables. 6
  • 7. Examples of CSPs 1. Graph/ Map Coloring 2. Sudoku Problems 3. Cryptarithmetic Problems 4. 4- Queen Problems 5. Puzzles etc. 7
  • 8. Example: Cryptarithmetic Cryptarithmetic: is a type of constraint satisfaction problem in which each alphabet and symbol is associated with unique digit. Rules: 1. Each alphabet has unique digit 2. Digit ranges from 0- 9 3. Only one carry should be found 4. Can be solved from both sides. 8
  • 9. Example: Cryptarithmetic + S E N D M O R E M O N E Y 9 Constraints 1. Every letter must have a digit. 2. Each letter must have different digit 𝑉𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠, 𝑋 = 0 {𝑆, 𝐸, 𝑁, 𝐷, 𝑀, 𝑂, 𝑅, 𝑌0} 𝐷𝑜𝑚𝑎𝑖𝑛𝑠, 𝐷 (𝑒𝑥𝑐𝑒𝑝𝑡 𝑆 & 𝑀) = {0,1, 2, 3, 4, 5, 6, 7, 8, 9} 𝐶𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠: 𝐴𝑙𝑙𝑑𝑖𝑓(𝑆, 𝐸, 𝑁, 𝐷, 𝑀, 𝑂, 𝑅, 𝑌)0 𝐷𝑜𝑚𝑎𝑖𝑛𝑠, 𝐷 (𝑆 & 𝑀) = {1, 2, 3, 4, 5, 6, 7, 8, 9}
  • 10. Example: Cryptarithmetic 10 + + S E N D M O R E M O N E Y Character Code S E N D M O R Y
  • 11. 11 + 1 + S E N D M O R E M O N E Y Character Code S E N D M O R Y
  • 12. 12 + 1 1 + S E N D M O R E M O N E Y Character Code S E N D M 1 O R Y
  • 13. 13 + 9 1 1 0 + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O R Y
  • 14. 14 + 9 1 0 1 0 + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O 0 R Y
  • 15. 15 + 9 ? 1 0 1 0 N + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O 0 R Y E + 0 = N
  • 16. 16 + 9 E 1 0 1 0 N + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O 0 R Y 1 CARRY FROM HERE Expression: E + 1 = N ( N & E differ by 1 )
  • 17. 17 + 9 E 1 0 1 0 N + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O 0 R Y 1 Expression: 1. E + 1 = N [ N & E differ by 1 ] 2. N + R (+1) = E + 10 [ (+1) will be considered only if needed ]
  • 18. 18 + 9 E 1 0 1 0 N + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O 0 R 8 Y 1 Expression: 1. E + 1 = N [ N & E differ by 1 ] 2. N + R (+1) = E + 10 [ (+1) will be considered only if needed ] Substituting the values: E + 1 + R (+1) = E + 10 Hence, R (+1) = 9 If we do not consider carry then R must be 9 but which is not possible because 9 has already taken, so R might be 8.
  • 19. 19 + 9 E 1 0 8 1 0 N + S E N D M O R E M O N E Y Character Code S 9 E N D M 1 O 0 R 8 Y 1 1 Now D+E= Y, has to be such that generates carry, D+E should be sum up to more than 11 because Y can not be 0 or 1 as they have already been taken, so to get that, the possibilities are 7+5 or 7+6 and so on. So, if we take D = 7, E = 5, Hence Y = 2
  • 20. 20 + 9 5 7 1 0 8 5 1 0 N 2 + S E N D M O R E M O N E Y Character Code S 9 E 5 N D 7 M 1 O 0 R 8 Y 2 1 1 Expression: 1. E + 1 = N
  • 21. 21 + 9 5 6 7 1 0 8 5 1 0 6 4 2 + S E N D M O R E M O N E Y Character Code S 9 E 5 N 6 D 7 M 1 O 0 R 8 Y 2 1 1 Hence N = 6
  • 22. 22 + 9 5 6 7 1 0 8 5 1 0 6 4 2 + S E N D M O R E M O N E Y Character Code S 9 E 5 N 6 D 7 M 1 O 0 R 8 Y 2
  • 23. Example: Sudoku 𝑋1 𝑋2 𝑋3 𝑋4 𝑋5 𝑋6 𝑋7 𝑋8 𝑋9 23 Constraints • Each box contains only unique values • Same values can not be on multiple place on sudoku box 𝑉𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠 ∶ 𝑋𝑖 = {𝑋1, 𝑋2, 𝑋3, 𝑋4, 𝑋5, 𝑋6, 𝑋7, 𝑋8, 𝑋9} 𝐷𝑜𝑚𝑎𝑖𝑛𝑠: 𝐷𝑖 = {1, 2, 3, 4, 5, 6, 7, 8, 9} Solution of this CSP is : {𝑋𝑖} = {𝐷𝑖} 𝐶𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠: 𝐴𝑙𝑙𝑑𝑖𝑓(1, 2, 3, 4, 5, 6, 7, 8, 9)0
  • 24. Example: 4-Queens • States: 4 queens in 4 columns (44 = 256 states) • Actions: move queen in column • Goal test: no attacks • Evaluation: h(n) = number of attacks 24
  • 25. Example: Map-Coloring 25 Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red, green, blue} Constraints: adjacent regions must have different colors. e.g., WA ≠ NT
  • 26. Example: Map-Coloring 26 Solutions are complete and consistent assignments, e.g., WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green