Foundations of Constraint Processing, CSCE421/821 Overview 11 CSCE421/821, Fall 2012 www.cse.unl.edu/~choueiry/F12-421-821 Questions: Piazza Berthe Y.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Problems
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 CMSC 471 Fall 2002 Class #6 – Wednesday, September 18.
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
Foundations of Constraint Processing, Fall 2005 October 21, 2005CSPs and Relational DBs1 Foundations of Constraint Processing CSCE421/821, Fall 2005:
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Satisfaction CSE 473 University of Washington.
CPSC 322, Lecture 12Slide 1 CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12 (Textbook Chpt ) January, 29, 2010.
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
Constraint Satisfaction Problems
CS460 Fall 2013 Lecture 4 Constraint Satisfaction Problems.
University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.
Chapter 5 Outline Formal definition of CSP CSP Examples
Distributed Scheduling. What is Distributed Scheduling? Scheduling: –A resource allocation problem –Often very complex set of constraints –Tied directly.
Foundations of Constraint Processing, Fall 2004 November 18, 2004More on BT search1 Foundations of Constraint Processing CSCE421/821, Fall 2004:
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.
1 Constraint Satisfaction Problems Slides by Prof WELLING.
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.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Searching by Constraint CMSC Artificial Intelligence January 24, 2008.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
Problem Solving with Constraints Lookahead Schemas 1 Foundations of Constraint Processing CSCE496/896, Fall
Foundations of Constraint Processing, Spring 2008 Jan 14, 2008 Overview 11 Foundations of Constraint Processing CSCE421/821, Spring 2008:
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
1 Chapter 5 Constraint Satisfaction Problems. 2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
Foundations of Constraint Processing, CSCE421/821 Overview 11 CSCE421/821, Fall Questions: Piazza Berthe Y.
Chapter 5 Constraint Satisfaction Problems
Review Test1. Robotics & Future Technology Future of Intelligent Systems / Ray Kurzweil futurist Ray Kurzweil / A Long Bet A Long Bet / Robot Soccer.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
Constraint Satisfaction Problems (Chapter 6)
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Grand Challenge:
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Constraint Satisfaction Problems University of Berkeley, USA
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
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.
Constraint Propagation Artificial Intelligence CMSC January 22, 2002.
Constraint Satisfaction CSE 473 University of Washington.
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.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction Problems (CSPs)
Constraint Satisfaction 101
Berthe Y. Choueiry (Shu-we-ri)
Empirical Comparison of Preprocessing and Lookahead Techniques for Binary Constraint Satisfaction Problems Zheying Jane Yang & Berthe Y. Choueiry Constraint.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Berthe Y. Choueiry (Shu-we-ri)
Foundations of Constraint Processing
Constraint Satisfaction Problems
Artificial Intelligence
Chapter 5: General search strategies: Look-ahead
Berthe Y. Choueiry (Shu-we-ri)
Constraint satisfaction problems
Foundations of Constraint Processing
CS 8520: Artificial Intelligence
Foundations of Constraint Processing
Constraint Satisfaction Problems
Constraint satisfaction problems
Consistency algorithms
Presentation transcript:

Foundations of Constraint Processing, CSCE421/821 Overview 11 CSCE421/821, Fall Questions: Piazza Berthe Y. Choueiry (Shu-we-ri) AVH 360 Constraint Satisfaction 101

Foundations of Constraint Processing, CSCE421/821 Overview 12 Outline Motivating example, application areas CSP: Definition, representation Some simple modeling examples More on definition and formal characterization Basic solving techniques (Implementing backtrack search) Advanced solving techniques Issues & research directions

Foundations of Constraint Processing, CSCE421/821 Overview 13 Motivating example Context: You are a senior in college Problem: You need to register in 4 courses for the Spring semester Possibilities: Many courses offered in Math, CSE, EE, CBA, etc. Constraints: restrict the choices you can make –Unary: Courses have prerequisites you have/don't have Courses/instructors you like/dislike –Binary: Courses are scheduled at the same time –n-ary: In CE: 4 courses from 5 tracks such as at least 3 tracks are covered You have choices, but are restricted by constraints – Make the right decisions!!

