1
- function row_cnt! (Arows, row_cnt:: Vector{Int} )
2
- for k = 1 : length (Arows)
3
- i = Arows[k]
4
- row_cnt[i] += 1
5
- end
6
- end
7
-
8
- find_empty_rows (row_cnt:: Vector{Int} ) = findall (isequal (0 ), row_cnt)
9
-
10
1
"""
11
- new_ncon = empty_rows!(Arows, lcon, ucon, ncon, row_cnt, empty_rows, Arows_s )
2
+ new_ncon = empty_rows!(Arows, lcon, ucon, ncon, row_cnt, empty_rows)
12
3
13
4
Removes the empty rows of A, and the corresponding elements in lcon and ucon that are in `empty_rows`.
14
- `Arows_s` is a view of `Arows` sorted in ascending order.
15
5
`row_cnt` is a vector of the number of elements per row.
16
6
17
7
Returns the new number of constraints `new_ncon` and updates in-place `Arows`, `lcon`, `ucon`.
@@ -23,7 +13,6 @@ function empty_rows!(
23
13
ncon,
24
14
row_cnt:: Vector{Int} ,
25
15
empty_rows:: Vector{Int} ,
26
- Arows_s,
27
16
) where {T}
28
17
new_ncon = 0
29
18
for i = 1 : ncon
@@ -38,13 +27,25 @@ function empty_rows!(
38
27
resize! (lcon, new_ncon)
39
28
resize! (ucon, new_ncon)
40
29
41
- c_rm = 1
42
- nrm = length (empty_rows)
43
- for k = 1 : length (Arows)
44
- while c_rm ≤ nrm && Arows_s[k] ≥ empty_rows[c_rm]
45
- c_rm += 1
30
+ # assume Acols is sorted
31
+ Annz = length (Arows)
32
+ nempty = length (empty_rows)
33
+
34
+ for idxempty = 1 : nempty
35
+ currentiempty = empty_rows[idxempty]
36
+ # index of the current singleton row that takes the number of
37
+ # already removed variables into account:
38
+ newcurrentiempty = currentiempty - idxempty + 1
39
+
40
+ # remove singleton rows in A rows
41
+ Awritepos = 1
42
+ k = 1
43
+ while k <= Annz
44
+ Ai = Arows[k]
45
+ Arows[Awritepos] = (Ai < newcurrentiempty) ? Ai : Ai - 1
46
+ Awritepos += 1
47
+ k += 1
46
48
end
47
- Arows_s[k] -= c_rm - 1
48
49
end
49
50
return new_ncon
50
51
end
0 commit comments