Constraint Satisfaction Problems Chapter 3, Section 7 and Chapter 4, Section 4.4 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section

Similar documents
Constraint Satisfaction

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Lecture 6: Constraint Satisfaction Problems (CSPs)

Example: Map-Coloring. Constraint Satisfaction Problems Western Australia. Example: Map-Coloring contd. Outline. Constraint graph

Constraint Satisfaction Problems

Constraint Satisfaction Problems (CSPs)

Constraints. CSC 411: AI Fall NC State University 1 / 53. Constraints

CSE 473: Artificial Intelligence

Outline. Best-first search

Constraint Satisfaction. AI Slides (5e) c Lin

Constraint Satisfaction Problems. Chapter 6

CS 188: Artificial Intelligence Fall 2008

Announcements. CS 188: Artificial Intelligence Fall Large Scale: Problems with A* What is Search For? Example: N-Queens

Week 8: Constraint Satisfaction Problems

Iterative improvement algorithms. Today. Example: Travelling Salesperson Problem. Example: n-queens

What is Search For? CSE 473: Artificial Intelligence. Example: N-Queens. Example: N-Queens. Example: Map-Coloring 4/7/17

Constraint Satisfaction Problems. A Quick Overview (based on AIMA book slides)

Outline. Best-first search

10/11/2017. Constraint Satisfaction Problems II. Review: CSP Representations. Heuristic 1: Most constrained variable

CS W4701 Artificial Intelligence

CS 188: Artificial Intelligence. Recap: Search

CS 188: Artificial Intelligence Fall 2011

Chapter 6 Constraint Satisfaction Problems

Announcements. CS 188: Artificial Intelligence Spring Today. A* Review. Consistency. A* Graph Search Gone Wrong

Constraint Satisfaction Problems

Announcements. Reminder: CSPs. Today. Example: N-Queens. Example: Map-Coloring. Introduction to Artificial Intelligence

Artificial Intelligence Constraint Satisfaction Problems

Announcements. CS 188: Artificial Intelligence Fall 2010

CS 188: Artificial Intelligence Spring Announcements

CS 188: Artificial Intelligence Fall 2011

What is Search For? CS 188: Artificial Intelligence. Example: Map Coloring. Example: N-Queens. Example: N-Queens. Constraint Satisfaction Problems

Australia Western Australia Western Territory Northern Territory Northern Australia South Australia South Tasmania Queensland Tasmania Victoria

Today. CS 188: Artificial Intelligence Fall Example: Boolean Satisfiability. Reminder: CSPs. Example: 3-SAT. CSPs: Queries.

Constraint Satisfaction Problems

Space of Search Strategies. CSE 573: Artificial Intelligence. Constraint Satisfaction. Recap: Search Problem. Example: Map-Coloring 11/30/2012

CS 4100 // artificial intelligence

Announcements. CS 188: Artificial Intelligence Fall Reminder: CSPs. Today. Example: 3-SAT. Example: Boolean Satisfiability.

CS 188: Artificial Intelligence Fall 2008

Constraint Satisfaction Problems

Map Colouring. Constraint Satisfaction. Map Colouring. Constraint Satisfaction

Constraint Satisfaction Problems

Constraint Satisfaction. CS 486/686: Introduction to Artificial Intelligence

Recap: Search Problem. CSE 473: Artificial Intelligence. Space of Search Strategies. Constraint Satisfaction. Example: N-Queens 4/9/2012

Announcements. CS 188: Artificial Intelligence Spring Production Scheduling. Today. Backtracking Search Review. Production Scheduling

Constraint Satisfaction Problems. slides from: Padhraic Smyth, Bryan Low, S. Russell and P. Norvig, Jean-Claude Latombe

CS 188: Artificial Intelligence Spring Announcements

CS 343: Artificial Intelligence

CS 188: Artificial Intelligence Spring Today

Constraint satisfaction search. Combinatorial optimization search.

Announcements. Homework 1: Search. Project 1: Search. Midterm date and time has been set:

Announcements. Homework 4. Project 3. Due tonight at 11:59pm. Due 3/8 at 4:00pm

What is Search For? CS 188: Artificial Intelligence. Constraint Satisfaction Problems

CS 188: Artificial Intelligence. What is Search For? Constraint Satisfaction Problems. Constraint Satisfaction Problems

Constraint Satisfaction Problems Part 2

CS 188: Artificial Intelligence

CS 188: Artificial Intelligence

K-Consistency. CS 188: Artificial Intelligence. K-Consistency. Strong K-Consistency. Constraint Satisfaction Problems II

CS 188: Artificial Intelligence

Artificial Intelligence

Material. Thought Question. Outline For Today. Example: Map-Coloring EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Constraint satisfaction search