Foundations of Constraint Processing, CSCE421/821 Overview 14 Motivating example (cont’d) Given –A set of variables: 4 courses at UNL –For each variable, a set of choices (values) –A set of constraints that restrict the combinations of values the variables can take at the same time Questions –Does a solution exist? (classical decision problem) –How two or more solutions differ? How to change specific choices without perturbing the solution? –If there is no solution, what are the sources of conflicts? Which constraints should be retracted? –etc.

Foundations of Constraint Processing, CSCE421/821 Overview 15 Practical applications Radio resource management (RRM) Databases (computing joins, view updates) Temporal and spatial reasoning Planning, scheduling, resource allocation Design and configuration Graphics, visualization, interfaces Hardware verification and software engineering HC Interaction and decision support Molecular biology Robotics, machine vision and computational linguistics Transportation Qualitative and diagnostic reasoning Adapted from E.C. Freuder

Foundations of Constraint Processing, CSCE421/821 Overview 16 Constraint Processing is about... –Solving a decision problem… –… While allowing the user to state arbitrary constraints in an expressive way and –Providing concise and high-level feedback about alternatives and conflicts Related areas: –AI, OR, Algorithmic, DB, TCS, Prog. Languages, etc.

Foundations of Constraint Processing, CSCE421/821 Overview 17 Flexibility & expressiveness of representations Interactivity users can constraints Power of Constraints Processing relax reinforce

Foundations of Constraint Processing, CSCE421/821 Overview 18 Outline Motivating example, application areas CSP: Definition, representation Some simple modeling examples More on definition and formal characterization Basic solving techniques

Foundations of Constraint Processing, CSCE421/821 Overview 19 Defining a problem General template of any computational problem –Given: Example: a set of objects, their relations, etc. –Query/Question: Example: Find x such that the condition y is satisfied How about the Constraint Satisfaction Problem?

Foundations of Constraint Processing, CSCE421/821 Overview 110 Definition of a CSP Given P = ( V, D, C ) –V is a set of variables, –D is a set of variable domains (domain values) –C is a set of constraints, Query: can we find a value for each variable such that all constraints are satisfied?

Foundations of Constraint Processing, CSCE421/821 Overview 111 Different Queries Yield Different Problems Find a solution decision problem Find number of/all solutionscounting problem Find a set of constraints that can be removed so that a solution existsoptimization problem Etc.

Foundations of Constraint Processing, CSCE421/821 Overview 112 Domain Types P = ( V, D, C ) where Domains: –Restricted to {0,1}: Boolean CSPs –Finite (discrete), enumeration works –Continuous, sophisticated algebraic techniques are needed Consistency techniques on domain bounds

Foundations of Constraint Processing, CSCE421/821 Overview 113 CSP Representation (I) Given P = ( V, D, C ), where Find a consistent assignment for variables Constraint Network (graph, hypergraph) Variable  node (vertex) Domain  node label Constraint  arc (edge) between nodes

Foundations of Constraint Processing, CSCE421/821 CSP Representation (II) Overview 114 {1, 2, 3, 4} { 3, 5, 7 } { 3, 4, 9 } { 3, 6, 7 } v2 > v4 V4 V2 v1+v3 < 9 V3 V1 v2 < v3 v1 < v2 Graph Vertices: variables Edges: binary constraints Hypergraph Vertices: variables Hyperedges: constraints

Foundations of Constraint Processing, CSCE421/821 Constraint Definition Overview 115 A constraint C is defined by −A scope, the set of variables on which the constraint applies Notation: SCOPE(C), scope(C), scp(C) −A relation, a subset of the Cartesian product of the domains of the variables in the scope of the constraint Notation: RELATION(C), rel(C) Arity, cardinality of the constraint’s scope −Unary, binary, ternary,…, global − Universal constraint

Foundations of Constraint Processing, CSCE421/821 Relation Definition Overview 116 Extension, all tuples are enumerated −As a list of allowed tuples (supports, positive table) −As a list of forbidden tuples (conflicts, no-goods) Intension, given by a set builder −When it is not practical or possible to list all tuples −Define types/templates of common constraints to be used repeatedly −Examples: linear constraints, All-Diff (mutex), Atmost, TSP-constraint, cycle-constraint, etc.

Foundations of Constraint Processing, CSCE421/821 Overview 117 Constraint Implementation Predicate function Set of tuples (list or table) Binary matrix (bit-matrix) Constrained Decision Diagrams ([Cheng & Yap, AAAI 05])[Cheng & Yap, AAAI 05] etc.

