CompSci 275, C ONSTRAINT Networks Rina Dechter, Fall 2020 - - PowerPoint PPT Presentation

compsci 275 c onstraint networks
SMART_READER_LITE
LIVE PREVIEW

CompSci 275, C ONSTRAINT Networks Rina Dechter, Fall 2020 - - PowerPoint PPT Presentation

CompSci 275, C ONSTRAINT Networks Rina Dechter, Fall 2020 Introduction, the constraint network model Chapters 1-2 Fall 2020 1 Class information Instructor: Rina Dechter Lectures: Monday & Wednesday Time: 3:30 4:50 pm


slide-1
SLIDE 1

CompSci 275, CONSTRAINT Networks

Rina Dechter, Fall 2020

Fall 2020 1

Introduction, the constraint network model Chapters 1-2

slide-2
SLIDE 2

Class information

  • Instructor:

Rina Dechter

  • Lectures:

Monday & Wednesday

  • Time:

3:30 ‐ 4:50 pm

  • Class page:

https://www.ics.uci.edu/~dechter/courses/ics‐275/fall‐ 2020/

Fall 2020 2

slide-3
SLIDE 3

Text book (required)

Rina Dechter, Constraint Processing, Morgan Kaufmann

Fall 2020 3

slide-4
SLIDE 4

Outline

 Motivation, applications, history  CSP: Definition, and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 4

slide-5
SLIDE 5

Outline

 Motivation, applications, history  CSP: Definition, representation and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 5

slide-6
SLIDE 6

Combinatorial problems

Fall 2020 6

Combinatorial Problems MO Optimization Optimization Decision

Graphical Models Graphical Models Those problems that can be expressed as: A set of variables Each variable takes its values from a finite set of domain values A set of local functions Main advantage: They provide unifying algorithms:

  • Search
  • Complete Inference
  • Incomplete Inference
slide-7
SLIDE 7

Combinatorial problems

Fall 2020 7

Combinatorial Problems MO Optimization Optimization Decision

Graphical Models Many Examples

x1 x2 x3 x4

Graph Coloring Timetabling EOS Scheduling … and many others. Bayesian Networks

slide-8
SLIDE 8

Example: student course selection

  • 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

– Courses have prerequisites you have/don't have Courses/instructors you

like/dislike

– Courses are scheduled at the same time – In CE: 4 courses from 5 tracks such that at least 3 tracks are covered

  • You have choices, but are restricted by constraints

– Make the right decisions!! – ICS Graduate program

Fall 2020 8

slide-9
SLIDE 9

Student course selection (continued)

  • Given

– A set of variables: 4 courses at your college – For each variable, a set of choices (values): the available classes. – 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 many solutions exists? (counting) – How two or more solutions differ? – Which solution is preferable? – etc.

Fall 2020 9

slide-10
SLIDE 10

The field of constraint programming

  • How did it start:

– Artificial Intelligence (vision) – Programming Languages (Logic Programming), – Databases (deductive, relational) – Logic‐based languages (propositional logic) – SATisfiability

  • Related areas:

– Hardware and software verification – Operation Research (Integer Programming) – Answer set programming

  • Graphical Models; deterministic

Fall 2020 10

slide-11
SLIDE 11

Fall 2020 11

Scene labeling constraint network

slide-12
SLIDE 12

Fall 2020 12

Scene labeling constraint network

slide-13
SLIDE 13

Fall 2020 13

3-dimentional interpretation of 2-dimentional drawings

slide-14
SLIDE 14

The field of constraint programming

  • How did it start:

– Artificial Intelligence (vision) – Programming Languages (Logic Programming), – Databases (deductive, relational) – Logic‐based languages (propositional logic) – SATisfiability

  • Related areas:

– Hardware and software verification – Operations Research (Integer Programming) – Answer set programming

  • Graphical Models; deterministic

Fall 2020 14

slide-15
SLIDE 15

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

Fall 2020 15

x1 x2 x3 x4

