I THINK that the single shooter is ok. I can always improve it later
This commit is contained in:
33
julia/single_shoot.jl
Normal file
33
julia/single_shoot.jl
Normal file
@@ -0,0 +1,33 @@
|
||||
using NLsolve
|
||||
|
||||
function treat_inputs(x::AbstractVector, n::Int)
|
||||
inputs = reshape(copy(x),(3,n))'
|
||||
for i in 1:n
|
||||
inputs[i,1] = 0.5*tanh(inputs[i,1]) + 0.5
|
||||
inputs[i,2] = π*tanh(inputs[i,2])
|
||||
inputs[i,3] = π*tanh(inputs[i,3])/2
|
||||
end
|
||||
return inputs
|
||||
end
|
||||
|
||||
function single_shoot(start::Vector{Float64},
|
||||
final::Vector{Float64},
|
||||
craft::Sc,
|
||||
μ::Float64,
|
||||
t0::Float64,
|
||||
tf::Float64,
|
||||
n::Int,
|
||||
x0::AbstractVector,
|
||||
tol=1e-2)
|
||||
|
||||
function f!(F,x)
|
||||
F[1:6] .= prop(treat_inputs(x,n), start, craft, μ, tf-t0)[1][end,:] - final
|
||||
F[7:3n] .= 0.
|
||||
# if typeof(F[1]) == Float64 println(F[1:6]) end
|
||||
# if typeof(F[1]) == Float64 println(treat_inputs(x,n)[1:8,1]) end
|
||||
|
||||
end
|
||||
|
||||
return nlsolve(f!, x0, ftol=tol, autodiff=:forward, iterations=10_000)
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user