SlideShare a Scribd company logo
18.10.2017
Constraint Satisfaction Problem (CSP)
Prepared By –
ABU ZAHID MD JALAL UDDIN JOY
Student, Department of Software Engineering
Daffodil International University
18.10.2017
CSP – What is it ?
➢ A kind of decision problem
➢ Making decisions without violating constraint
18.10.2017
CSP – Consists of 3 Components
➢ A set of variables
➢ A set of values for each of the variables
➢ A set of constraints
18.10.2017
Applications
➢ Time Tabling (class rooms, times)
➢ Configuration (hardware, cars…)
➢ Airplane Applications
• (British airways uses Constraint Satisfaction to schedule
aircraft)
➢ Image Processing
• (Microsoft auto collage uses it to blend photos together)
➢ Spreadsheets
➢ Scheduling
➢ Floor Planning
➢ Sudoku etc.
18.10.2017
Scientific Challenges
➢ Modelling
• (Defining the decisions and constraint)
➢ Combinatorial Explosion
• (How to decide, who to do which job and when?)
18.10.2017
Finding Solution
➢ If each variable has d values and there are n variables, so we have
𝒅 𝒏 possible assignments
18.10.2017
Solving N-Queens as a CSP
➢ The N Queen is the problem of placing N chess queens on an N×N
chessboard so that no two queens attack each other. For example,
following is a solution for 4 Queen problem.
18.10.2017
Solving N-Queens Using Backtracking
➢ N Queen as a example problem that can be solved using
Backtracking.
18.10.2017
Backtracking
➢ Backtracking is considered an important technique to solve
constraint satisfaction issues and puzzles.
➢ Backtracking is one of the main methods for solving problems
like N-Queens.
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
➢ Variables: Q
➢ Domains: D = {1, 2, 3, 4}
➢ Constraints
• Qi≠Qj (cannot be in same row)
• |Qi - Qj| ≠ |i - j| (or same
diagonal)
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 1 at position [1, 1]
*Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 1 at position [1, 2]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 1 at position [2, 2]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 2 at position [3, 2]
*Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [1, 3]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [2, 3]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [3, 3]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [4, 3]
* Violating Constraints
18.10.2017
Backtrack
➢ No more valid Cells, so Backtrack it’s immediate stage (Variable)
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 2 at position [4, 2]
*Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [1, 3]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [2, 3]
*Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [1, 4]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [2, 4]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [3, 4]
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [4, 4]
No more valid Cells, so Backtrack it’s
immediate variable
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [3, 3]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [4, 3]
* Violating Constraints
No more valid Cells, so Backtrack it’s
immediate immediate variable
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 1 at position [2, 1]
* Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 2 at position [1, 2]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 2 at position [2, 2]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 2 at position [3, 2]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 2 at position [4, 2]
*Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 3 at position [1, 3]
*Fulfil Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [1, 4]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [2, 4]
* Violating Constraints
18.10.2017
4-Queens Using Backtracking
1 2 3 4
1
2
3
4
Place Queen 4 at position [3, 4]
*Fulfil Constraints
18.10.2017
This was the basic explanation
➢ Do you have any questions ?
18.10.2017
Thank You ☺

More Related Content

PDF
প্রোগ্রামিং ভাষা (পঞ্চম অধ্যায়) Hsc C Programming-by a. z. m. jalal uddin joy...
PDF
DIU ISACA STUDENT GROUP 2019 version2
PDF
Intelligent Emergency Patient Support System || Diu app contest project descr...
PPTX
Artificial intelligence (Project)Presentation-Daffodil International Universi...
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
প্রোগ্রামিং ভাষা (পঞ্চম অধ্যায়) Hsc C Programming-by a. z. m. jalal uddin joy...
DIU ISACA STUDENT GROUP 2019 version2
Intelligent Emergency Patient Support System || Diu app contest project descr...
Artificial intelligence (Project)Presentation-Daffodil International Universi...
2024 Trend Updates: What Really Works In SEO & Content Marketing
Storytelling For The Web: Integrate Storytelling in your Design Process
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...

Recently uploaded (20)

PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
additive manufacturing of ss316l using mig welding
PDF
Digital Logic Computer Design lecture notes
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Well-logging-methods_new................
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Welding lecture in detail for understanding
PPT
Mechanical Engineering MATERIALS Selection
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Construction Project Organization Group 2.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Sustainable Sites - Green Building Construction
additive manufacturing of ss316l using mig welding
Digital Logic Computer Design lecture notes
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Lecture Notes Electrical Wiring System Components
Well-logging-methods_new................
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Welding lecture in detail for understanding
Mechanical Engineering MATERIALS Selection
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Construction Project Organization Group 2.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Ad
Ad

Constraint Satisfaction Problem (CSP) by A z m jalal uddin joy_v1.0.1