Sweep Based Algorithms for Constraint Propagation - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Sweep Based Algorithms for Constraint Propagation

Description:

Sweep Algorithms in Computational Geometry. Main Ideas of ... [Berg, Kreveld, Overmars & Schwarzkopf, 1997] G om trie algorithmique [Boissonnat & Yvinec, 1995] ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 42
Provided by: licensedga
Category:

less

Transcript and Presenter's Notes

Title: Sweep Based Algorithms for Constraint Propagation


1
Sweep Based Algorithms for Constraint
Propagation Nicolas BeldiceanuSICSLägerhydds
vägen 1875237 Uppsalaemail nicolas_at_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 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 used within constraint programming !
6
Applications of Sweep Algorithms within
Constraint Programming
Pruning for the following constraint patterns
  • A conjunction of constraints with two shared
    variables
  • The cardinality operator with two shared variables
  • The non-overlapping constraint between polygons
  • A multi-resource cumulatives constraint

7
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
Forbidden Regions
DEFINITION forbidden 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 assignment
Xx and Yy is false.
EXAMPLE forbidden regions of
alldifferent(X,Y,R) according to X and Y

10
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 0?T?2 0?U?3
0?X?4 0?Y?4
0?X?4 0?Y?4 1?S?6
X2?T ? T3?X ? Y4?U ? U2?Y
alldifferent(X,Y,R)
X-Ygt2
X2Y?S
XY?0 (mod 2)
(A)
(B)
(C)
(D)
(E)
11
Primitives for Getting Forbidden Regions on
Request
Y
Y
max(Y)
min(Y)
X
X
Y
min(X)
max(X)
get_first_forbidden_regions
XY?0 (mod 2)
X
Y
get_next_forbidden_regions
  • 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)

X
get_next_forbidden_regions
12
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 gt 0
14
Possible Utilisations
  • Feasibility check
  • ? Adjusting bounds
  • ? Pruning values

Y
X
Y
X
Y
X
15
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-Ygt2 X2Y?S X2?T ? T3?X ?Y4?U ?
U2?Y XY?0 (mod 2)
Y
X 0
16
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-Ygt2 X2Y?S X2?T ? T3?X ?Y4?U ?
U2?Y XY?0 (mod 2)
Y
Y
x0
X 1
17
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-Ygt2 X2Y?S X2?T ? T3?X ?Y4?U ?
U2?Y XY?0 (mod 2)
Deduction Xgt3
Y
Y
Y
Y
Y
X0
X1
X2
X3
X 4
18
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 1 Set 2 Set 3 Set 4 Set
5 Set 6 cardinality 113830 5110 508150
382870 9751490 1940 cons.disj. 5300 210
44190 16330 590890 10 diffn
600 140 690 1030 520 10 sweep
260 170 300 350 120
10
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 cardinality operator, Van Hentenryck,
P., Deville, Y. (ICLP 1991)
n
C ? ?CTRj(V1,.., Vm )
  • Definition
  • Pruning

j
j1
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 (throu
gh the shared variables)
22
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 Xx and
Yy 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 Xx and
Yy is true.
EXAMPLE
Y
0 ? X ? 4 0 ? Y ? 4 1 ? S ? 6
X 2Y ? S
X
23
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) nsafey..nctr?nforbiddeny ? C ?
24
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-YgtZ X2Y?S X3?T
? T1?X ?Y3?U ? U4?Y XY?0 (mod 2)
Deduction Xgt1
Y
Y
Y
X0
X2
X1
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
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
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
Pruning Condition
NECESSARY CONDITION for pruning x0 from Ox
(Domain(P2)\Forbidden(P1, P2) ) ? Lx0 does
not contain any point with integer coordinates
30
Sweep Algorithm(continuous case)
Sweep Status
  • ? 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
The cumulative Constraint
The original cumulative constraint Aggoun
Beldiceanu 92
Restrict the resource consumption at each point
in time.
The generalized cumulatives 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
t
t
i
D E F I N I T I O N
t
m
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
The Sweep Algorithm Fixed Tasks
? nb_task2 ? sum_height3
? nb_task1 ? sum_height2
? nb_task0 ? sum_height0
? nb_task1 ? sum_height4
? nb_task0 ? sum_height0
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(origint)ltmin(endt) min(machinet)max(mac
hinet)r max(heightt)ltmax(0,Limitm)

machinet
nb_tasknb_task1 nb_tasknb_task?1
Start End
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(origint) lt min(endt) min(machinet)
max(machinet) r max(heightt) lt 0

r
sum_heightsum_heightmax(heightt)
sum_heightsum_height ?max(heightt)
Start End
Preconditions for a Good Profile Event
r
r ? dom(machinet) max(heightt) gt 0

sum_heightsum_heightmax(heightt)
sum_heightsum_height ?max(heightt)
Start End
37
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
  • start of forbidden regions
  • end of forbidden regions

? of forbidden regions
  • domain of the
  • variable to prune

Conjunction of constraints
  • domain of the
  • variable to prune

? of forbidden regions ? of safe regions ?
contradiction
  • start of forbidden regions
  • end of forbidden regions
  • start of safe regions
  • end of safe regions

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.
Write a Comment
User Comments (0)
About PowerShow.com