- 42 Views
- Uploaded on
- Presentation posted in: General

From Constraints to Finite Automata to Filtering Algorithms

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

From Constraintsto Finite Automatato Filtering Algorithms

Mats Carlsson, SICS

Nicolas Beldiceanu, EMN

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

x + y = 92x + 4y = 24

ESOP, March 29, 2004

- Variables
- feature variable domain (finite set of integers)

- implement constraints

- execute propagators until simultaneous fixpoint

ESOP, March 29, 2004

- Propagator p is a procedure (coroutine)
- implements constraintcon(p)
its semantics (set of tuples)

- computes on set of variablesvar(p)

- implements constraintcon(p)

- filters domains of variables in var(p)
- signals failure
- signals entailment

ESOP, March 29, 2004

- Propagators implement filtering
- aka: narrowing, domain reduction, value removal

- impractical in most cases (space)

- can be provided by special propagator
- often: “element” constraint, “relation” constraint, …

ESOP, March 29, 2004

- Normally, a propagator p is resumed whenever some value in a domain of var(p) has been removed.
- In some cases, some events (e.g. removing internal values) are irrelevant whilst other (bounds adjustments) are relevant.

ESOP, March 29, 2004

- A propagator is idempotent if it always computes a fixpoint.
- Most constraint programming systems can accommodate both idempotent and non-idempotent propagators.

ESOP, March 29, 2004

- Implementation uses operations on variables
- reading domain information
- filtering domains (removing values)

- Domain filtering
- Failure detection
- Entailment detection

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

- Basic constraints
- Constraints for which the solver is complete
- x D, x = v, x = y (variable aliasing)

- Constraints for which the solver is complete
- Primitive constraints (need propagators)
- Non-decomposable constraints
- x<y, xy, x+y = z, x*y = z, …

- Non-decomposable constraints
- Global constraints (need propagators)
- Subsume a set of basic or primitive constraints, usually providing stronger consistency

ESOP, March 29, 2004

- Given: constraint C, variable x var(C), its domain D(x), integer v.
- x=vhas support for Ciff
- v D(x)
- C has a solution such that x=v

- x var(C) v D(x) x=v has support for C

ESOP, March 29, 2004

- A constraint con(p) is entailed if it holds for any combination of values in the current domains.
- Consequences for its propagator p:
- It has no more work to do
- It should not be resumed any more (up to backtracking)
- It is usually reponsible for detecting entailment

ESOP, March 29, 2004

- A constraint con(p) is false if it does not hold for any combination of values in the current domains.
- Consequences for its propagator p:
- It should signal inconsistency, e.g. by instigating backtracking
- It is reponsible for detecting failure

ESOP, March 29, 2004

- Vectors and subvectors
- X = (x0,…,xn-1)
- X[0,r) = (x0,…,xr-1), r n

- Domain variables
- D(x), the domain of x (set of integers)
- min(x), lower bound of x, O(1)
- max(x), upper bound of x, O(1)
- prev(x,b) = max{y D(x) | y<b}, O(d)
- next(x,b) = min{y D(x) | y>b}, O(d)

ESOP, March 29, 2004

- The constraint store is the set of all domains D(x)
- For alphabet A, constraint C, constraint store G, let S(C,G,A) be the signature of C wrt. G and A.
- The filtering algorithm is derived from a finite automaton for signatures.

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

- Let:
- X = (x0,…,xn-1)
- Y = (y0,…,yn-1)
- xi, yi domain variables or integers

- X lex Y holds iff
- n=0, or
- x0<y0, or
- x0=y0 (x1,…,xn-1) lex(y1,…,yn-1).

ESOP, March 29, 2004

ESOP, March 29, 2004

ESOP, March 29, 2004

?

<

=

>

E.g., a becomes a < or a = in a ground store.

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

T1

T3

T2

$

$

$

1

2

3

4

$

F1

D1

D3

D2

ESOP, March 29, 2004

T1

$

1

Enforce xi=yi in the leading prefix for C to hold.

Afterwards, the leading prefix is ground and equal.

ESOP, March 29, 2004

T2

<

1

2

4

q

Enforce xq<yq in order for there to be at least one <

preceding the first >.

ESOP, March 29, 2004

T3

$

$

1

2

3

q

Only enforce xqyq , for < can appear in a later position.

ESOP, March 29, 2004

T1

T3

T2

$

$

$

1

2

3

4

q

