Skip to content

Commit 1038350

Browse files
🤖 Format .jl files
1 parent ed73618 commit 1038350

File tree

5 files changed

+47
-18
lines changed

5 files changed

+47
-18
lines changed

src/presolve/empty_rows.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function row_cnt!(Arows, row_cnt::Vector{Int})
2-
for k=1:length(Arows)
2+
for k = 1:length(Arows)
33
i = Arows[k]
44
row_cnt[i] += 1
55
end
@@ -16,10 +16,17 @@ Removes the empty rows of A, and the corresponding elements in lcon and ucon tha
1616
1717
Returns the new number of constraints `new_ncon` and updates in-place `Arows`, `lcon`, `ucon`.
1818
"""
19-
function empty_rows!(Arows, lcon::Vector{T}, ucon::Vector{T}, ncon, row_cnt::Vector{Int},
20-
empty_rows::Vector{Int}, Arows_s) where {T}
19+
function empty_rows!(
20+
Arows,
21+
lcon::Vector{T},
22+
ucon::Vector{T},
23+
ncon,
24+
row_cnt::Vector{Int},
25+
empty_rows::Vector{Int},
26+
Arows_s,
27+
) where {T}
2128
new_ncon = 0
22-
for i=1:ncon
29+
for i = 1:ncon
2330
if row_cnt[i] == 0
2431
@assert lcon[i] zero(T) ucon[i]
2532
else
@@ -33,9 +40,9 @@ function empty_rows!(Arows, lcon::Vector{T}, ucon::Vector{T}, ncon, row_cnt::Vec
3340

3441
c_rm = 1
3542
nrm = length(empty_rows)
36-
for k=1:length(Arows)
43+
for k = 1:length(Arows)
3744
while c_rm nrm && Arows_s[k] empty_rows[c_rm]
38-
c_rm += 1
45+
c_rm += 1
3946
end
4047
Arows_s[k] -= c_rm - 1
4148
end

src/presolve/postsolve_utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function restore_ilow_iupp!(ilow, iupp, ifix)
3030
nfix = length(ifix)
3131

3232
nlow = length(ilow)
33-
for i in 1:nlow
33+
for i = 1:nlow
3434
while c_fix nfix && ilow[i] ifix[c_fix]
3535
c_fix += 1
3636
end
@@ -39,10 +39,10 @@ function restore_ilow_iupp!(ilow, iupp, ifix)
3939

4040
c_fix = 1
4141
nupp = length(iupp)
42-
for i in 1:nupp
42+
for i = 1:nupp
4343
while c_fix nfix && iupp[i] ifix[c_fix]
4444
c_fix += 1
4545
end
4646
iupp[i] += c_fix - 1
4747
end
48-
end
48+
end

src/presolve/presolve.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function update_kept_rows!(kept_rows::Vector{Bool}, vec_to_rm::Vector{Int})
2222
n_rm = length(vec_to_rm)
2323
offset = 0
2424
c_v = 1
25-
for i=1:ncon
25+
for i = 1:ncon
2626
if !kept_rows[i]
2727
offset += 1
2828
else
@@ -99,7 +99,19 @@ function presolve(
9999
if length(singl_rows) > 0
100100
singl_row_pass = true
101101
update_kept_rows!(kept_rows, singl_rows)
102-
nconps = singleton_rows!(psdata.A.rows, psdata.A.cols, psdata.A.vals, lcon, ucon, lvar, uvar, nvar, nconps, row_cnt, singl_rows)
102+
nconps = singleton_rows!(
103+
psdata.A.rows,
104+
psdata.A.cols,
105+
psdata.A.vals,
106+
lcon,
107+
ucon,
108+
lvar,
109+
uvar,
110+
nvar,
111+
nconps,
112+
row_cnt,
113+
singl_rows,
114+
)
103115
else
104116
singl_row_pass = false
105117
nconps = nconps
@@ -232,4 +244,4 @@ function postsolve(
232244
y_out = similar(qm.meta.y0)
233245
s_l_out, s_u_out = postsolve!(qm, psqm, x_in, x_out, y_in, y_out, s_l, s_u)
234246
return x_out, y_out, s_l_out, s_u_out
235-
end
247+
end

src/presolve/singleton_rows.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ Removes the singleton rows of A, and the corresponding elements in lcon and ucon
99
1010
Returns the new number of constraints `new_ncon` and updates in-place `Arows`, `Acols`, `Avals`, `lcon`, `ucon`, `lvar`, `uvar`.
1111
"""
12-
function singleton_rows!(Arows, Acols, Avals, lcon::Vector{T}, ucon::Vector{T}, lvar, uvar,
13-
nvar, ncon, row_cnt::Vector{Int},
14-
singl_rows::Vector{Int}) where {T}
12+
function singleton_rows!(
13+
Arows,
14+
Acols,
15+
Avals,
16+
lcon::Vector{T},
17+
ucon::Vector{T},
18+
lvar,
19+
uvar,
20+
nvar,
21+
ncon,
22+
row_cnt::Vector{Int},
23+
singl_rows::Vector{Int},
24+
) where {T}
1525

1626
# assume Acols is sorted
1727
Annz = length(Arows)
@@ -59,4 +69,4 @@ function singleton_rows!(Arows, Acols, Avals, lcon::Vector{T}, ucon::Vector{T},
5969
deleteat!(lcon, singl_rows)
6070
deleteat!(ucon, singl_rows)
6171
return ncon - nsingl
62-
end
72+
end

test/test_presolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,5 @@ end
226226
s_u = sparse([3.0; 0.0])
227227
x_out, y_out, s_l, s_u = postsolve(qp, psqp, x_in, y_in, s_l, s_u)
228228
@test y_out == [2.0; 0.0; 0.0; 0.0; 0.0; 4.0]
229-
@test x_out == [4.0/3.0; 7.0; 4.0]
230-
end
229+
@test x_out == [4.0 / 3.0; 7.0; 4.0]
230+
end

0 commit comments

Comments
 (0)