Skip to content

Commit e29ba55

Browse files
🤖 Format .jl files (#100)
Co-authored-by: geoffroyleconte <[email protected]>
1 parent a531b33 commit e29ba55

9 files changed

+25
-21
lines changed

src/presolve/empty_rows.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function empty_rows!(
88
) where {T, S}
99
qmp.empty_row_pass = false
1010
lcon, ucon, row_cnt, kept_rows = qmp.lcon, qmp.ucon, qmp.row_cnt, qmp.kept_rows
11-
for i = 1:qmp.ncon
11+
for i = 1:(qmp.ncon)
1212
(kept_rows[i] && (row_cnt[i] == 0)) || continue
1313
qmp.empty_row_pass = true
1414
@assert (lcon[i] zero(T) ucon[i])

src/presolve/free_rows.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function free_rows!(
99
lcon, ucon = qmp.lcon, qmp.ucon
1010
row_cnt, kept_rows = qmp.row_cnt, qmp.kept_rows
1111
qmp.free_row_pass = false
12-
for i = 1:qmp.ncon
12+
for i = 1:(qmp.ncon)
1313
(kept_rows[i] && lcon[i] == -T(Inf) && ucon[i] == T(Inf)) || continue
1414
qmp.free_row_pass = true
1515
row_cnt[i] = -1

src/presolve/linear_singleton_columns.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function free_linear_singleton_columns!(
1717
row_cnt, col_cnt = qmp.row_cnt, qmp.col_cnt
1818
kept_rows, kept_cols = qmp.kept_rows, qmp.kept_cols
1919

20-
for j = 1:qmp.nvar
20+
for j = 1:(qmp.nvar)
2121
(kept_cols[j] && (col_cnt[j] == 1)) || continue
2222
# check infinity bounds and no hessian contribution
2323
if lvar[j] == -T(Inf) && uvar[j] == T(Inf) && isempty(hcols[j].nzind)
@@ -76,7 +76,7 @@ function postsolve!(
7676
# x[j] = (coival - Σₖ Aik x[k]) / aij , where k ≂̸ j
7777
x[j] = operation.conival
7878
for (l, ail) in zip(arowi.nzind, arowi.nzval)
79-
(l != j && kept_cols[l]) || continue
79+
(l != j && kept_cols[l]) || continue
8080
x[j] -= ail * x[l]
8181
end
8282
x[j] /= operation.aij

src/presolve/presolve.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ end
145145
function check_bounds!(qmp::QuadraticModelPresolveData)
146146
lvar, uvar, lcon, ucon = qmp.lvar, qmp.uvar, qmp.lcon, qmp.ucon
147147
kept_rows, kept_cols = qmp.kept_rows, qmp.kept_cols
148-
for i = 1:qmp.ncon
148+
for i = 1:(qmp.ncon)
149149
if kept_rows[i] && lcon[i] > ucon[i]
150150
@warn "row $i primal infeasible"
151151
qmp.infeasible_bnd = true
152152
return nothing
153153
end
154154
end
155-
for j = 1:qmp.nvar
155+
for j = 1:(qmp.nvar)
156156
if kept_cols[j] && lvar[j] > uvar[j]
157157
@warn "col $j primal infeasible"
158158
qmp.infeasible_bnd = true
@@ -197,7 +197,7 @@ The presolve operations are inspired from [`MathOptPresolve.jl`](https://github.
197197
function presolve(
198198
qm::QuadraticModel{T, S, M1, M2};
199199
fixed_vars_only::Bool = false,
200-
kwargs...
200+
kwargs...,
201201
) where {T <: Real, S, M1 <: SparseMatrixCOO, M2 <: SparseMatrixCOO}
202202
start_time = time()
203203
psqm = copy_qm(qm)

src/presolve/presolve_utils.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function switch_H_to_max!(data::QPData)
88
data.H = -data.H
99
end
1010

11-
check_reductions(qmp::QuadraticModelPresolveData) =
11+
check_reductions(qmp::QuadraticModelPresolveData) =
1212
qmp.empty_row_pass ||
1313
qmp.singl_row_pass ||
1414
qmp.ifix_pass ||
@@ -60,15 +60,15 @@ function remove_rowscols_A_H!(A, H, qmp::QuadraticModelPresolveData)
6060
kept_rows, kept_cols = qmp.kept_rows, qmp.kept_cols
6161
ps_rows_idx = zeros(Int, qmp.ncon)
6262
ci = 0
63-
for i in 1:qmp.ncon
63+
for i = 1:(qmp.ncon)
6464
if kept_rows[i]
6565
ci += 1
6666
ps_rows_idx[i] = ci
6767
end
6868
end
6969
ps_cols_idx = zeros(Int, qmp.nvar)
7070
cj = 0
71-
for j in 1:qmp.nvar
71+
for j = 1:(qmp.nvar)
7272
if kept_cols[j]
7373
cj += 1
7474
ps_cols_idx[j] = cj
@@ -79,7 +79,7 @@ function remove_rowscols_A_H!(A, H, qmp::QuadraticModelPresolveData)
7979
Annz = length(Arows)
8080
Arm = 0
8181
Awritepos = 0
82-
for k in 1:Annz
82+
for k = 1:Annz
8383
i, j = Arows[k], Acols[k]
8484
if (kept_rows[i] && kept_cols[j])
8585
Awritepos += 1
@@ -101,7 +101,7 @@ function remove_rowscols_A_H!(A, H, qmp::QuadraticModelPresolveData)
101101
Hnnz = length(Hrows)
102102
Hrm = 0
103103
Hwritepos = 0
104-
for k in 1:Hnnz
104+
for k = 1:Hnnz
105105
i, j = Hrows[k], Hcols[k]
106106
if (kept_cols[i] && kept_cols[j])
107107
Hwritepos += 1
@@ -125,15 +125,15 @@ function update_vectors!(qmp::QuadraticModelPresolveData)
125125
lcon, ucon, lvar, uvar = qmp.lcon, qmp.ucon, qmp.lvar, qmp.uvar
126126
kept_rows, kept_cols = qmp.kept_rows, qmp.kept_cols
127127
nconps = 0
128-
for i = 1:qmp.ncon
128+
for i = 1:(qmp.ncon)
129129
if kept_rows[i]
130130
nconps += 1
131131
lcon[nconps] = lcon[i]
132132
ucon[nconps] = ucon[i]
133133
end
134134
end
135135
nvarps = 0
136-
for j = 1:qmp.nvar
136+
for j = 1:(qmp.nvar)
137137
if kept_cols[j]
138138
nvarps += 1
139139
lvar[nvarps] = lvar[j]

src/presolve/primal_constraints.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function primal_constraints!(
55
arows, lcon, ucon, lvar, uvar = qmp.arows, qmp.lcon, qmp.ucon, qmp.lvar, qmp.uvar
66
kept_rows, kept_cols = qmp.kept_rows, qmp.kept_cols
77
row_cnt, col_cnt = qmp.row_cnt, qmp.col_cnt
8-
for i = 1:qmp.ncon
8+
for i = 1:(qmp.ncon)
99
(kept_rows[i] && !(lcon[i] == -T(Inf) && ucon[i] == T(Inf))) || continue
1010
rowi = arows[i]
1111
uconi2 = zero(T)

src/presolve/remove_ifix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function remove_ifix!(
1919
xps = qmp.xps
2020
c0_offset = zero(T)
2121

22-
for j = 1:qmp.nvar
22+
for j = 1:(qmp.nvar)
2323
(kept_cols[j] && (lvar[j] == uvar[j])) || continue
2424
qmp.ifix_pass = true
2525
xj = lvar[j]
@@ -81,7 +81,7 @@ function postsolve!(
8181
psd.kept_cols[i] || continue
8282
Hxj += hij * x[i]
8383
end
84-
84+
8585
s = operation.cj + Hxj - ATyj
8686
if s > zero(T)
8787
sol.s_l[j] = s

src/presolve/singleton_rows.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function singleton_rows!(
1616
row_cnt, col_cnt = qmp.row_cnt, qmp.col_cnt
1717
kept_rows, kept_cols = qmp.kept_rows, qmp.kept_cols
1818

19-
for i = 1:qmp.ncon
19+
for i = 1:(qmp.ncon)
2020
(kept_rows[i] && (row_cnt[i] == 1)) || continue
2121
qmp.singl_row_pass = true
2222
tightened_lvar = false
@@ -56,7 +56,11 @@ function singleton_rows!(
5656
end
5757
end
5858

59-
function postsolve!(sol::QMSolution, operation::SingletonRow{T, S}, psd::PresolvedData{T, S}) where {T, S}
59+
function postsolve!(
60+
sol::QMSolution,
61+
operation::SingletonRow{T, S},
62+
psd::PresolvedData{T, S},
63+
) where {T, S}
6064
i, j = operation.i, operation.j
6165
psd.kept_rows[i] = true
6266
aij = operation.aij

src/presolve/unconstrained_reductions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function unconstrained_reductions!(
1212
col_cnt, kept_cols = qmp.col_cnt, qmp.kept_cols
1313

1414
# assume Hcols sorted
15-
for j = 1:qmp.nvar
15+
for j = 1:(qmp.nvar)
1616
(kept_cols[j] && (col_cnt[j] == 0)) || continue
1717
# check empty rows/col j in H
1818
if isempty(hcols[j].nzind)
@@ -43,4 +43,4 @@ end
4343

4444
function postsolve!(sol::QMSolution, operation::UnconstrainedReduction, psd::PresolvedData)
4545
psd.kept_cols[operation.j] = true
46-
end
46+
end

0 commit comments

Comments
 (0)