Constraint Satisfaction Problems (CSPs) Introduction

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) Sept, 11, 2013.
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.
Slide 1 Planning: Representation and Forward Search Jim Little UBC CS 322 October 10, 2014 Textbook §8.1 (Skip )- 8.2)
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.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) January, 12, 2009.
CPSC 322, Lecture 18Slide 1 Planning: Heuristics and CSP Planning Computer Science cpsc322, Lecture 18 (Textbook Chpt 8) February, 12, 2010.
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 17Slide 1 Planning: Representation and Forward Search Computer Science cpsc322, Lecture 17 (Textbook Chpt 8.1 (Skip )- 8.2) February,
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.
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.
Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Jim Little UBC CS 322 – CSP 1 September 27, 2014 Textbook §
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) Oct, 26, 2010.
Branch & Bound, CSP: Intro CPSC 322 – CSP 1 Textbook § & January 28, 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.
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.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
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.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Constraint Satisfaction Problems University of Berkeley, USA
Arc Consistency CPSC 322 – CSP 3 Textbook § 4.5 February 2, 2011.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) Sept, 12, 2012.
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.
CPSC 322, Lecture 2Slide 1 Representational Dimensions Computer Science cpsc322, Lecture 2 (Textbook Chpt1) Sept, 7, 2012.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
Constraint Satisfaction Problems (CSPs) Introduction
Computer Science cpsc322, Lecture 4
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Artificial Intelligence (AI) Computer Science cpsc502, Lecture 3
Computer Science cpsc322, Lecture 13
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Planning: Forward Planning and CSP Planning
Planning: Representation and Forward Search
CS 188: Artificial Intelligence
Planning: Heuristics and CSP Planning
Planning: Heuristics and CSP Planning
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Planning: Representation and Forward Search
Computer Science cpsc322, Lecture 13
Planning: Heuristics and CSP Planning
Decision Theory: Single Stage Decisions
Constraint Satisfaction Problems
Artificial Intelligence
Logic: Domain Modeling /Proofs + Computer Science cpsc322, Lecture 22
Constraint satisfaction problems
Constraint Satisfaction Problems. A Quick Overview
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems (CSP)
Planning: Representation and Forward Search
Presentation transcript:

Constraint Satisfaction Problems (CSPs) Introduction Computer Science cpsc322, Lecture 11 (Textbook Chpt 4.0 – 4.2) May, 25, 2017 CPSC 322, Lecture 11

Announcements Assignment1 due on Tue Post questions on Piazza Search wrap-up Go back to learning goals (end of slides) Make sure you understands the inked slides More details or different examples on textbook Work on the practice exercises If still confused, come to office hours CPSC 322, Lecture 10

Generic Search vs. Constraint Satisfaction Problems Variables Lecture Overview Generic Search vs. Constraint Satisfaction Problems Variables Constraints CSPs CPSC 322, Lecture 11

Standard Search To learn about search we have used it as the reasoning strategy for a simple goal-driven planning agent….. Standard search problem: An agent can solve a problem by searching in a space of states state is a "black box“ – any arbitrary data structure that supports three problem-specific routines Solution? General but not arbitrary General purpose rather than problem specific successor function, heuristic function goal test Deterministic, goal-driven agent Agent is given a goal (subset of possible states) Environment changes only when the agent acts Agent perfectly knows: what actions can be applied in any given state the state it is going to end up in when an action is applied in a given state CPSC 322, Lecture 11

Modules we'll cover in this course: R&Rsys Environment Stochastic Deterministic Problem Arc Consistency Constraint Satisfaction Vars + Constraints Search Static Belief Nets Logics Query Var. Elimination Search R&R Sys Representation and reasoning Systems Each cell is a R&R system STRIPS actions preconditions and effects Sequential Decision Nets STRIPS Var. Elimination Planning Search Markov Processes Representation Value Iteration Reasoning Technique CPSC 322, Lecture 2

Standard Search vs. Specific R&R systems Constraint Satisfaction (Problems): State Successor function Goal test Solution Planning : Inference Allows useful general-purpose algorithms with more power than standard search algorithms CPSC 322, Lecture 11

