Constraint Satisfaction Problems
Overview
Constraint satisfaction problems are a subset of search problems. The goal is to find values for some set of variables, but in accordance to some constraint. This can either be discrete variables or continuous variables.
There are three components:
- Variables:
- Domains:
- Constraints:
Constraints
A constraint has a scope and permitted values.
Assignments and Solutions
An assignment is a mapping of values to variables. These can be complete (if every variable is included) or partial (if some variables are not included).
If the assignment satisfies all the constraints, it is a consistent/legal assignment (this does not need to be complete).
A solution is a consistent and complete assignment.
Constraints
A unary constraint concerns one variable. For instance, .
A binary constraint involves two variables, like or .
Example: Sudoku
Each row, column, and sub-grid needs the numbers 1-9.
As a CSP:
- Variables:
- Domain:
- Constraints:
- where is sub-grid
Example: -Queens
As a CSP:
- Variables:
- Domain:
- Constraints:
Example: Map Coloring
Color a planar graph with 4 colors (this is always possible). By brute force, there would be possible coloring options.
Using DFS/BFS, start with one node and pick the first available color. Continue to the next node and pick the next available color. Keep going until the entire graph is colored.
Better options include visiting the minimum remaining values, the least constraining value, look ahead, etc.15`