|
63 | 63 | solve(prob, alg)
|
64 | 64 | end
|
65 | 65 | 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 |
66 | 130 | end
|
67 | 131 |
|
68 | 132 | end
|
0 commit comments