Skip to content

Commit

Permalink
Merge pull request #462 from ErikQQY/initial
Browse files Browse the repository at this point in the history
Improve initial guess for TwoPointBVProblem
  • Loading branch information
ChrisRackauckas authored Jul 30, 2023
2 parents 5d0b887 + bc07f97 commit 6cfe683
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/problems/bvp_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ TwoPointBVProblem{isinplace}(f,bc!,u0,tspan,p=NullParameters();kwargs...)
BVProblem{isinplace}(f,bc!,u0,tspan,p=NullParameters();kwargs...)
```
or if we have an initial guess function `initialGuess(t)` for the given BVP,
we can pass the initial guess to the problem constructors:
```julia
TwoPointBVProblem{isinplace}(f,bc!,initialGuess,tspan,p=NullParameters();kwargs...)
BVProblem{isinplace}(f,bc!,initialGuess,tspan,p=NullParameters();kwargs...)
```
For any BVP problem type, `bc!` is the inplace function:
```julia
Expand Down Expand Up @@ -141,3 +149,22 @@ function TwoPointBVProblem{iip}(f, bc, u0, tspan, p = NullParameters();
kwargs...) where {iip}
BVProblem{iip}(f, TwoPointBVPFunction(bc), u0, tspan, p; kwargs...)
end

# Allow previous timeseries solution
function TwoPointBVProblem(f::AbstractODEFunction,
bc,
sol::T,
tspan::Tuple,
p = NullParameters()) where {T <: AbstractTimeseriesSolution}
TwoPointBVProblem(f, bc, sol.u, tspan, p)
end
# Allow initial guess function for the initial guess
function TwoPointBVProblem(f::AbstractODEFunction,
bc,
initialGuess,
tspan::AbstractVector,
p = NullParameters();
kwargs...)
u0 = [initialGuess(i) for i in tspan]
TwoPointBVProblem(f, bc, u0, (tspan[1], tspan[end]), p)
end

0 comments on commit 6cfe683

Please sign in to comment.