Skip to content

Commit 639bd1b

Browse files
🤖 Format .jl files (#119)
Co-authored-by: geoffroyleconte <[email protected]>
1 parent 3302e98 commit 639bd1b

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

src/presolve/postsolve_utils.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ function restore_s!(
6767
restore_x!(kept_cols, s_u_in, s_u, nvar)
6868
end
6969

70-
function add_Hx!(z::Vector{T}, hcols::Vector{Col{T}}, kept_cols::Vector{Bool}, x::Vector{T}) where {T}
71-
for j in 1:length(hcols)
70+
function add_Hx!(
71+
z::Vector{T},
72+
hcols::Vector{Col{T}},
73+
kept_cols::Vector{Bool},
74+
x::Vector{T},
75+
) where {T}
76+
for j = 1:length(hcols)
7277
hcolj = hcols[j]
7378
Hxj = zero(T)
7479
for (i, hij) in zip(hcolj.nzind, hcolj.nzval)
@@ -78,4 +83,4 @@ function add_Hx!(z::Vector{T}, hcols::Vector{Col{T}}, kept_cols::Vector{Bool}, x
7883
z[j] += Hxj
7984
end
8085
return z
81-
end
86+
end

src/presolve/presolve.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,7 @@ postsolve!(
414414
sol_in::QMSolution{S},
415415
) where {T, S} = postsolve!(psqm.psd, sol, sol_in)
416416

417-
function postsolve(
418-
psd::PresolvedData{T, S},
419-
sol_in::QMSolution{S},
420-
) where {T, S}
417+
function postsolve(psd::PresolvedData{T, S}, sol_in::QMSolution{S}) where {T, S}
421418
x = fill!(S(undef, psd.nvar), zero(T))
422419
y = fill!(S(undef, psd.ncon), zero(T))
423420
s_l = fill!(S(undef, psd.nvar), zero(T))

src/presolve/primal_constraints.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ function postsolve!(
8181
add_Hx!(z, psd.hcols, kept_cols, x) # z = c + Hx
8282
for l = 1:n
8383
kept_cols[l] || continue
84-
for (k, akl) in zip(acols[l].nzind, acols[l].nzval)
84+
for (k, akl) in zip(acols[l].nzind, acols[l].nzval)
8585
(psd.kept_rows[i] && k != i) || continue
8686
z[l] -= akl * y[k]
8787
end
8888
end
8989

9090
if forced_lcon
91-
yi = T(-Inf)
91+
yi = T(-Inf)
9292
for (l, ail) in zip(arowi.nzind, arowi.nzval)
9393
(kept_cols[l]) || continue
9494
trial = z[l] / ail
9595
(trial > yi) && (yi = trial)
9696
end
9797
else
98-
yi = T(Inf)
98+
yi = T(Inf)
9999
for (l, ail) in zip(arowi.nzind, arowi.nzval)
100100
(kept_cols[l]) || continue
101101
trial = z[l] / ail

test/test_presolve.jl

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,29 @@ end
166166
end
167167

168168
@testset "presolve solves problem" begin
169-
Q = [6. 2. 1.
170-
2. 5. 2.
171-
1. 2. 4.]
172-
c = [-8.; -3; -3]
173-
A = [1. 0. 1.
174-
0. 2. 1.]
175-
b = [0.; 3]
176-
l = [0.;0;0]
169+
Q = [
170+
6.0 2.0 1.0
171+
2.0 5.0 2.0
172+
1.0 2.0 4.0
173+
]
174+
c = [-8.0; -3; -3]
175+
A = [
176+
1.0 0.0 1.0
177+
0.0 2.0 1.0
178+
]
179+
b = [0.0; 3]
180+
l = [0.0; 0; 0]
177181
u = [Inf; Inf; Inf]
178182
qp = QuadraticModel(
179183
c,
180184
SparseMatrixCOO(tril(Q)),
181-
A=SparseMatrixCOO(A),
182-
lcon=b,
183-
ucon=b,
184-
lvar=l,
185-
uvar=u,
186-
c0=0.,
187-
name="QM"
185+
A = SparseMatrixCOO(A),
186+
lcon = b,
187+
ucon = b,
188+
lvar = l,
189+
uvar = u,
190+
c0 = 0.0,
191+
name = "QM",
188192
)
189193
statsps = presolve(qp)
190194
psqp = statsps.solver_specific[:presolvedQM]

0 commit comments

Comments
 (0)