ARTIFICIAL INTELLIGENCE (CS 370D)

Similar documents
Constraint Satisfaction Problems Part 2

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

Reading: Chapter 6 (3 rd ed.); Chapter 5 (2 nd ed.) For next week: Thursday: Chapter 8

Constraint Satisfaction Problems (CSPs) Introduction and Backtracking Search

Constraint Satisfaction Problems

CS 771 Artificial Intelligence. Constraint Satisfaction Problem

Constraint Satisfaction Problems

Constraint Satisfaction Problems

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

Constraint Satisfaction Problems

Constraint Satisfaction

Spezielle Themen der Künstlichen Intelligenz

Constraint Satisfaction Problems

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

Discussion Section Week 1

Lecture 6: Constraint Satisfaction Problems (CSPs)

Constraint Satisfaction Problems

Constraint Satisfaction Problems (CSPs)

CS 188: Artificial Intelligence Fall 2011

Chapter 6 Constraint Satisfaction Problems

Constraint Satisfaction Problems. Chapter 6

Week 8: Constraint Satisfaction Problems

Constraint Satisfaction Problems

Constraint Satisfaction. AI Slides (5e) c Lin

CS W4701 Artificial Intelligence

CSE 473: Artificial Intelligence

CS 343: Artificial Intelligence

Announcements. CS 188: Artificial Intelligence Fall 2010

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

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

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

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

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

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

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

Artificial Intelligence Constraint Satisfaction Problems

Artificial Intelligence

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

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

CS 188: Artificial Intelligence. Recap: Search

Constraint Satisfaction Problems

Outline. Best-first search

Foundations of Artificial Intelligence

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

Solving Problems by Searching: Constraint Satisfaction Problems

CS 188: Artificial Intelligence Fall 2011

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

Outline. Best-first search

Constraint Satisfaction Problems

Artificial Intelligence

Artificial Intelligence

CS 4100 // artificial intelligence

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

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

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

Constraint Satisfaction Problems

CS 188: Artificial Intelligence Spring Announcements

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

Constraint Satisfaction Problems

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

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

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

Constraint Satisfaction Problems

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

CS 188: Artificial Intelligence Fall 2008

CS 188: Artificial Intelligence Spring Announcements

General Methods and Search Algorithms

CS 4100/5100: Foundations of AI

AI Fundamentals: Constraints Satisfaction Problems. Maria Simi

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

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

Review I" CMPSCI 383 December 6, 2011!

CMU-Q Lecture 7: Searching in solution space Constraint Satisfaction Problems (CSPs) Teacher: Gianni A. Di Caro

What is Search For? CS 188: Ar)ficial Intelligence. Constraint Sa)sfac)on Problems Sep 14, 2015

Constraint Satisfaction Problems

Constraint Satisfaction Problems

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

Review Adversarial (Game) Search ( ) Review Constraint Satisfaction ( ) Please review your quizzes and old CS-271 tests

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

CS 188: Artificial Intelligence

CONSTRAINT SATISFACTION

CS 188: Artificial Intelligence

Constraint Satisfaction

CS 188: Artificial Intelligence. Recap Search I

Mathematical Programming Formulations, Constraint Programming

Constraint satisfaction search. Combinatorial optimization search.

Comments about assign 1. Quick search recap. Constraint Satisfaction Problems (CSPs) Search uninformed BFS, DFS, IDS. Adversarial search

Lecture 9 Arc Consistency

Local Search and Constraint Reasoning. CS 510 Lecture 3 October 6, 2009

constraint propagation, answer set programming CS 4100/5100 Foundations of AI

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

Example: Map coloring

Introduction. 2D1380 Constraint Satisfaction Problems. Outline. Outline. Earlier lectures have considered search The goal is a final state

Constraint Satisfaction Problems (Backtracking Search)

Constraint satisfaction search

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

Transcription:

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D)

(CHAPTER-6) CONSTRAINT SATISFACTION PROBLEMS

Outline What is a CSP CSP applications Backtracking search Problem structure and decomposition 3

Mean of Constraint Satisfaction Problems 4

