University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Problems Russell and Norvig: Chapter
Constraint Satisfaction Problems
Lecture 11 Last Time: Local Search, Constraint Satisfaction Problems Today: More on CSPs.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Constraint Satisfaction problems (CSP)
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
Lecture 5: Constraint Satisfaction
Constraint Satisfaction Problems. Constraint satisfaction problems (CSPs) Standard search problem: – State is a “black box” – any data structure that.
Constraint Satisfaction Problems
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Artificial Intelligence Constraint satisfaction Chapter 5, AIMA.
Constraint Satisfaction Problems
Constraint Satisfaction
Lecture 5: On-line search Constraint Satisfaction Problems
Chapter 5 Outline Formal definition of CSP CSP Examples
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Constraint Satisfaction Problems
ISC 4322/6300 – GAM 4322 Artificial Intelligence Lecture 4 Constraint Satisfaction Problems Instructor: Alireza Tavakkoli September 17, 2009 University.
1 Constraint Satisfaction Problems Slides by Prof WELLING.
1 CSP and Games CSP and Games Introduction 5 Constraint Satisfaction Problems Source of contents: MIT OpenCourseWare.
CSPs Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew Moore,
CSPs Tamara Berg CS Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CSC 8520 Spring Paula Matuszek Based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf.
Searching by Constraint CMSC Artificial Intelligence January 24, 2008.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
1 Constraint Satisfaction Problems Soup Total Cost < $30 Chicken Dish Vegetable RiceSeafood Pork Dish Appetizer Must be Hot&Sour No Peanuts No Peanuts.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
1 Chapter 5 Constraint Satisfaction Problems. 2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
Chapter 5 Constraint Satisfaction Problems
Constraint Satisfaction Problems (Chapter 6)
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Grand Challenge:
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Constraint Satisfaction Problems University of Berkeley, USA
4/18/2005EE5621 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 5, 4/18/2005 University of Washington, Department of Electrical Engineering Spring.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
1 Constraint Satisfaction Problems: Formulation, Arc Consistency & Propagation 1 Brian C. Williams October 13 th, 2004 Slides adapted from:
Computing & Information Sciences Kansas State University Friday, 08 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 7 of 42 Friday, 08 September.
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Dr. Shazzad Hosain Department of EECS North South University Lecture 01 – Part C Constraint Satisfaction Problems.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
Constraint Satisfaction Problems
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information Systems.
Cse 150, Fall 2012Gary Cottrell: Many slides borrowed from David Kriegman! Constraint Satisfaction Problems Introduction to Artificial Intelligence CSE.
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
Constraint Satisfaction Problems Lecture # 14, 15 & 16
Advanced Artificial Intelligence
CS 188: Artificial Intelligence
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Artificial Intelligence
Constraint satisfaction problems
Constraint Satisfaction Problems. A Quick Overview
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture 4

University College Cork (Ireland) Department of Civil and Environmental Engineering Today’s class o Constraint satisfaction problems (CSP) R. Marinescu October-2009page 2

University College Cork (Ireland) Department of Civil and Environmental Engineering Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints Constraint propagation Variables: 81 slots Domains = {1,2,3,4,5,6,7,8,9} Constraints: 27 not-equal Sudoku

University College Cork (Ireland) Department of Civil and Environmental Engineering Sudoku Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint satisfaction problems o CSP state – is defined by variable X i with values from domain D i goal test – is a set of constraints specifying allowable combinations of values for subsets of variables o Applications for CSPs Scheduling tasks (transportation, maintenance) Robot planning tasks Puzzles Tail-Gate assignment (airports) Radio-link frequency assignment (telecom) … R. Marinescu October-2009page 5

University College Cork (Ireland) Department of Civil and Environmental Engineering Example: map coloring o variables: WA, NT, Q, SA, NSW, V, T o domains: Di = {red, green, blue} o constraints: adjacent regions must have different colors e.g., WA ≠ NT or (WA, NT) in {( red, green ), ( red, blue ), ( green, red ), ( green, blue ), ( blue, red ), ( blue, green )} R. Marinescu October-2009page 6

