SLIDE 1
Soft’01, Paphos, Cyprus
Sweep as a Generic Pruning Technique Applied to Constraint Relaxation Nicolas Beldiceanu and Mats Carlsson SICS
Lägerhyddsvägen 18 75237 Uppsala email: nicolas@sics.se
SLIDE 2 Outline of the Presentation
INTRODUCTION
- Sweep Algorithms in Computational Geometry
- Main Ideas of Sweep Algorithms
CARDINALITY OPERATOR
- Representing an Elementary Constraint: Forbidden and Safe Regions
- The Sweep Algorithm
CONCLUSION
SLIDE 3 Sweep Algorithms in Computational Geometry
Standard technique in the design of efficient algorithms, described in:
- Computational geometry, an introduction
[Preparata & Shamos, 1985]
- Computational Geometry, Algorithms and Applications
[Berg, Kreveld, Overmars & Schwarzkopf, 1997]
[Boissonnat & Yvinec, 1995]
SLIDE 4 Applications of Sweep Algorithms
Within the Geometry Literature Database, more than 100 references:
- Voronoi diagram
- Map overlay
- Nearest objects
- Triangulations
- Hidden surface removals
- Rectangles intersection
- Shortest path
But not yet common within constraint programming !
SLIDE 5 Applications of Sweep Algorithms within Constraint Programming
Pruning for the following constraint patterns:
- A conjunction of constraints with two shared variables
TRICS, CP’01 [Beldiceanu,Carlsson]
- The cardinality operator with two shared variables
Soft’01 [Beldiceanu,Carlsson]
- The non-overlapping constraint between polygons
CP’01 [Beldiceanu,Guo,Thiel]
- A multi-resource cumulatives constraint
http://www.sics.se/libindex.html [Beldiceanu,Carlsson]
- Filtering algorithms for tabular constraints
CICLOPS’01 [Bartak]
SLIDE 6 Main Ideas of Sweep Algorithms
(in the context of line segment intersection) y x
event point sweep line sweep line status (1) (2)
Steps of the sweep algorithm:
(1) Move to the next event point (2) Update the sweep line status:
- start events:
- end events:
GOAL: the worst case complexity should also depend of the number of intersections
SLIDE 7 A Restricted Case of the cardinality Operator
The cardinality operator, Van Hentenryck, P., Deville, Y. (ICLP 1991): : C = ∑ #CTRj(V1,.., Vm ) A restricted case of the cardinality operator :
j=1 n
- Definition
- Pruning
- Restriction
- Pruning
: 2 variables X and Y occur in each constraint CTRj
j
considers interaction between constraints (through the shared variables) : : based on counting entailment
SLIDE 8
Forbidden and Safe Regions
Two intervals inf_x..sup_x and inf_y..sup_y such that: ∀ x ∈ inf_x..sup_x, ∀ y ∈ inf_y..sup_y: Ctr with the assignment X=x and Y=y is false. DEFINITION forbidden region according to a constraint Ctr and 2 variables X,Y of Ctr : Two intervals inf_x..sup_x and inf_y..sup_y such that: ∀ x ∈ inf_x..sup_x, ∀ y ∈ inf_y..sup_y: Ctr with the assignment X=x and Y=y is true. DEFINITION safe region according to a constraint Ctr and 2 variables X,Y of Ctr :
X Y
0 1 2 3 4 1 2 3 4
0 ≤ X ≤ 4 0 ≤ Y ≤ 4 1 ≤ S ≤ 6 X + 2Y ≤ S
EXAMPLE
SLIDE 9
Examples of Forbidden and Safe Regions
(A) (B) (C) (D) (E)
0≤X≤4 0≤Y≤4 0≤R≤9 X Y 0 1 2 3 4 1 2 3 4 X Y 0 1 2 3 4 1 2 3 4 X Y 0 1 2 3 4 1 2 3 4 0≤X≤4 0≤Y≤4 2≤Z≤3 0≤X≤4 0≤Y≤4 0≤T≤0 1≤U≤2 X Y 0 1 2 3 4 1 2 3 4 0≤X≤4 0≤Y≤4 alldifferent( |X-Y|>Z X Y 0 1 2 3 4 1 2 3 4 0≤X≤4 0≤Y≤4 1≤S≤6 X+2Y≤S X+1≤T ∨ T+1≤X ∨ Y+1≤U ∨ U+4≤Y X+Y≡0 (mod 2) {X,Y,4-Y,R})
SLIDE 10
0 1 2 3 4 1 2 3 4
get_first_regions(X,Y,Ctr) get_next_regions(X,Y,Ctr,Previous) get_last_regions(X,Y,Ctr) get_prev_regions(X,Y,Ctr,Previous)
Primitives for Getting Forbidden/Safe Regions on Request
X Y get_first_regions X Y get_next_regions X Y get_next_regions max(Y) X Y min(X) max(X) min(Y) X+Y≡0 (mod 2) 0 1 2 3 4 1 2 3 4 0 1 2 3 4 1 2 3 4
0 1 2 3 4
1 2 3 4
SLIDE 11 Sweep Line Status
For each y ∈ dom(Y):
- number of safe regions
- number of forbidden regions
containing the point (Δ,y) Y X
Δ
sweep line status Y
1,0 1,1 0,1 0,1 1,0 1,0
X Remove a value Δ ∈ dom(X) if for all y ∈ dom(Y): nsafe[y]..nctr−nforbidden[y] ∩ C = ∅ Forbidden regions Safe regions
SLIDE 12
alldifferent({X,Y,4-Y,R})
An Example
0≤X≤4 0≤Y≤4 2≤Z≤3 1≤S≤6 0≤T≤0 1≤U≤2 alldifferent({X,Y,4-Y, R}) |X-Y|>Z X+2Y≤S X+1≤T ∨ T+1≤X ∨ Y+1≤U ∨ U+4≤Y X+Y≡0 (mod 2)
PROBLEM:
Adjust minimum of X according to Y and to the fact that 4 or 5 constraints should hold: |X-Y|>Z X+2Y≤S X+1≤T ∨ T+1≤X ∨ Y+1≤U ∨ U+4≤Y X+Y≡0 (mod 2) Y X=0
1 2 3 4
Y
1 2 3 4
X=2 Y
1 2 3 4
X=1
Deduction: X>1
SLIDE 13 Possible Utilisations
- Feasibility check
- Adjusting bounds
- Pruning values
X Y X Y X Y
SLIDE 14 Typical Constraint Structure for Applying Sweep
- A R G U M E N T(S)
- R E S T R I C T I O N (S)
- V E R T E X I N P U T
- V E R T E X G E N E R A T O R
- E D G E I N P U T
- E D G E G E N E R A T O R
- E D G E A R I T Y
- E D G E C O N S T R A I N T
- G R A P H P R O P E R T Y
: COUNT : dvar : OBJECTS: collection(X-dvar,Y-dvar,...) : required(OBJECTS.X,OBJECTS.Y) : OBJECTS : IDENTITY : OBJECTS : CLIQUE(≠) : 2 : : NEDGE = COUNT
X1,Y1 X2,Y2 X3,Y3 X4,Y4
Non-overlapping Scheduling with set-up Cyclic scheduling
SLIDE 15 Summary
Conjunction
Cardinality
Sweep axis Event points Sweep status
variable to prune
- start of forbidden regions
- end of forbidden regions
- # of forbidden regions
- # of forbidden regions
- # of safe regions
- contradiction
- start of forbidden regions
- end of forbidden regions
- start of safe regions
- end of safe regions
- domain of the
variable to prune
SLIDE 16 Conclusion
- Yet another use of sweep algorithms
(sweep algorithms were already used for a lot of different purpose)
- Combine generality (forbidden, safe regions) with a specific algorithm (sweep)
(lead to a generic class of propagation algorithms and to open global constraints)
- Worst case complexity of the algorithm could perhaps be improved
(for instance by using specialized data structures for searching the relevant regions)