Class2: Constraint Networks Rina Dechter

Similar documents
Class2: Constraint Networks Rina Dechter

Class 2 Constraint Networks

CONSTRAINT Networks Chapters 1-2

Set 5: Constraint Satisfaction Problems

Set 5: Constraint Satisfaction Problems Chapter 6 R&N

Set 5: Constraint Satisfaction Problems

Set 5: Constraint Satisfaction Problems

!!" '!" Fall 2003 ICS 275A - Constraint Networks 2

Acyclic Network. Tree Based Clustering. Tree Decomposition Methods

1 Inference for Boolean theories

Semi-Independent Partitioning: A Method for Bounding the Solution to COP s

Recitation 3 Problems

Summary. Acyclic Networks Join Tree Clustering. Tree Decomposition Methods. Acyclic Network. Tree Based Clustering. Tree Decomposition.

Constraint Satisfaction Problems

Acyclic Network. Tree Based Clustering. Tree Decomposition Methods

Constraint (Logic) Programming

CSE 473: Artificial Intelligence

Constraint Satisfaction Problems

Constraint Satisfaction Problems

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

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

Constraint Satisfaction Problems (CSPs)

CS 188: Artificial Intelligence Fall 2011

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

Mini-Buckets: A General Scheme for Generating Approximations in Automated Reasoning

Hybrid Algorithms for SAT. Irina Rish and Rina Dechter.

Constraint Satisfaction. AI Slides (5e) c Lin

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

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

Outline. Best-first search

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

Example: Map coloring

Constraint Satisfaction Problems

Foundations of AI. 8. Satisfiability and Model Construction. Davis-Putnam, Phase Transitions, GSAT and GWSAT. Wolfram Burgard & Bernhard Nebel

CS 343: Artificial Intelligence

Outline. Best-first search

Lecture 6: Constraint Satisfaction Problems (CSPs)

Constraint Satisfaction Problems

Constraint Satisfaction Problems. Chapter 6

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

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

Chapter 6 Constraint Satisfaction Problems

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

Constraint Satisfaction Problems. Chapter 6

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

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

Constraint Satisfaction

Constraint Satisfaction Problems

Announcements. CS 188: Artificial Intelligence Fall 2010

Normal Forms for Boolean Expressions

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

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

Constraint Satisfaction Problems Part 2

CS 4100 // artificial intelligence

Constraint Satisfaction Problems

Artificial Intelligence Constraint Satisfaction Problems

Constraint Satisfaction Problems (CSPs)

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

Belief propagation in a bucket-tree. Handouts, 275B Fall Rina Dechter. November 1, 2000

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. What is Search For? Constraint Satisfaction Problems. Constraint Satisfaction Problems

CS 771 Artificial Intelligence. Constraint Satisfaction Problem

CS 188: Artificial Intelligence Fall 2008

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

CONSTRAINT SATISFACTION

Map Colouring. Constraint Satisfaction. Map Colouring. Constraint Satisfaction

CONSTRAINT SATISFACTION

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

AND/OR Cutset Conditioning

CSP- and SAT-based Inference Techniques Applied to Gnomine

Constraint Satisfaction Problems

Rina Dechter. Irvine, California, USA A constraint satisfaction problem (csp) dened over a constraint network

Constraint Optimisation Problems. Constraint Optimisation. Cost Networks. Branch and Bound. Dynamic Programming

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

CONSTRAINT SATISFACTION

Constraint Satisfaction Problems

CS 4100/5100: Foundations of AI

Ch9: Exact Inference: Variable Elimination. Shimi Salant, Barak Sternberg

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

Local Search for CSPs

EXPERIMENTAL EVALUATION OF PREPROCESSING TECHNIQUES IN CONSTRAINT SATISFACTION PROBLEMS*

Artificial Intelligence

Constraint Satisfaction Problems

On Path Consistency for Binary Constraint Satisfaction Problems

Search Algorithms for Solving Queries on Graphical Models & the Importance of Pseudo-trees in their Complexity.

Constraint Satisfaction

Foundations of Artificial Intelligence

Unifying and extending hybrid tractable classes of CSPs

Integrating Probabilistic Reasoning with Constraint Satisfaction

Topological parameters for time-space tradeoff

STAT 598L Probabilistic Graphical Models. Instructor: Sergey Kirshner. Exact Inference

