Skip to content

Commit 2634990

Browse files
committed
Precompile NLLS Workflows as well
1 parent 211d935 commit 2634990

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

ext/BoundaryValueDiffEqOrdinaryDiffEqExt.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,70 @@ end
6363
solve(prob, alg)
6464
end
6565
end
66+
67+
function f1_nlls!(du, u, p, t)
68+
du[1] = u[2]
69+
du[2] = -u[1]
70+
end
71+
72+
f1_nlls(u, p, t) = [u[2], -u[1]]
73+
74+
function bc1_nlls!(resid, sol, p, t)
75+
solₜ₁ = sol(0.0)
76+
solₜ₂ = sol(100.0)
77+
resid[1] = solₜ₁[1]
78+
resid[2] = solₜ₂[1] - 1
79+
resid[3] = solₜ₂[2] + 1.729109
80+
return nothing
81+
end
82+
bc1_nlls(sol, p, t) = [sol(0.0)[1], sol(100.0)[1] - 1, sol(100.0)[2] + 1.729109]
83+
84+
bc1_nlls_a!(resid, ua, p) = (resid[1] = ua[1])
85+
bc1_nlls_b!(resid, ub, p) = (resid[1] = ub[1] - 1; resid[2] = ub[2] + 1.729109)
86+
87+
bc1_nlls_a(ua, p) = [ua[1]]
88+
bc1_nlls_b(ub, p) = [ub[1] - 1, ub[2] + 1.729109]
89+
90+
tspan = (0.0, 100.0)
91+
u0 = [0.0, 1.0]
92+
bcresid_prototype1 = Array{Float64}(undef, 3)
93+
bcresid_prototype2 = (Array{Float64}(undef, 1), Array{Float64}(undef, 2))
94+
95+
probs = [
96+
BVProblem(BVPFunction(f1_nlls!, bc1_nlls!; bcresid_prototype = bcresid_prototype1),
97+
u0, tspan),
98+
BVProblem(BVPFunction(f1_nlls, bc1_nlls; bcresid_prototype = bcresid_prototype1),
99+
u0, tspan),
100+
TwoPointBVProblem(f1_nlls!, (bc1_nlls_a!, bc1_nlls_b!), u0, tspan;
101+
bcresid_prototype = bcresid_prototype2),
102+
TwoPointBVProblem(f1_nlls, (bc1_nlls_a, bc1_nlls_b), u0, tspan;
103+
bcresid_prototype = bcresid_prototype2),
104+
]
105+
106+
algs = [
107+
Shooting(Tsit5();
108+
nlsolve = LevenbergMarquardt(; autodiff = AutoForwardDiff(chunksize = 2))),
109+
Shooting(Tsit5();
110+
nlsolve = GaussNewton(; autodiff = AutoForwardDiff(chunksize = 2))),
111+
MultipleShooting(10,
112+
Tsit5();
113+
nlsolve = LevenbergMarquardt(; autodiff = AutoForwardDiff(chunksize = 2)),
114+
jac_alg = BVPJacobianAlgorithm(;
115+
bc_diffmode = AutoForwardDiff(; chunksize = 2),
116+
nonbc_diffmode = AutoSparseForwardDiff(; chunksize = 2))),
117+
MultipleShooting(10,
118+
Tsit5();
119+
nlsolve = GaussNewton(; autodiff = AutoForwardDiff(chunksize = 2)),
120+
jac_alg = BVPJacobianAlgorithm(;
121+
bc_diffmode = AutoForwardDiff(; chunksize = 2),
122+
nonbc_diffmode = AutoSparseForwardDiff(; chunksize = 2))),
123+
]
124+
125+
@compile_workload begin
126+
for prob in probs, alg in algs
127+
solve(prob, alg)
128+
end
129+
end
66130
end
67131

68132
end

0 commit comments

Comments
 (0)