Constraint Satisfaction Problems (CSPs)

Similar documents
Branch & Bound (B&B) and Constraint Satisfaction Problems (CSPs)

CSPs: Search and Arc Consistency

Lecture 9 Arc Consistency

CSE 473: Artificial Intelligence

CS 188: Artificial Intelligence Fall 2011

Announcements. CS 188: Artificial Intelligence Fall 2010

Constraint Satisfaction Problems

Planning: Wrap up CSP Planning Logic: Intro

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

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

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

Artificial Intelligence

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

Artificial Intelligence Constraint Satisfaction Problems

CS 343: Artificial Intelligence

Agent Design Example Problems State Spaces. Searching: Intro. CPSC 322 Search 1. Textbook Searching: Intro CPSC 322 Search 1, Slide 1

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. CS 188: Artificial Intelligence Spring Today. Example: Map-Coloring. Example: Cryptarithmetic.

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

Constraint Satisfaction Problems (CSPs)

CS 4100 // artificial intelligence

Class2: Constraint Networks Rina Dechter

Constraint Satisfaction Problems. Chapter 6

Constraint Satisfaction

Name: UW CSE 473 Midterm, Fall 2014

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

Uninformed Search Strategies

Domain Splitting CPSC 322 CSP 4. Textbook 4.6. February 4, 2011

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

Constraint Satisfaction Problems. Chapter 6

Local Search for CSPs

Arc Consistency and Domain Splitting in CSPs

Today. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 5. Constraint Satisfaction Problems (CSP) CSP Definition

Constraint Networks. Constraint networks. Definition. Normalized. Constraint Networks. Deduction. Constraint. Networks and Graphs. Solving.

Constraint Satisfaction Problems

CS 188: Artificial Intelligence. Recap: Search

Set 5: Constraint Satisfaction Problems Chapter 6 R&N

Constraint Satisfaction Problems

Introduction. Bernhard Nebel, Julien Hué, and Stefan Wölfl. April 23, 2012

CS W4701 Artificial Intelligence

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Class2: Constraint Networks Rina Dechter

Constraint Satisfaction. AI Slides (5e) c Lin

Lecture 6: Constraint Satisfaction Problems (CSPs)

Outline. Best-first search

Artificial Intelligence

CONSTRAINT Networks Chapters 1-2

Search. (Textbook Chpt ) Computer Science cpsc322, Lecture 2. May, 10, CPSC 322, Lecture 2 Slide 1

Constraint Satisfaction Problems

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

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

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

Potential Midterm Exam Questions

Constraint Satisfaction Problems. Constraint Satisfaction Problems. Constraint networks. 1 Constraint Networks. 1 Constraint Networks

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

Set 5: Constraint Satisfaction Problems

Constraint Satisfaction Problems (CSP)

Index. optimal package assignments, 143 optimal package assignments, symmetrybreaking,

Artificial Intelligence

Constraint Satisfaction Problems (CSPs) Introduction and Backtracking Search

University of British Columbia, CPSC 322, Winter 2009 Assignment on Constraint Satisfaction Problems

1 Inference for Boolean theories

Slides for Faculty Oxford University Press All rights reserved.

Chapter 6 Constraint Satisfaction Problems

Set 5: Constraint Satisfaction Problems

Logic: TD as search, Datalog (variables)

Set 5: Constraint Satisfaction Problems

Week 8: Constraint Satisfaction Problems

Constraint Satisfaction Problems (CSPs) Lecture 4 - Features and Constraints. CSPs as Graph searching problems. Example Domains. Dual Representations

G53CLP Constraint Logic Programming

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

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

