@@ -8,20 +8,33 @@ mutable struct PresolvedQuadraticModel{T, S, M1, M2} <: AbstractQuadraticModel{T
8
8
end
9
9
10
10
"""
11
- psqm = presolve(qm::QuadraticModel{T, S}; kwargs...)
11
+ stats_ps = presolve(qm::QuadraticModel{T, S}; kwargs...)
12
12
13
- Apply a presolve routine to `qm` and returns a `PresolvedQuadraticModel{T, S} <: AbstractQuadraticModel{T, S}`.
13
+ Apply a presolve routine to `qm` and returns a
14
+ [`GenericExecutionStats`](https://juliasmoothoptimizers.github.io/SolverCore.jl/stable/reference/#SolverCore.GenericExecutionStats)
15
+ from the package [`SolverCore.jl`](https://github.com/JuliaSmoothOptimizers/SolverCore.jl).
14
16
The presolve operations currently implemented are:
15
17
16
- - [`remove_ifix!`](@ref)
18
+ - [`remove_ifix!`](@ref) : remove fixed variables
17
19
20
+ The `PresolvedQuadraticModel{T, S} <: AbstractQuadraticModel{T, S}` is located in the `solver_specific` field:
21
+
22
+ psqm = stats_ps.solver_specific[:presolvedQM]
23
+
24
+ and should be used to call [`postsolve!`](@ref).
25
+
26
+ If the presolved problem has 0 variables, `stats_ps` contains a solution such that `stats_ps.solution` minimizes the primal problem,
27
+ `stats_ps.multipliers` is a `SparseVector` full of zeros, and, with
28
+
29
+ s = qm.data.c + qm.data.H * stats_ps.solution
30
+
31
+ `stats_ps.multipliers_L` is the positive part of `s` and `stats_ps.multipliers_U` is the opposite of the negative part of `s`.
18
32
"""
19
33
function presolve (
20
34
qm:: QuadraticModel{T, S, M1, M2} ;
21
35
kwargs... ,
22
36
) where {T <: Real , S, M1 <: SparseMatrixCOO , M2 <: SparseMatrixCOO }
23
37
start_time = time ()
24
- elapsed_time = 0.0
25
38
psqm = deepcopy (qm)
26
39
psdata = psqm. data
27
40
lvar, uvar = psqm. meta. lvar, psqm. meta. uvar
@@ -63,14 +76,14 @@ function presolve(
63
76
64
77
if nvarps == 0
65
78
feasible = all (qm. meta. lcon .<= qm. data. A * xrm .<= qm. meta. ucon)
66
- s = qm. data. c .+ qm. data. Q * xrm
79
+ s = qm. data. c .+ Symmetric ( qm. data. H, :L ) * xrm
67
80
i_l = findall (s .> zero (T))
68
81
s_l = sparsevec (i_l, s[i_l])
69
82
i_u = findall (s .< zero (T))
70
83
s_u = sparsevec (i_u, .- s[i_u])
71
84
return GenericExecutionStats (
72
85
feasible ? :acceptable : :infeasible ,
73
- ps ,
86
+ qm ,
74
87
solution = xrm,
75
88
objective = obj (qm, xrm),
76
89
multipliers = zeros (T, qm. meta. nvar),
0 commit comments