|
64 | 64 | end
|
65 | 65 | end
|
66 | 66 |
|
67 |
| - if VERSION ≥ v"1.10-" |
68 |
| - function f1_nlls!(du, u, p, t) |
69 |
| - du[1] = u[2] |
70 |
| - du[2] = -u[1] |
71 |
| - end |
| 67 | + function f1_nlls!(du, u, p, t) |
| 68 | + du[1] = u[2] |
| 69 | + du[2] = -u[1] |
| 70 | + end |
72 | 71 |
|
73 |
| - f1_nlls(u, p, t) = [u[2], -u[1]] |
| 72 | + f1_nlls(u, p, t) = [u[2], -u[1]] |
74 | 73 |
|
75 |
| - function bc1_nlls!(resid, sol, p, t) |
76 |
| - solₜ₁ = sol(0.0) |
77 |
| - solₜ₂ = sol(100.0) |
78 |
| - resid[1] = solₜ₁[1] |
79 |
| - resid[2] = solₜ₂[1] - 1 |
80 |
| - resid[3] = solₜ₂[2] + 1.729109 |
81 |
| - return nothing |
82 |
| - end |
83 |
| - bc1_nlls(sol, p, t) = [sol(0.0)[1], sol(100.0)[1] - 1, sol(100.0)[2] + 1.729109] |
84 |
| - |
85 |
| - bc1_nlls_a!(resid, ua, p) = (resid[1] = ua[1]) |
86 |
| - bc1_nlls_b!(resid, ub, p) = (resid[1] = ub[1] - 1; resid[2] = ub[2] + 1.729109) |
87 |
| - |
88 |
| - bc1_nlls_a(ua, p) = [ua[1]] |
89 |
| - bc1_nlls_b(ub, p) = [ub[1] - 1, ub[2] + 1.729109] |
90 |
| - |
91 |
| - tspan = (0.0, 100.0) |
92 |
| - u0 = [0.0, 1.0] |
93 |
| - bcresid_prototype1 = Array{Float64}(undef, 3) |
94 |
| - bcresid_prototype2 = (Array{Float64}(undef, 1), Array{Float64}(undef, 2)) |
95 |
| - |
96 |
| - probs = [ |
97 |
| - BVProblem(BVPFunction(f1_nlls!, bc1_nlls!; bcresid_prototype = bcresid_prototype1), |
98 |
| - u0, tspan), |
99 |
| - BVProblem(BVPFunction(f1_nlls, bc1_nlls; bcresid_prototype = bcresid_prototype1), |
100 |
| - u0, tspan), |
101 |
| - TwoPointBVProblem(f1_nlls!, (bc1_nlls_a!, bc1_nlls_b!), u0, tspan; |
102 |
| - bcresid_prototype = bcresid_prototype2), |
103 |
| - TwoPointBVProblem(f1_nlls, (bc1_nlls_a, bc1_nlls_b), u0, tspan; |
104 |
| - bcresid_prototype = bcresid_prototype2), |
105 |
| - ] |
106 |
| - |
107 |
| - algs = [ |
108 |
| - Shooting(Tsit5(); |
109 |
| - nlsolve = LevenbergMarquardt(; autodiff = AutoForwardDiff(chunksize = 2))), |
110 |
| - Shooting(Tsit5(); |
111 |
| - nlsolve = GaussNewton(; autodiff = AutoForwardDiff(chunksize = 2))), |
112 |
| - MultipleShooting(10, |
113 |
| - Tsit5(); |
114 |
| - nlsolve = LevenbergMarquardt(; autodiff = AutoForwardDiff(chunksize = 2)), |
115 |
| - jac_alg = BVPJacobianAlgorithm(; |
116 |
| - bc_diffmode = AutoForwardDiff(; chunksize = 2), |
117 |
| - nonbc_diffmode = AutoSparseForwardDiff(; chunksize = 2))), |
118 |
| - MultipleShooting(10, |
119 |
| - Tsit5(); |
120 |
| - nlsolve = GaussNewton(; autodiff = AutoForwardDiff(chunksize = 2)), |
121 |
| - jac_alg = BVPJacobianAlgorithm(; |
122 |
| - bc_diffmode = AutoForwardDiff(; chunksize = 2), |
123 |
| - nonbc_diffmode = AutoSparseForwardDiff(; chunksize = 2))), |
124 |
| - ] |
| 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] |
125 | 83 |
|
126 |
| - @compile_workload begin |
127 |
| - for prob in probs, alg in algs |
128 |
| - solve(prob, alg) |
129 |
| - end |
| 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 | + |
| 108 | + if @load_preference("PrecompileShootingNLLS", VERSION≥v"1.10-") |
| 109 | + append!(algs, |
| 110 | + [ |
| 111 | + Shooting(Tsit5(); |
| 112 | + nlsolve = LevenbergMarquardt(; |
| 113 | + autodiff = AutoForwardDiff(chunksize = 2))), |
| 114 | + Shooting(Tsit5(); |
| 115 | + nlsolve = GaussNewton(; autodiff = AutoForwardDiff(chunksize = 2))), |
| 116 | + ]) |
| 117 | + end |
| 118 | + |
| 119 | + if @load_preference("PrecompileMultipleShootingNLLS", VERSION≥v"1.10-") |
| 120 | + append!(algs, |
| 121 | + [ |
| 122 | + MultipleShooting(10, Tsit5(); |
| 123 | + nlsolve = LevenbergMarquardt(; |
| 124 | + autodiff = AutoForwardDiff(chunksize = 2)), |
| 125 | + jac_alg = BVPJacobianAlgorithm(; |
| 126 | + bc_diffmode = AutoForwardDiff(; chunksize = 2), |
| 127 | + nonbc_diffmode = AutoSparseForwardDiff(; chunksize = 2))), |
| 128 | + MultipleShooting(10, Tsit5(); |
| 129 | + nlsolve = GaussNewton(; autodiff = AutoForwardDiff(chunksize = 2)), |
| 130 | + jac_alg = BVPJacobianAlgorithm(; |
| 131 | + bc_diffmode = AutoForwardDiff(; chunksize = 2), |
| 132 | + nonbc_diffmode = AutoSparseForwardDiff(; chunksize = 2))), |
| 133 | + ]) |
| 134 | + end |
| 135 | + |
| 136 | + @compile_workload begin |
| 137 | + for prob in probs, alg in algs |
| 138 | + solve(prob, alg) |
130 | 139 | end
|
131 | 140 | end
|
132 | 141 | end
|
|
0 commit comments