Constraint satisfaction problems

Constrain Satisfaction Problems (CSPs)

  • CSPs are a subset of search problems in general
  • State defined by variables XiX_i, with values from a domain DD
  • “Goal test” is set of constraints specifying allowable combinations of values for subsets of variables

Example: Map Coloring (for Australia)

  • Variables: WA, NT, Q, NSW, V, SA, T
  • Domain: D={red,green,blue}D = \{red,green,blue\}
  • Constraints: adjacent regions must not have same color, can be encoded implicitly or explicitly
    • Implicit could be region colors WANTWA \not= NT, whereas explicit would be explicitly stating what’s allowed (WA,NT){(red,green),(red,blue),}(WA,NT) \in \{(red,green),(red,blue),\dots\}
  • Solutions are assignments of elements in the domain to the variables such that all constraints are satisfied. In this example, a solution might be something like {WA=red,NT=green,Q=red,}\{WA=red, NT=green, Q=red, \dots \}
Australia Map Coloring CSP

Constraint Graphs

  • Binary CSP: constraints relate at most two variables; variables represented as nodes, edges between nodes indicate a constraint involved those variables

Varieties of CSPs

  • Discrete variables
    • Finite domains like boolean CSPs, variables take on one value from a finite set
    • Infinite domains like integers, strings
  • Continuous variables
    • Variables can take on continuous values like times

Ordering: Least Constraining Value

  • Heuristic on order of values with variables (i.e. given that a variable has already been chosen) that chooses the least constraining value
  • This leaves the largest possible number of remaining states for other variables, giving us greater flexibility as we continue to searchA

Iterative Algorithms

Start with a complete assignment where all variables have assigned values, and iteratively fix problems. - Pick a variable with conflicts at random - Reassign the value to that variable that violates the fewest constraints

Turns out this strategy is very effective for virtually any random CSP except for those having a critical ratio of number of constraints to number of variables. That is, with a large number of constraints and few variables (or vice versa), the CSP is quite easy to solve with an iterative reassignment approach. But those with critical ratio of variables to constraints (no explicitly ratio is given) turn out to take a ton of time with limited success.

CSP Summary

  • CSPs are subset of search problems, where states are partial assignments, and goals are assignments without constrain conflicts
  • Basic approach to solving CSPs is backtracking search, with common speedups using ordering, filtering, and exploiting problem structure
  • Iterative algorithms with min-conflicts is often an effective approach as well

Hill Climbing

Start somewhere and move to the best neighboring state. Continue this until there are no neighbors better than current position. Not complete (may never reach a local optima) or optimal (may get stuck in local max), but often useful

Simulated Annealing

Hill climbing but smarter: continuously decrease a “temperature” parameter which controls the probability of taking a downward step. This helps to bounce out of local maxima early on, and ultimately leads to convergence if the temperature is decreased slowly enough

Genetic Algorithms

Know these for now