University College Cork (Ireland) Department of Civil and Environmental Engineering Example: map coloring o Solutions are complete and consistent assignments E.g., WA = red, NT = green, SA = blue, Q = red, NSW = green, V = red, T = green R. Marinescu October-2009page 7

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint graph R. Marinescu October-2009page 8 Binary CSP variable V i with values in domain D i General class of problems: Unary constraint arc Binary constraint arc (Unary constraint just cut down domains) This diagram is called a constraint graph

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint graph R. Marinescu October-2009page 9 Binary CSP variable V i with values in domain D i General class of problems: Unary constraint arc Binary constraint arc (Unary constraint just cut down domains) This diagram is called a constraint graph Basic problem: Find d j in D i for each V i s.t. all constraints satisfied (finding consistent labeling for variables)

University College Cork (Ireland) Department of Civil and Environmental Engineering N-Queens as CSP R. Marinescu October-2009page 10 1Q 2Q 3Q 4Q 1234 Place N queens on an NxN chessboard so that none can attack the other Classic “benchmark” problem Variables Domains Constraints are board positions in NxN chessboard Queen or blank Two positions on a line (vertical, horizontal, diagonal) cannot both be Q

University College Cork (Ireland) Department of Civil and Environmental Engineering Scheduling as CSP R. Marinescu October-2009page 11 Choose time for activities e.g., observations on Hubble telescope, or terms to take required classes time activity Variables Domains Constraints are activities sets of start times (or “chunks” of time) 1. Activities that use the same resource cannot overlap in time 2. Preconditions satisfied

University College Cork (Ireland) Department of Civil and Environmental Engineering 3-SAT as CSP R. Marinescu October-2009page 12 Variables Domains Constraints clauses Boolean variable assignments that make clauses true Clauses with shared Boolean variables must agree on value of variables Find values for Boolean variables A, B, C, … that satisfy the formula The original NP-complete problem

University College Cork (Ireland) Department of Civil and Environmental Engineering Varieties of CSPs o Discrete variables Finite domains  n variables, domain size d → O(d n ) complete assignments  E.g., map coloring, n-queens, … Infinite domains  Integers, strings  E.g., job scheduling (variables are start/end days of each job) o Continuous variables Usually, the domain of the variables are real numbers R. Marinescu October-2009page 13

University College Cork (Ireland) Department of Civil and Environmental Engineering Varieties of constraints o Unary constraints involve one variable E.g., SA ≠ green o Binary constraints involve pairs of variables E.g., SA ≠ WA o Higher-order constraints involve 3 or more variables E.g., crypt-arithmetic column constraints (see next) R. Marinescu October-2009page 14

University College Cork (Ireland) Department of Civil and Environmental Engineering Example: crypt-arithmetic puzzle R. Marinescu October-2009page 15 Variables Domains Constraints F T U O R W X 1 X 2 X 3 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} AllDiff(F, T, U, O, R, W) O + O = R + 10∙X 1 X 1 + W + W = U + 10∙X 2 X 2 + T + T = O + 10∙X 3 X 3 = F F ≠ 0 T ≠ 0

University College Cork (Ireland) Department of Civil and Environmental Engineering Good news / Bad news o Good news – very general & interesting class problems o Bad news – includes NP-hard (intractable) problems So, good behavior is a function of domain not the formulation as a CSP R. Marinescu October-2009page 16

University College Cork (Ireland) Department of Civil and Environmental Engineering CSP example Given 40 courses (8.01, 8.02, …, 6.840) and 10 terms (Fall 1, Spring 1,,,, Spring 5). Find a legal schedule Constraints Pre-requisites Courses offered on limited terms Limited number of courses per term Avoid time conflicts Note: CSPs are not for expressing (soft) preferences, e.g. minimize difficulty, balance subject areas, etc R. Marinescu October-2009page 17

University College Cork (Ireland) Department of Civil and Environmental Engineering Choice of variables & values VARIABLESDOMAINS R. Marinescu October-2009page 18 A. Terms? Legal combinations of for example 4 courses (but this is huge set of values) B. Terms Slots? Courses offered during that term Subdivide terms into slots e.g. 4 of them (Fall 1,1) (Fall 1,2) (Fall 1,3) C. Courses? Terms or term slots (Term slots allow expressing constraints on limited number of courses/term)

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraints R. Marinescu October-2009page 19 Use courses as variables and term slots as values Prerequisite > Term before Term after For pairs of courses that must be ordered Courses offered only in some terms > Filter domain Avoid time conflicts> Term not equal For pairs offered at same or overlapping times