Constraint Satisfaction Problems A constraint satisfaction problem consists of three components, X is a set of variables, {Xi,., XT,}. X, D, and C D is a set of domains, {Di,, Dn.}, one for each variable. C is a set of constraints that specify allowable values. Each constraint C i limits the values that variables can take, e.g., V V 2 A state is defined as an assignment of values to some or all variables. 5

CSPs (continued) An assignment is complete when every variable is mentioned. A solution to a CSP is a complete assignment that satisfies all constraints. Some CSPs require a solution that maximizes an objective function. 6

Varieties of constraints Unary constraints involve a single variable. e.g. SA green Binary constraints involve pairs of variables. e.g. SA WA Higher-order constraints involve 3 or more variables. Professors A, B,and C cannot be on a committee together Can always be represented by multiple binary constraints Preference (soft constraints) e.g. red is better than green often can be represented by a cost for each variable assignment combination of optimization with CSPs 7

Constraint Satisfaction Applications 8

CSPs (continued) Examples of Applications Scheduling : Scheduling the timetable of lectures Airline schedules Scheduling your MS or PhD thesis exam Configuration To arrange objects of different sizes in a container, Map Coloring. CSP solvers can be faster than state-space searchers because the CSP solver can quickly eliminate large swatches of the search space. 9

Example problem timetable of university () state - collection of schedule objects schedule professor(~0 2 ) (~350 at LU) course (~0 3 ) time slot (~0) (6 at LU) location (~0 2 ) constraints objective function 0

Example problem timetable of university () Constraints professors assigned to courses one course per location per time slot location capacity >= course (projected) enrollment professors assigned only once per time slot rooms assigned only once per time slot courses in program in different time slots

Example problem timetable of university () objective function minimize total course enrollment in early morning time slots distribute program courses across days accommodate special requests 2

Solving CSPs analysis of problem state structure is critical two basic approaches: start state is null: assign state variables one at a time and backtrack if constraint is violated assign variables randomly/intelligently to make a start state and use greedy search by changing variable assignments 3

CSP example: map coloring Variables: WA, NT, Q, NSW, V, SA, T Domains: D i ={red,green,blue} Constraints: adjacent regions must have different colors. 4 E.g. WA NT

CSP example: map coloring Solutions are assignments satisfying all constraints, e.g. {WA=red,NT=green,Q=red,NSW=green,V=red,SA=blue,T=green} 5

Solving CSPs As general searching problem. Back-Tracking. Arc-consistency Checking. Heuristics. 6

As General Searching Problem 7

CSP as a standard search problem A CSP can easily be expressed as a standard search problem. Incremental formulation Initial State: the empty assignment {} Successor function: Assign a value to any unassigned variable provided that it does not violate a constraint Goal test: the current assignment is complete (by construction its consistent) Path cost: constant cost for every step (not really relevant) 8

Backtracking Search 9

Backtracking Search Variable assignments are commutative if the order of any given set of actions has no effect on the outcome. i.e., [WA = red then NT = green] same as [NT = green then WA = red]. Only need to consider assignments to a single variable at each node. and backtracks when a variable has no legal values left to assign. Depth-first search for CSPs with single-variable assignments is called Backtracking Search: Chooses values for one variable at a time. Checks for constraint violations at each assignment. Backtracks when a variable has no legal values left to ass 20

Backtracking search function BACKTRACKING-SEARCH(csp) return a solution or failure return RECURSIVE-BACKTRACKING({}, csp) function RECURSIVE-BACKTRACKING(assignment, csp) return a solution or failure if assignment is complete then return assignment var SELECT-UNASSIGNED-VARIABLE(VARIABLES[csp],assignment,csp) for each value in ORDER-DOMAIN-VALUES(var, assignment, csp) do if value is consistent with assignment according to CONSTRAINTS [csp] then return failure 2 add {var=value} to assignment result RRECURSIVE-BACTRACKING(assignment, csp) if result failure then return result remove {var=value} from assignment Backtacking

Backtracking example 22

Backtracking example 23

Backtracking example 24

Backtracking example Constraints on SA will eventually cause failure when WA!= Q. When not the same color (bottom right), SA cannot be assigned. The algorithm will backtrack to a node with unexplored states. For example, such as WA=red, NT=blue. 25