Graph Coloring Timetabling EOS Scheduling

… and many others.

Bayesian Networks

slide-16
SLIDE 16

Outline

 Motivation, applications, history  CSP: Definitions and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 16

slide-17
SLIDE 17

Fall 2020 17

A B

red green red yellow green red green yellow yellow green yellow red

Example: map coloring

Variables - countries (A,B,C,etc.) Values - colors (red, green, blue) Constraints:

etc. , E D D, A B, A   

C A B D E F G

A B E G D F C

Constraint graph

Constraint networks

slide-18
SLIDE 18

Fall 2020 18

Example: map coloring

Variables - countries (A,B,C,etc.) Values - colors (e.g., red, green, yellow) Constraints:

etc. , E D D, A B, A   

A B C D E… red

green

red

green blue

red

blue

green

green blue

… … … …

green

… … … … red red

blue

red

green

red

Are the constraints consistent? Find a solution, find all solutions Count all solutions Find a good solution

Constraint satisfaction tasks

slide-19
SLIDE 19

Information as constraints

  • I have to finish my class in 50 minutes
  • 180 degrees in a triangle
  • Memory in our computer is limited
  • The four nucleotides that makes up a DNA only combine in a

particular sequence

  • Sentences in English must obey the rules of syntax
  • Susan cannot be married to both John and Bill
  • Alexander the Great died in 333 B.C.

Fall 2020 19

slide-20
SLIDE 20

Constraint network; definition

} ,..., {

1 n

X X X 

Fall 2020 20

  • A constraint network is: R=(X,D,C)

– X variables – D domain – C constraints – 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

} ,... { }, ,..., {

1 1 k i n

v v D D D D  

) , ( , , }, ,... {

1 i i i t

R S C C C C  

slide-21
SLIDE 21

Fall 2020 21

The N-queens problem

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

slide-22
SLIDE 22

A solution and a partial consistent tuple (configuration)

Fall 2020 22

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).

slide-23
SLIDE 23

Example: crossword puzzle

Fall 2020 23

  • Variables: x1, …, x13
  • 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}

slide-24
SLIDE 24

Example: Sudoku (constraint propagation)

Fall 2020 26

Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints

2 3 4 6

2

Constraint propagation

  • Variables: 81 slots
  • Domains =

{1,2,3,4,5,6,7,8,9}

  • Constraints:
  • 27 not-equal
slide-25
SLIDE 25

Sudoku (inference)

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

Fall 2020 27

slide-26
SLIDE 26

Outline

 Motivation, applications, history  CSP: Definition, representation and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 28

slide-27
SLIDE 27

Mathematical background

  • Sets, domains, tuples
  • Relations
  • Operations on relations
  • Graphs
  • Complexity

Fall 2020 29

slide-28
SLIDE 28

Fall 2020 30

Two Representations of a relation: R = {(black, coffee), (black, tea), (green, tea)}.

Variables: Drink, color

slide-29
SLIDE 29

Fall 2020 31

Two Representations of a relation: R = {(black, coffee), (black, tea), (green, tea)}.

Variables: Drink, color

slide-30
SLIDE 30

Fall 2020 32

Examples

slide-31
SLIDE 31

Operations with relations

  • Intersection
  • Union
  • Difference
  • Selection
  • Projection
  • Join
  • Composition

Fall 2020 33

slide-32
SLIDE 32

Relations are local functions

Fall 2020 34

  • Relations are special case of a Local function

where scope(f) = Y  X: scope of function f A: is a set of valuations

  • In constraint networks: functions are boolean

A D f

Y x i

i

:

x1 x2

f a a true a b false b a false b b true

x1 x2

a a b b

relation

slide-33
SLIDE 33

Fall 2020 35

Set operations: intersection, union, difference on relations.

slide-34
SLIDE 34

Fall 2020 36

Selection, projection, join

slide-35
SLIDE 35

Fall 2020 37

The join and the logical “and”

x1 x2

a a b b

x2 x3

a a a b b a

x1 x2 x3 a a a a a b b b a

g f

x1 x2

f a a true a b false b a false b b true

x2 x3

g a a true a b true b a true b b false

x1 x2 x3 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

  • Join :
  • Logical AND:
slide-36
SLIDE 36

Outline

 Motivation, applications, history  CSP: Definition, representation and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints/ Languages  Constraint graphs  The binary Constraint Networks properties

Fall 2020 38

slide-37
SLIDE 37

Modeling; Representing a problems

  • If a CSP M = <X,D,C> represents a real problem P , then every solution of

M corresponds to a solution of P and every solution of P can be derived from at least one solution of M

  • The variables and values of M represent entities in P
  • The constraints of M ensure the correspondence between solutions
  • The aim is to find a model M that can be solved as quickly as possible
  • goal of modelling: choose a set of variables and values that allows

the constraints to be expressed easily and concisely

Fall 2020 39 x4 x3 x2 x1 a b c d

slide-38
SLIDE 38

Example: satisfiability

Fall 2020 40

 = {(A v B), (C v ¬B)}

Given a proposition theory does it have a model?

Can it be encoded as a constraint network?

Variables: Domains: Relations: {A, B, C} DA = DB = DC = {0, 1}

A B

1 1 1 1

B C

1 1 1

slide-39
SLIDE 39

Constraint’s representations

  • Relation: allowed tuples
  • Algebraic expression:
  • Propositional formula:
  • A decision tree, a procedure
  • Semantics: by a relation

Y X Y X    , 10

2