Binary Encodings of Non-binary Constraint Satisfaction Problems: Algorithms and Experimental Results

PART II: Local Consistency & Constraint Propagation

Constraint Satisfaction Problems (Backtracking Search)

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

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

Solving 3-SAT. Radboud University Nijmegen. Bachelor Thesis. Supervisors: Henk Barendregt Alexandra Silva. Author: Peter Maandag s

Spezielle Themen der Künstlichen Intelligenz

A Comparison of Structural CSP Decomposition Methods

Transcription:

Algorithms for Reasoning with graphical models Class2: Constraint Networks Rina Dechter Dbook: chapter 2-3, Constraint book: chapters 2 and 4

Text Books

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Sudoku Approximation: Constraint Propagation Constraint Propagation Inference Variables: empty slots Domains = {1,2,3,4,5,6,7,8,9} Constraints: 27 all-different 2 3 42 6 Each row, column and major block must be alldifferent Well posed if it has unique solution: 27 constraints

Sudoku Each row, column and major block must be alldifferent Well posed if it has unique solution

Constraint Networks Example: map coloring Variables - countries (A,B,C,etc.) Values - colors (red, green, blue) Constraints: A B, A D, D E, etc. A Constraint graph A red red green green yellow yellow B green yellow red yellow green red A B C D G E F B A D E G F C

Constraint Satisfaction Tasks Example: map coloring Variables - countries (A,B,C,etc.) Values - colors (e.g., red, green, yellow) Constraints: A B, A D, D E, etc. A B C D E red green red green blue red blue green green blue Are the constraints consistent? Find a solution, find all solutions Count all solutions green red red blue red green red Find a good (optimal) solution

Constraint Network A constraint network is: R=(X,D,C) X variables D domain C constraints X { X 1,..., X n } D { D1,..., Dn}, Di { v1,... vk} C { C 1,... C } C i ( S i, R ) i t R expresses allowed tuples over scopes A solution is an assignment to all variables that satisfies all constraints (join of all relations). Tasks: consistency?, one or all solutions, counting, optimization

Crossword Puzzle Variables: x 1,, x 13 Domains: letters Constraints: words from {HOSES, LASER, SHEET, SNAIL, STEER, ALSO, EARN, HIKE, IRON, SAME, EAT, LET, RUN, SUN, TEN, YES, BE, IT, NO, US}

Crossword Puzzle I

The Queen Problem The network has four variables, all with domains D i = {1, 2, 3, 4}. (a) The labeled chess board. (b) The constraints between variables.

The Queen Problem The network has four variables, all with domains D i = {1, 2, 3, 4}. (a) The labeled chess board. (b) The constraints between variables.

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, e.g., cryptarithmetic column constraints

Constraint s Representations Relation: allowed tuples Algebraic expression: X X Y Z 1 3 2 2 1 3 2 Y 10, X Y Propositional formula: ( a b) c Semantics: by a relation

Partial Solutions Not all consistent instantiations are part of a solution: (a) A consistent instantiation that is not part of a solution. (b) The placement of the queens corresponding to the solution (2, 4, 1, 3). (c) The placement of the queens corresponding to the solution (3, 1, 4, 2).

Constraint Graphs: Primal, dual and hypergraphs When variables are squares: A (primal) constraint graph: a node per variable arcs connect constrained variables. A dual constraint graph: a node per constraint s scope, an arc connect nodes sharing variables =hypergraph

Graph Concepts

Propositional Satisfiability = {( C), (A v B v C), ( A v B v E), ( B v C v D)}.

Example: Radio Link Assignment cost fi fj Given a telecommunication network (where each communication link has various antenas), assign a frequency to each antenna in such a way that all antennas may operate together without noticeable interference. Encoding? Variables: one for each antenna Domains: the set of available frequencies Constraints: the ones referring to the antennas in the same communication link

Constraint graphs of 3 instances of the Radio frequency assignment problem in CELAR s benchmark

Operations With Relations Intersection Union Difference Selection Projection Join Composition

Combination Local Functions f g Join : x 1 x 2 a b a b x 2 x 3 a a b a b a x 1 x 2 x 3 a a a a a b b b a Logical AND: x 1 x 2 f a a true a b false b a false b b true f g x 2 x 3 g a a true a b true b a true b b false x 1 x 2 x 3 h a a a true a a b true a b a false a b b false b a a false b a b false b b a true b b b false