Constraint Satisfaction Problems (CSP) (Where we postpone making difficult

Decision Theory: Single & Sequential Decisions. VE for Decision Networks.

1. [5 points each] True or False. If the question is currently open, write O or Open.

Recitation 3 Problems

CMPSCI 250: Introduction to Computation. Lecture #24: General Search, DFS, and BFS David Mix Barrington 24 March 2014

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Uninformed Search. CPSC 322 Lecture 5. September 14, 2007 Textbook 2.4. Graph Search Searching Depth-First Search

Constraint Satisfaction Problems

1. (15 points) Consider the crossword puzzle

521495A: Artificial Intelligence

Map Colouring. Constraint Satisfaction. Map Colouring. Constraint Satisfaction

Constraint (Logic) Programming

Constraint Satisfaction Problems

CONSTRAINT SATISFACTION

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

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

PART 1 GRAPHICAL STRUCTURE

Section Marks Pre-Midterm / 32. Logic / 29. Total / 100

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

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

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

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

CS 188: Artificial Intelligence Fall 2008

Relational Database: The Relational Data Model; Operations on Database Relations

Transcription:

Constraint Satisfaction Problems (CSPs) CPSC 322 CSP 1 Poole & Mackworth textbook: Sections 4.0-4.2 Lecturer: Alan Mackworth September 28, 2012

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

Lecture Overview Representations: States vs. Features (Variables) Variables and Possible Worlds Constraints Constraint Satisfaction Problems (CSPs) 3

Main Representational Dimensions (Lecture 2) Domains can be classified by the following dimensions: 1. Uncertainty Deterministic vs. stochastic domains 2. How many actions does the agent need to perform? Static vs. sequential domains An important design choice is: 3. Representation scheme Explicit states vs. features (vs. relations) 4

Explicit State vs. Features (Lecture 2) How do we model the environment? You can enumerate the possible states of the world A state can be described in terms of features Assignment to (one or more) variables Often the more natural description 30 binary features can represent 2 30 =1,073,741,824 states 5

Lecture Overview Representations: States vs. Features (Variables) Variables and Possible Worlds Constraints Constraint Satisfaction Problems (CSPs) 6

Variables/Features and Possible Worlds Variable: a synonym for feature We denote variables using capital letters Each variable V has a domain dom(v) of possible values Variables can be of several main kinds: Boolean: dom(v) = 2 e.g. {true, false} Finite: dom(v) is finite e.g. {1, 2, 3, 4, 5} Infinite but discrete: the domain is countably infinite e.g. the positive integers, {1, 2, 3, } Continuous: e.g., real numbers from 0 to 1, [0,1] Possible world Complete assignment of values to each variable In contrast, states also include partial assignments 7

Examples: variables, domains, possible worlds Crossword Puzzle: variables are words that have to be filled in domains are English words of correct length possible worlds: all ways of assigning words Crossword 2: variables are cells (individual squares) domains are letters of the alphabet possible worlds: all ways of assigning letters to cells 8

How many possible worlds? Crossword Puzzle: variables are words that have to be filled in domains are English words of correct length possible worlds: all ways of assigning words Number of English words? Let s say 150,000 Of the right length? Assume for simplicity: 15,000 for each word Number of words to be filled in? 63 How many possible worlds? (assume any combination is ok) 15000*63 15000 63 63 15000 9

How many possible worlds? Crossword 2: variables are cells (individual squares) domains are letters of the alphabet possible worlds: all ways of assigning letters to cells Number of empty cells? 15*15 32 = 193 Number of letters in the alphabet? 26 How many possible worlds? (assume any combination is ok) 193*26 193 26 26 193 In general: (domain size) #variables (only an upper bound) 10

Examples: variables, domains, possible worlds Sudoku variables are cells domains are numbers between 1 and 9 possible worlds: all ways of assigning numbers to cells 11

Examples: variables, domains, possible worlds Scheduling Problem: variables are different tasks that need to be scheduled (e.g., course in a university; job in a machine shop) domains are the different combinations of times and locations for each task (e.g., time/room for course; time/machine for job) possible worlds: time/location assignments for each task n-queens problem variable: location of a queen on a chess board there are n of them in total, hence the name domains: grid coordinates possible worlds: locations of all queens 12

Lecture Overview Representations: States vs. Features (Variables) Variables and Possible Worlds Constraints Constraint Satisfaction Problems (CSPs) 13

Constraints 1 Constraints are restrictions on the values that one or more variables can take Unary constraint: restriction involving a single variable of course, we could also achieve the same thing by using a smaller domain in the first place k-ary constraint: restriction involving k different variables We will mostly deal with binary constraints (k=2 variables) Constraints can be specified by 1. listing all combinations of valid domain values for the variables participating in the constraint (or listing all invalid combinations) 2. giving a function (predicate) that returns true when given values for each variable which satisfy the constraint 14

Constraints 2 A possible world satisfies a set of constraints If, in that possible world, the values for the variables involved in each constraint are consistent with that constraint: either: Elements of the list of valid domain values or: Function returns true for those values 15

Examples: variables, domains, constraints Crossword Puzzle: variables are words that have to be filled in domains are English words of correct length (binary) constraints: two words have the same letter at character where they intersect Crossword 2: variables are cells (individual squares) domains are letters of the alphabet (k-ary) constraints: sequences of letters form valid English words 16

Examples: variables, domains, constraints Sudoku variables are cells domains are numbers between 1 and 9 constraints: rows, columns, boxes contain all different numbers: they are each a permutation of {1, 2, 3, 4, 5, 6, 7, 8, 9} 17

Examples: variables, domains, constraints Scheduling Problem: variables are different tasks that need to be scheduled (e.g., course in a university; job in a machine shop) domains are the different combinations of times and locations for each task (e.g., time/room for course; time/machine for job) constraints: tasks can't be scheduled in the same location at the same time; certain tasks can't be scheduled in different locations at the same time; some tasks must come earlier than others; etc. n-queens problem variable: location of a queen on a chess board there are n of them in total, hence the name domains: grid coordinates constraints: no queen can attack another 18

Lecture Overview Representations: States vs. Features (Variables) Variables and Possible Worlds Constraints Constraint Satisfaction Problems (CSPs) 19

Constraint Satisfaction Problems: Definition Definition: A constraint satisfaction problem (CSP) consists of: a set of variables a domain for each variable a set of constraints Definition: A model of a CSP is an assignment of values to all of its variables that satisfies all of its constraints. 20

Constraint Satisfaction Problems: Variants We may want to solve the following problems with a CSP: determine whether or not a model exists find a model find all of the models count the number of models find the best model, given some measure of model quality this is now an optimization problem determine whether some property of the variables holds in all models 21

Constraint Satisfaction Problems: Game Plan Even the simplest problem of determining whether or not a model exists in a general CSP with finite domains is NPhard There is no known algorithm with worst case polynomial runtime We can't hope to find an algorithm that is efficient for all CSPs However, we can try to: find consistency algorithms that reduce the size of the search space identify special cases for which algorithms are efficient (polynomial) work on approximation algorithms that can find good solutions quickly, even though they may offer no theoretical guarantees find algorithms that are fast on typical cases 22

Constraint Satisfaction Problems (CSPs): Definition Definition: A constraint satisfaction problem (CSP) consists of: a set of variables V a domain dom(v) for each variable V V a set of constraints C Simple example: V = {V 1 } dom(v 1 ) = {1,2,3,4} C = {C 1,C 2 } C 1 : V 1 2 C 2 : V 1 > 1 Another example: V = {V 1,V 2 } dom(v 1 ) = {1,2,3} dom(v 2 ) = {1,2} C = {C 1,C 2,C 3 } C 1 : V 2 2 C 2 : V 1 + V 2 < 5 C 3 : V 1 > V 2 23

Constraint Satisfaction Problems (CSPs): Definition Definition: A constraint satisfaction problem (CSP) consists of: a set of variables V a domain dom(v) for each variable V V a set of constraints C Definition: A model of a CSP is an assignment of values to all of its variables that satisfies all of its constraints. Simple example: V = {V 1 } dom(v 1 ) = {1,2,3,4} C = {C 1,C 2 } C 1 : V 1 2 C 2 : V 1 > 1 All models for this CSP: {V 1 = 3} {V 1 = 4} 24

Constraint Satisfaction Problems (CSPs): Definition Definition: A constraint satisfaction problem (CSP) consists of: a set of variables V a domain dom(v) for each variable V V a set of constraints C Definition: A model of a CSP is an assignment of values to all of its variables that satisfies all of its constraints. Another example: V = {V 1,V 2 } dom(v 1 ) = {1,2,3} dom(v 2 ) = {1,2} C = {C 1,C 2,C 3 } C 1 : V 2 2 Which are models for this CSP? {V 1 =1, V 2 =1} {V 1 =2, V 2 =1} {V 1 =3, V 2 =1} C 2 : V 1 + V 2 < 5 C 3 : V 1 > V 2 {V 1 =3, V 2 =2} 25

Possible Worlds Definition: A possible world of a CSP is an assignment of values to all of its variables. Definition: A model of a CSP is an assignment of values to all of its variables that satisfies all of its constraints. i.e. a model is a possible world that satisfies all constraints Another example: V = {V 1,V 2 } dom(v 1 ) = {1,2,3} dom(v 2 ) = {1,2} C = {C 1,C 2,C 3 } C 1 : V 2 2 C 2 : V 1 + V 2 < 5 C 3 : V 1 > V 2 Possible worlds for this CSP: {V 1 =1, V 2 =1} {V 1 =1, V 2 =2} {V 1 =2, V 2 =1} (a model) {V 1 =2, V 2 =2} {V 1 =3, V 2 =1} (a model) {V 1 =3, V 2 =2} 26

Constraints Constraints are restrictions on the values that one or more variables can take Unary constraint: restriction involving a single variable E.g.: V 2 2 k-ary constraint: restriction involving k different variables E.g. binary (k=2): V 1 + V 2 < 5 E.g. 3-ary: V 1 + V 2 + V 4 < 5 We will mostly deal with binary constraints Constraints can be specified by 1. listing all combinations of valid domain values for the variables participating in the constraint E.g. for constraint V 1 > V 2 and dom(v 1 ) = {1,2,3} and dom(v 2 ) = {1,2}: V 1 V 2 2 1 3 1 3 2 2. giving a function (predicate) that returns true if given values for each variable which satisfy the constraint else false: V 1 > V 2 27

Constraints A possible world satisfies a set of constraints if the values for the variables involved in each constraint are consistent with that constraint 1. They are elements of the list of valid domain values 2. Function returns true for those values Examples V 1 V 2 2 1 3 1 3 2 {V 1 =1, V 2 =1} (does not satisfy above constraint) {V 1 =3, V 2 =1} (satisfies above constraint) 28

Scope of a constraint Definition: The scope of a constraint is the set of variables that are involved in the constraint Examples: V 2 2 has scope {V 2 } V 1 > V 2 has scope {V 1,V 2 } V 1 + V 2 + V 4 < 5 has scope {V 1,V 2,V 4 } How many variables are in the scope of a k-ary constraint? k variables 29

Finite Constraint Satisfaction Problem: Definition Definition: A finite constraint satisfaction problem (FCSP) is a CSP with a finite set of variables and a finite domain for each variable. We will only study finite CSPs here but many of the techniques carry over to countably infinite and continuous domains. We use CSP here to refer to FCSP. The scope of each constraint is automatically finite since it is a subset of the finite set of variables. 30

Learning Goals for CSP so far Define possible worlds in term of variables and their domains Compute number of possible worlds on real examples Specify constraints to represent real world problems differentiating between: Unary and k-ary constraints List vs. function format Verify whether a possible world satisfies a set of constraints (i.e., whether it is a model, a solution) Coming up: CSP as search Read Sections 4.3-2 Get busy with assignment 1 (Due: Friday, October 5) 31