The document discusses constraint satisfaction problems (CSPs). It defines a CSP as a decision problem that involves making choices without violating constraints. A CSP consists of variables, values for each variable, and constraints on the values. Examples of CSP applications include timetabling, scheduling, and Sudoku puzzles. Solving a CSP involves exploring all possible assignments of values to variables while checking constraints. Backtracking is an important technique for solving CSPs by trying assignments and abandoning ("backtracking") from ones that violate constraints. The document walks through solving the 4-Queens puzzle as a CSP using backtracking.
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Constraint Satisfaction Problem (CSP) by A z m jalal uddin joy_v1.0.1
1. 18.10.2017
Constraint Satisfaction Problem (CSP)
Prepared By –
ABU ZAHID MD JALAL UDDIN JOY
Student, Department of Software Engineering
Daffodil International University
2. 18.10.2017
CSP – What is it ?
➢ A kind of decision problem
➢ Making decisions without violating constraint
3. 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
4. 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.
7. 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.
9. 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.
10. 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)
28. 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