# SciML collocation BVP solvers overwrite the initial guess - bug or feature?

**URL:** https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715
**Category:** Numerics
**Created:** [April 15, 2026, 12:07am UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715 "2026-04-15T00:07:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ThermionicsGuy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@ThermionicsGuy](https://discourse.julialang.org/u/ThermionicsGuy)
#### Post date: [April 15, 2026, 12:07am UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/1 "2026-04-15T00:07:07Z")

</div>

I’ve encountered a behavior that I didn’t expect when solving BVPs with SciML collocation methods and using the continuation method. When you call “solve” and are using a previous solution object as the initial guess, that initial guess is overwritten by the new solution. Is that intended? Is it documented somewhere?

Here’s a code example:

```julia-auto
using BoundaryValueDiffEq, NonlinearSolve
tspan = (0.0, 1.0)
function f!(du, u, p, t)
    cond = p[1]
    vol_heat = p[2]
    du[1] = -u[2]/cond
    du[2] = vol_heat
    du[3] = 0.0
end
function bca!(res_a, u_a, p)
    res_a[1] = u_a[2]
    res_a[2] = u_a[1] - 100.0
end
function bcb!(res_b, u_b, p)
    tref = 20.0
    res_b[1] = u_b[3] * (u_b[1] - tref) - u_b[2]
 end
u_guess = [[100.0, 0.0, 0.006666666666666668],
    [99.5, 0.020000000000000004, 0.006666666666666668],
    [98.0, 0.04000000000000001, 0.006666666666666668],
    [95.5, 0.060000000000000005, 0.006666666666666668],
    [92.0, 0.08000000000000002, 0.006666666666666668],
    [87.5, 0.1, 0.006666666666666668],
    [82.0, 0.12000000000000001, 0.006666666666666668],
    [75.5, 0.14, 0.006666666666666668],
    [68.0, 0.16000000000000003, 0.006666666666666668],
    [59.49999999999999, 0.18000000000000002, 0.006666666666666668],
    [50.0, 0.2, 0.006666666666666668] ]
p1 = [0.002, 0.2]
bvp1 = TwoPointBVProblem(f!, (bca!, bcb!), u_guess, tspan, p1; bcresid_prototype = (zeros(2), zeros(1)))
sol1 = solve(bvp1, MIRK5(nlsolve = NewtonRaphson()), dt = 0.1, adaptive = false; nlsolve_kwargs = (; maxiters = 10, show_trace = Val(false)))

println("sol1.u[1][1]= ",sol1.u[1][1], " sol1.u[1][2]= ", sol1.u[1][2], " sol1.u[1][3]= ", sol1.u[1][3])

p1[1] = 0.0015
p1[2] = 0.03
sol_guess = deepcopy(sol1)
println("sol_guess.u[1][1]=",sol_guess.u[1][1], " sol_guess.u[1][2]=", sol_guess.u[1][2], " sol_guess.u[1][3]=", sol_guess.u[1][3])
println("Solving")
bvp2 = TwoPointBVProblem(f!, (bca!, bcb!), sol_guess, tspan, p1; bcresid_prototype = (zeros(2), zeros(1)))
sol2 = solve(bvp2, MIRK5(nlsolve = NewtonRaphson()), dt = 0.1, adaptive = false; nlsolve_kwargs = (; maxiters = 10, show_trace = Val(false)));
println("sol1.u[1][1]= ",sol1.u[1][1], " sol1.u[1][2]= ", sol1.u[1][2], " sol1.u[1][3]= ", sol1.u[1][3])
println("sol_guess.u[1][1]=",sol_guess.u[1][1], " sol_guess.u[1][2]=", sol_guess.u[1][2], " sol_guess.u[1][3]=", sol_guess.u[1][3])
println("sol2.u[1][1]= ",sol2.u[1][1], " sol2.u[1][2]= ", sol2.u[1][2], " sol2.u[1][3]= ", sol2.u[1][3])

```

And here is the output:

```julia-auto
sol1.u[1][1]= 100.0 sol1.u[1][2]= 0.0 sol1.u[1][3]= 0.006666666666666668
sol_guess.u[1][1]=100.0 sol_guess.u[1][2]=0.0 sol_guess.u[1][3]=0.006666666666666668
Solving
sol1.u[1][1]= 100.0 sol1.u[1][2]= 0.0 sol1.u[1][3]= 0.006666666666666668
sol_guess.u[1][1]=100.0 sol_guess.u[1][2]=3.604278872980289e-17 sol_guess.u[1][3]=0.00042857142857142747
sol2.u[1][1]= 100.0 sol2.u[1][2]= 3.604278872980289e-17 sol2.u[1][3]= 0.00042857142857142747

```

The values in “sol\_guess” have become identical to the values in “sol2” after the call “sol2 = solve(bvp2,…)”.

In my continuation scheme it may be that I try to solve using one method and it fails to converge. I then want to try to solve using a different method (one that might be more robust) and **the same initial guess as was used for the failed solve**. Unless I’ve saved my previous initial guess as a separate data item (such as “sol1” in the example I’ve given) that initial guess has been destroyed. This issue can be easily fixed, but if you don’t expect the initial guess to be overwritten it can cause a lot of debugging in order to find the issue.

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [April 15, 2026, 12:55am UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/2 "2026-04-15T00:55:42Z")

</div>

This likely isn’t intended. Sometime in the last ~year or so we’ve added an actual aliasing system to most of the sciml solvers, but it is very possible that the BVP solvers haven’t gotten it yet.

Our default generally is to not alias user provided arrays unless the user specifically tells us to.

---

<div class="post-metadata">

### Author: ![ThermionicsGuy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@ThermionicsGuy](https://discourse.julialang.org/u/ThermionicsGuy)
#### Post date: [April 15, 2026, 2:23am UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/3 "2026-04-15T02:23:18Z")

</div>

Should I file a bug report on GitHub or not?

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [April 15, 2026, 4:16am UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/4 "2026-04-15T04:16:08Z")

</div>

Yes please.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 16, 2026, 2:33pm UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/5 "2026-04-16T14:33:18Z")

</div>

I think this was fixed [Fix initial guess in collocation solvers by ErikQQY · Pull Request #460 · SciML/BoundaryValueDiffEq.jl · GitHub](https://github.com/SciML/BoundaryValueDiffEq.jl/pull/460) but not released.

---

<div class="post-metadata">

### Author: ![ThermionicsGuy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@ThermionicsGuy](https://discourse.julialang.org/u/ThermionicsGuy)
#### Post date: [April 16, 2026, 4:29pm UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/6 "2026-04-16T16:29:47Z")

</div>

Issue 460 solved a different problem that was also affecting the initial guess.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 16, 2026, 4:36pm UTC](https://discourse.julialang.org/t/sciml-collocation-bvp-solvers-overwrite-the-initial-guess-bug-or-feature/136715/7 "2026-04-16T16:36:37Z")

</div>

Okay we’ll figure this out.