Foundations of Constraint Processing, CSCE421/821 Overview 118 Outline Motivating example, application areas CSP: Definition, representation Some simple modeling examples More on definition and formal characterization Basic solving techniques

Foundations of Constraint Processing, CSCE421/821 Overview 119 Example II: Temporal reasoning Give one solution: ……. Satisfaction, yes/no: decision problem

Foundations of Constraint Processing, CSCE421/821 Overview 120 Example III: Map coloring Using 3 colors (R, G, & B), color the US map such that no two adjacent states have the same color Variables? Domains? Constraints?

Foundations of Constraint Processing, CSCE421/821 Overview 121 Example III: Map coloring (cont’d) Using 3 colors (R, G, & B), color the US map such that no two adjacent states have the same color

Foundations of Constraint Processing, CSCE421/821 Overview 122 Example IV: Resource Allocation What is the CSP formulation? { a, b, c } { a, b } { a, c, d } { b, c, d }

Foundations of Constraint Processing, CSCE421/821 Overview 123 Example IV: RA (cont’d) { a, b, c } { a, b } { a, c, d } { b, c, d } { R1, R3 } T1 { R1, R3 } { R1, R3, R4 } { R1, R2, R3 } { R2, R4 } T2 T3 T4 T5 T6 T7 Interval Order T2 T1 Constraint Graph T4 { R1, R3 } T3 { R2, R4 } T6 T7 T5 { R1, R2, R3 } { R1, R3 } { R1, R2, R3 }             

Foundations of Constraint Processing, CSCE421/821 Overview 124 Example V: Cryptarithmetic puzzles D X1 = D X2 = D X3 = {0,1} D F =D T =D U =D W =D R =D O =[0,9] O+O = R+10X1 X1+W+W = U+10X2 X2+ T+T = O + 10X3 X3=F Alldiff({F,D,U,V,R,O})

Foundations of Constraint Processing, CSCE421/821 Overview 125 Example VI: Product Configuration Train, elevator, car, etc. Given: Components and their attributes (variables) Domain covered by each characteristic (values) Relations among the components (constraints) A set of required functionalities (more constraints) Find: a product configuration i.e., an acceptable combination of components that realizes the required functionalities

Foundations of Constraint Processing, CSCE421/821 Overview 126 Example VII: Puzzle Given: Four musicians: Fred, Ike, Mike, and Sal, play bass, drums, guitar and keyboard, not necessarily in that order. They have 4 successful songs, ‘Blue Sky,’ ‘Happy Song,’ ‘Gentle Rhythm,’ and ‘Nice Melody.’ Ike and Mike are, in one order or the other, the composer of ‘Nice Melody’ and the keyboardist. etc... Query: Who plays which instrument and who composed which song?

Foundations of Constraint Processing, CSCE421/821 Overview 127 Example VII: Puzzle (cont’d) Formulation 1: Variables: Bass, Drums, Guitar, Keyboard, Blue Sky, Happy Song Gentle Rhythm and Nice Melody. Domains: Fred, Ike, Mike, Sal Constraints: … Formulation 2: Variables: Fred's-instrument, Ike's-instrument, …, Fred's-song, Ikes's-song, Mike’s-song, …, etc. Domains: { bass, drums, guitar, keyboard } { Blue Sky, Happy Song, Gentle Rhythm, Nice Melody} Constraints: …

Foundations of Constraint Processing, CSCE421/821 Overview 128 Constraint types: examples Example I: algebraic constraints Example II: (algebraic) constraints of bounded difference Example III & IV: coloring, mutual exclusion, difference constraints Example V & VI: elements of C must be made explicit {1, 2, 3, 4} { 3, 5, 7 } { 3, 4, 9 } { 3, 6, 7 } v2 > v4 V4 V2 v1+v3 < 9 V3 V1 v2 < v3 v1 < v2 T1 Constraint Graph T4 { R1, R3 } T3 { R2, R4 } T6 T7 T5 { R1, R2, R3 } { R1, R3 } { R1, R2, R3 }             

Foundations of Constraint Processing, CSCE421/821 Overview 129 More examples Example VII: Databases –Join operation in relational DB is a CSP –View materialization is a CSP Example VIII: Interactive systems –Data-flow constraints –Spreadsheets –Graphical layout systems and animation –Graphical user interfaces Example IX: Molecular biology (bioinformatics) –Threading, etc

