Title: Global Constraints for Strategy Graphs
1Global Constraints for Strategy Graphs
- Gary Gengo
- COM 3220
- June 9, 1998
2Outline
- Global constraints on strategies
- Traversal algorithm
- Checking constraints algorithm
- Demo
3Global Constraints on Strategies
- Given class graph CG, strategy graph SG, source
s,target t, constraint X lt 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
4Constraint Example 1
Class Graph
A lt B true B lt A false A lt X true X lt A
false B lt X true X lt B false
Strategy Graph
Note A lt B even if B can come before A (e.g.
path ABXABX)
Traversal Graph
5Constraint Example 2
Class Graph
P lt Q true Q lt P true
Strategy Graph
Since neither P nor Q are part of any path from
source to target, P lt Q and Q lt P
Traversal Graph
source node
target node
6Constraint Example 3
Class Graph
Dlt C false (ABCABDE) C lt D false (ABDE)
Strategy Graph
Traversal Graph
7Constraint Example 4
Class Graph
Dlt C true C lt D false
Strategy Graph
Traversal Graph
8Traversal Graph Algorithm TG(CG,SG,s,t)
- Step1For each SG edge (u,v), make a copy Guv of
CG - Step 2For 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 Guv , v
in Gvw) - Step 3Eliminate edges not reachable from some
source s and target t
9Traversal AlgorithmStep 1
Class Graph
Strategy Graph
10Traversal AlgorithmStep 2
Class Graph
Strategy Graph
11Traversal AlgorithmStep 3
Class Graph
Strategy Graph
Traversal Graph
12Traversal Algorithm Property
- Each node in the traversal graph can reach the
target. - This occurs in Step 3 of the algorithm
13Alternate 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
14Algorithm to check constraint XltY
- 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
15If 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
16Checking Constraint Example 1
check constraint P lt Q
Class Graph
compute traversal graph for class graph
strategy graph
Strategy Graph
Traversal Graph
traversal graph is empty so constraint is
satisfied
17Checking Constraint Example 2
check constraint C lt D
Class Graph
compute traversal graph for class graph
strategy graph
Strategy Graph
Traversal Graph
traversal graph is not empty so constraint is
not satisfied
18Checking Constraint Example 3
check constraint C lt D
Class Graph
Strategy Graph
Traversal Graph
19Checking Constraint Example 3(contd)
compute traversal graph for class graph
check constraint C lt D
strategy graph
Ai
for i,j 1 to 2
traversal graph non-empty for i1 and j1
constraint C lt D is not satisfied
20Implementation Details
- command line
- java graph Cgfile SGfile source target X Y
- check constraint XltY 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 ltreturngt at end of each line