$

D1

D3

D2

Not yet enough information to know what to do at position q.

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

- Non-incremental, O(n)
- Run finite automaton from scratch
- Consider all letters from scratch

- Incremental, amortized O(1)
- Deal with one letter change at a time
- Needs to know what letter has changed, in what state

ESOP, March 29, 2004

T1

T3

T2

$

$

$

1

2

3

4

$

F1

D1

D3

D2

Resume in state 1.

ESOP, March 29, 2004

T1

T3

T2

$

$

$

1

2

3

4

$

F1

D1

D3

D2

Resume in state 2.

ESOP, March 29, 2004

T1

T3

T2

$

$

$

1

2

3

4

$

F1

D1

D3

D2

Resume in state 3 or 4, resp.

ESOP, March 29, 2004

T1

T3

T2

$

$

$

1

2

3

4

$

F1

D1

D3

D2

If changed to =, no-op. Otherwise, resume in state 3 or 4, resp.

ESOP, March 29, 2004

T1

T3

T2

1

2

3

4

$

$

$

$

F1

D1

D3

D2

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

- Let:
- Xi = (xi0,…,xin-1)
- xij domain variables or integers

- lex_chain(X0,…,Xm-1) holds iff
X0 lex… lexXm-1

ESOP, March 29, 2004

- Preconditions:
- A = (a0,…,an-1), B = (b0,…,bn-1)
- X = (x0,…,xn-1)
- ai,bi integers; xi domain variables
- i[0,n) : ai D(xi), bi D(xi)

- Holds iff:
Alex X lexB

ESOP, March 29, 2004

ESOP, March 29, 2004

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

State 1 denotes a prefix in which ai=bi. Hence we must enforce xi=ai=bi there.

T1

T2

«$

<«»#$

<

1

2

=#

>=

>»

F1

ESOP, March 29, 2004

Either q=n or xq=v has support for all aqvbq.

Hence we enforce aqxqbq.

T1

«$

q

1

=#

ESOP, March 29, 2004

We have:

X[0,r)=A[0,r)X[0,r)=B[0,r)

Hence we enforce:

aixibi for i[0,r).

T2

<«»#$

r

<

1

2

=#

>=

Either r=n or xr=v has support for all vbr var.

Hence we enforce:

xrbr xrar.

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

- Given X and B, compute the lexicographically largest U such that:
U lex B i[0,n) : ui D(xi)

- Similarly for feasible lowest bound

ESOP, March 29, 2004

- Compute as the smallest i such that
U[0,i)B[0,i)

- Compute:
- ui = bi, if i <
- ui = prev(xi,bi), if i =
- ui = max(xi), if i >

- Similarly for feasible lowest bound

ESOP, March 29, 2004

- Compute feasible upper bound Bi for Xi from i=m-1 down to i=0.
- Compute feasible lower bound Ai for Xi from i=0 to i=m-1.
- Enforce AilexXilex Bi for all i.
Arc-consistency in O(nmd) time.

ESOP, March 29, 2004

- Constraint Propagation: Example & Model
- Constraints and Key Notions
- Case Study: X lex Y
- Definition and signature
- Finite automaton
- Filtering algorithm

- Definition and signature
- Finite automaton
- Filtering algorithm

ESOP, March 29, 2004

- An approach to designing filtering algorithms by derivation from FAs on constraint signatures
- Case studies and hyperarc consistency algorithms for two constraints:
- X lex Y, running in amortized O(1) time per propagation event
- lex_chain(X0,…,Xm-1), running in O(nmd) time per invocation

ESOP, March 29, 2004

- What constraints are amenable to the approach?
- Where does the alphabet come from?
- Where does the automaton come from?
- Where do the pruning rules come from?
- How do we make the algorithms incremental?

ESOP, March 29, 2004

- SICS T2002-17:Revisiting the Lexicographic Ordering Constraint, Mats Carlsson, Nicolas Beldiceanu.
- SICS T2002-18:Arc-Consistency for a Chain of Lexicographic Ordering Constraints, Mats Carlsson, Nicolas Beldiceanu.
- http://www.sics.se/libindex.html

ESOP, March 29, 2004

- Global constraints for lexicographic orderings. A. Frisch, B. Hnich, Z. Kızıltan, I. Miguel, T. Walsh. Proc. CP’2002. LNCS 2470, pp. 93-108, Springer, 2002.

ESOP, March 29, 2004