1 / 41

SICS Seminar, May 29 2001

Sweep Based Algorithms for Constraint Propagation Nicolas Beldiceanu SICS Lägerhyddsvägen 18 75237 Uppsala email: nicolas@sics.se. SICS Seminar, May 29 2001. Outline of the Presentation. INTRODUCTION Sweep Algorithms in Computational Geometry Main Ideas of Sweep Algorithms

Télécharger la présentation

SICS Seminar, May 29 2001

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sweep Based Algorithms for Constraint PropagationNicolas BeldiceanuSICSLägerhyddsvägen 1875237 Uppsalaemail: nicolas@sics.se SICS Seminar, May 29 2001

  2. Outline of the Presentation INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  3. INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  4. 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]

  5. Applications of Sweep Algorithms Within theGeometry Literature Database, more than 100 references: • Voronoi diagram • Map overlay • Nearest objects • Triangulations • Hidden surface removals • Rectangles intersection • Shortest path But not yet used within constraint programming !

  6. Applications of Sweep Algorithms within Constraint Programming Pruning for the following constraint patterns: • A conjunction of constraints with two sharedvariables • The cardinality operator with two sharedvariables • The non-overlapping constraint between polygons • A multi-resource cumulatives constraint

  7. sweep line Steps of the sweep algorithm: event point y (1) (1)Move to the next eventpoint (2)Update the sweep line status:  start events:  end events: (2) sweep line status x 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

  8. INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  9. Y X 4 3 2 1 0 0 1 2 3 4 Forbidden Regions DEFINITIONforbidden region according to a constraint Ctr and two variables X,Y of Ctr : Two intervals inf_x..sup_x and inf_y..sup_y such that: For all x in inf_x..sup_x, y in inf_y..sup_y: Ctr with the assignmentX=x andY=y is false. EXAMPLE forbidden regions of alldifferent({X,Y,R}) according to X and Y:

  10. 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 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 Examples of Forbidden Regions Y Y Y Y Y X X X X X 0X4 0Y4 0R9 0X4 0Y4 0X4 0Y4 1S6 0X4 0Y4 0T2 0U3 0X4 0Y4 X+2T T+3X Y+4U U+2Y alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+Y0 (mod 2) (A) (B) (C) (D) (E)

  11. 4 4 4 4 3 3 3 3 2 2 2 2 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 Primitives for Getting Forbidden Regions on Request Y Y max(Y) get_first_forbidden_regions(X,Y,Ctr) get_next_forbidden_regions(X,Y,Ctr,Previous) get_last_forbidden_regions(X,Y,Ctr) get_prev_forbidden_regions(X,Y,Ctr,Previous) check_if_in_forbidden_regions(x,y,Ctr) min(Y) X X Y max(X) min(X) get_first_forbidden_regions X+Y0 (mod 2) X Y get_next_forbidden_regions X get_next_forbidden_regions

  12. sweep line event point Y CTR1(X,Y,…) CTR2(X,Y,…) ……………… CTRn(X,Y,…) sweep line status Is min(X) feasible ? No, so move the sweep-line. X Basic Idea of Sweep Pruning Accumulates forbiden regions that come from different constraints involving two given variables X and Y

  13. Sweep Line Status Y Y 1 2 1 1 1 1 sweep line status  X X For each y dom(Y): number of forbidden regions containing the point (,y) Remove a value  dom(X) if : for all y dom(Y) the number of forbidden regions is > 0

  14. Possible Utilisations • Feasibility check  Adjusting bounds  Pruning values Y X Y X Y X

  15. alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+2T  T+3X Y+4U  U+2Y X+Y0 (mod 2) 4 3 2 1 0 An Example PROBLEM: Adjust minimum of X according to Y and to all following constraints: 0X4 0Y4 1S6 0T2 0U3 alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+2T  T+3XY+4U  U+2Y X+Y0 (mod 2) Y X= 0

  16. alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+2T  T+3X Y+4U  U+2Y X+Y0 (mod 2) 4 4 3 3 2 2 1 1 0 0 An Example PROBLEM: Adjust minimum of X according to Y and to all following constraints: 0X4 0Y4 1S6 0T2 0U3 alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+2T  T+3XY+4U  U+2Y X+Y0 (mod 2) Y Y x=0 X= 1

  17. alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+2T  T+3X Y+4U  U+2Y X+Y0 (mod 2) 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 An Example PROBLEM: Adjust minimum of X according to Y and to all following constraints: 0X4 0Y4 1S6 0T2 0U3 alldifferent({X,Y,R}) |X-Y|>2 X+2YS X+2T  T+3XY+4U  U+2Y X+Y0 (mod 2) Deduction: X>3 Y Y Y Y Y X=0 X=1 X=2 X=3 X= 4

  18. X1,Y1 X2,Y2 • ARGUMENT • RESTRICTION(S) • VERTEXINPUT • VERTEXGENERATOR • EDGEINPUT • EDGEGENERATOR • EDGE ARITY • EDGE CONSTRAINT • GRAPH PROPERTY : OBJECTS: collection(X-dvar,Y-dvar,...) : required(OBJECTS.X,OBJECTS.Y) : OBJECTS : IDENTITY : OBJECTS : CLIQUE() : 2 : : NEDGE = |OBJECTS|.|OBJECTS| - |OBJECTS| X3,Y3 X4,Y4 Non-overlapping Scheduling with set-up Cyclic scheduling Typical Constraint Structure for Applying Sweep

  19. Evaluation of the Filtering Algorithm forthe Non-Overlapping Rectangles Constraint Worst case complexity Memory consumption : n2  log(n) : no trail Empirical evaluation Incomparable rectangles Rectangles of same size Random small size Squares of  sizes Mostly fixed Loose Set 1Set 2Set 3Set 4Set 5Set 6 cardinality113830 5110 508150 382870 9751490 1940 cons.disj. 5300 210 44190 16330 590890 10 diffn 600 140 690 1030 520 10 sweep260 170 30035012010 Time in msec for finding a first solution for 100 rectangles (SICStus Prolog gcc -O2 248Mhz UltraSPARC-II, Solaris 7)

  20. INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  21. : A Restricted Case of the cardinality Operator The cardinalityoperator, Van Hentenryck, P., Deville, Y. (ICLP 1991): n • Definition • Pruning : C =  CTRj(V1,.., Vm ) j j=1 counting entailment : based on A restricted case of the cardinality operator : • Restriction • Pruning : 2 variables X and Y occur in each constraint CTRj considers interaction between constraints (through the shared variables)

  22. 4 3 2 1 0 0 1 2 3 4 Forbidden and Safe Regions DEFINITIONforbidden 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 assignmentX=x andY=y isfalse. DEFINITIONsaferegion 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 assignmentX=x andY=y istrue. EXAMPLE Y 0  X  4 0  Y  4 1  S  6 X + 2Y  S X

  23. Y 1,0 1,1 0,1 0,1 1,0 1,0 X Sweep Line Status Y Safe regions Forbidden regions sweep line status  X For each y dom(Y): number of safe regions number of forbidden regions containing the point (,y) Remove a value  dom(X) if for all y dom(Y): nsafe[y]..nctrnforbidden[y] C = 

  24. alldifferent({X,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) 4 4 4 3 3 3 2 2 2 1 1 1 0 0 0 An Example PROBLEM: Adjust minimum of X according to Y and to the fact that 4 or 5 constraints should hold: 0X4 0Y4 2Z3 1S6 0T0 1U2 alldifferent({X,Y,R}) |X-Y|>Z X+2YS X+3T  T+1XY+3U  U+4Y X+Y0 (mod 2) Deduction: X>1 Y Y Y X=0 X=1 X=2

  25. INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  26. P1 Y X Translations of P1 with origin within D1 Polygon P1 with an origin X,Y D1 Polygon D1 for the domain of the origin of P1 A Family of Polygons

  27. Shadow Polygon P1 P2 P2 Shadow polygon:P1 + (P2) If the origin of P2 is situated within the shadow polygon then P2 overlap P1 If the origin of P2 is situated outside the shadow polygon then P2 do not overlap P1

  28. E1 E2 E4 E3 Extremum polygons of P1 according to its domain D1 Forbidden Polygon E1 E2 E3 E4 Forbidden(P1,P2) If the origin of P2 is situated within the forbidden polygon then P2 overlap any translation of P1 So, prune the origin variables of P2 with a sweep algorithm

  29. GOAL: prune the x-coordinate Ox of the origin of P2 in order to avoid the origin to be located within Forbidden(P1,P2) Fupper(x0) Dupper(x0) P2 x0 Ox Dlower(x0) Flower(x0) Lx0 Domain(P2) Forbidden(P1,P2) PruningCondition NECESSARY CONDITION for pruning x0 from Ox: (Domain(P2)\Forbidden(P1, P2)• )  Lx0 does not contain any point with integer coordinates

  30. Sweep Status: SweepAlgorithm(continuous case) •  x0 • the 4 edges that are intersected by Lx0 the 4 y-coordinates of the intersected points Event points:  Vertices of the two polygons  Proper intersection between two edges

  31. INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  32. resource consumption 4  4 3 4 3 2 1 1 2 0 time resource consumption 7  0 6 Cumulated profiles 4 5 2  0 1 1 2 2 3 3 4 4 5 5 6 6 3 1 time 1 0 -1 2 1 0 -1 -2 The cumulative Constraint The originalcumulative constraint [Aggoun & Beldiceanu 92]: Restrict the resource consumption at each point in time. The generalizedcumulatives constraint [Beldiceanu & Carlsoon 01]: A pool of cumulative resources , Height of a task can be negative, Maximum or minimum resource consumption , Holds for time-points crossed by at least one task.

  33. For all tasks : For all time-points crossed by task : Let be the machine where task is assigned , For all tasks that both cross point , and are assigned to : The sum of the height of tasks is not greater (less) than the capacity of machine . 1 2 3 4 5 6 1 0 -1 2 1 0 -1 -2 t i t D E F I N I T I O N m t s i m s m resource consumption 7  0 6 Machine 2 E X A M P L E 4 5 2  0 3 1 Machine 1 time

  34. Sweep linestatus: Event points: number of tasks sum of the height start of each task end of each task that overlap the sweep line 4 3 2 1 0 5 The Sweep Algorithm: Fixed Tasks nb_task=1 sum_height=2 nb_task=2 sum_height=3 nb_task=0 sum_height=0 nb_task=1 sum_height=4 nb_task=0 sum_height=0 Sweep-line status resource Task 3 Task 2 Task 1 time Event points Minimum level to reach for those instants where there is at least one task 1 2 4 Current position of the sweep line: 3

  35. The Sweep Algorithm: Not Yet Fixed Tasks QUESTION ANSWER ACTION : which instants to check ? : those instants for which there is a task that can cause a problem : count the number of such tasks that overlap the sweep line Preconditions for a Check Event max(origin[t])<min(end[t]) min(machine[t])=max(machine[t])=r max(height[t])<max(0,Limit[m]) machine[t] Start End : nb_task=nb_task+1 : nb_task=nb_task1

  36. The Sweep Algorithm: Not Yet Fixed Tasks QUESTION ANSWER ACTION : how to build an ”optimistic” resource consumption profile ? : consider the ”bad” and ”good” tasks : sum up the height of such tasks that overlap the sweep line Preconditions for a Bad Profile Event max(origin[t]) < min(end[t]) min(machine[t]) = max(machine[t]) = r max(height[t]) < 0 r Start End : sum_height=sum_height+max(height[t]) : sum_height=sum_heightmax(height[t]) Preconditions for a Good Profile Event r r  dom(machine[t]) max(height[t]) > 0 Start End : sum_height=sum_height+max(height[t]) : sum_height=sum_heightmax(height[t])

  37. INITIALIZATION 1. Scan the tasks and generate the check and profile events 2. Sort the events in increasing order 3. Set nb_task and sum_height to 0 and d to the smallest date 4. while there still exist an event Edo MODIFY SWEEP STATUS 5. ifddate of Ethen 6. ifnb_task0 andsum_height<limit to reach thenreturn fail 7. Set d to date of E 8. if type of E=check then add E.inc to nb_taskelse add E.inc to sum_height CHECK 9. Extract the next event E (if it exists) 10. ifnb_task0 andsum_height<limit to reach thenreturn fail CHECK The Sweep Algorithm: Main Loop(simplified version: one resource, no pruning)

  38. INTRODUCTION • Sweep Algorithms in Computational Geometry • Main Ideas of Sweep Algorithms CONJUNCTION OF CONSTRAINTS • Representing an Elementary Constraint: Forbidden Regions • The Sweep Algorithm CARDINALITY OPERATOR • Representing an Elementary Constraint: Forbidden and Safe Regions • The Sweep Algorithm NON-OVERLAPPING CONSTRAINT BETWEEN CONVEX POLYGONS • The Forbidden Polygon • The Sweep Algorithm CUMULATIVES CONSTRAINT • Definition of the Cumulatives Constraint • The Sweep Algorithm SUMMARY AND CONCLUSION

  39. Summary Sweep axis Event points Sweep status • domain of the variable to prune • start of forbidden regions • end of forbidden regions  # of forbidden regions Conjunction of constraints • domain of the variable to prune • start of forbidden regions • end of forbidden regions • start of safe regions • end of safe regions # of forbidden regions # of safe regions  contradiction Cardinality operator • domain of the variable to prune • vertices of the forbidden and domain polygons • edges proper intersection • the 4 edges intersected by the sweep line • the 4 y-coordinates of the 4 intersected points Non-overlapping between polygons  time axis  task earliest start  task latest start  task earliest end  task latest end # of tasks to check  cumulated height of the optimistic profile Cumulatives constraint

  40. 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 algorithms could perhaps be improved (for instance by using specialized data structures for searching the relevant regions) • May become a standard technique for constraint solving (there may exist other utilisations of sweep algorithms for constraint propagation)

  41. Further Sources of Information http://www.sics.se/libindex.html • Sweep as a Generic Pruning Technique Applied to the Non-Overlapping Rectangles Constraint, [Beldiceanu,Carlsson 2001] . • Sweep as a Generic Pruning Technique Applied to Constraint Relaxation, [Beldiceanu,Carlsson 2001] .(in preparation) • Non-overlapping Constraints between Convex Polytopes, [Beldiceanu,Guo,Thiel 2001] . • A New Multi-Resource cumulatives Constraint with Negative Heights, [Beldiceanu,Carlsson 2001] . http://www.sics.se/sicstus/ • Implementation of different variants of the non-overlapping rectangles constraint, • Implementation of the multi-resource cumulatives constraint.

More Related