1 the topic 2 tasks 3 modeling 3.2 constraint systems goal

21
Model-Based Systems & Qualitative Reasoning Group of the Technical University of Munich - 55 Knowledge-based Systems for Industrial Applications 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal: Implementation of behavior prediction Definition Algorithms Complexity SS 15 KBSIA 3

Upload: others

Post on 10-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 55

Knowledge-based Systems for Industrial Applications

1 The Topic

2 Tasks

3 Modeling

3.2 Constraint Systems

Goal:

Implementation of behavior

prediction

Definition

Algorithms

Complexity

SS 15 KBSIA 3

Page 2: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 56 SS 15 KBSIA 3

Example: A Crossword Puzzle

1 2 3

4 5

6 7

8

Instructions

fill in words from the list

List of Words

Aft

Ale

Eel

Hike

Hoses

Keel

Knot

Laser

Lee

Line

Sails

Sheet

Steer

Tie

Page 3: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 57 SS 15 KBSIA 3

Definitions

Variables and Domains

variables V = {v1, v2, ..., vn}

domains D = {DOM(v1), DOM(v2), ..., DOM(vn)}

Constraints

relations Ri DOM(vk1) DOM(vk2) ... DOM(vkj)

Constraint Satisfaction Problem (CSP)

Given (V, D, C)

determine tuples in DOM(v1) DOM(v2) ... DOM(vn)

that satisfy given set of constraints C = {R1, R2, ..., Rc}

Page 4: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 58 SS 15 KBSIA 3

Example: CSP for the Crossword Puzzle

Variables V

V = {1 across, 4 across, 2 down, ... }

Domains D

For all i DOMi = {Aft, Ale, Eel, Hike, ...}

Constraints C

For each variable vi:

Equal(LengthWord(vi), NumberPositions(vi))

For two variables vi, vj sharing positions pik, pjl:

Equal(Character(pik),Character(pjl))

Page 5: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 59 SS 15 KBSIA 3

Graphical Representations of CSPs

Primal Constraint Graph

nodes represent variables

hyperarcs represent constraints

Dual Constraint Graph

nodes represent constraints

multiarcs represent variables

C1 C2

v2

C3

v2 v3 v2 v4

v1

v2

v3 v4

C1

C2

C3

Page 6: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 60 SS 15 KBSIA 3

Example: Primal Constraint Graph for the Crossword Puzzle

1 across 4 across 7 across 8 across

2 down 3 down 5 down 6 down

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Aft

Ale

Eel

Hike

...

Page 7: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 61 SS 15 KBSIA 3

Solving CSPs

Basic Search Methods

general search strategies

– generate and test

– chronological backtracking:

backtracking to the last choice

“gather information while searching”

strategies

– dependency-directed backtracking:

(ddp) backtracking to a choice that

caused the inconsistency

– truth maintenance systems:

record dependencies and avoid

choices leading to discovered

inconsistencies (see ch. 4.3)

Page 8: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 62 SS 15 KBSIA 3

Problem Reduction

Removing Domain Values through Constraint Filtering

remove values for nodes (1-consistency, “node consistency”)

remove values for arcs (2-consistency, “arc consistency”)

...

remove values for paths of length k-1 (k-consistency)

Basic Idea

reduce size of CSP without ruling out solutions

Page 9: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 63 SS 15 KBSIA 3

Algorithm for Node Consistency

Procedure NC (V, D, C)

For each vi V

For each Rj C with Rj DOM(vi)

For each a DOM(vi)

If a Rj Then DOM(vi) DOM(vi) \ {a}

Return (V, D, C)

Note:

Here: DOM not fixed

Initial domain given

Then reduced by removing inconsistent values

Page 10: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 64 SS 15 KBSIA 3

Crossword Puzzle: After Applying Node Consistency

1 across 4 across 7 across 8 across

2 down 3 down 5 down 6 down

Hoses

Laser

Sails

Sheet

Steer

Hike

Keel

Knot

Line

Aft

Ale

Eel

Lee

Tie

Hoses

Laser

Sails

Sheet

Steer

Hoses

Laser

Sails

Sheet

Steer

Hoses

Laser

Sails

Sheet

Steer

Hike

Keel

Knot

Line

Aft

Ale

Eel

Lee

Tie

Page 11: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 65 SS 15 KBSIA 3

Definition: (Classical) Arc-Consistency (2-Consistency)

Constraint network R = ( V, D, C)

Binary constraints Rik C

Variable vi is arc-consistent relative to vk

iff for every value ai DOM(vi)

there exists ak DOM(vk)

such that (ai, ak) Rik

Arc (vi, vk) is arc-consistent

iff vi is arc-consistent relative to vk and

vk is arc-consistent relative to vi

( V, D, C) is arc-consistent