University College Cork (Ireland) Department of Civil and Environmental Engineering Solving CSPs o Solving CSPs involve some combination of: Constraint propagation, to eliminate values that could not be part of any solution Search, to explore valid assignments R. Marinescu October-2009page 20

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation (aka Arc Consistency) o Arc consistency eliminates values from domain of variable that can never be part of a consistent solution o Directed arc (V i, V j ) is arc consistent if R. Marinescu October-2009page 21

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation (aka Arc Consistency) o Arc consistency eliminates values from domain of variable that can never be part of a consistent solution o Directed arc (V i, V j ) is arc consistent if o We can achieve consistency on arc by deleting values from D i (domain of variable at tail of constraint arc) that fail condition R. Marinescu October-2009page 22

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation (aka Arc Consistency) o Arc consistency eliminates values from domain of variable that can never be part of a consistent solution o Directed arc (V i, V j ) is arc consistent if o We can achieve consistency on arc by deleting values from D i (domain of variable at tail of constraint arc) that fail condition o Assume domain size at most d and there are e binary constraints o A simple algorithm for arc consistency is O(ed 3 ) – note that just verifying arc consistency takes O(ed 2 ) for each arc R. Marinescu October-2009page 23

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 24 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 25 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted R, G, B R, GG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 26 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none R, G, B R, GG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 27 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) R, B R, GG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 28 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) R, B RG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 29 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) V 1 – V 2 V1(R)V1(R) B RG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 30 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) V 1 – V 2 V1(R)V1(R) V 1 – V 3 none B RG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 31 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) V 1 – V 2 V1(R)V1(R) V 1 – V 3 none V 2 – V 3 none B RG V1V1 V2V2 V3V3 CSP is arc-consistent

University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 32 R, G arc consistent but no solutions Graph coloring

University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 33 R, G arc consistent but no solutions Graph coloring B, G R, G arc consistent but 2 solutions: B,R,G; B,G,R

University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 34 R, G arc consistent but no solutions Graph coloring B, G R, G arc consistent but 2 solutions: B,R,G; B,G,R B, G R, G arc consistent but 1 solutions: B,R,G; Assume B, R not allowed

University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 35 R, G arc consistent but no solutions Graph coloring B, G R, G arc consistent but 2 solutions: B,R,G; B,G,R B, G R, G arc consistent but 1 solutions: B,R,G; Assume B, R not allowed Need to search to find solutions (if any)

