Download presentation
Presentation is loading. Please wait.
Published byPoppy Skinner Modified over 8 years ago
1
Global Constraints for Strategy Graphs Gary Gengo COM 3220 June 9, 1998
2
Outline Global constraints on strategies Traversal algorithm Checking constraints algorithm Demo
3
Global Constraints on Strategies Given: class graph CG, strategy graph SG, source s,target t, constraint X < Y Question: Does the following constraint hold for all paths P in CG corresponding to some path from s to t in SG? –for every vertex Y in the path P, there is a vertex X in P that comes before Y
4
Constraint Example 1 Class Graph Strategy Graph ABX AX Traversal Graph AB X A < B true B < A false A < X true X < A false B < X true X < B false Note: A < B even if B can come before A (e.g. path ABXABX)
5
Constraint Example 2 Class Graph Strategy Graph Traversal Graph P < Q true Q < P true X ABPQC ABC X X AB Since neither P nor Q are part of any path from source to target, P < Q and Q < P = target node = source node
6
Constraint Example 3 Class Graph Strategy Graph Traversal Graph D< C false (ABCABDE) C < D false (ABDE) A E C ABDE C ABD E
7
Constraint Example 4 Class Graph Strategy Graph Traversal Graph D< C true C < D false A E C ABDE C ABD E
8
Traversal Graph Algorithm TG(CG,SG,s,t) Step1: For each SG edge (u,v), make a copy G uv of CG Step 2: For each vertex v in SG, and for each combination (u,v) (v,w) edges in SG add “intercopy” edges of the form (pred(v) in G uv, v in G vw ) Step 3: Eliminate edges not reachable from some source s and target t
9
Class GraphStrategy Graph X ABPQC ABC X X ABPQC X ABPQC X ABPQC Traversal Algorithm:Step 1
10
Class GraphStrategy Graph X ABPQC ABC X X ABPQC X ABPQC X ABPQC Traversal Algorithm:Step 2
11
Class GraphStrategy Graph X ABPQC ABC X Traversal Algorithm:Step 3 X AB Traversal Graph
12
Traversal Algorithm Property Each node in the traversal graph can reach the target. This occurs in Step 3 of the algorithm
13
Alternate Algorithm You might compute traversal graph by –First computing the TG for each edge –Then add intercopy edges HOWEVER, property mentioned before holds ONLY if the strategy graph does not have any “useless” edges Previous algorithm is better in this sense We use previous algorithm in checking constraints algorithm
14
Algorithm to check constraint X<Y Step 1: Compute traversal graph TG1 = TG(CG,SG, s, t) Step 2: Remove all edges with X as a vertex from TG1 Step 3: For each source s and each Y inTG1 –compute newTG = TG(TG1,newSG,s,Y) where newSG is – if newTG is not empty, constraint is violated Y s
15
If you use “Alternate Traversal Algorithm” Change Step 3 to: For each source s, each target t, and each Y inTG1 –compute newTG = TG(TG1,newSG,s,t) where newSG is –if newTG is not empty, constraint is violated change necessary because there might not be a path from Y to t in TG i t Y s
16
Checking Constraint Example 1 Class Graph Strategy Graph Traversal Graph check constraint P < Q X ABPQC ABC X X AB AQ compute traversal graph for class graph = strategy graph = X AB traversal graph is empty so constraint is satisfied
17
Checking Constraint Example 2 Class Graph Strategy Graph check constraint C < D compute traversal graph for class graph = strategy graph = traversal graph is not empty so constraint is not satisfied Traversal Graph A E C ABDE C ABDE ABD E A D
18
Checking Constraint Example 3 Class Graph Strategy Graph check constraint C < D Traversal Graph C ABDE C A D E C ABDE C ABDE C ABDE C ABDE ACDE C ABDE
19
Checking Constraint Example 3 (cont’d) check constraint C < D D2E2A2 A1B1D1E1 compute traversal graph for class graph = strategy graph = Ai Ej for i,j = 1 to 2 traversal graph non-empty for i=1 and j=1 constraint C < D is not satisfied
20
Implementation Details command line –java graph Cgfile SGfile source target X Y –check constraint X<Y on CG,SG –graphs stored as text files first line is list of vertices all other lines give adjacency list no error checking on graph input need at end of each line
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.