Skip to content

Commit 7b560e8

Browse files
timholyamontoison
authored andcommitted
Fix warm-start of bipartite methods
Applies to BiLQR and TriLQR (only in cases of wrong input sizes) and to TriCG, TriMR, and GPMR where `x0` and `y0` had their sizes swapped.
1 parent ce143db commit 7b560e8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/workspace_accessors.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [
153153
issolved(workspace :: $KS) = workspace.stats.solved
154154
end
155155
if $warm_start
156-
if $KS in (BilqrWorkspace, TrilqrWorkspace, TricgWorkspace, TrimrWorkspace, GpmrWorkspace)
156+
if $KS in (BilqrWorkspace, TrilqrWorkspace)
157157
function warm_start!(workspace :: $KS, x0, y0)
158-
length(x0) == workspace.n || error("x0 should have size $n")
159-
length(y0) == workspace.m || error("y0 should have size $m")
158+
length(x0) == workspace.n || error("x0 should have size $(workspace.n)")
159+
length(y0) == workspace.m || error("y0 should have size $(workspace.m)")
160160
S = typeof(workspace.x)
161161
allocate_if(true, workspace, :Δx, S, workspace.x) # The length of Δx is n
162162
allocate_if(true, workspace, :Δy, S, workspace.y) # The length of Δy is m
@@ -165,6 +165,18 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [
165165
workspace.warm_start = true
166166
return workspace
167167
end
168+
elseif $KS in (TricgWorkspace, TrimrWorkspace, GpmrWorkspace)
169+
function warm_start!(workspace :: $KS, x0, y0)
170+
length(x0) == workspace.m || error("x0 should have size $(workspace.m)")
171+
length(y0) == workspace.n || error("y0 should have size $(workspace.n)")
172+
S = typeof(workspace.x)
173+
allocate_if(true, workspace, :Δx, S, workspace.x) # The length of Δx is m
174+
allocate_if(true, workspace, :Δy, S, workspace.y) # The length of Δy is n
175+
kcopy!(workspace.m, workspace.Δx, x0)
176+
kcopy!(workspace.n, workspace.Δy, y0)
177+
workspace.warm_start = true
178+
return workspace
179+
end
168180
else
169181
function warm_start!(workspace :: $KS, x0)
170182
S = typeof(workspace.x)

0 commit comments

Comments
 (0)