100 lines
3.0 KiB
Markdown
100 lines
3.0 KiB
Markdown
|
|
# Constraint Satisfaction Problems
|
||
|
|
|
||
|
|
Book pg. 164 to 169
|
||
|
|
|
||
|
|
We have 3 components
|
||
|
|
|
||
|
|
- $\mathcal{X}$: Set of variables
|
||
|
|
- $\mathcal{D}$: Set of domains, one (domain) for each variable
|
||
|
|
- $\mathcal{C}$: Set of constraints
|
||
|
|
|
||
|
|
Here we try to assign a value to variables, such that each variable holds a value contained in their
|
||
|
|
domain, without violating any constraint.
|
||
|
|
|
||
|
|
A solution to this problem must be:
|
||
|
|
|
||
|
|
- Consistent: Each assignment is legal
|
||
|
|
- Complete: All variables have a value assigned
|
||
|
|
|
||
|
|
## Inference in CSP
|
||
|
|
|
||
|
|
We can inference a solution in these ways
|
||
|
|
|
||
|
|
- Generate successors and if not consistent assignments, prune and continue
|
||
|
|
- Constraint Propagation:\
|
||
|
|
Use contraints to reduce possible assignments and mix with search, if needed
|
||
|
|
|
||
|
|
The idea is to treat each assignment as a **vertex** and each contraint as an **edge**, we our tree would not have inconsistent values, making
|
||
|
|
the search faster.
|
||
|
|
|
||
|
|
## Consistency
|
||
|
|
|
||
|
|
### Node consistency
|
||
|
|
|
||
|
|
A domain already satisfies constraints
|
||
|
|
|
||
|
|
### Arc Consistency
|
||
|
|
|
||
|
|
A variable is arc consistent wrt another variable id its domain respects all constraints
|
||
|
|
|
||
|
|
> [!WARNING]
|
||
|
|
> Arco Consistency is not useful for every problem
|
||
|
|
|
||
|
|
> [!NOTE]
|
||
|
|
> AC-3 is an algorithm to achieve Arc Consistency (alorithm on page 171 book)
|
||
|
|
|
||
|
|
### Path Consistency
|
||
|
|
|
||
|
|
It is achievable on 3 variables and says that a set of 2 variable is path consistent wrt a 3rd only if for each assignment
|
||
|
|
consistent with constraints between these variables makes it possible to make a legal assignment on the 3rd
|
||
|
|
|
||
|
|
### K-Consistency
|
||
|
|
|
||
|
|
basically the same as the one above, but for k-variables, technically we need $O(n^2 d)$ to check if a problem is
|
||
|
|
total k-consistent (consistent from 1 up to k), however it is expensive and only 2-Consistency is usually computed.
|
||
|
|
|
||
|
|
## Global Contraints
|
||
|
|
|
||
|
|
Constraints that take an arbitrary number of variables (but not necessarily all).
|
||
|
|
|
||
|
|
### Checking for Aldiff Constraint
|
||
|
|
|
||
|
|
Aldiff constraint says that all variables must have different values.
|
||
|
|
|
||
|
|
A way to check for inconsistencies is to remove variables with single value domains and remove such value
|
||
|
|
from all domains, then iterate until there are no more single value domain variables.
|
||
|
|
|
||
|
|
If an empty domain is produced, or there are more variables than domain values, congrats!! You found an inconsistency
|
||
|
|
|
||
|
|
### Checking for Atmost Constraint
|
||
|
|
|
||
|
|
Atmost constraint says that we can assign max tot resources
|
||
|
|
|
||
|
|
Sum all minimum resources for each problem, and if it goes over the max, we have an inconsistency
|
||
|
|
|
||
|
|
### Bound Consistency
|
||
|
|
|
||
|
|
We check that for each variable X and for both the lower and higher bound of X there exists a value of U that satisfies the constraints between X and each Y.
|
||
|
|
|
||
|
|
## Backtracking Search in CSP
|
||
|
|
|
||
|
|
Book pg 175 to 178
|
||
|
|
|
||
|
|
After finishing the constraint propagation, reducing our options, we still need to search for a solution.
|
||
|
|
|
||
|
|
- The order of values is not relevant (we can save up on computation and memoru)
|
||
|
|
|
||
|
|
### Forward Checking
|
||
|
|
|
||
|
|
<!-- TODO -->
|
||
|
|
|
||
|
|
### Intelligent Backtracking (Backjumping)
|
||
|
|
|
||
|
|
<!-- TODO -->
|
||
|
|
|
||
|
|
## The structure of Problems
|
||
|
|
|
||
|
|
<!-- TODO -->
|
||
|
|
|
||
|
|
Book from 183 to 187
|