Foundations of Constraint Processing, CSCE421/821 Overview 130 Outline Motivating example, application areas CSP: Definition, representation Some simple modeling examples More on definition and formal characterization Basic solving techniques

Foundations of Constraint Processing, CSCE421/821 Overview 131 Representation (again) Macrostructure G(P): - constraint graph for binary constraints - constraint network for non-binary constraints Micro-structure  (P): Co-microstructure co-  (P) : a, b a, c b, c    V1 V2 V3 (V1, a ) (V1, b) (V2, a ) (V2, c) (V3, b ) (V3, c) (V1, a ) (V1, b) (V2, a ) (V2, c) (V3, b ) (V3, c) no goods

Foundations of Constraint Processing, CSCE421/821 Overview 132 Complexity of CSP Characterization Decision problem In general, NP-complete by reduction from 3SAT

Foundations of Constraint Processing, CSCE421/821 Overview 133 Proving NP-completeness 1.Show that  1 is in NP 2.Given a problem  1 in NP, show that an known NP-complete problem  2 can be efficiently reduced to  1 –Select a known NP-complete problem  2 (e.g., SAT) –Construct a transformation f from  2 to  1 –Prove that f is a polynomial transformation (Check Chapter 3 of Garey & Johnson)

Foundations of Constraint Processing, CSCE421/821 Overview 134 What is SAT? Given a sentence: –Sentence: conjunction of clauses – Clause: disjunction of literals – Literal: a term or its negation – Term: Boolean variable Question: Find an assignment of truth values to the Boolean variables such the sentence is satisfied.

Foundations of Constraint Processing, CSCE421/821 Overview 135 CSP is NP-Complete Verifying that an assignment for all variables is a solution –Provided constraints can be checked in polynomial time Reduction from 3SAT to CSP –Many such reductions exist in the literature (perhaps 7 of them)

Foundations of Constraint Processing, CSCE421/821 Overview 136 Problem Reduction Example: CSP into SAT (proves nothing, just an exercise) Notation: variable-value pair = vvp vvp  term –V 1 = {a, b, c, d} yields x 1 = (V 1, a), x 2 = (V 1, b), x 3 = (V 1, c), x 4 = (V 1, d), –V 2 = {a, b, c} yields x 5 = (V 2, a), x 6 = (V 2, b), x 7 = (V 2,c). The vvp’s of a variable  disjunction of terms –V 1 = {a, b, c, d} yields (Optional) At most one VVP per variable

Foundations of Constraint Processing, CSCE421/821 Overview 137 CSP into SAT (cont.) Constraint: 1.Way 1: Each inconsistent tuple  one disjunctive clause –For example: how many? 2.Way 2: a)Consistent tuple  conjunction of terms b)Each constraint  disjunction of these conjunctions  transform into conjunctive normal form (CNF) Question : find a truth assignment of the Boolean variables such that the sentence is satisfied

Foundations of Constraint Processing, CSCE421/821 Overview 138 Outline Motivating example, application areas CSP: Definition, representation Some simple modeling examples More on definition and formal characterization Basic solving techniques Modeling and consistency checking Constructive, systematic search Iterative improvement, local search

Foundations of Constraint Processing, CSCE421/821 Overview 139 How to solve a CSP? Search 1. Constructive, systematic 2. Iterative repair, local search

Foundations of Constraint Processing, CSCE421/821 Overview 140 Before starting search! Consider: Importance of modeling/formulation: –To control the size of the search space Preprocessing –A.k.a. constraint filtering/propagation, consistency checking –reduces size of search space

Foundations of Constraint Processing, CSCE421/821 Overview Rows V1V2V3V4V1V2V3V4 Importance of Modeling N-queen: formulation 1 –Variables? –Domains? –Size of CSP? N-queens: formulation 2 –Variables? –Domains? –Size of CSP? 4 Column positions {0,1} 16 Cells V 11 V 12 V 13 V 14 V 21 V 22 V 23 V 24 V 31 V 32 V 33 V 34 V 41 V 42 V 43 V 44

Foundations of Constraint Processing, CSCE421/821 Overview 142 Constraint Checking  Arc-consistency [ ] [ ] [ ] B < C A < B B A 2 < C - A < 5 C 2- A: [ ] C: [ ] 3- B: [ ] C: [ ] 1- B: [ ]