Generic Search vs. Constraint Satisfaction Problems Variables/Features Lecture Overview Generic Search vs. Constraint Satisfaction Problems Variables/Features Constraints CSPs CPSC 322, Lecture 11

Variables/Features, domains and Possible Worlds 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 Finite: the domain contains a finite number of values Infinite but Discrete: the domain is countably infinite Continuous: e.g., real numbers between 0 and 1 Countably infinite Reduce infinite by simply bounding the the values of all variables Continuous domains – operation research – linear programming Possible world: a complete assignment of values to a set of variables CPSC 322, Lecture 11

Example (lecture 2) Mars Explorer Example Weather Temperature Longitude Latitude One possible world (state) Number of possible (mutually exclusive) worlds (states) {S, C} [-40, 40] [0, 359] [0, 179] {S, -30, 320, 91} 2 x 81 x 360 x 180 Product of cardinality of each domain … always exponential in the number of variables

Examples Crossword Puzzle: variables are words that have to be filled in domains are valid English words of required length possible worlds: all ways of assigning words Number of English words? Number of words of length k ? So, how many possible worlds? ~150,000 Variables are the places where word can go e.g. (1 across, 3 down) Domains are words of the appropriate length (for 1 across in this example – length equals 6) Constraints letter should be the same at the intersection A. 15,000*63 B. 6315,000 C. 15,00063 D. 1,56363 CPSC 322, Lecture 11

More Examples Crossword 2: Sudoku: variables are cells (individual squares) domains are letters of the alphabet possible worlds: all ways of assigning letters to cells So, how many possible worlds? Sudoku: variables are empty cells domains are numbers between 1 and 9 possible worlds: all ways of assigning numbers to cells So, how many possible worlds? CPSC 322, Lecture 11

More examples 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 the number of ways that k things can be 'chosen' from a set of n things. Hence, is often read as "n choose k" and called the choose function of n and k Task1 start-time Task1 end-time Task1 location CPSC 322, Lecture 11

More examples 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 the number of ways that k things can be 'chosen' from a set of n things. Hence, is often read as "n choose k" and called the choose function of n and k Task1 start-time Task1 end-time Task1 location CPSC 322, Lecture 11

Scheduling possible world how many possible worlds? CPSC 322, Lecture 11

More examples…. Map Coloring Problem variable: regions on the map domains: possible colors possible worlds: color assignments for each region how many possible worlds? Task1 start-time Task1 end-time Task1 location CPSC 322, Lecture 11

Generic Search vs. Constraint Satisfaction Problems Variables/Features Lecture Overview Generic Search vs. Constraint Satisfaction Problems Variables/Features Constraints CSPs CPSC 322, Lecture 11

Constraints Constraints are restrictions on the values that one or more variables can take Unary constraint: restriction involving a single variable k-ary constraint: restriction involving the domains of k different variables it turns out that k-ary constraints can always be represented as binary constraints, so we'll mainly only talk about this case Constraints can be specified by giving a function that returns true when given values for each variable which satisfy the constraint giving a list of valid domain values for each variable participating in the constraint 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 constraints can always be represented as binary constraints http://ai.uwaterloo.ca/~vanbeek/Publications/ai02.pdf In the dual transformation, the constraints of the original formulation become variables in the new representation. We refer to these variables, which represent the original constraints, as the dual variables, and the variables in the original CSP as the ordinary variables. The domain of each dual variable is exactly the set of tuples that are in the original constraint relation. There is a binary constraint, called a dual constraint, between two dual variables iff the two original constraints share some variables. A dual constraint prohibits pairs of tuples that do not agree on the shared variables. In the hidden transformation, the set of variables consists of all the ordinary variables in the original formulation with their original domains plus all the dual variables as defined by the dual transformation. There is a binary constraint, called a hidden constraint, between a dual variable and each of the ordinary variables in the constraint represented by the dual variable. A hidden constraint enforces the condition that a value of the ordinary variable must be the same as the value assigned to it by the tuple that is the value of the dual variable. CPSC 322, Lecture 11

