Features and Constraints

Constraint Satisfaction Problems (CSPs)

CSPs as Graph Searching Problems

Two ways to represent CSPs as a graph searching:

Classic CSP: Crossword Construction

Pasted image 20250415202956.png

Dual Representations

Two ways to represent the crossword as a CSP

Posing a CSP

Variables: V1,V2,,Vn
Domains: for each variable, Vi has a domain Dvi
Constraints: Restrictions on the values a set of variables can jointly have

Constraints

Solutions:

Generate and test

Backtracking

Consistency

AC-3

Makes a CN arc consistent and domain consistent

Implementation

  1. Make all domains domain consistent
  2. Put all arcs (Z,c(Z,_)) in TDA
  3. repeat
    a. Select and remove an arc (X,c(X,Y)) from TDA
    b. Remove all values of domain of X that don’t have a value in domain of Y that satisfies the constraint c(X,Y)
    c. If any were removed, Add all arcs (Z,c(Z,X)) to TDA ZY

until TDA is empty

When AC-3 Terminates

AC-3 always terminates with one of these three conditions:

Complexity
Variable Elimination

Idea: Eliminate the variables one-by-one passing their constraints to their neighbors

Algorithm

  • If there is only one variable, return the intersection of the (unary) constraints that contain it
  • Select a variable X
    • Join the constraints in which X appears, forming constraint R
    • Project R onto its variables other than X: call this R2
    • Place new constraint R2 between all variables that were connected to X
    • Remove X
    • Recursively solve the simplified problem
    • Return R joined with the recursive solution

Hill-Climbing

Requires:
Local Search for CSPs
Greedy Descent Variants
Problems with Greedy Descent

Pasted image 20250415215939.png

Randomized Greedy Descent

As well as downward steps we can allow for:

High Dimensional Search Spaces

A mix of:

Variant: Simulated Annealing
Tabu Lists

A total assignment is called an individual

Like beam search, but it probabilistically chooses the k individuals at the next generation

Genetic Algorithms

Like stochastic beam search, but pairs of individuals are combined to create the offspring:

Crossover
X1=a1,X2=a2,,Xm=amX1=b1,X2=b2,,Xm=bm X1=a1,,Xi=ai,Xi+1=bi+1,,Xm=bmX1=b1,,Xi=bi,Xi+1=ai+1,,Xm=am

Compare Stochastic Algorithms

How can you compare three algorithms when

Summary statistics, such as mean run time, median run time, and mode run time don’t make much sense

Runtime Distribution

Plots runtime and the proportion of the runs that are solved within that runtime
Pasted image 20250416110020.png