|
20 | 20 | function get_arows_acols(A::SparseMatrixCOO{T}, row_cnt, col_cnt, nvar, ncon) where {T}
|
21 | 21 | Arows, Acols, Avals = A.rows, A.cols, A.vals
|
22 | 22 | cnt_vec_rows = ones(Int, ncon)
|
23 |
| - arows = [Row{T}(zeros(Int, row_cnt[i]), fill(T(Inf), row_cnt[i])) for i in 1:ncon] |
24 |
| - for k in 1:length(Arows) |
| 23 | + arows = [Row{T}(zeros(Int, row_cnt[i]), fill(T(Inf), row_cnt[i])) for i = 1:ncon] |
| 24 | + for k = 1:length(Arows) |
25 | 25 | i, j, Ax = Arows[k], Acols[k], Avals[k]
|
26 | 26 | arows[i].nzind[cnt_vec_rows[i]] = j
|
27 | 27 | arows[i].nzval[cnt_vec_rows[i]] = Ax
|
28 | 28 | cnt_vec_rows[i] += 1
|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | cnt_vec_cols = ones(Int, nvar)
|
32 |
| - acols = [Col{T}(zeros(Int, col_cnt[j]), fill(T(Inf), col_cnt[j])) for j in 1:nvar] |
33 |
| - for k in 1:length(Arows) |
| 32 | + acols = [Col{T}(zeros(Int, col_cnt[j]), fill(T(Inf), col_cnt[j])) for j = 1:nvar] |
| 33 | + for k = 1:length(Arows) |
34 | 34 | i, j, Ax = Arows[k], Acols[k], Avals[k]
|
35 | 35 | acols[j].nzind[cnt_vec_cols[j]] = i
|
36 | 36 | acols[j].nzval[cnt_vec_cols[j]] = Ax
|
|
42 | 42 | function get_hcols(H::SparseMatrixCOO{T}, nvar) where {T}
|
43 | 43 | Hrows, Hcols, Hvals = H.rows, H.cols, H.vals
|
44 | 44 | hcol_cnt = zeros(Int, nvar)
|
45 |
| - for k in 1:length(Hrows) |
| 45 | + for k = 1:length(Hrows) |
46 | 46 | i, j = Hrows[k], Hcols[k]
|
47 | 47 | hcol_cnt[i] += 1
|
48 | 48 | (i != j) && (hcol_cnt[j] += 1)
|
49 | 49 | end
|
50 |
| - hcols = [Col{T}(zeros(Int, hcol_cnt[i]), fill(T(Inf), hcol_cnt[i])) for i in 1:nvar] |
| 50 | + hcols = [Col{T}(zeros(Int, hcol_cnt[i]), fill(T(Inf), hcol_cnt[i])) for i = 1:nvar] |
51 | 51 |
|
52 | 52 | cnt_vec_cols = ones(Int, nvar)
|
53 |
| - for k in 1:length(Hrows) |
| 53 | + for k = 1:length(Hrows) |
54 | 54 | i, j, Hx = Hrows[k], Hcols[k], Hvals[k]
|
55 | 55 | hcols[j].nzind[cnt_vec_cols[j]] = i
|
56 | 56 | hcols[j].nzval[cnt_vec_cols[j]] = Hx
|
@@ -89,13 +89,13 @@ mutable struct PresolvedQuadraticModel{T, S, M1, M2} <: AbstractQuadraticModel{T
|
89 | 89 | end
|
90 | 90 |
|
91 | 91 | function check_bounds(lvar, uvar, lcon, ucon, nvar, ncon, kept_rows, kept_cols)
|
92 |
| - for i in 1:ncon |
| 92 | + for i = 1:ncon |
93 | 93 | if kept_rows[i] && lcon[i] > ucon[i]
|
94 | 94 | @warn "row $i primal infeasible"
|
95 | 95 | return true
|
96 | 96 | end
|
97 | 97 | end
|
98 |
| - for j in 1:nvar |
| 98 | + for j = 1:nvar |
99 | 99 | if kept_cols[j] && lvar[j] > uvar[j]
|
100 | 100 | @warn "col $j primal infeasible"
|
101 | 101 | return true
|
@@ -189,17 +189,8 @@ function presolve(
|
189 | 189 | kept_cols,
|
190 | 190 | )
|
191 | 191 |
|
192 |
| - unbounded = unconstrained_reductions!( |
193 |
| - operations, |
194 |
| - c, |
195 |
| - hcols, |
196 |
| - lvar, |
197 |
| - uvar, |
198 |
| - xps, |
199 |
| - nvar, |
200 |
| - col_cnt, |
201 |
| - kept_cols, |
202 |
| - ) |
| 192 | + unbounded = |
| 193 | + unconstrained_reductions!(operations, c, hcols, lvar, uvar, xps, nvar, col_cnt, kept_cols) |
203 | 194 |
|
204 | 195 | free_lsc_pass, psdata.c0 = free_linear_singleton_columns!(
|
205 | 196 | operations,
|
@@ -239,12 +230,22 @@ function presolve(
|
239 | 230 |
|
240 | 231 | infeasible = check_bounds(lvar, uvar, lcon, ucon, nvar, ncon, kept_rows, kept_cols)
|
241 | 232 |
|
242 |
| - keep_iterating = (empty_row_pass || singl_row_pass || ifix_pass || free_lsc_pass) && (!unbounded || !infeasible) |
| 233 | + keep_iterating = |
| 234 | + (empty_row_pass || singl_row_pass || ifix_pass || free_lsc_pass) && |
| 235 | + (!unbounded || !infeasible) |
243 | 236 | keep_iterating && (nb_pass += 1)
|
244 | 237 | end
|
245 | 238 |
|
246 | 239 | if !isempty(operations)
|
247 |
| - remove_rowscols_A!(psdata.A.rows, psdata.A.cols, psdata.A.vals, kept_rows, kept_cols, nvar, ncon) |
| 240 | + remove_rowscols_A!( |
| 241 | + psdata.A.rows, |
| 242 | + psdata.A.cols, |
| 243 | + psdata.A.vals, |
| 244 | + kept_rows, |
| 245 | + kept_cols, |
| 246 | + nvar, |
| 247 | + ncon, |
| 248 | + ) |
248 | 249 | remove_rowscols_H!(psdata.H.rows, psdata.H.cols, psdata.H.vals, kept_cols, nvar)
|
249 | 250 | nconps, nvarps = update_vectors!(lcon, ucon, c, lvar, uvar, kept_rows, kept_cols, ncon, nvar)
|
250 | 251 | end
|
@@ -335,7 +336,7 @@ function postsolve!(
|
335 | 336 | restore_x!(psqm.psd.kept_cols, x_in, pt_out.x, nvar)
|
336 | 337 | ncon = length(pt_out.y)
|
337 | 338 | restore_y!(psqm.psd.kept_rows, y_in, pt_out.y, ncon)
|
338 |
| - for i=n_operations:-1:1 |
| 339 | + for i = n_operations:-1:1 |
339 | 340 | operation_i = psqm.psd.operations[i]
|
340 | 341 | postsolve!(pt_out, operation_i)
|
341 | 342 | end
|
|
0 commit comments