Domain Splitting, Local Search CPSC 322 – CSP 4 Textbook §4.6, §4.8 February 4, 2011.

Slides:



Advertisements
Similar presentations
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Advertisements

Decision Theory: Sequential Decisions Computer Science cpsc322, Lecture 34 (Textbook Chpt 9.3) Nov, 28, 2012.
Local Search Jim Little UBC CS 322 – CSP October 3, 2014 Textbook §4.8
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) Oct, 5, 2012.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) Sept, 11, 2013.
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
CPSC 322, Lecture 10Slide 1 Finish Search Computer Science cpsc322, Lecture 10 (Textbook Chpt 3.6) January, 28, 2008.
CPSC 322, Lecture 16Slide 1 Stochastic Local Search Variants Computer Science cpsc322, Lecture 16 (Textbook Chpt 4.8) February, 9, 2009.
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 23, 2009.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CPSC 322, Lecture 19Slide 1 Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19 (Textbook Chpt ) February, 23, 2009.
Decision Theory: Single Stage Decisions Computer Science cpsc322, Lecture 33 (Textbook Chpt 9.2) March, 30, 2009.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) January, 12, 2009.
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) February, 3, 2010.
CPSC 322, Lecture 18Slide 1 Planning: Heuristics and CSP Planning Computer Science cpsc322, Lecture 18 (Textbook Chpt 8) February, 12, 2010.
CPSC 322, Lecture 10Slide 1 Finish Search Computer Science cpsc322, Lecture 10 (Textbook Chpt 3.6) January, 25, 2010.
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 22, 2010.
CPSC 322, Lecture 13Slide 1 CSPs: Arc Consistency & Domain Splitting Computer Science cpsc322, Lecture 13 (Textbook Chpt 4.5,4.6) February, 01, 2010.
CPSC 322, Lecture 15Slide 1 Stochastic Local Search Computer Science cpsc322, Lecture 15 (Textbook Chpt 4.8) February, 6, 2009.
CPSC 322, Lecture 30Slide 1 Reasoning Under Uncertainty: Variable elimination Computer Science cpsc322, Lecture 30 (Textbook Chpt 6.4) March, 23, 2009.
CPSC 322, Lecture 11Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Computer Science cpsc322, Lecture 11 (Textbook Chpt 4.0 – 4.2) January,
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CPSC 322, Lecture 12Slide 1 CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12 (Textbook Chpt ) January, 29, 2010.
CPSC 322, Lecture 13Slide 1 CSPs: Arc Consistency & Domain Splitting Computer Science cpsc322, Lecture 13 (Textbook Chpt 4.5,4.8) February, 02, 2009.
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) February, 4, 2009.
CPSC 322, Lecture 17Slide 1 Planning: Representation and Forward Search Computer Science cpsc322, Lecture 17 (Textbook Chpt 8.1 (Skip )- 8.2) February,
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) March, 8, 2010.
CPSC 322, Lecture 24Slide 1 Reasoning under Uncertainty: Intro to Probability Computer Science cpsc322, Lecture 24 (Textbook Chpt 6.1, 6.1.1) March, 15,
Planning: Wrap up CSP Planning. Logic: Intro CPSC 322 – Planning 3 Textbook §8.4, §5.1 March 2, 2011.
Slide 1 CSPs: Arc Consistency & Domain Splitting Jim Little UBC CS 322 – Search 7 October 1, 2014 Textbook §
Computer Science CPSC 322 Lecture 3 AI Applications 1.
Uninformed Search Strategies CPSC 322 – Search 2 January 14, 2011 Textbook §3.5 1.
Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Jim Little UBC CS 322 – CSP 1 September 27, 2014 Textbook §
Computer Science CPSC 322 Lecture 4 Search: Intro (textbook Ch: ) 1.
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) Oct, 26, 2010.
Department of Computer Science Undergraduate Events More
Local Search CPSC 322 – CSP 5 Textbook §4.8 February 7, 2011.
Computer Science CPSC 502 Lecture 3 Constraint Satisfaction Problems (Ch. 4 )
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Computer Science CPSC 322 Lecture 13 Arc Consistency (4.5, 4.6 ) Slide 1.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Computer Science CPSC 322 Lecture 16 CSP: wrap-up Planning: Intro (Ch 8.1) Slide 1.
Solving Constraint Satisfaction Problems (CSPs) using Search CPSC 322 – CSP 2 Textbook § January 31, 2011.
Solving Constraint Satisfaction Problems (CSPs) using Search
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Arc Consistency CPSC 322 – CSP 3 Textbook § 4.5 February 2, 2011.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) Sept, 12, 2012.
Logic: Proof procedures, soundness and correctness CPSC 322 – Logic 2 Textbook §5.2 March 7, 2011.
Arc Consistency and Domain Splitting in CSPs CPSC 322 – CSP 3 Textbook Poole and Mackworth: § 4.5 and 4.6 Lecturer: Alan Mackworth October 3, 2012.
CPSC 322, Lecture 16Slide 1 Stochastic Local Search Variants Computer Science cpsc322, Lecture 16 (Textbook Chpt 4.8) Oct, 11, 2013.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Decision Theory: Single & Sequential Decisions. VE for Decision Networks. CPSC 322 – Decision Theory 2 Textbook §9.2 April 1, 2011.
CPSC 322, Lecture 10Slide 1 Finish Search Computer Science cpsc322, Lecture 10 (Textbook Chpt 3.6) Sep, 26, 2010.
Constraint Satisfaction Problems (CSPs) Introduction
Computer Science cpsc322, Lecture 4
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 13
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Planning: Forward Planning and CSP Planning
Reasoning Under Uncertainty: Conditioning, Bayes Rule & Chain Rule
Computer Science cpsc322, Lecture 14
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 13
Computer Science cpsc322, Lecture 14
Domain Splitting CPSC 322 – CSP 4 Textbook §4.6 February 4, 2011.
Presentation transcript:

Domain Splitting, Local Search CPSC 322 – CSP 4 Textbook §4.6, §4.8 February 4, 2011

Discussion of feedback Pace –2 “fine”, 1 “could go faster” –2: recap too long, 3: “sometimes rushed later (as a consequence)” Coloured card questions –Some more explanation would be good –More consistent: get everyone to vote” Which parts are most important? –Definitions + algorithms. Examples are for illustration Hard concepts: –Arc consistency: today + work in AIspace + practice exercise –Alternative formulation of CSP as graph search: after class 2

Discussion of feedback Midterm: review & sample questions? –Midterm date confirmed: Mon, Feb 28, 3pm (1 to 1.5 hours, TBD) –Sample midterm has been on WebCT for ~2 weeks Topics: everything up to (including all of) CSP The topic of its question 2 (Planning based on CSP) won’t be on the midterm –Should we do a midterm review session? More explanation of practice exercises? –I’ll show where they are in WebCT –If you have trouble with them, please come to office hours How will what we learn eventually be applied in making an intelligent agent? –Game AI: lots of search –Reasoning under constraints is core to making intelligent decisions With CSPs, we’re right in the middle of it! 3

4 Course Overview Environment Problem Type Logic Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Variables + Constraints Variable Elimination Bayesian Networks Decision Networks Markov Processes Static Sequential Representation Reasoning Technique Uncertainty Decision Theory Course Module Variable Elimination Value Iteration Planning We’ll now focus on CSP

Lecture Overview Arc consistency -Recap -Complexity analysis -Domain Splitting Intro to Local Search Slide 5

Arc Consistency Definition: An arc is arc consistent if for each value x in dom(X) there is some value y in dom(Y) such that r(x,y) is satisfied. A network is arc consistent if all its arcs are arc consistent. 1,2,3 2,3 A B A< B Not arc consistent: No value in domain of B that satisfies A<B if A=3 Arc consistent: Both B=2 and B=3 have ok values for A (e.g. A=1)

Arc Consistency {2,3} {3} A B A< B Not arc consistent: No value in domain of B that satisfies A<B if A=3 A>C {1,2} C Arc consistent: For each value in dom(C), there is one in dom(A) that satisfies A>C (namely A=3)

Arc Consistency {2,3} {3} A B A< B A>C {1,2} C Not arc consistent anymore: For C=2, there is no value in dom(A) that satisfies A>C

Which arcs need to reconsidered? every arc  Z,c'  where c’  c involves Z and X: Z1Z1 c1c1 Z2Z2 c2c2 Z3Z3 c3c3 Y c THESETHESE X A c4c4 When we reduce the domain of a variable X to make an arc  X,c  arc consistent, which arcs do we need to reconsider? You do not need to reconsider other arcs - If an arc  X,c'  was arc consistent before, it will still be arc consistent - Nothing changes for arcs of constraints not involving X

Lecture Overview Arc consistency -Recap -Complexity analysis -Domain Splitting Intro to Local Search 10

How often will we prune the domain of variable V? O(d) times How many arcs will be put on the ToDoArc list when pruning domain of variable V? -O(degree of variable V) -In total, across all variables: sum of degrees of all variables = … 2*number of constraints, i.e. 2*c Together: we will only put O(dc) arcs on the ToDoArc list Checking consistency is O(d 2 ) for each of them Overall complexity: O(cd 3 ) Compare to O(d N ) of DFS!! Arc consistency is MUCH faster Arc Consistency Algorithm: Complexity Worst-case complexity of arc consistency procedure on a problem with N variables –let d be the max size of a variable domain –let c be the number of constraints