University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) o Standard search formulation Initial state : the empty assignment {} Successor function : assign a value to an unassigned variable that does not conflict with the current assignment  fail is no legal assignments Goal test : the current assignment is complete 1.This is the same for all CSPs 2.Every solution appears at depth n (for n variables) 3.Path is irrelevant 4.Depth-first search for CSPs is called backtracking 5.Variable assignments are commutative (e.g., [WA=red then NT=blue] is the same as [NT=blue then WA=red] R. Marinescu October-2009page 36

University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 37 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3

University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 38 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment

University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 39 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment

University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 40 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment Inconsistent with V 2 = G

University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 41 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment Inconsistent with V 2 = G consistent

University College Cork (Ireland) Department of Civil and Environmental Engineering Combine backtracking and constraint propagation o A node in BT tree is partial assignment in which the domain of each variable has been set (tentatively) to singleton set o Use constraint propagation (arc-consistency) to propagate the effect of this tentative assignment i.e., eliminate values inconsistent with current values R. Marinescu October-2009page 42

University College Cork (Ireland) Department of Civil and Environmental Engineering Combine backtracking and constraint propagation o A node in BT tree is partial assignment in which the domain of each variable has been set (tentatively) to singleton set o Use constraint propagation (arc-consistency) to propagate the effect of this tentative assignment i.e., eliminate values inconsistent with current values o Question: how much propagation to do? R. Marinescu October-2009page 43

University College Cork (Ireland) Department of Civil and Environmental Engineering Combine backtracking and constraint propagation o A node in BT tree is partial assignment in which the domain of each variable has been set (tentatively) to singleton set o Use constraint propagation (arc-consistency) to propagate the effect of this tentative assignment i.e., eliminate values inconsistent with current values o Question: how much propagation to do? o Answer: not much, just local propagations from domains with unique assignments, which is called forward checking (FC). This conclusion is not necessarily obvious, but it generally holds in practice R. Marinescu October-2009page 44

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 45 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph R V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 46 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph R V 1 assignments V 2 assignments V 3 assignments R GG V1V1 V2V2 V3V3 G

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 47 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph R V 1 assignments V 2 assignments V 3 assignments R G V1V1 V2V2 V3V3 G We have a conflict whenever a domain becomes empty

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 48 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments When backing up, need to restore domain values, since deletions were done to reach consistency with tentative assignments considered during search G R, G, B R, G V1V1 V2V2 V3V3

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 49 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments G G RR V1V1 V2V2 V3V3

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 50 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments G G RR V1V1 V2V2 V3V3 R

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 51 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments G G RR V1V1 V2V2 V3V3 R

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 52 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 B

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 53 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B R, G V1V1 V2V2 V3V3 B R

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 54 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B RG V1V1 V2V2 V3V3 B R

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 55 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B RG V1V1 V2V2 V3V3 B R G

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 56 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B GR V1V1 V2V2 V3V3 B G R

University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 57 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B GR V1V1 V2V2 V3V3 B G R No need to check previous assignments Generally preferable to pure BT

University College Cork (Ireland) Department of Civil and Environmental Engineering BT-FC with dynamic ordering o Traditional backtracking uses fixed ordering of variables & values, e.g., random order or place variables with many constraints first o We can usually do better by choosing an order dynamically as the search proceeds R. Marinescu October-2009page 58

University College Cork (Ireland) Department of Civil and Environmental Engineering BT-FC with dynamic ordering o Traditional backtracking uses fixed ordering of variables & values, e.g., random order or place variables with many constraints first o We can usually do better by choosing an order dynamically as the search proceeds 1. Most constrained variable When doing forward-checking, pick variable with fewest legal values to assign next (minimizes branching factor) R. Marinescu October-2009page 59

University College Cork (Ireland) Department of Civil and Environmental Engineering BT-FC with dynamic ordering o Traditional backtracking uses fixed ordering of variables & values, e.g., random order or place variables with many constraints first o We can usually do better by choosing an order dynamically as the search proceeds 1. Most constrained variable When doing forward-checking, pick variable with fewest legal values to assign next (minimizes branching factor) 2. Least constraining value Choose value that rules out the fewest values from neighboring domains R. Marinescu October-2009page 60

University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint optimization problems o COP formulation Variables: X 1, X 2, …, X n with domains D 1, D 2, …, D n Constraints: C 1, C 2, …, C m Objective function: f(X 1, …, X n ) o Goal: find a solution that satisfies all constraints and minimizes the objective function o Example Maintenance scheduling in smart buildings: schedule a set of maintenance tasks (eg, clean rooms, repair outlet) such that there is no overlap between tasks and the sum of costs is minimized o Solution techniques Depth-first Branch-and-Bound search R. Marinescu October-2009page 61

University College Cork (Ireland) Department of Civil and Environmental Engineering Local search o In many problems, the path to the goal is irrelevant; the goal state itself is the solution o State space = set of "complete" configurations o Find configuration satisfying constraints, e.g., n- queens o In such cases, we can use local search algorithms which keep a single "current" state, try to improve it o Constant space. Good for offline and online search R. Marinescu October-2009page 62

University College Cork (Ireland) Department of Civil and Environmental Engineering Local search for CSPs o Hill-climbing, simulated annealing typically work with “complete” states, i.e., all variables assigned o Apply to CSPs Allow states with unsatisfied constraints Operators reassign variable values Variable selection  Randomly select any conflicted variable Value selection by min-conflict heuristic  Choose value that violates the fewest constraints  i.e., hill climbing: h(n) = total number of violated constraints R. Marinescu October-2009page 63

University College Cork (Ireland) Department of Civil and Environmental Engineering Example: 4-Queens problem o States: 4 queens in 4 columns (4 4 = 256 states) o Actions: move queen to column o Goal test: no attacks o Evaluation: h(n) = number of attacks o Given random initial state, can solve n-queens in almost constant time for arbitrary n with high probability (e.g., n = 10,000,000) R. Marinescu October-2009page 64

University College Cork (Ireland) Department of Civil and Environmental Engineering Summary o CSPs are a special kind of problem: states defined by values of a fixed set of variables goal test defined by constraints on variable values o Backtracking = depth-first search with one variable assigned per node o Variable ordering and value selection heuristics help significantly o Forward checking prevents assignments that guarantee later failure o Constraint propagation (e.g., arc consistency) does additional work to constrain values and detect inconsistencies R. Marinescu October-2009page 65