Example of Selection, Projection and Join

TASK Global View of the Problem C 1 C 2 Global View x 1 x 2 a b a b What about counting? x 2 x 3 a a b a b a x 1 x 2 x 3 a a a a a b b b a x 1 x 2 x 3 h a a a true a a b true a b a false a b b false b a a false b a b false b b a true b b b false Number of true tuples true is 1 false is 0 logical AND? x 1 x 2 x 3 h a a a 1 a a b 1 a b a 0 a b b 0 b a a 0 b a b 0 b b a 1 b b b 0 Sum over all the tuples

The minimal network, An extreme case of re-parameterization

The N-queens Constraint Network The network has four variables, all with domains Di = {1, 2, 3, 4}. (a) The labeled chess board. (b) The constraints between variables. Solutions are: (2,4,1,3) (3,1,4,2)

Figure 2.11: The 4-queens constraint network: (a) The constraint graph. (b) The minimal binary constraints. (c) The minimal unary constraints (the domains). Solutions are: (2,4,1,3) (3,1,4,2)

The Minimal Network The minimal network is perfectly explicit for binary and unary constraints: Every pair of values permitted by the minimal constraint is in a solution.

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Bucket Elimination Adaptive Consistency (Dechter & Pearl, 1987) = = Bucket E: E D, E C Bucket D: D A Bucket C: C B Bucket B: B A Bucket A: w * - D = C A C B = A contradiction Complexity: O(n exp(w induced width * ))

The Idea of Elimination D A E {1,2} { 1,2} {1,2,3 } {1,2} C B {1,2} eliminating E C R DBC R DBC ED Eliminate variable R EB E R D EC join and R DBC B project 3 value assignment

Bucket-Elimination {1,2} D A E {1,2} { 1,2} {1,2,3 } C B {1,2} Bucket( E) : Bucket( D) : Bucket( C) : Bucket( B) : Bucket( A) : Bucket( A) : Bucket( D) : Bucket( C) : Bucket( B) : Bucket( E) : E D, D A C B B A R A A D, D E C B, B E R E * Complexity : O(n exp(w (d))), * w (d) - induced widthalong ordering d E C, R DCB R ACB R AB A B R DB C E R D BE, E R C BE B E D C B A A D C B E

The Induced-Width Width along d, w(d): max # of previous parents Induced width w*(d): The width in the ordered induced graph Induced-width w*: Smallest induced-width over all orderings Finding w* NP-complete (Arnborg, 1985) but greedy heuristics (min-fill).

Adaptive-Consistency, Bucket-Elimination Initialize: partition constraints into bucket 1,..., bucket n For i=n down to 1 along d ( process in reverse order) for all relations R,..., 1 R m bucket i do (join all relations and project-out ) R new ( X ) jr R new ( j i If is not empty, add it to where k is the largest variable index in Else problem is unsatisfiable ) X i bucket k, k i, R new Return the set of all relations (old and new) in the buckets

Algorithms for Reasoning with graphical models Class3 Rina Dechter

Example: deadends, backtrack-freeness A 1,2 B = = C 1,2,3 1,2,3 1,2 D Assign values in the order D,B,C,A before and after adaptive-consistence Order A,B,C,D, order A,B,D,C

Properties of Adaptive-Consistency Adaptive-consistency generates a constraint network that is backtrack-free (can be solved without dead-ends). The time and space complexity of adaptive-consistency along ordering d is time and memory exponential in w*(d). Therefore, problems having bounded induced width are tractable (solved in polynomial time). trees ( w*=1), series-parallel networks ( w*=2 ), and in general k-trees ( w*=k).

Solving Trees (Mackworth and Freuder, 1985) Adaptive consistency is linear for trees and equivalent to enforcing directional arc-consistency (recording only unary constraints)

Tree Solving is Easy T Z 1,2,3 X < 1,2,3 1,2,3 R S Y < U 1,2,3 1,2,3 1,2,3 1,2,3

Tree Solving is Easy T Z 1,2,3 X < 1,2,3 1,2,3 R S Y < U 1,2,3 1,2,3 1,2,3 1,2,3

Tree Solving is Easy T Z R 1,2,3 X < 1,2 1,2 S Y < U 1,2,3 1,2,3 1,2,3 1,2,3

Tree Solving is Easy T Z R 1,2,3 X < 1,2 1,2 S Y < U 1,2,3 1,2,3 1,2,3 1,2,3