Foundations of Constraint Processing, CSCE421/821 Overview 143 Constraint Checking  Arc-consistency: every combination of two adjacent variables  3-consistency, k-consistency (k  n)  Constraint filtering, constraint checking, etc..  Eliminate non-acceptable tuples prior to search  Warning: arc-consistency does not solve the problem still is not a solution!

Foundations of Constraint Processing, CSCE421/821 Overview 144 Systematic Search  Starting from a root node  Consider all values for a variable V 1  For every value for V 1, consider all values for V 2  etc..  For n variables, each of domain size d  Maximum depth? fixed!  Maximum number of paths? size of search space, size of CSP

Foundations of Constraint Processing, CSCE421/821 Overview 145 Systematic search: Back-checking Systematic search generates d n possibilities Are all possibilities acceptable?  Expand a partial solution only when it is consistent  This yields early pruning of inconsistent paths

Foundations of Constraint Processing, CSCE421/821 Overview 146 Systematic search: Chronological backtracking What if only one solution is needed? Depth-first search & Chronological backtracking DFS: Soundness? Completeness?

Foundations of Constraint Processing, CSCE421/821 Overview 147 Systematic search: Intelligent backtracking What if the reason for failure was higher up in the tree? Backtrack to source of conflict !!  Backjumping, conflict-directed backjumping, etc.

Foundations of Constraint Processing, CSCE421/821 Overview 148 Systematic search: Ordering heuristics Which variable to expand first? Heuristics: –most constrained variable first (reduce branching factor) –most promising value first (find quickly first solution)

Foundations of Constraint Processing, CSCE421/821 Overview 149 Systematic search: Back-checking Search tree with only backtrack search? Root node Q 3 Q Q 2 Q Q 4 Q 1 Q 3 Q Solution! 26 nodes visited.

Foundations of Constraint Processing, CSCE421/821 Overview 150 Systematic search: Forward checking Root node 1 Q 3 QQ 4 Domain Wipe Out V 3 2 Q Domain Wipe Out V 4 2 Q 4 Q 1 Q 3 Q Solution! 8 nodes visited. Search Tree with domains filter by Forward Check

Foundations of Constraint Processing, CSCE421/821 Overview 151 Improving BT search General purpose methods for 1.Variable, value ordering 2.Improving backtracking: intelligent backtracking avoids repeating failure 3.Look-ahead techniques: propagate constraints as variables are instantiated

Foundations of Constraint Processing, CSCE421/821 Overview 152 Search-tree branching K-way branching –One branch for every value in the domain Binary branching –One branch for the first value –One branch for all the remaining values in the domain –Used in commercial constraint solvers: ILOG, Eclipse Have different behaviors (e.g., WRT value ordering heuristics [Smith, IJCAI 95] )[Smith, IJCAI 95]

Foundations of Constraint Processing, CSCE421/821 Overview 153 Summary of backtrack search Constructive, systematic, exhaustive –In general sound and complete Back-checking: expands nodes consistent with past Backtracking: Chronological vs. intelligent Ordering heuristics: –Static –Dynamic variable –Dynamic variable-value pairs Looking ahead: –Partial look-ahead Forward checking (FC) Directional arc-consistency (DAC) –Full (a.k.a. Maintaining Arc-consistency or MAC)

Foundations of Constraint Processing, CSCE421/821 Overview 154 CSP: a decision problem (NP-complete) 1.Modeling: abstraction and reformulation 2.Preprocessing techniques: eliminate non-acceptable tuples prior to search 3.Systematic search: potentially d n paths of fixed lengths chronological backtracking intelligent backtracking variable/value ordering heuristics 4.Search ‘hybrids:’ Mixing consistency checking with search: look-ahead strategies

Foundations of Constraint Processing, CSCE421/821 Overview 155 Non-Systematic Search Iterative repair, local search: modifies a global but inconsistent solution to decrease the number of violated constraints Examples : Hill climbing, taboo search, simulated annealing, GSAT, WalkSAT, Genetic Algorithms, Swarm intelligence, etc. Features : Incomplete & not sound –Advantage: anytime algorithm –Shortcoming: cannot tell that no solution exists

Foundations of Constraint Processing, CSCE421/821 Overview 156 Outline of CSP 101 We have seen Motivating example, application areas CSP: Definition, representation Some simple modeling examples More on definition and formal characterization Basic solving techniques We will move to  (Implementing backtrack search) Advanced solving techniques Issues & research directions