diff --git a/julia/Manifest.toml b/julia/Manifest.toml index 86b56f6..0d4e7e0 100644 --- a/julia/Manifest.toml +++ b/julia/Manifest.toml @@ -1,8 +1,32 @@ # This file is machine-generated - editing it directly is not advised +[[ASL_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "370cafc70604b2522f2c7cf9915ebcd17b4cd38b" +uuid = "ae81ac8f-d209-56e5-92de-9978fef736f9" +version = "0.1.2+0" + +[[AbstractFFTs]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0" +uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" +version = "1.0.1" + +[[Adapt]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "84918055d15b3114ede17ac6a7182f68870c16f7" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "3.3.1" + [[ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +[[ArnoldiMethod]] +deps = ["LinearAlgebra", "Random", "StaticArrays"] +git-tree-sha1 = "f87e559f87a45bece9c9ed97458d3afe98b1ebb9" +uuid = "ec485272-7323-5ecc-a04f-4719b315124d" +version = "0.1.0" + [[ArrayInterface]] deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] git-tree-sha1 = "85d03b60274807181bae7549bb22b2204b6e5a0e" @@ -21,30 +45,66 @@ version = "0.1.0" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +[[BenchmarkTools]] +deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] +git-tree-sha1 = "61adeb0823084487000600ef8b1c00cc2474cd47" +uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +version = "1.2.0" + [[BinDeps]] deps = ["Libdl", "Pkg", "SHA", "URIParser", "Unicode"] git-tree-sha1 = "1289b57e8cf019aede076edab0587eb9644175bd" uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" version = "1.0.2" +[[BinaryProvider]] +deps = ["Libdl", "Logging", "SHA"] +git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058" +uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" +version = "0.5.10" + [[Blink]] deps = ["Base64", "BinDeps", "Distributed", "JSExpr", "JSON", "Lazy", "Logging", "MacroTools", "Mustache", "Mux", "Reexport", "Sockets", "WebIO", "WebSockets"] git-tree-sha1 = "08d0b679fd7caa49e2bca9214b131289e19808c0" uuid = "ad839575-38b3-5650-b840-f874b8c74a25" version = "0.12.5" +[[Bzip2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2" +uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" +version = "1.0.8+0" + [[CSPICE_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "56fbc7d843c24bb3a3689e81b064aa730f72db8c" uuid = "07f52509-e9d9-513c-a20d-3b911885bf96" version = "66.1.0+0" +[[ChainRules]] +deps = ["ChainRulesCore", "Compat", "LinearAlgebra", "Random", "Statistics"] +git-tree-sha1 = "d88340ab502af66cfffc821e70ae72f7dbdce645" +uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2" +version = "1.11.5" + [[ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] git-tree-sha1 = "bdc0937269321858ab2a4f288486cb258b9a0af7" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" version = "1.3.0" +[[CodecBzip2]] +deps = ["Bzip2_jll", "Libdl", "TranscodingStreams"] +git-tree-sha1 = "2e62a725210ce3c3c2e1a3080190e7ca491f18d7" +uuid = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd" +version = "0.7.2" + +[[CodecZlib]] +deps = ["TranscodingStreams", "Zlib_jll"] +git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da" +uuid = "944b1d66-785c-5afd-91f1-9de20f533193" +version = "0.7.0" + [[ColorTypes]] deps = ["FixedPointNumbers", "Random"] git-tree-sha1 = "024fe24d83e4a5bf5fc80501a314ce0d1aa35597" @@ -78,6 +138,12 @@ git-tree-sha1 = "ee400abb2298bd13bfc3df1c412ed228061a2385" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" version = "1.7.0" +[[DataStructures]] +deps = ["Compat", "InteractiveUtils", "OrderedCollections"] +git-tree-sha1 = "7d9d316f04214f7efdbb6398d545446e246eff02" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.18.10" + [[DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464" @@ -126,6 +192,12 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" [[FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +[[FillArrays]] +deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"] +git-tree-sha1 = "29890dfbc427afa59598b8cfcc10034719bd7744" +uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" +version = "0.12.6" + [[FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"] git-tree-sha1 = "8b3c09b56acaf3c0e581c66638b85c8650ee9dca" @@ -144,6 +216,11 @@ git-tree-sha1 = "b5e930ac60b613ef3406da6d4f42c35d8dc51419" uuid = "f6369f11-7733-5829-9624-2563aa707210" version = "0.10.19" +[[FunctionWrappers]] +git-tree-sha1 = "241552bc2209f0fa068b6415b1942cc0aa486bcc" +uuid = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" +version = "1.1.2" + [[FunctionalCollections]] deps = ["Test"] git-tree-sha1 = "04cb9cfaa6ba5311973994fe3496ddec19b6292a" @@ -162,11 +239,22 @@ git-tree-sha1 = "6187bb2d5fcbb2007c39e7ac53308b0d371124bd" uuid = "9fb69e20-1954-56bb-a84f-559cc56a8ff7" version = "0.2.2" +[[IRTools]] +deps = ["InteractiveUtils", "MacroTools", "Test"] +git-tree-sha1 = "95215cd0076a150ef46ff7928892bc341864c73c" +uuid = "7869d1d1-7146-5819-86e3-90919afe41df" +version = "0.4.3" + [[IfElse]] git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef" uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" version = "0.1.0" +[[Inflate]] +git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c" +uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9" +version = "0.1.2" + [[IniFile]] deps = ["Test"] git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" @@ -177,6 +265,18 @@ version = "0.5.0" deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +[[Ipopt]] +deps = ["BinaryProvider", "Ipopt_jll", "Libdl", "LinearAlgebra", "MathOptInterface", "MathProgBase"] +git-tree-sha1 = "380786b4929b8d18d76e909c6b2eca355b7c3bd6" +uuid = "b6b21f68-93f8-5de0-b562-5493be1d77c9" +version = "0.7.0" + +[[Ipopt_jll]] +deps = ["ASL_jll", "Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "MUMPS_seq_jll", "OpenBLAS32_jll", "Pkg"] +git-tree-sha1 = "82124f27743f2802c23fcb05febc517d0b15d86e" +uuid = "9cc047cb-c261-5740-88fc-0cf96f7bdcc7" +version = "3.13.4+2" + [[IrrationalConstants]] git-tree-sha1 = "f76424439413893a832026ca355fe273e93bce94" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" @@ -205,6 +305,12 @@ git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.2" +[[JSONSchema]] +deps = ["HTTP", "JSON", "URIs"] +git-tree-sha1 = "2f49f7f86762a0fbbeef84912265a1ae61c4ef80" +uuid = "7d188eb4-7ad8-530c-ae41-71a32a6d4692" +version = "0.3.4" + [[Kaleido_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "2ef87eeaa28713cb010f9fb0be288b6c1a4ecd53" @@ -241,6 +347,12 @@ uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" [[Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +[[LightGraphs]] +deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] +git-tree-sha1 = "432428df5f360964040ed60418dd5601ecd240b6" +uuid = "093fc24a-ae57-5d10-9952-331d41423f4d" +version = "1.3.5" + [[LineSearches]] deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"] git-tree-sha1 = "f27132e551e959b3667d8c93eae90973225032dd" @@ -260,6 +372,18 @@ version = "0.3.0" [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +[[METIS_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "2dc1a9fc87e57e32b1fc186db78811157b30c118" +uuid = "d00139f3-1899-568f-a2f0-47f597d42d70" +version = "5.1.0+5" + +[[MUMPS_seq_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "METIS_jll", "OpenBLAS32_jll", "Pkg"] +git-tree-sha1 = "1a11a84b2af5feb5a62a820574804056cdc59c39" +uuid = "d7ed1dd3-d0ae-5e8e-bfb4-87a502085b8d" +version = "5.2.1+4" + [[MacroTools]] deps = ["Markdown", "Random"] git-tree-sha1 = "0fb723cd8c45858c22169b2e42269e53271a6df7" @@ -270,6 +394,18 @@ version = "0.5.7" deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +[[MathOptInterface]] +deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "JSON", "JSONSchema", "LinearAlgebra", "MutableArithmetics", "OrderedCollections", "SparseArrays", "Test", "Unicode"] +git-tree-sha1 = "575644e3c05b258250bb599e57cf73bbf1062901" +uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" +version = "0.9.22" + +[[MathProgBase]] +deps = ["LinearAlgebra", "SparseArrays"] +git-tree-sha1 = "9abbe463a1e9fc507f12a69e7f29346c2cdc472c" +uuid = "fdba3010-5040-5b88-9595-932c9decdf73" +version = "0.7.8" + [[MbedTLS]] deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"] git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe" @@ -292,6 +428,12 @@ git-tree-sha1 = "36995ef0d532fe08119d70b2365b7b03d4e00f48" uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" version = "1.0.10" +[[MutableArithmetics]] +deps = ["LinearAlgebra", "SparseArrays", "Test"] +git-tree-sha1 = "3927848ccebcc165952dc0d9ac9aa274a87bfe01" +uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" +version = "0.2.20" + [[Mux]] deps = ["AssetRegistry", "Base64", "HTTP", "Hiccup", "Pkg", "Sockets", "WebSockets"] git-tree-sha1 = "82dfb2cead9895e10ee1b0ca37a01088456c4364" @@ -323,6 +465,12 @@ git-tree-sha1 = "3469ef96607a6b9a1e89e54e6f23401073ed3126" uuid = "510215fc-4207-5dde-b226-833fc4488ee2" version = "0.3.3" +[[OpenBLAS32_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "ba4a8f683303c9082e84afba96f25af3c7fb2436" +uuid = "656ef2d0-ae68-5445-9ca0-591084a874a2" +version = "0.3.12+1" + [[OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" @@ -378,6 +526,10 @@ version = "1.2.2" deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +[[Profile]] +deps = ["Printf"] +uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" + [[REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" @@ -397,9 +549,21 @@ git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621" uuid = "ae029012-a4dd-5104-9daa-d747884805df" version = "1.1.3" +[[ReverseDiff]] +deps = ["DiffResults", "DiffRules", "ForwardDiff", "FunctionWrappers", "LinearAlgebra", "MacroTools", "NaNMath", "Random", "SpecialFunctions", "StaticArrays", "Statistics"] +git-tree-sha1 = "63ee24ea0689157a1113dbdab10c6cb011d519c4" +uuid = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +version = "1.9.0" + [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +[[SNOW]] +deps = ["DiffResults", "FiniteDiff", "ForwardDiff", "Ipopt", "Requires", "ReverseDiff", "SparseArrays", "SparseDiffTools", "Zygote"] +git-tree-sha1 = "e299ceee0c1c96ad62a8bba3044c152861493f66" +uuid = "105f6ee8-0889-46b1-9d4b-65e03cbc8f13" +version = "0.2.0" + [[SPICE]] deps = ["CSPICE_jll", "LinearAlgebra"] git-tree-sha1 = "dcbc85c97ea75057e96547a189d819b5e80af86a" @@ -413,6 +577,12 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" deps = ["Distributed", "Mmap", "Random", "Serialization"] uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" +[[SimpleTraits]] +deps = ["InteractiveUtils", "MacroTools"] +git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231" +uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" +version = "0.9.4" + [[Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -420,6 +590,12 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc" deps = ["LinearAlgebra", "Random"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +[[SparseDiffTools]] +deps = ["Adapt", "ArrayInterface", "Compat", "DataStructures", "FiniteDiff", "ForwardDiff", "LightGraphs", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays", "VertexSafeGraphs"] +git-tree-sha1 = "36a4d27a02af48a1eafd2baff58b32deeeb68926" +uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804" +version = "1.16.5" + [[SpecialFunctions]] deps = ["ChainRulesCore", "LogExpFunctions", "OpenSpecFun_jll"] git-tree-sha1 = "a322a9493e49c5f3a10b50df3aedaf1cdb3244b7" @@ -471,6 +647,12 @@ uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +[[TranscodingStreams]] +deps = ["Random", "Test"] +git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c" +uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" +version = "0.9.6" + [[URIParser]] deps = ["Unicode"] git-tree-sha1 = "53a9f49546b8d2dd2e688d216421d050c9a31d0d" @@ -494,6 +676,12 @@ version = "1.0.2" [[Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +[[VertexSafeGraphs]] +deps = ["LightGraphs"] +git-tree-sha1 = "b9b450c99a3ca1cc1c6836f560d8d887bcbe356e" +uuid = "19fa3120-7c27-5ec5-8db8-b0b0aa330d6f" +version = "0.1.2" + [[WebIO]] deps = ["AssetRegistry", "Base64", "Distributed", "FunctionalCollections", "JSON", "Logging", "Observables", "Pkg", "Random", "Requires", "Sockets", "UUIDs", "WebSockets", "Widgets"] git-tree-sha1 = "adc25e225bc334c7df6eec3b39496edfc451cc38" @@ -516,6 +704,18 @@ version = "0.6.3" deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +[[Zygote]] +deps = ["AbstractFFTs", "ChainRules", "ChainRulesCore", "DiffRules", "Distributed", "FillArrays", "ForwardDiff", "IRTools", "InteractiveUtils", "LinearAlgebra", "MacroTools", "NaNMath", "Random", "Requires", "SpecialFunctions", "Statistics", "ZygoteRules"] +git-tree-sha1 = "ffbf36ba9cd8476347486a013c93590b910a4855" +uuid = "e88e6eb3-aa80-5325-afca-941959d7151f" +version = "0.6.21" + +[[ZygoteRules]] +deps = ["MacroTools"] +git-tree-sha1 = "9e7a1e8ca60b742e508a315c17eef5211e7fbfd7" +uuid = "700de1a5-db45-46bc-99cf-38207098b444" +version = "0.2.1" + [[nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" diff --git a/julia/Project.toml b/julia/Project.toml index a857c64..f437e32 100644 --- a/julia/Project.toml +++ b/julia/Project.toml @@ -12,5 +12,6 @@ NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +SNOW = "105f6ee8-0889-46b1-9d4b-65e03cbc8f13" SPICE = "5bab7191-041a-5c2e-a744-024b9c3a5062" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/julia/src/errors.jl b/julia/src/errors.jl index 78aa617..5949997 100644 --- a/julia/src/errors.jl +++ b/julia/src/errors.jl @@ -6,7 +6,7 @@ struct Convergence_Error <: Exception end Base.showerror(io::IO, e::Convergence_Error) = print(io, "NLP solver didn't converge...") struct GenOrbit_Error <: Exception end -Base.showerror(io::IO, e::GenOrbit_Error) = print(io, "Infinite Loop trying to generate the init orbit") +Base.showerror(io::IO, e::GenOrbit_Error) = print(io, "infinite Loop trying to generate the init orbit") struct PropOne_Error <: Exception ΔV_unit::AbstractVector @@ -16,4 +16,4 @@ Base.showerror(io::IO, e::PropOne_Error) = print(io, "tried to prop a unit ΔV o struct Mass_Error{T} <: Exception where T <: Real mass::T end -Base.showerror(io::IO, e::Mass_Error) = print(io, "Mass (", e.mass, ") got too low in propagation") +Base.showerror(io::IO, e::Mass_Error) = print(io, "mass (", e.mass, ") got too low in propagation") diff --git a/julia/src/inner_loop/monotonic_basin_hopping.jl b/julia/src/inner_loop/monotonic_basin_hopping.jl index 7813886..3d8003a 100644 --- a/julia/src/inner_loop/monotonic_basin_hopping.jl +++ b/julia/src/inner_loop/monotonic_basin_hopping.jl @@ -157,8 +157,8 @@ function inner_loop_solve(guess::Mission_Guess) time += phase.tof goal = spkssb(phase.planet.id, time, "ECLIPJ2000") + [zeros(3); phase.v∞_in] result = solve_phase( start, goal, guess.sc, phase.tof, phase.thrust_profile) - converged(result) || return Bad_Mission() # Drop if it's not working - corrected_phase = Phase(phase.planet, phase.v∞_in, phase.δ, phase.tof, result.zero) + result.converged || return Bad_Mission(result.info) # Drop if it's not working + corrected_phase = Phase(phase.planet, phase.v∞_in, phase.δ, phase.tof, result.sol) push!(corrected_phases, corrected_phase) mass_used = mass_consumption(guess.sc, corrected_phase) if i != length(guess.phases) diff --git a/julia/src/inner_loop/phase.jl b/julia/src/inner_loop/phase.jl index 5044a89..b4701c7 100644 --- a/julia/src/inner_loop/phase.jl +++ b/julia/src/inner_loop/phase.jl @@ -1,7 +1,13 @@ -using NLsolve +using SNOW export solve_phase +struct Result + converged::Bool + info::Symbol + sol::Matrix{Float64} +end + """ This function will take a single phase (so an initial state, and a final state) and an initial guess to the thrust profile and use an NLP solver to find the nearest thrust profile to that initial guess @@ -13,26 +19,40 @@ function solve_phase( start::Vector{Float64}, tof::Float64, x0::Matrix{Float64}, primary::Body=Sun; - tol=1e-6, - num_iters=1_000 ) + tol=1e-8, + verbose::Bool=false ) + n = size(x0)[1] - function f!(F,x) + function f!(g,x) try - F .= 0.0 - F[1:6, 1] .= prop(tanh.(x), start, craft, tof, primary)[2][1:6] .- final[1:6] + g[1:6] .= prop(reshape(x,(n,3)), start, craft, tof, primary)[2][1:6] + return 1. catch e - # If the error is due to something natural, just imply a penalty - if isa(e, Mass_Error) || isa(e, PropOne_Error) - F .= 10000000.0 + if isa(e,LaGuerreConway_Error) || isa(e, Mass_Error) || isa(e, PropOne_Error) + return 10_000. else - rethrow() + rethrow end end end - result = nlsolve(f!, atanh.(x0), ftol=tol, autodiff=:forward, iterations=num_iters) - if converged(result) result.zero = tanh.(result.zero) end - - return result + lower_x = -1 * ones(3n) + upper_x = ones(3n) + num_constraints = 6 + ipopt_options = Dict("constr_viol_tol" => tol, + "acceptable_constr_viol_tol" => 1e-4, + "max_iter" => 10_000, + "max_cpu_time" => 30., + "print_level" => 0) + # if verbose ipopt_options["print_level"] = 5 end + options = Options(solver=IPOPT(ipopt_options), + derivatives=ForwardAD()) + x, _, info = minimize(f!, vec(x0), num_constraints, lower_x, upper_x, final[1:6], final[1:6], options) + if info in [:Solve_Succeeded, :Solved_To_Acceptable_Level] + return Result(true, info, reshape(x,(n,3))) + else + if verbose println(info) end + return Result(false, info, x0) + end end diff --git a/julia/src/mission.jl b/julia/src/mission.jl index 6469f60..c87508b 100644 --- a/julia/src/mission.jl +++ b/julia/src/mission.jl @@ -56,6 +56,7 @@ const test_mission_simple = Mission(bepi, [test_phase1]) struct Bad_Mission + message::Symbol converged::Bool end -Bad_Mission() = Bad_Mission(false) +Bad_Mission(s) = Bad_Mission(s,false) diff --git a/julia/test/inner_loop/monotonic_basin_hopping.jl b/julia/test/inner_loop/monotonic_basin_hopping.jl index 70f25e3..2d1ff4e 100644 --- a/julia/test/inner_loop/monotonic_basin_hopping.jl +++ b/julia/test/inner_loop/monotonic_basin_hopping.jl @@ -37,9 +37,10 @@ earth_state = [spkssb(Earth.id, time_leave, "ECLIPJ2000"); 0.0] venus_state = [spkssb(Venus.id, time_arrive, "ECLIPJ2000"); 0.0] v∞_out, v∞_in, tof = Thesis.lamberts(Earth, Venus, leave, arrive) - phase = Phase(Venus, 1.0001v∞_in, 0.2, tof, 0.0*ones(20,3)) + phase = Phase(Venus, 1.01v∞_in, 0.2, tof, 0.01*ones(20,3)) mission_guess = Mission_Guess(bepi, 12_000., leave, v∞_out, [phase]) mission = Thesis.inner_loop_solve(mission_guess) @test mission.converged + if !mission.converged println(mission.message) end end diff --git a/julia/test/inner_loop/phase.jl b/julia/test/inner_loop/phase.jl index 5ea7978..3f428d3 100644 --- a/julia/test/inner_loop/phase.jl +++ b/julia/test/inner_loop/phase.jl @@ -2,7 +2,7 @@ println("Testing NLP solver") - using NLsolve, PlotlyJS + using SNOW, PlotlyJS # First we'll test an Earth case # Initial Setup @@ -19,12 +19,14 @@ # This should be close enough to converge, but Earth orbits are picky thrust_guess = spiral(0.89, n, start, test_sc, revs*T, Earth) - result = solve_phase(start, final, test_sc, revs*T, thrust_guess, Earth) - calc_path, calc_final = prop(result.zero, start, test_sc, revs*T, Earth, interpolate=true) + guess_final = prop(thrust_guess, start, test_sc, revs*T, Earth)[2] + result = solve_phase(start, final, test_sc, revs*T, thrust_guess, Earth, verbose=true) + calc_path, calc_final = prop(result.sol, start, test_sc, revs*T, Earth, interpolate=true) # Test - @test converged(result) - @test norm(calc_final[1:6] - final[1:6]) < 1e-5 + @test norm(guess_final[1:6] - final[1:6]) > 1e-4 + @test result.converged + @test norm(calc_final[1:6] - final[1:6]) < 1e-4 # Plot paths = Pathlist() @@ -51,12 +53,14 @@ # This should be close enough to converge thrust_guess = spiral(0.55, n, start, bepi, tof) - result = solve_phase(start, final, bepi, tof, thrust_guess) - calc_path, calc_final = prop(result.zero, start, bepi, tof, interpolate=true) + guess_final = prop(thrust_guess, start, bepi, tof)[2] + result = solve_phase(start, final, bepi, tof, thrust_guess, verbose=true) + calc_path, calc_final = prop(result.sol, start, bepi, tof, interpolate=true) # Test - @test converged(result) - @test norm(calc_final[1:6] - final[1:6]) < 1e-5 + @test norm(guess_final[1:6] - final[1:6]) > 1e-4 + @test result.converged + @test norm(calc_final[1:6] - final[1:6]) < 1e-4 # Plot paths = Pathlist() diff --git a/julia/test/runtests.jl b/julia/test/runtests.jl index 97b7a2c..f86c16e 100644 --- a/julia/test/runtests.jl +++ b/julia/test/runtests.jl @@ -13,9 +13,9 @@ catch end @testset "All Tests" begin - # include("plotting.jl") - # include("inner_loop/laguerre-conway.jl") - # include("inner_loop/propagator.jl") - # include("inner_loop/phase.jl") + include("plotting.jl") + include("inner_loop/laguerre-conway.jl") + include("inner_loop/propagator.jl") + include("inner_loop/phase.jl") include("inner_loop/monotonic_basin_hopping.jl") end