Tree Solving is Easy T Z R 1 X < 1,2 1,2 S Y < U 1,2,3 1,2,3 1,2,3 1,2,3

Tree Solving is Easy T Z R 1 X < 2 2 S Y < U 1,2,3 1,2,3 1,2,3 1,2,3

Tree Solving is Easy T Z R 1 X < 2 2 S Y < U 3 3 3 3

Tree Solving is Easy T Z R 1 X < 2 2 S Y < U 3 3 3 3 Adaptive-consistency is linear time because induced-width is 1 (Constraint propagation Solves trees in linear time)

Example: crossword puzzle

Adaptive-Consistency on the Crossword Puzzle

Adaptive-Consistency on the Crossword Puzzle

Adaptive-Consistency on the Crossword Puzzle

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Gausian and Boolean Propagation, Resolution Linear inequalities x y z 15, z 13 x 2, y 2 Boolean constraint propagation, unit resolution ( A B C),( B) ( A C)

The Effect of Resolution on Its Graph (~C) (AVBVC) (~AvBvE)(~B,C,E)

Directional Resolution Adaptive Consistency (~C) (AVBVC) (~AvBvE)(~B,C,E) * bucket i O(exp( w )) DR time and space : O( n exp( w * ))

Directional Resolution Adaptive Consistency (~C) (AVBVC) (~AvBvE)(~B,C,E) * bucket i O(exp( w )) DR time and space : O( n exp( w * ))

Directional Resolution Adaptive Consistency (~C) (AVBVC) (~AvBvE)(~B,C,E) * bucket i O(exp( w )) DR time and space : O( n exp( w * ))

Directional Resolution Adaptive Consistency

Directional Resolution

History 1960 resolution-based Davis-Putnam algorithm 1962 resolution step replaced by conditioning (Davis, Logemann and Loveland, 1962) to avoid memory explosion, resulting into a backtracking search algorithm known as Davis-Putnam (DP), or DPLL procedure. The dependency on induced width was not known in 1960. 1994 Directional Resolution (DR), a rediscovery of the original Davis-Putnam, identification of tractable classes (Dechter and Rish, 1994).

Properties of DR

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Greedy search for induced-width orderings Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Graph Properties Finding a minimum induced-width ordering is hard (NP-complete, lots of literature). So we have approximation greedy schemes.

Greedy Algorithms for Induced-Width Min-width ordering Min-induced-width ordering Max-cardinality ordering Min-fill ordering Chordal graphs Hypergraph partitionings (Project: present papers on induced-width, run algorithms for induced-width on new benchmarks )

Min-width Ordering Proposition: algorithm min-width finds a min-width ordering of a graph Complexity:? O(e)

Greedy Orderings Heuristics min-induced-width (miw) input: a graph G = (V;E), V = {v1; :::; vn} output: A miw ordering of the nodes d = (v1; :::; vn). 1. for j = n to 1 by -1 do 2. r a node in V with smallest degree. 3. put r in position j. 4. connect r's neighbors: E E union {(vi; vj) (vi; r) in E; (vj ; r) 2 in E}, 5. remove r from the resulting graph: V V - {r}. Theorem: A graph is a tree iff it has both width and induced-width of 1. min-fill (min-fill) input: a graph G = (V;E), V = {v1; :::; vn} output: An ordering of the nodes d = (v1; :::; vn). 1. for j = n to 1 by -1 do 2. r a node in V with smallest fill edges for his parents. 3. put r in position j. 4. connect r's neighbors: E E union {(vi; vj) (vi; r) 2 E; (vj ; r) in E}, 5. remove r from the resulting graph: V V {r}.

Example

Example