CONSTRAINT SATISFACTION

CS 771 Artificial Intelligence. Constraint Satisfaction Problem

Announcements. CS 188: Artificial Intelligence Spring Today. Example: Map-Coloring. Example: Cryptarithmetic.

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 30 January, 2018

Constraint Satisfaction Problems

Constraint satisfaction search. Combinatorial optimization search.

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Informed (heuristic) search (cont). Constraint-satisfaction search.

Local Search. (Textbook Chpt 4.8) Computer Science cpsc322, Lecture 14. May, 30, CPSC 322, Lecture 14 Slide 1

Moving to a different formalism... SEND + MORE MONEY

CS 4100/5100: Foundations of AI

CONSTRAINT SATISFACTION

Foundations of Artificial Intelligence

Artificial Intelligence

Artificial Intelligence

Example: Map coloring

Games and Adversarial Search II Alpha-Beta Pruning (AIMA 5.3)

ARTIFICIAL INTELLIGENCE (CS 370D)

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on Artificial Intelligence,

Constraint Satisfaction Problems. Chapter 6

Informed search algorithms. Chapter 4

Spezielle Themen der Künstlichen Intelligenz

CONSTRAINT SATISFACTION

Local Search for CSPs

Constraint Satisfaction Problems. Some material from: D Lin, J You, JC Latombe

Constraint Satisfaction Problems

Lecture 18. Questions? Monday, February 20 CS 430 Artificial Intelligence - Lecture 18 1

Local Search. (Textbook Chpt 4.8) Computer Science cpsc322, Lecture 14. Oct, 7, CPSC 322, Lecture 14 Slide 1

1. (15 points) Consider the crossword puzzle

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

Informed search algorithms. (Based on slides by Oren Etzioni, Stuart Russell)

Constraint satisfaction problems. CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop

Artificial Intelligence

Module 4. Constraint satisfaction problems. Version 2 CSE IIT, Kharagpur

Problem Solving Agents

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 6 February, 2018

Transcription:

Constraint Satisfaction Problems Chapter 3, Section 7 and Chapter 4, Section 4.4 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 1

Outline } CSP examples } General search applied to CSPs } Backtracking } Forward checking } Heuristics for CSPs AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 2

CSP: is dened by variables V i with values from domain D i state Simple example of a formal representation language Constraint satisfaction problems (CSPs) search problem: Standard is a \black box" any old data structure state that supports goal test, eval, successor test is a set of constraints specifying goal combinations of values for subsets of variables allowable useful general-purpose algorithms with more power Allows standard search algorithms than AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 3

Variables Q 1, Q 2, Q 3, Q 4 E.g., values for (Q 1 ;Q 2 ) are (1; 3) (1; 4) (2; 4) (3; 1) (4; 1) (4; 2) Example: 4-Queens as a CSP Assume one queen in each column. Which row does each one go in? Domains D i = f1; 2; 3; 4g Constraints i 6= Q j (cannot be in same row) Q jq i, Q j j6= ji, jj (or same diagonal) 1 Q = 1 Q 2 = 3 Translate each constraint into set of allowable values for its variables AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 4

Constraint graph Binary CSP: each constraint relates at most two variables Constraint graph: nodes are variables, arcs show constraints Q1 Q 2 Q 3 Q 4 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 5

= D + E or Y = D + E, 10, etc. Y 6= E, D 6= M, D 6= N, etc. D Example: Cryptarithmetic Variables N ORSY DEM S E N D Domains 1; 2; 3; 4; 5; 6; 7; 8; 9g f0; M O R E + O N E Y M Constraints 6= 0, S 6= 0(unary constraints) M AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 6

Variables C i Countries Example: Map coloring C C 1 2 Color a map so that no adjacant countries have the same color C 3 Domains Blue; Greeng fred; Constraints 1 6= C 2, C 1 6= C 5, etc. C C 5 C 6 C 4 C1 C2 Constraint graph: C 5 C 3 C 6 C 4 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 7

Real-world CSPs problems Assignment who teaches what class e.g., problems Timetabling which class is oered when and where? e.g., Hardware conguration Spreadsheets Transportation scheduling Factory scheduling Floorplanning Notice that many real-world problems involve real-valued variables AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 8

Applying standard search Let's start with the straightforward, dumb approach, then x it States are dened by the values assigned so far Initial state: all variables unassigned Operators: assign a value to an unassigned variable Goal test: all variables assigned, no constraints violated Notice that this is the same for all CSPs! AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 9

Implementation state keeps track of which variables have values so far CSP variable has a domain and a current value Each CSP-State datatype Unassigned, a list of variables not yet assigned components: Assigned, a list of variables that have values CSP-Var datatype Name, for i/o purposes components: Domain, a list of possible values Value, current value (if any) can be represented Constraints as sets of allowable values, or explicitly implicitly by a function that tests for satisfaction of the constraint AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 10