Improving Backtracking Efficiency Consider Which variable should be assigned next? In what order should the variables be tried? Can we detect inevitable failure early? Can we take advantage of problem structure? 26

Most Constrained Variable or minimum remaining values (MRV) Heuristic Rule: Choose the variable with the fewest legal values. Idea is that variable with fewest choices will likely fail sooner allowing branch to be pruned early. Legal values are those that do not conflict with any already assigned to a neighbor (i.e. do not violate constrains). After WA=red, NT and SA have only 2 remaining legal values, the other unassigned variables all have 3. Choose between NT and SA. 27

Most constraining variable Choose the variable that constrains the most remaining variables SA places constrains on 5 variables; WA, NT, Q, V, NSW only on 3, T on 0. Purpose is to prune early by reducing number of choices. Tie breaker among minimum remaining variables (MRV) 28

Least Constraining Value Heuristic Rule: Given a variable, choose the least constraining value Idea is to explore paths, those with most options, most likely to lead to a solution. 29

Forward checking Can we detect inevitable failure early? And avoid it later? Forward checking idea: keep track of remaining legal values for unassigned variables. Terminate search when any variable has no legal values. 30

Forward checking Assign {WA=red} Effects on other variables connected by constraints to WA NT can no longer be red SA can no longer be red 3

Forward checking Assign {Q=green} Effects on other variables connected by constraints with WA NT can no longer be green NSW can no longer be green SA can no longer be green

Forward checking If V is assigned blue Effects on other variables connected by constraints with WA NSW can no longer be blue SA is empty FC has detected that partial assignment is inconsistent with the constraints and backtracking can occur.

Forward checking Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,2,3,4} 2 3 4 X3 {,2,3,4} X4 {,2,3,4} 34 34

Forward checking Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,2,3,4} 2 3 4 X3 {,2,3,4} X4 {,2,3,4} 35 35

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,3,4} 2 3 4 X3 {,2,,4} X4 {,2,3, } 36 36

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,3,4} 2 3 4 X3 {,2,,4} X4 {,2,3, } 37 37

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,3,4} 2 3 4 X3 {,,, } X4 {,,3, } 38 38

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,2,,4} X4 {,2,3, } 39 39

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,2,,4} X4 {,2,3, } 40 40

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,2,, } X4 {,,3, } 4 4

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,2,, } X4 {,,3, } 42 42

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,3,4} 2 3 4 X3 {,2,, } X4 {,,, } Dead End Backtrack 43 43

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {, 2,3,4} 2 3 4 X3 {,2, 3,4 } X4 {, 2, 3, 4 } 44 44

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,, 3, } X4 {,, 3, 4 } 45 45

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,, 3, } X4 {,, 3, 4 } 46 46

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,, 3, } X4 {,, 3, } 47 47

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,,, } X4 {,, 3, } 48 48

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,,, } X4 {,, 3, } 49 49

Example: 4-Queens Problem 2 3 4 X {,2,3,4} X2 {,,,4} 2 3 4 X3 {,,, } X4 {,, 3, } 50 Solution!!!! 50

Consistency Techniques removing inconsistent values from variables domains graph representation of the CSP arc consistency (AC)

Arc consistency Simplest form of propagation makes each arc consistent X Y is consistent iff for every value x of X there is some allowed y Arc from SA to NSW is consistent because SA (blue) allows NSW (red) 52

Arc consistency Arc from NSW to SA is not consistent because NSW (blue) does not allow SA (blue) Can be made consistent by removing blue from NSW domain 53

Arc consistency If X loses a value, neighbors of X need to be rechecked. After removing blue from NSW, must check neighbors for consistency leading to removal of red from V. 54

Arc consistency If X loses a value, neighbors of X need to be rechecked Arc consistency detects failure earlier than forward checking Can be run as a preprocessor or after each assignment After removing blue, SA domain is {}, pruning SA completely for the two assignments {NSW=red, Q=green} and forcing backtracking. 55

Is the arc (WA,NSW) consistent? Is the arc (NSW,WA) consistent? If not, what should be the domain of NSW and WA? Is the arc (SA,T) consistent? is the arc (T, SA) consistent? 56

Thank you End of Chapter 6 57