Lecture Overview Arc consistency -Recap -Complexity analysis -Domain Splitting Intro to Local Search 12

Can we have an arc consistent network with no solution? YES NO Example: vars A, B, C with domain {1, 2} and constraints A ≠ B, B ≠ C, A ≠ C Or see AIspace CSP applet Simple Problem 2

Domain splitting (or case analysis) Arc consistency ends: Some domains have more than one value  may or may not have a solution A. Apply Depth-First Search with Pruning or B. Split the problem in a number of disjoint cases: CSP with dom(X) = {x 1, x 2, x 3, x 4 } becomes CSP 1 with dom(X) = {x 1, x 2 } and CSP 2 with dom(X) = {x 3, x 4 } Solution to CSP is the union of solutions to CSP i 14

Domain splitting Each smaller CSP is easier to solve –Arc consistency might already solve it For each subCSP, which arcs have to be on the ToDoArcs list when we get the subCSP by splitting the domain of X? arcs arcs and All arcs A1A1 c1c1 A2A2 c2c2 A3A3 c3c3 Y c THESETHESE X A c4c4 THISTHIS

Trace it on “simple problem 2” Domain splitting in action

If domains with multiple values Split on one Searching by domain splitting 17 How many CSPs do we need to keep around at a time? With depth m and b children at each split: O(bm). It’s a DFS CSP, apply AC CSP 1, apply AC CSP n, apply AC If domains with multiple values Split on one If domains with multiple values…..Split on one

Learning Goals up to here Define/read/write/trace/debug the arc consistency algorithm. Compute its complexity and assess its possible outcomes Define/read/write/trace/debug domain splitting and its integration with arc consistency 18

Lecture Overview Arc consistency -Recap -Complexity analysis -Domain Splitting Intro to Local Search 19

Solving a CSP is NP hard -Search space for many CSPs is huge -Exponential in the number of variables -Even arc consistency with domain splitting isn’t enough Alternative: local search –Algorithms that often find a solution quickly –But that cannot prove that there is no solution Useful method in practice –Best available method for many constraint satisfaction and constraint optimization problems –Extremely general! –Works for problems other than CSPs –E.g. arc consistency only works for CSPs Local Search: Why

Local Search Idea: –Consider the space of complete assignments of values to variables (all possible worlds) –Neighbours of a current node are similar variable assignments –Move from one node to another according to a function that scores how good each assignment is

Local Search Problem: Definition 22 Definition: A local search problem consists of a: CSP: a set of variables, domains for these variables, and constraints on their joint values. A node in the search space will be a complete assignment to all of the variables. Neighbour relation: an edge in the search space will exist when the neighbour relation holds between a pair of nodes. Scoring function: this can be used to incorporate information about how many constraints are violated. It can also incorporate information about the cost of the solution in an optimization context.

Example: Sudoku as a local search problem CSP: usual Sudoku CSP -One variable per cell; domains {1,…,9}; -Constraints: each number occurs once per row, per column, and per 3x3 box Neighbour relation: value of a single cell differs Scoring function: number of constraint violations

V 1 = v 1,V 2 = v 1,.., V n = v 1 Search Space V 1 = v 2,V 2 = v 1,.., V n = v 1 V 1 = v 4,V 2 = v 1,.., V n = v 1 V 1 = v 1,V 2 = v n,.., V n = v 1 V 1 = v 4,V 2 = v 2,.., V n = v 1 V 1 = v 4,V 2 = v 3,.., V n = v 1 V 1 = v 4,V 2 = v 1,.., V n = v 2 Only the current node is kept in memory at each step. Very different from the search approaches we have seen so far! Local search does NOT backtrack!

25 Example: Hill climbing for Sudoku Assign random numbers between 1 and 9 to blank fields

26 Example: Hill climbing for Sudoku Assign random numbers between 1 and 9 to blank fields Repeat –For each cell & each number: Evaluate how many constraint violations the assignment would yield –Choose the cell and number that leads to the fewest violated constraints; change it Until solved

Example: Hill climbing for Sudoku Example for one local search step: Reduces #constraint violations by 3: -Two 1s in the first column -Two 1s in the first row -Two 1s in the top-left box

General Local Search Algorithm You can be smart about selecting a variable and a new value for it: variable and value selection heuristics Based on local information. E.g., for each neighbour, you can evaluate how many constraints are unsatisfied. Hill climbing: select Y and V to minimize #unsatisfied constraints at each step

Learning Goals for local search (started) Implement local search for a CSP. –Implement different ways to generate neighbors –Implement scoring functions to solve a CSP by local search through either greedy descent or hill-climbing. Assignment 1 is due on Monday Local search practice exercise is on WebCT Programming assignment (part of assignment #2) is available on WebCT (due Wednesday, Feb 23 rd ) Coming up: more local search, Section 4.8