Standard search applied to map-coloring UNASSIGNED ASSIGNED C1 C2 C3 UNASSIGNED ASSIGNED C2 C3 C1 = RED UNASSIGNED ASSIGNED C1 C3 C2 = BLUE UNASSIGNED ASSIGNED C1 C2 C3 = GREEN AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 11

Complexity of the dumb approach Max. depth of space m =?? Depth of solution state d =?? Search algorithm to use?? Branching factor b =?? This can be improved dramatically by noting the following: Order of assignment is irrelevant, hence many paths are equivalent 1) Adding assignments cannot correct a violated constraint 2) AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 12

Complexity of the dumb approach Max. depth of space m =?? n (number of variables) Depth of solution state d =?? n (all vars assigned) Search algorithm to use?? depth-rst Branching factor b =?? i jd i j (at top of tree) This can be improved dramatically by noting the following: Order of assignment is irrelevant so many paths are equivalent 1) Adding assignments cannot correct a violated constraint 2) AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 13

Can solve n-queens for n 15 Backtracking search depth-rst search, but Use x the order of assignment, ) b = jd i j 1) be done in the Successors function) (can check for constraint violations 2) constraint violation check can be implemented in twoways: The modify Successors to assign only values that 1) allowed, given the values already assigned are 2) check constraints are satised before expanding a state or Backtracking search is the basic uninformed algorithm for CSPs AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 14

C 5 Can solve n-queens up to n 30 Forward checking Keep track of remaining legal values for unassigned variables Idea: search when any variable has no legal values Terminate Simplied map-coloring example: C 1 C C 5 4 red blue green 1 C 2 C C 2 3 C 4 C C 3 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 15

... p AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 16

... p AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 17

... p AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 18

Can solve n-queens for n 1000 Heuristics for CSPs intelligent decisions on More value to choose for each variable which which variable to assign next C C 1 2 C 3 C 1 = Red, C 2 = Green, choose C 3 =?? Given. C 5 C 6 C 4 C 1 = Red, C 2 = Green, what next?? Given. AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 19

Can solve n-queens for n 1000 Heuristics for CSPs intelligent decisions on More value to choose for each variable which which variable to assign next C C 1 2 C 3 C 1 = Red, C 2 = Green, choose C 3 =?? Given 3 = Green: least-constraining-value C C 1 = Red, C 2 = Green, what next?? Given 5 : most-constrained-variable C C 5 C 6 C 4 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 20

heuristic: min-conicts value that violates the fewest constraints choose Iterative algorithms for CSPs simulated annealing typically work with Hill-climbing, states, i.e., all variables assigned \complete" apply to CSPs: To states with unsatised constraints allow operators reassign variable values Variable selection: randomly select any conicted variable i.e., hillclimb with h(n) = total number of violated constraints AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 21

States: 4 queens in 4 columns (4 4 Example: 4-Queens = 256 states) Operators: move queen in column Goal test: no attacks Evaluation: h(n) = number of attacks h = 5 h = 2 h = 0 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 22

of constraints number of variables number Performance of min-conicts random initial state, can solve n-queens in almost constant time Given arbitrary n with high probability (e.g., n = 10,000,000) for same appears to be true for any randomly-generated CSP The in a narrow range of the ratio except R = CPU time critical ratio R AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 23

Compare to general CSPs, where worst-case time is O(jDj n ) A B D E C F Tree-structured CSPs if the constraint graph has no loops, the CSP can be solved Theorem: O(njDj 2 ) time in property also applies to logical and probabilistic reasoning: This important example of the relation between syntactic restrictions and an complexity of reasoning. AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 24

Algorithm for tree-structured CSPs Basic step is called ltering: i ;V j ) Filter(V values of V i that are inconsistent with ALL values of V j removes Filtering example: Vi Vj allowed pairs: < 1, 1 > < 3, 2 > < 3, 3 > remove 2 from domain of V i AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 25

2) For j = n to 1, apply Filter(V i ;V j ) where V i isaparent of V j A B D E C F Algorithm contd. Order nodes breadth-rst starting from any leaf: 1) A B C D E F 3) For j =1to n, pick legal value for V j given parent value AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 26

Summary are a special kind of problem: CSPs dened by values of a xed set of variables states goal test dened by constraints on variable values = depth-rst search with Backtracking xed variable order 1) 2) only legal successors Forward checking prevents assignments that guarantee later failure Variable ordering and value selection heuristics help signicantly Iterative min-conicts is usually eective in practice Tree-structured CSPs can always be solved very eciently AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section 7 and Chapter 4, Section 4.4 27