• Keine Ergebnisse gefunden

6.2 Canonicalization of EDBM

6.2.3 Minimization of LDBM

Minimization of LCG that is closure of ECG G defines constraints of the canonical form of polyhedron represented by G.

In case of classical constraint graphs, the canonical form of a represented polyhedron was obtained by minimization using the Floyd-Warschall algorithm. The canonical form of a polyhedron that is represented by ECG can be obtained by minimizing its closure. Due to existence of equivalent edges in LCG the classical Floyd-Warschall shortest path algorithm will not work. The reason for this is that bringing a LCG to a minimal form with Floyd-Warschall algorithm will not preserve its consistency. Then, making the graph consistent may not preserve the minimal form, as shown in the Example 6.2.

6.2. Canonicalization of EDBM 93

Algorithm 6.4 closure(G)

Input: G= (N, ω, E)extended constraint graph with nodes in N and edges in E Output: LCG G that is closure of Gand has minimal possible set of nodes

N =N; E =E;

Ψ =combinations(G);

for all ψ ∈Ψdo max_score1 =−∞;

min_score2 =∞;

for all ψ ∈permutations(ψ) do Nodes=nodes(ψ);

if ψ cannot be represented by a path then continue;

end if score1= 0;

score2= 0;

for all n∈Nodes do if n∈N then

score1+ +;

end if

score2+ =variables(n);

end for

if (score1 > max_score1)∨ (score1 = max_score1)∧(score2 < min_score2) then

NewNodes=Nodes;

end if end for

N =N∪NewNodes;

add edges toE so that nodes inNewNodesare connected with all other nodes inN; end for

consistent(G);

ψ ∈combinations(G) path in G that represents ψ

(consists of edges equivalent with those in ψ) {α} → {x},∅ → {x, α} ∅ → {x, α} → {2x}

{α} → {y},∅ → {y, α} ∅ → {y, α} → {2y}

{x} → {α},∅ → {x, α} ∅ → {x, α} → {2α}

{y} → {α},∅ → {y, α} ∅ → {y, α} → {2α}

{y} → {x, α}, {x} → {y, α} {y} → {x, α} → {2α, y}

∅ → {x},{y} → {x, α},∅ → {y, α} ∅ → {x} → {x, y, α} → {2x,2α}

{y} → {x},{y} → {α},∅ → {x, α} {2y} → {x, y} → {x, α} → {2x,2α}

∅ → {y},∅ → {x, α},{x} → {y, α} ∅ → {y} → {x, y, α} → {2y,2α}

{x} → {y},{x} → {α},∅ → {y, α} {2x} → {x, y} → {yα} → {2y,2α}

{x} → {α},{y} → {x, α},∅ → {y, α} {y} → {x, α} → {2α} → {3α, y}

{y} → {α},{x} → {y, α},∅ → {x, α} ∅ → {x, α} → {2α, y} → {3α}

All inverse paths

Table 2: Paths in closure{G} that represent sum of expressions returned bycombinations{G}

One solution to overcome this problem could be subsequently repeating operations of min-imization and bringing the graph to consistent form unless it is minimal and consistent.

However, checking consistency and minimality can be done only by applying the opera-tion consistent() and minimal() to the LDBM representing the graph and then checking whether it was changed by the operation. This would result in a complexity overhead, since the last iteration from the computational point of view would be redundant.

The same result that is obtained by subsequently minimizing LDBM and making it con-sistent can be obtained by using function minimalL(G) presented by the Algorithm 6.5.

Let G = (N, ω, E) be a linear constraint graph corresponding to LDBM M and G = (N, ω, E) be a LCG corresponding to the matrix that is obtained by the function minimalL(M). Then the following is true:

1. ∀e∈E : ω(e)≤min ω(p) | p∈path(e) . 2. G is consistent.

3. In each equivalence class there exists at least one edge e ∈ E such that ω(e) =

6.2. Canonicalization of EDBM 95

Algorithm 6.5 minimalL(G): minimization of LCG Arguments: Consistent LDBM M

Output: minimal and consistent version of M

for all k∈[1..length(M)] do for all i∈[1..length(M)]do

for all j ∈[1..length(M)]do if Mi,k+Mk,j < Mi,j then for all Mx,y ∈ E(Mi,j) do

Mx,y = (Mi,k+Mk,j)· ϕx,y

ϕi,j

; end for

end if end for end for end for return M

min

ω path(e)

The first property means that each edge e ∈ E has weight not higher than any of the paths from path(e) in graph G. This is the actual condition that the graph G is minimal.

Because the graph is also consistent, it implies that weight of each edgee ∈E is not only lower or equal that weight of any path p∈path(e)but is also lower or equal (with respect to the equivalence factor) that any path p ∈ path(e) for all edges e that are equivalent with e. The last property means that in each equivalence group there is at least one edge e whose weight was calculated using the weight of the shortest path from path(e). This means that the constraint defined by eis the tightest constraint for expression represented by all edges in the equivalence group. This property implies thatG defines canonical form of a polyhedron represented by graphs for which G is a closure.

Proof. The correctness of the Algorithm 6.5 can be proved by induction. Let pathk(e) denote all paths that connect the same nodes that are connected by edge e and traverse nodes with index less than k. Now let Φk denote the property that after kth iteration of the outer loop all of conditions below are satisfied:

Φ1k: ∀e∈E : ωG(e)≤ω

min pathk(e) ,

Φ2k: G is consistent,

Φ3k : In each equivalence class of G there exists an edge e such that ω(e) = min ω(p)|p∈pathk(e)

.

The initial assumption is that before start of the first loop the graph G is consistent. It means that weights of all edges in each equivalence class equals the weight of the lightest edge in the class with respect to the equivalence factors. In the first iteration a weight of each edge ni → nj is compared to weight of a path ni → n1 → nj. If the latter is lower, weights of all edges nx →ny equivalent toni →nj are changed to the weight of the path ni → n1 → nj with respect to equivalence factors ϕx,y and ϕi,j. Because the graph was consistent before, it means that weights of all those edges are now lower than before.

Therefore after entire iteration the property Φ11 is satisfied. Since the weight ofni →nj is also changed, the property Φ31 is satisfied as well. Also, because weight of all edges within equivalence class are always changed together, the graph is still consistent (property Φ21).

In kth step, weights of edges ni → nk and nk → nj are lower or equal to any path from pathk(ni → nk) and pathk(nk → nj) respectively. Than, if ω(ni → nk) +ω(nk → nj) <

ω(ni → nj) the weights of all edges equivalent to ni → nj are changed. Because before the graph was consistent it means that the new weight is lower than weight of any edge in the equivalence class (property Φ1k). Naturally, the graph is consistent after kth iteration, because the same set of paths was compared for each edge within given equivalence class (Φ2k).Φ3k is satisfied as well. This means that satisfaction ofΦk−1 implies satisfaction ofΦk

and the algorithm is correct.

The canonical form of the matrix M from the Figure 26 has following form: