@@ -27,18 +27,18 @@ using ..BLTandPantelidesUtilities
27
27
const log = false
28
28
29
29
"""
30
- function augmentPath!(G, i, assign, vColour, eColour, vActive )
30
+ function augmentPath!(G, i, assign, vColour, eColour, vPassive )
31
31
Construction of augmenting path
32
32
33
33
Reference:
34
34
Pantelides, C.: The consistent initialization of differential-algebraic systems. SIAM Journal
35
35
of Scientific and Statistical Computing, 9(2), pp. 213–231 (1988).
36
36
"""
37
- function augmentPath! (G, i, assign, vColour, eColour, vActive )
37
+ function augmentPath! (G, i, assign, vColour, eColour, vPassive )
38
38
# returns pathFound
39
39
# assign: assign[j] contains the E-node to which V-node j is assigned or 0 if V-node j not assigned
40
40
# i: E-node
41
- # vActive : set to false has the same effect as deleting V-node and corresponding edges
41
+ # vPassive : set to != 0 has the same effect as deleting V-node and corresponding edges
42
42
# j: V-node
43
43
44
44
if log
@@ -50,7 +50,7 @@ function augmentPath!(G, i, assign, vColour, eColour, vActive)
50
50
51
51
# If a V-node j exists such that edge (i-j) exists and assign[j] == 0
52
52
for j in G[i]
53
- if vActive [j] && assign[j] == 0
53
+ if vPassive [j] == 0 && assign[j] == 0
54
54
pathFound = true
55
55
assign[j] = i
56
56
return pathFound
@@ -59,10 +59,10 @@ function augmentPath!(G, i, assign, vColour, eColour, vActive)
59
59
60
60
# For every j such that edge (i-j) exists and j is uncoloured
61
61
for j in G[i]
62
- if vActive [j] && ! vColour[j]
62
+ if vPassive [j] == 0 && ! vColour[j]
63
63
vColour[j] = true
64
64
k = assign[j]
65
- pathFound = augmentPath! (G, k, assign, vColour, eColour, vActive )
65
+ pathFound = augmentPath! (G, k, assign, vColour, eColour, vPassive )
66
66
67
67
if pathFound
68
68
assign[j] = i
@@ -74,11 +74,11 @@ function augmentPath!(G, i, assign, vColour, eColour, vActive)
74
74
end
75
75
76
76
77
- function checkAssign (assign, VSizes, VTypes, ESizes, ETypes, equationsInfix, variableNames, A, vActive = [a == 0 for a in A] )
77
+ function checkAssign (assign, VSizes, VTypes, ESizes, ETypes, equationsInfix, variableNames, A, vPassive = A )
78
78
println (" Checking assignment" )
79
79
assignmentOK = true
80
80
for j in 1 : length (assign)
81
- if vActive [j]
81
+ if vPassive [j] == 0
82
82
i = assign[j]
83
83
if i > 0 && VSizes[j] != ESizes[i]
84
84
assignmentOK = false
@@ -114,10 +114,11 @@ function matching(G, M, vActive=fill(true, M))
114
114
assign:: Array{Int,1} = fill (0 , M)
115
115
eColour:: Array{Bool,1} = fill (false , length (G))
116
116
vColour:: Array{Bool,1} = fill (false , M)
117
+ vPassive:: Array{Int,1} = [if va; 0 else 1 end for va in vActive]
117
118
for i in 1 : length (G)
118
119
fill! (eColour, false )
119
120
fill! (vColour, false )
120
- pathFound = augmentPath! (G, i, assign, vColour, eColour, vActive )
121
+ pathFound = augmentPath! (G, i, assign, vColour, eColour, vPassive )
121
122
end
122
123
return assign
123
124
end
@@ -142,18 +143,28 @@ of Scientific and Statistical Computing, 9(2), pp. 213–231 (1988).
142
143
function pantelides! (G, M, A)
143
144
assign:: Array{Int,1} = fill (0 , M)
144
145
B:: Array{Int,1} = fill (0 , length (G))
146
+ eColour:: Array{Bool,1} = fill (false , length (G))
147
+ vColour:: Array{Bool,1} = fill (false , M)
145
148
N = length (G)
146
149
N2 = N
147
150
for k in 1 : N2
148
151
pathFound = false
149
152
i = k
150
153
while ! pathFound
151
154
# Delete all V-nodes with A[.] != 0 and all their incidence edges from the graph
152
- vActive:: Array{Bool,1} = [a == 0 for a in A]
153
155
# Designate all nodes as "uncoloured"
154
- eColour:: Array{Bool,1} = fill (false , length (G))
155
- vColour:: Array{Bool,1} = fill (false , M)
156
- pathFound = augmentPath! (G, i, assign, vColour, eColour, vActive)
156
+ if length (eColour) == length (G)
157
+ fill! (eColour, false )
158
+ else
159
+ eColour = fill (false , length (G))
160
+ end
161
+ if length (vColour) == length (M)
162
+ fill! (vColour, false )
163
+ else
164
+ vColour = fill (false , M)
165
+ end
166
+
167
+ pathFound = augmentPath! (G, i, assign, vColour, eColour, A)
157
168
if ! pathFound
158
169
if log
159
170
println (" \n Differentiate:" )
0 commit comments