iff all arcs are arc-consistent

compute by closure over DOM(vi) DOM(vi) i (Rik DOM(vk) )

i: projection to vi

Page 12: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 66 SS 15 KBSIA 3

Algorithm for Arc Consistency

Procedure REVISE_DOMAIN (vi,vk)

deleted False;

For each ai DOM(vi)

If Not exists ak DOM(vk) such that (ai,ak) Ri,k

Then

DOM(vi) DOM(vi) \ {ai};

deleted True

return(deleted)

compute by closure over DOM(vi) DOM(vi) i (Rik DOM(vk) )

i: projection to vi

Page 13: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 67 SS 15 KBSIA 3

AC-1: A Simple Algorithm for Arc Consistency

Procedure AC-1 (V, D, C)

agenda {(vi,vk) | 1 i,k n, i k};

Repeat

changed False;

For each (vi,vk) agenda

changed REVISE_DOMAIN(vi,vk) or changed

Until Not changed;

return(V,D,C)

compute by closure over DOM(vi) DOM(vi) i (Rik DOM(vk) )

i: projection to vi

Page 14: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 68 SS 15 KBSIA 3

AC-3: An Improved Algorithm for Arc Consistency

Procedure AC-3 (V, D, C)

agenda {(vi,vk) | 1 i,k n, i k};

While agenda { }

choose (vi,vk) agenda;

agenda agenda \ (vi,vk);

If REVISE_DOMAIN(vi,vk) Then

agenda agenda {(vm,vi) | 1 m n, m k,i}

Wend;

return(V,D,C)

compute by closure over DOM(vi) DOM(vi) i (Rik DOM(vk) )

i: projection to vi

Page 15: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 69 SS 15 KBSIA 3

Example: Crossword Puzzle: Applying Arc Consistency

1 across 4 across 7 across 8 across

2 down 3 down 5 down 6 down

Hoses

Laser

Sails

Sheet

Steer

Hike

Keel

Knot

Line

Aft

Ale

Eel

Lee

Tie

Hoses

Laser

Sails

Sheet

Steer

Hoses

Laser

Sails

Sheet

Steer

Hoses

Laser

Sails

Sheet

Steer

Hike

Keel

Knot

Line

Aft

Ale

Eel

Lee

Tie

Page 16: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 70 SS 15 KBSIA 3

Example: Crossword Puzzle: Solution

1 2 3

4 5

6 7

8

H

K

O S E S

T

E I

A

H

A L

E

E

R E S A L

E

L

Page 17: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 71 SS 15 KBSIA 3

Definition: Classical Path-Consistency (3-Consistency)

Constraint network R = ( V, D, C)

{ vi, vj } is path-consistent relative to vk

iff for every consistent assignment (vi = ai, vj = aj)

there is a value ak DOM(vk) such that

the assignments (vi=ai, vk=ak) and (vk=ak,vj=aj) are consistent

A binary constraint Rij is path-consistent relative to vk

iff for every tuple (ai,aj) Rij

there is ak DOM(vk) such that (ai,ak) Rik and (ak,aj) Rkj

A constraint network is path-consistent

iff every Rij is path-consistent relative to vk for every k i, j

compute by closure over Rij Rij ij (Rik DOM(vk) Rkj)

ij: projection to variables of Rij

Page 18: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 72 SS 15 KBSIA 3

Complexity of Constraint Filtering (Binary CSPs)

Polynomial Algorithms

n: number of variables

c: number of constraints

d: (maximal) domain size

Time Space

2-consistency

3-consistency

O(cd3) O(c+nd)

O(cd2) O(cd2)

O(n3d3) O(n3d3)

Page 19: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 73 SS 15 KBSIA 3

Example: Centigrade - Fahrenheit: 9C = 5(F-32)

Evaluation of Constraints

no built-in “direction”

Incompleteness due to directed computation (cf. slide 4.46)

compare this to statement in programming languages like C++

compare this to Matlab

u=Mult(C,w)

9 5 32 y x

C F v

w

u u=Mult(v,x) F=Add(v,y)

!

Page 20: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 74 SS 15 KBSIA 3

Completeness of Consistency Filtering

Theoretical Results

[Freuder 78]: k-consistency does in general

not guarantee existence of solutions

[Dechter-Pearl 88]: arc consistency sufficient

for tree-structured constraint graphs

ADD ADD

y x z

x = 1

z = 5

y = ?

Page 21: 1 The Topic 2 Tasks 3 Modeling 3.2 Constraint Systems Goal

Model-Based Systems & Qualitative Reasoning

Group of the Technical University of Munich - 75 SS 15 KBSIA 3

References

[Dechter 03] “Constraint Processing”, Morgan

Kaufmann, 2003

• http://www.aispace.org/index.shtml