0% found this document useful (0 votes)
18 views19 pages

Ai 6

Constraint Satisfaction Problem • Precedence Constraints • Back-tracking algorithm • Improvements in CSPs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views19 pages

Ai 6

Constraint Satisfaction Problem • Precedence Constraints • Back-tracking algorithm • Improvements in CSPs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Arti cial Intelligence

Constraint Satisfaction Problem

Dr. Junaid Younas


fi
Last week

• Stochastic Games
• Monte Carlo Tree search
• Constraint Satisfaction Problems (CSPs)
This week

• Constraint Satisfaction Problem


• Precedence Constraints
• Back-tracking algorithm
• Improvements in CSPs
A constraint can have precedence over the other task
• Lets consider an assembly problem for automotive industry
• Install AXELS, each axel installation is in 10 minutes
• Install WHEELS, each wheel needs 1 minute
• Tighten their NUTS, each needs 4 minutes
• A x HUBCAPS, 1 minute each
• INSPECT for proper Installation, 3 minutes
ffi
Tasks with Precedence Constraints can be represented arithmetically

• If T1 has precedence over T2, and T1 requires t seconds, it can be formulated


as T1 + t ≤ T2 — Precedence constraint

• When same resource is required for two di erent tasks, can’t overlap in time
— Disjunctive constraint

• Requires arithmetic + logical operation T1 + t ≤ T2 OR T2 + t ≤ T1

ff
A constraint can have precedence over the other task
• Lets consider an assembly problem for automotive industry
• Install AXELS, each axel installation is in 10 minutes
• Install WHEELS, each wheel needs 1 minute
• Tighten their NUTS, each needs 4 minutes
• A x HUBCAPS, 1 minute each
• INSPECT for proper Installation, 3 minutes

How can this be formulated as CSP?


ffi
CSPS are solved using Back-tracking search algorithm

• Back-tracking is an optimisation on DFS with two additional principles


• Fix an ordering for variables, and assign values in that order, satisfying
commutative property, WA=Red, NT=Green is same as NT=Green, WA=Red

• Only assign the non-con icting values, if a con ict exists back-track to
previously assigned values for updating
fl
fl
Back-tracking can be improved using multiple techniques

• Filtering
• Ordering
• Structural exploitation
Back-tracking can be improved using multiple techniques

• Filtering
• Pruning the values beforehand that can result in back-tracking
• Ordering
• Fixing some ordering both for variables and values involved
• Structural exploitation
• Assuming CSP as tree structured with cut-sett conditioning
Filtering prunes the con icting values before it occurs

• When assigning a value to Xi, prune the domains of variable that share constraint with Xi, — Forward
checking

• Removing inconsistencies from the CSP graph using forward checking is termed as local consistency
• Node consistency
• If all values satisfy unary constraints — node consistent graph
• Usually done in the start by reducing domain of variables unary constraints
• Arc consistency
• All values satisfy binary constraints — principle of arc consistency
• AC-3 algorithm is applied to achieve arc consistency
fl
Arc consistency — removing binary constraints

• Xi is arc-consistent w.r.t Xj, if for every value in Di there is some value in Dj to


satisfy binary constraint for (Xi, Xj) —edge consistent

2
• Lets consider x = y , how to make is x-consistent and y-consistent
Arc-consistency is implemented using AC-3 Algorithm

• Store all arcs for the constraint graph in a queue Q.


• Iteratively removes arcs from Q by enforcing condition for the
removed arc Xi ⇝ Xj

• Xi = v, Xj = w, Doesn’t violate any constraint


• Else remove v from the Domain of Xi
• If atleast One value is removed for Xi while enforcing arc
consistency Xi ⇝ Xj, add arcs of the from Xk ⇝ Xi

• If it is already in Q, don’t add


• Iterate until Queue is empty
Arc-consistency is subset of K-consistency

• A CSP is K-consistent if, a consistent assignment for any subset of K-1


values guarantees K-consistency

• 1-consistency, 2-consistency
• If the Graph is K, K-1, …..1 consistent — Strong K-consistency
Ordering also improves the e ciency of CSPs

• Ordering uses two principles


• Minimum remaining values
• Least constraining value

ffi
Ordering also improves the e ciency of CSPs

• Ordering uses two principles


• Minimum remaining values
• Choose whichever variable has the fewest remains values — the most
constrained variable

• Least constraining value


• On next value assignment, select the value that prunes the fewest values
from the domains of the remaining unassigned values

ffi
Exploiting structure of problem can improve the CSP

• Tree-structured CSP can reduce the


n 2
complexity from O(d ) to O(nd )

• Root node selection — Any node in the


graph can serve as root node

• Topological Sorting — convert all


undirected edges to directed edges with
reference to root
Exploiting structure of problem can improve the CSP

• Tree-structured CSP can reduce the complexity


n 2
from O(d ) to O(nd )

• Root node selection — Any node in the graph can


serve as root node

• Topological Sorting — convert all undirected


edges to directed edges with reference to root

• Pruning — Perform backward pass from i = n to


i = 2for arc consistency
• Assignment — Forward assignments from Xi to Xn
in consistence with the parents
Cut-set algorithm transforms CSP graph as tree

• Assign a value to SA, and prune the domains of rest variables


• How will remaining graph look like?
• Any solution for CSP after SA and its constraints are removed
will be consistent with the value chosen for SA — cutset
conditioning

• Choose a subset S of the CSP such that constraint graph


becomes a tree — cycle cutest

• For each possible assignment to S, must satisfy all


constraints

• Update the domains of remaining variables


• If solution exist, return it after combining with S.
Reminder: Work on Assignment-3
Thanks … Content Inspiration CS-188

You might also like