c b a

 ) (

Fall 2020 41

3 1 2 2 3 1 Z Y X

A decision tree or a neural network

slide-40
SLIDE 40

X Y Z T 1 1 1 1 1 1 1 1 1 1 1

X Y Y Z Z Z T T T T

1 1 1 1 1 1 1 1 1

Decision tree representations

X Y Z 1 1 1 1 1 1 1 1 1 1 1 1

X v Y v Z X Y

1

Y

1 1

slide-41
SLIDE 41

Outline

 Motivation, applications, history  CSP: Definition, representation and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 43

slide-42
SLIDE 42

Constraint graphs:

Primal, Dual and Hypergraphs

45 1 2 5 4 3 6 9 12 7 11 8 10 13 5,7,11 8,9,10,11 10,13 12,13 1,2,3,4,5 3,6,9,12 3 12 13 10 11 5 9 (a) (b)

  • 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

C A B D E F G

R{1,2,3,4;,5}= {(H,O,S,E,S), (L,A,S,E,R), (S,H,E,E,T), (S,N,A,I,L), (S,T,E,E,R)} R{3,6,9,12} = {(A,L,S,O), (E,A,R,N),(H,I,K,E), (I,R,O,N), (S A M E)}

slide-43
SLIDE 43

Graph concepts Reviews:

Hyper Graphs and Dual Graphs

Fall 2020 46

Primal graphs Dual graph Factor graphs A hypergraph Definition 2.1.1 (hypergraph) A hypergraph is a structure H = (V; S) that consists

  • f vertices V = {v_1,…, v_n} and a set of subsets of these vertices S =

{S 1,…;S l}

slide-44
SLIDE 44

Example: cryptarithmetic

Variables: F T U W R O X1 X2 X3 Domains: {0,1,2,3,4,5,6,7,8,9} Constraints: Alldiff (F,T,U,W,R,O)

O + O = R + 10 ꞏ X1 X1 + W + W = U + 10 ꞏ X2 X2 + T + T = O + 10 ꞏ X3 X3 = F, T ≠ 0, F ≠ 0

What is the primal graph? What is the dual graph?

Fall 2020 48

slide-45
SLIDE 45

Propositional satisfiability

Fall 2020 49

 = {(¬C), (A v B v C), (¬A v B v E), (¬B v C v D)}.

slide-46
SLIDE 46

Example: radio link assignment

50

cost

i j

f f   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

Fall 2020

Constraints: the ones referring to the antennas in the same communication link

slide-47
SLIDE 47

Fall 2020 51

Constraint graphs, 3 instances of radio frequency assignment in CELAR’s benchmark

slide-48
SLIDE 48

Fall 2020 52

Example: scheduling problem

Variables: one for each task Domains: DT1 = DT2 = DT3 = DT3 = {1:00, 2:00, 3:00} Five tasks: T1, T2, T3, T4, T5 Each one takes one hour to complete The tasks may start at 1:00, 2:00 or 3:00 Requirements: T1 must start after T3 T3 must start before T4 and after T5 T2 cannot execute at the same time as T1 or T4 T4 cannot start at 2:00

T4

1:00 3:00

slide-49
SLIDE 49

Fall 2020 53

The constraint graph and relations

  • f scheduling problem
slide-50
SLIDE 50

Fall 2020 57

A combinatorial circuit M a multiplier, A is an adder

slide-51
SLIDE 51

Outline

 Motivation, applications, history  CSP: Definition, representation and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 58

slide-52
SLIDE 52

Fall 2020 59

Binary constraint networks

Equivalence and deduction with constraints (composition) A graph  to be colored by two colors, an equivalent representation ’ having a newly inferred constraint between x1 and x3.

slide-53
SLIDE 53

Composition of relations (Montanari'74)

Input: two binary relations Rab and Rbc with one variable in common. Output: a new induced relation Rac . Bit‐matrix operation: matrix multiplication

60

bc ab ac

R R R  

? , 1 1 1 1 , 1 1 1                     

ac bc ab

R R R

Constraint deduction can be accomplished through the composition operation.

slide-54
SLIDE 54

Equivalence, redundancy, composition

  • Equivalence: Two constraint networks are

equivalent if they have the same set of solutions.

  • Composition in matrix notation
  • Composition in relational operation

Fall 2020 61

) (

yz xy xz xz

R R R   

𝑆 𝑆 · 𝑆 ⋈

slide-55
SLIDE 55

Relations vs networks

  • Can we represent by binary constraint

networks the relations

  • R(𝑦, 𝑦 , 𝑦) = {(0,0,0)(0,1,1)(1,0,1)(1,1,0)}
  • R(𝑦, 𝑦 , 𝑦 , 𝑦) = {(1,0,0,0)(0,1,0,0) (0,0,1,0)(0,0,0,1)}
  • Number of relations
  • Number of networks:
  • Most relations cannot be represented by

binary constraint networks

Fall 2020 62

slide-56
SLIDE 56

Fall 2020 63

The N-queens constraint network is there a tighter 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)

slide-57
SLIDE 57

Fall 2020 64

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) 2 2

slide-58
SLIDE 58

The projection networks

  • The projection network of a relation is obtained by

projecting it onto each pair of its variables (yielding a binary network).

  • Relation = {(1,1,2)(1,2,2)(1,2,1)}

– What is the projection network?

  • What is the relationship between a relation and its

projection network?

  • R = {(1,1,2)(1,2,2)(2,1,3)(2,2,2)}
  • What are the solutions of its projection network?

Fall 2020 65

slide-59
SLIDE 59

Projection network (continued)

  • Theorem: Every relation is included in the

set of solutions of its projection network.

  • Theorem: The projection network is the

tightest upper bound binary networks representation of the relation.

Fall 2020 66

Therefore, If a network cannot be represented by its projection network it has no binary network representation

slide-60
SLIDE 60

Example: Sudoku (constraint propagation)

Fall 2020 67

Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints

2 3 4 6

2

Constraint propagation

  • Variables: 81 slots
  • Domains =

{1,2,3,4,5,6,7,8,9}

  • Constraints:
  • 27 not-equal

What is the minimal network? The projection network?

slide-61
SLIDE 61

Outline

 Motivation, applications, history  CSP: Definition, and simple modeling examples  Mathematical concepts (relations, graphs)  Representing constraints  Constraint graphs  The binary Constraint Networks properties

Fall 2020 72