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 Soft’01, Paphos, Cyprus
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
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] • Géométrie algorithmique [Boissonnat & Yvinec, 1995]
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 !
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 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] The cardinality operator with two shared variables • Soft’01 [Beldiceanu,Carlsson]
Main Ideas of Sweep Algorithms (in the context of line segment intersection) GOAL : the worst case complexity should also depend of the number of intersections sweep line event point y (1) Steps of the sweep algorithm: (1) Move to the next event point (2) (2) Update the sweep line status : • start events: sweep line status • end events: x
A Restricted Case of the cardinality Operator The cardinality operator , Van Hentenryck, P., Deville, Y. (ICLP 1991) : n : C = ∑ # CTR j (V 1 ,.., V m ) • Definition j j=1 counting : based on • Pruning entailment A restricted case of the cardinality operator : • Restriction : 2 variables X and Y occur in each constraint CTR j considers interaction between constraints • Pruning : (through the shared variables)
Forbidden and Safe Regions 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 false . DEFINITION safe 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 . EXAMPLE Y 0 ≤ X ≤ 4 4 3 0 ≤ Y ≤ 4 2 1 ≤ S ≤ 6 1 0 X + 2 Y ≤ S 0 1 2 3 4 X
Examples of Forbidden and Safe Regions Y Y Y Y Y 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 0 0 0 0 0 0 1 2 3 4 X 0 1 2 3 4 X 0 1 2 3 4 X 0 1 2 3 4 X 0 1 2 3 4 X 0 ≤ X ≤ 4 0 ≤ X ≤ 4 0 ≤ X ≤ 4 0 ≤ X ≤ 4 0 ≤ Y ≤ 4 0 ≤ X ≤ 4 0 ≤ Y ≤ 4 0 ≤ Y ≤ 4 0 ≤ Y ≤ 4 0 ≤ Y ≤ 4 0 ≤ T ≤ 0 1 ≤ U ≤ 2 0 ≤ R ≤ 9 2 ≤ Z ≤ 3 1 ≤ S ≤ 6 X +1 ≤ T ∨ T +1 ≤ X ∨ alldifferent( Y +1 ≤ U ∨ { X , Y ,4- Y , R }) | X - Y | > Z X +2 Y ≤ S U +4 ≤ Y X + Y ≡ 0 (mod 2) (A) (B) (C) (D) (E)
Primitives for Getting Forbidden/Safe Regions on Request Y Y 4 4 max(Y) 3 3 2 2 1 1 0 0 min(Y) 0 1 2 3 4 0 1 2 3 4 X X Y min(X) max(X) 4 get_first _regions 3 2 X + Y ≡ 0 (mod 2) 1 0 0 1 2 3 4 X Y get_next _regions 4 3 2 get_first _regions(X,Y,Ctr) 1 0 get_next _regions(X,Y,Ctr,Previous) 0 1 2 3 4 X get_last _regions(X,Y,Ctr) get_prev _regions(X,Y,Ctr,Previous) get_next _regions
Sweep Line Status Y Safe regions Y Forbidden 1 , 0 regions 1 , 1 0 , 1 0 , 1 1 , 0 sweep line status 1 , 0 X Δ X For each y ∈ dom( Y ): Remove a value Δ ∈ dom( X ) if for all y ∈ dom( Y ): • number of safe regions nsafe[y] .. nctr − nforbidden[y] ∩ C = ∅ • number of forbidden regions containing the point ( Δ , y )
alldifferent({ X , Y ,4- Y ,R}) An Example | X - Y |>Z PROBLEM: Adjust minimum of X according to Y and to the X +2 Y ≤ S fact that 4 or 5 constraints should hold : 0 ≤ X ≤ 4 0 ≤ Y ≤ 4 2 ≤ Z ≤ 3 X +1 ≤ T ∨ T+1 ≤ X ∨ 1 ≤ S ≤ 6 0 ≤ T ≤ 0 1 ≤ U ≤ 2 Y +1 ≤ U ∨ U+4 ≤ Y alldifferent({ X , Y ,4- Y , R}) | X - Y |>Z X + Y ≡ 0 (mod 2) X +2 Y ≤ S Deduction: X +1 ≤ T ∨ T+1 ≤ X ∨ X>1 Y +1 ≤ U ∨ U+4 ≤ Y Y Y Y 4 4 4 X + Y ≡ 0 (mod 2) 3 3 3 2 2 2 1 1 1 0 0 0 X=0 X=1 X=2
Possible Utilisations • Feasibility check Y X • Adjusting bounds Y X • Pruning values Y X
Typical Constraint Structure for Applying Sweep : COUNT : dvar • A R G U M E N T(S) : OBJECTS : collection( X -dvar, Y -dvar,...) • R E S T R I C T I O N (S) : required( OBJECTS.X , OBJECTS.Y ) : OBJECTS • V E R T E X I N P U T X 1 ,Y 1 X 2 ,Y 2 : IDENTITY • V E R T E X G E N E R A T O R : OBJECTS • E D G E I N P U T : CLIQUE( ≠ ) • E D G E G E N E R A T O R • E D G E A R I T Y : 2 X 3 ,Y 3 X 4 ,Y 4 : • E D G E C O N S T R A I N T : NEDGE = COUNT • G R A P H P R O P E R T Y Non-overlapping Scheduling with set-up Cyclic scheduling
Summary Sweep axis Event points Sweep status • # of forbidden regions • domain of the • start of forbidden regions Conjunction variable to prune • end of forbidden regions of constraints • # of forbidden regions • domain of the • start of forbidden regions • # of safe regions Cardinality variable to prune • end of forbidden regions • contradiction operator • start of safe regions • end of safe regions
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 )
Recommend
More recommend