Example: Map-Coloring Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red, green, blue} Constraints: adjacent regions must have different colors e.g., WA ≠ or, (WA,NT) in {(red,green),(red,blue),(green,red), (green,blue),(blue,red),(blue,green)} CPSC 322, Lecture 11

Constraints (cont.) A possible world satisfies a set of constraints if the set of variables involved in each constraint take values that are consistent with that constraint Variables: A,B,C domains [1 .. 10] Possible world W: {A= 1 , B = 2, C = 10} Constraint set1 {A = B, C>B} Constraint set2 {A ≠ B, C>B, (A,C) in {(10,1),(1,10)} W satisfies both set1 and set2 W satisfies set1 but not set2 W does not satisfy any of the two constraint sets W satisfies set2 but not set1 CPSC 322, Lecture 11

Examples Crossword Puzzle: variables are words that have to be filled in domains are valid English words constraints: words have the same letters at points where they intersect Crossword 2: variables are cells (individual squares) domains are letters of the alphabet constraints: sequences of letters form valid English words CPSC 322, Lecture 11

Examples Sudoku: variables are cells domains are numbers between 1 and 9 constraints: rows, columns, boxes contain all different numbers CPSC 322, Lecture 11

More examples 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 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 be scheduled only in certain locations; some tasks must come earlier than others; etc. CPSC 322, Lecture 11

Generic Search vs. Constraint Satisfaction Problems Variables/Features Lecture Overview Generic Search vs. Constraint Satisfaction Problems Variables/Features Constraints CSPs CPSC 322, Lecture 11

Constraint Satisfaction Problems: definitions Definition (Constraint Satisfaction Problem) A constraint satisfaction problem consists of a set of variables a domain for each variable a set of constraints Definition (model / solution) A model of a CSP is an assignment of values to variables that satisfies all of the constraints. A possible world satisfies a set of constraints if the set of variables involved in each constraint take values that are consistent with that constraint CPSC 322, Lecture 11

Example: Map-Coloring Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red,green,blue} 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)} CPSC 322, Lecture 11

Example: Map-Coloring Models / Solutions are complete and consistent assignments, e.g., WA = red, NT = green, Q = red, NSW = green, V = red,SA = blue, T = green CPSC 322, Lecture 11

Constraint Satisfaction Problem: Variants We may want to solve the following problems using a CSP determine whether or not a model exists find a model find all of the models count the number of the models find the best model given some model quality this is now an optimization problem determine whether some properties of the variables hold in all models Get a “quick answer” then spend more time to find the model Typical To assess the difficulty of the problem Same as above If you want the largest regions to be red (can be encoded as additional constraints) In all models do two variables have the same value? (even if it was not required by the constraints) CPSC 322, Lecture 11

To summarize Next class Need to think of search beyond simple goal driven planning agent. We started exploring the first AI Representation and Reasoning framework: CSPs Next class CSPs: Search and Arc Consistency (Textbook Chpt 4.3-4.5) Standard search problem: An agent can solve a problem by searching in a space of states state is a "black box“ – any arbitrary data structure that supports three problem-specific routines successor function, heuristic function goal test General but not arbitrary General purpose rather than problem specific CPSC 322, Lecture 11

Learning Goals for today’s class 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) CPSC 322, Lecture 4

Extra slide (may be used here?) Goal state: 9×9 grid completely filled so that each column, each row, and each of the nine 3×3 boxes contains the digits from 1 to 9, only one time each Sudoku is a logic-based number placement puzzle. The objective is to fill a 9×9 grid so that each column, each row, and each of the nine 3×3 boxes (also called blocks or regions) contains the digits from 1 to 9, only one time each (that is, exclusively). The puzzle setter provides a partially completed grid. Restate / justify that the following is true Environment changes only when the agent acts Agent can perfectly predict effect of its actions Agent is given a goal A possible start state (partially completed grid) CPSC 322, Lecture 4