Chordal Graphs; Max-Cardinality Ordering A graph is chordal if every cycle of length at least 4 has a chord Finding w* over chordal graph is easy using the max-cardinality ordering If G* is an induced graph of it is chordal K-trees are special chordal graphs. Finding the max-clique in chordal graphs is easy (just enumerate all cliques in a maxcardinality ordering

Max-Cardinality Ordering

Example We see again that G in the Figure (a) is not chordal since the parents of A are not connected in the maxcardinality ordering in Figure (d). If we connect B and C, the resulting induced graph is chordal.

Which Greedy Algorithm is Best? MinFill, prefers a node who add the least number of fill-in arcs. Empirically, fill-in is the best among the greedy algorithms (MW,MIW,MF,MC) Complexity of greedy orderings? MW is O(?), MIW: O(?) MF (?) MC is O(mn)

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Greedy search for induced-width orderings Variable elimination for Linear Inequalities Constraint propagation Search Probabilistic Networks

Linear Inequalities

Linear Inequalities: Fourier Elimination

Directional linear elimination, DLE : generates a backtrack-free representation

Example

Algorithms for Reasoning with graphical models Class4 Rina Dechter

Road Map Graphical models Constraint networks Model Inference Variable elimination for Constraints Variable elimination for CNFs Variable elimination for Linear Inequalities Constraint propagation (ch 2 Dechter2) Search Probabilistic Networks

Sudoku Approximation: Constraint Propagation Constraint Propagation Inference Variables: empty slots Domains = {1,2,3,4,5,6,7,8,9} Constraints: 27 all-different 2 3 42 6 Each row, column and major block must be alldifferent Well posed if it has unique solution: 27 constraints

Approximating Inference: Local Constraint Propagation Problem: bucket-elimination/tree-clustering algorithms are intractable when induced width is large Approximation: bound the size of recorded dependencies, i.e. perform local constraint propagation (local inference)

From Global to Local Consistency

Arc-Consistency R X A binary constraint R(X,Y) is arc-consistent w.r.t. X is every value In x s domain has a match in y s domain. {1,2,3}, R Y {1,2,3}, constraint X Y Only domains are reduced: R X X RXY DY

Arc-Consistency Definition: Given a constraint graph G, A variable V i is arc-consistent relative to V j iff for every value a D Vi there exists a value b D Vj (a, b) R Vi,Vj. Vi Vj Vi Vj 1 1 1 2 2 2 2 3 3 3 The constraint R Vi,Vj is arc-consistent iff V i is arc-consistent relative to V j and V j is arc-consistent relative to V i. A binary CSP is arc-consistent iff every constraint (or sub-graph of size 2) is arc-consistent

Arc-consistency 1 X, Y, Z, T 3 X Y Y = Z T Z X T X 1,2, 3 Y 1,2, 3 1, 2, 3 1,2, 3 T Z =

Arc-consistency 1 X, Y, Z, T 3 X Y Y = Z T Z X T X T Y 1 3 = 2 3 R X Z X RXY DY

AC-1 O( enk 3 ) Complexity (Mackworth and Freuder, 1986): e = number of arcs, n variables, k values (ek^2, each loop, nk number of loops), best-case = ek 2 Arc-consistency is: ( ek ) Complexity of AC-1: O(enk 3 )

AC-3 Complexity: O( ek 3 ) Best case O(ek), since each arc may be processed in O(2k)

Arc-Consistency Algorithms AC-1: brute-force, distributed AC-3, queue-based O( ek O( nek 3 ) 3 ) AC-4, context-based, optimal O( ek 2 ) AC-5,6,7,. Good in special cases Important: applied at every node of search n=number of variables, e=#constraints, k=domain size Mackworth and Freuder (1977,1983), Mohr and Anderson, (1985)

Relational Distributed Arc- Consistency Primal Dual A 1 2 3 A < D 1 2 2 3 A A < B 1 2 2 3 B B = C 1 1 2 2 3 3 B 1 2 3 AB 1 2 2 3 AB AD 1 2 1 2 2 3 2 3 AB A AB BC 1 2 2 2 2 3 3 3 B BC C BC 1 1 2 2 3 3 BC DC 2 2 1 2 3 3 2 3 D 1 2 3 D D < C 1 2 2 3 C C 1 2 3 AD 1 2 2 3 AD D AD DC DC DC 1 2 2 3 1 2 2 3

Path-Consistency A pair (x, y) is path-consistent relative to Z, if every consistent assignment (x, y) has a consistent extension to z.

Example: Path-Consistency

Directional i-consistency D A E C B D C B E D C E B D C B E E : D : C : B : E D, E C, E D C, D A C B A B B Adaptive R DCB R d-path, DC R DB R CB d-arc R D R C R D A :

Variable Elimination Eliminate variables one by one: constraint propagation Solution generation after elimination is backtrack-free 3

Road Map Graphical models Constraint networks Model Inference Variable elimination: Tree-clustering Constraint propagation Search Probabilistic Networks