diff --git a/Climate/NeuralPDE/2 b/Climate/NeuralPDE/2 new file mode 100644 index 0000000..77045bb --- /dev/null +++ b/Climate/NeuralPDE/2 @@ -0,0 +1,137 @@ +cd(@__DIR__) +using Pkg; Pkg.activate("."); Pkg.instantiate() +using Revise +using Zygote, Optim +using OrdinaryDiffEq, Flux, DiffEqFlux, LinearAlgebra, Plots +using DiffEqSensitivity +const EIGEN_EST = Ref(0.0f0) +const USE_GPU = Ref(false) + +USE_GPU[] = false # the network is small enough such that CPU works just great + +USE_GPU[] && (using CuArrays) + +_gpu(arg) = USE_GPU[] ? gpu(arg) : cpu(arg) +_cu(arg) = USE_GPU[] ? cu(arg) : identity(arg) + +function getops(grid, T=Float32) + N, dz = length(grid), step(grid) + d = ones(N-2) + dl = ones(N-3) # super/lower diagonal + zv = zeros(N-2) # zero diagonal used to extend D* for boundary conditions + + # D1 first order discretization of ∂_z + D1= diagm(-1 => -dl, 0 => d) + D1_B = hcat(zv, D1, zv) + D1_B[1,1] = -1 + D1_B = _cu((1/dz)*D1_B) + + # D2 discretization of ∂_zz + D2 = diagm(-1 => dl, 0 => -2*d, 1 => dl) + κ = 0.05 + D2_B = hcat(zv, D2, zv) #add space for the boundary conditions space for "ghost nodes" + #we only solve for the interior space steps + D2_B[1,1] = D2_B[end, end] = 1 + + D2_B = _cu((κ/(dz^2)).*D2_B) #add the constant κ as the equation requires and finish the discretization + + # Boundary conditions matrix QQ + Q = Matrix{Int}(I, N-2, N-2) + QQ = _cu(vcat(zeros(1,N-2), Q, zeros(1,N-2))) + + D1 = D1_B * QQ + D2 = D2_B * QQ + EIGEN_EST[] = maximum(abs, eigvals(Matrix(D2))) + return (D1=T.(D1), D2=T.(D2)) +end + +function getu0(grid, T=Float32) + z = grid[2:N-1] + f0 = z -> T(exp(-200*(z-0.75)^2)) + u0 = f0.(z) |> _gpu +end + +function ode_i(u, p, t) + Φ = u -> cos.(sin.(u.^3) .+ sin.(cos.(u.^2))) + return p.D1*Φ(u) + p.D2*u +end + +function ground_truth(grid, tspan) + prob = ODEProblem(ode_i, u0, (tspan[1], tspan[2]+0.1), ops) + sol = solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), abstol = 1e-9, reltol = 1e-9) + return sol +end + +N = 32 +grid = range(0, 1, length = N) +tspan = (0.0f0, 1.5f0) +u0 = getu0(grid) +ops = getops(grid) +soldata = ground_truth(grid, tspan) + +ann = FastChain(FastDense(30,8,tanh), FastDense(8,30,tanh)) |> _gpu +pp = initial_params(ann) +lyrs = Flux.params(pp) +function dudt_(u,p,t) + Φ = ann + return ops.D1*Φ(u, p) + ops.D2*u +end + +function predict_adjoint(iterat, fullp) + Array(concrete_solve(prob, + ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), + u0, fullp, saveat = saveat)) +end + +function loss_adjoint(iterat, fullp) + pre = predict_adjoint(fullp) + sum(abs2, training_data - pre) +end + +function random_data() + print("here") + ones(N, N) +end + +function cb(opt_state:: Optim.OptimizationState) + cur_pred = collect(predict_adjoint(opt_state.metadata["x"])) + n = size(training_data, 1) + #pl = scatter(1:n,training_data[:,10],label="data", legend =:bottomright,title="Spatial Plot at t=$(saveat[10])") + #scatter!(pl,1:n,cur_pred[:,10],label="prediction") + #pl2 = scatter(saveat,training_data[N÷2,:],label="data", legend =:bottomright, title="Timeseries Plot at Middle X") + #scatter!(pl2,saveat,cur_pred[N÷2,:],label="prediction") + #display(plot(pl, pl2, size=(600, 300))) + display(opt_state.value) + false +end + +cb(trace::Optim.OptimizationTrace) = cb(last(trace)) + + +saveat = range(tspan..., length = 30) #time range +prob = ODEProblem{false}(dudt_,u0,tspan,pp) +training_data = _cu(soldata(saveat)) + +epochs = Iterators.repeated(random_data(), 20) +concrete_solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), u0, pp) +loss_adjoint(pp) + +#function loss_adjoint_gradient!(G, fullp) +# G .= Zygote.gradient(loss_adjoint, fullp)[1] +#end +res = DiffEqFlux.sciml_train(loss_adjoint, pp, BFGS(initial_stepnorm=0.01), epochs;cb = cb,maxiters = 1000) +#result = optimize(loss_adjoint, loss_adjoint_gradient!, pp, BFGS(), Optim.Options(extended_trace=true,callback = cb)) + +#prob2 = ODEProblem{false}(dudt_,u0,(0f0,10f0),pp) +#@time full_sol = solve(prob2, +# ROCK2(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), +# saveat = saveat, abstol=1e-4, reltol=1e-2) +# +#cur_pred = collect((predict_adjoint(result.minimizer))) +#n = size(training_data, 1) +#pl = scatter(1:n,training_data[:,10],label="data", legend =:bottomright) +#scatter!(pl,1:n,cur_pred[:,10],label="prediction",title="Spatial Plot at t=$(saveat[10])") +#pl2 = scatter(saveat,training_data[N÷2,:],label="data", legend =:bottomright, title="Time Series Plot: Middle X") +#scatter!(pl2,saveat,cur_pred[N÷2,:],label="prediction") +#plot(pl, pl2, size=(600, 300)) +#savefig("npde_fit.pdf") diff --git a/Climate/NeuralPDE/Manifest.toml b/Climate/NeuralPDE/Manifest.toml index 1c7962c..99e0cc1 100644 --- a/Climate/NeuralPDE/Manifest.toml +++ b/Climate/NeuralPDE/Manifest.toml @@ -8,15 +8,15 @@ version = "0.5.0" [[AbstractTrees]] deps = ["Markdown"] -git-tree-sha1 = "940760b82db1f7090f7d16fe6e4b121cc181db45" +git-tree-sha1 = "86d092c2599f1f7bb01668bf8eb3412f98d61e47" uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" -version = "0.3.1" +version = "0.3.2" [[Adapt]] deps = ["LinearAlgebra"] -git-tree-sha1 = "82dab828020b872fa9efd3abec1152b075bc7cbf" +git-tree-sha1 = "c88cfc7f9c1f9f8633cddf0b56e86302b70f64c5" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "1.0.0" +version = "1.0.1" [[ApproxFun]] deps = ["AbstractFFTs", "ApproxFunBase", "ApproxFunFourier", "ApproxFunOrthogonalPolynomials", "ApproxFunSingularities", "Calculus", "DomainSets", "DualNumbers", "FFTW", "FastTransforms", "LinearAlgebra", "RecipesBase", "Reexport"] @@ -68,9 +68,9 @@ version = "3.5.0+2" [[ArrayInterface]] deps = ["LinearAlgebra", "Requires", "SparseArrays"] -git-tree-sha1 = "656fd4bcdf204ea96945d9bc1068c0056013438a" +git-tree-sha1 = "7ab65638f4664498b01aeddf2e82f93780ba5e21" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "2.3.1" +version = "2.6.0" [[ArrayLayouts]] deps = ["FillArrays", "LinearAlgebra"] @@ -123,21 +123,21 @@ version = "1.0.0" [[CUDAapi]] deps = ["Libdl", "Logging"] -git-tree-sha1 = "56a813440ac98a1aa64672ab460a1512552211a7" +git-tree-sha1 = "d7ceadd8f821177d05b897c0517e94633db535fe" uuid = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3" -version = "2.1.0" +version = "3.1.0" [[CUDAdrv]] deps = ["CEnum", "CUDAapi", "Printf"] -git-tree-sha1 = "1fce616fa0806c67c133eb1d2f68f0f1a7504665" +git-tree-sha1 = "01e90fa34e25776bc7c8661183d4519149ebfe59" uuid = "c5f51814-7f29-56b8-a69c-e4d8f6be1fde" -version = "5.0.1" +version = "6.0.0" [[CUDAnative]] deps = ["Adapt", "CEnum", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "Printf", "TimerOutputs"] -git-tree-sha1 = "ba0725f487fb4a6c63efad7890a659659b6a6754" +git-tree-sha1 = "f86269ff60ebe082a2806ecbce51f3cadc68afe9" uuid = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17" -version = "2.8.1" +version = "2.10.2" [[Calculus]] deps = ["LinearAlgebra"] @@ -145,17 +145,11 @@ git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad" uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" version = "0.5.1" -[[CategoricalArrays]] -deps = ["Compat", "DataAPI", "Future", "JSON", "Missings", "Printf", "Reexport", "Statistics", "Unicode"] -git-tree-sha1 = "23d7324164c89638c18f6d7f90d972fa9c4fa9fb" -uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597" -version = "0.7.7" - [[ChainRulesCore]] deps = ["MuladdMacro"] -git-tree-sha1 = "eb54d7349210f37c142e58d67668951efc1e5cdc" +git-tree-sha1 = "840cdd255e267a4dfcb14cecd872facb2997a326" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "0.6.1" +version = "0.7.1" [[CodeTracking]] deps = ["InteractiveUtils", "UUIDs"] @@ -171,15 +165,15 @@ version = "0.6.0" [[ColorTypes]] deps = ["FixedPointNumbers", "Random"] -git-tree-sha1 = "7b62b728a5f3dd6ee3b23910303ccf27e82fad5e" +git-tree-sha1 = "b9de8dc6106e09c79f3f776c27c62360d30e5eb8" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" -version = "0.8.1" +version = "0.9.1" [[Colors]] deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Printf", "Reexport"] -git-tree-sha1 = "c9c1845d6bf22e34738bee65c357a69f416ed5d1" +git-tree-sha1 = "177d8b959d3c103a6d57574c38ee79c81059c31b" uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" -version = "0.9.6" +version = "0.11.2" [[CommonSubexpressions]] deps = ["Test"] @@ -188,28 +182,34 @@ uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" version = "0.2.0" [[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb" +deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] +git-tree-sha1 = "0198d18b28c093bef39872a22f1a897218a925f5" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "2.2.0" +version = "3.8.0" [[CompilerSupportLibraries_jll]] deps = ["Libdl", "Pkg"] -git-tree-sha1 = "b57c5d019367c90f234a7bc7e24ff0a84971da5d" +git-tree-sha1 = "aa832564f930a7fc9290972526908d01a35aefac" uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "0.2.0+1" +version = "0.3.0+0" + +[[ConsoleProgressMonitor]] +deps = ["Logging", "ProgressMeter"] +git-tree-sha1 = "3ab7b2136722890b9af903859afcf457fa3059e8" +uuid = "88cd18e8-d9cc-4ea6-8889-5259c0d15c8b" +version = "0.1.2" [[Contour]] -deps = ["LinearAlgebra", "StaticArrays", "Test"] -git-tree-sha1 = "b974e164358fea753ef853ce7bad97afec15bb80" +deps = ["StaticArrays"] +git-tree-sha1 = "6d56f927b33d3820561b8f89d7de311718683846" uuid = "d38c429a-6771-53c6-b99e-75d170b6e991" -version = "0.5.1" +version = "0.5.2" [[CuArrays]] deps = ["AbstractFFTs", "Adapt", "CEnum", "CUDAapi", "CUDAdrv", "CUDAnative", "DataStructures", "GPUArrays", "Libdl", "LinearAlgebra", "MacroTools", "NNlib", "Printf", "Random", "Requires", "SparseArrays", "TimerOutputs"] -git-tree-sha1 = "4e536542c5c898b1bf43011b6187f3c97ebcc91e" +git-tree-sha1 = "7fa1331a0e0cd10e43b94b280027bda45990cb63" uuid = "3a865a2d-5b23-5a0f-bc46-62713ec82fae" -version = "1.7.0" +version = "1.7.3" [[DSP]] deps = ["FFTW", "IterTools", "LinearAlgebra", "Polynomials", "Random", "Reexport", "SpecialFunctions", "Statistics"] @@ -222,22 +222,11 @@ git-tree-sha1 = "674b67f344687a88310213ddfa8a2b3c76cc4252" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" version = "1.1.0" -[[DataFrames]] -deps = ["CategoricalArrays", "Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "Missings", "PooledArrays", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] -git-tree-sha1 = "00136fcd39d503e66ab1b2eab800c47deaf7ca04" -uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -version = "0.20.0" - [[DataStructures]] deps = ["InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "b7720de347734f4716d1815b00ce5664ed6bbfd4" +git-tree-sha1 = "5a431d46abf2ef2a4d5d00bd0ae61f651cf854c8" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.17.9" - -[[DataValueInterfaces]] -git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" -uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464" -version = "1.0.0" +version = "0.17.10" [[Dates]] deps = ["Printf"] @@ -248,28 +237,28 @@ deps = ["Mmap"] uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" [[DiffEqBase]] -deps = ["ArrayInterface", "ChainRulesCore", "Compat", "DataStructures", "Distributed", "DocStringExtensions", "FunctionWrappers", "IterativeSolvers", "IteratorInterfaceExtensions", "LinearAlgebra", "MuladdMacro", "Parameters", "Printf", "RecipesBase", "RecursiveArrayTools", "RecursiveFactorization", "Requires", "Roots", "SparseArrays", "StaticArrays", "Statistics", "SuiteSparse", "TableTraits", "TreeViews", "ZygoteRules"] -git-tree-sha1 = "3ef848bc1b8b09ce3cc14b53ddd0b4abec0407ae" +deps = ["ArrayInterface", "ChainRulesCore", "ConsoleProgressMonitor", "DataStructures", "Distributed", "DocStringExtensions", "FunctionWrappers", "IterativeSolvers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "LoggingExtras", "MuladdMacro", "Parameters", "Printf", "ProgressLogging", "RecipesBase", "RecursiveArrayTools", "RecursiveFactorization", "Requires", "Roots", "SparseArrays", "StaticArrays", "Statistics", "SuiteSparse", "TableTraits", "TerminalLoggers", "TreeViews", "ZygoteRules"] +git-tree-sha1 = "b20a1c5741d279787c7db100e11106ea14ee6dbf" uuid = "2b5f629d-d688-5b77-993f-72d75c75574e" -version = "6.13.1" +version = "6.25.0" [[DiffEqCallbacks]] deps = ["DataStructures", "DiffEqBase", "ForwardDiff", "LinearAlgebra", "NLsolve", "OrdinaryDiffEq", "RecipesBase", "RecursiveArrayTools", "StaticArrays"] -git-tree-sha1 = "573b46d716ff12b79e9f6e1c1602b0553b619e84" +git-tree-sha1 = "3aadf5d6b987aaec2bb7421aba522df744609960" uuid = "459566f4-90b8-5000-8ac3-15dfb0a30def" -version = "2.11.0" +version = "2.12.1" [[DiffEqFlux]] -deps = ["Adapt", "DiffEqBase", "DiffEqSensitivity", "DiffResults", "Flux", "ForwardDiff", "LinearAlgebra", "RecursiveArrayTools", "Requires", "Tracker", "ZygoteRules"] -git-tree-sha1 = "db1b35fb42fb81325a4aa0fb7d7d599d4352b07c" +deps = ["Adapt", "DiffEqBase", "DiffEqSensitivity", "DiffResults", "Flux", "ForwardDiff", "Juno", "LinearAlgebra", "Logging", "Optim", "RecursiveArrayTools", "Requires", "ReverseDiff", "StaticArrays", "Tracker", "ZygoteRules"] +git-tree-sha1 = "145c4578542cf7ba8781d672dae1b6e371810f2d" uuid = "aae7a2af-3d4f-5e19-a356-7da93b79d9d0" -version = "1.1.1" +version = "1.7.0" [[DiffEqSensitivity]] -deps = ["Adapt", "DataFrames", "DiffEqBase", "DiffEqCallbacks", "Distributions", "FFTW", "FiniteDiff", "ForwardDiff", "GLM", "LinearAlgebra", "Parameters", "QuadGK", "QuasiMonteCarlo", "RecursiveArrayTools", "Statistics", "Tracker", "Zygote", "ZygoteRules"] -git-tree-sha1 = "2e60be09027dc348480467c8d1cd7c5779dff6cb" +deps = ["Adapt", "DiffEqBase", "DiffEqCallbacks", "Distributions", "FFTW", "FiniteDiff", "ForwardDiff", "LinearAlgebra", "Parameters", "QuadGK", "QuasiMonteCarlo", "RecursiveArrayTools", "ReverseDiff", "Statistics", "Tracker", "Zygote", "ZygoteRules"] +git-tree-sha1 = "00a6d02598e6fa54c88d43feed3c0baaf8280278" uuid = "41bf760c-e81c-5289-8e54-58b1f1f8abe2" -version = "6.6.0" +version = "6.8.0" [[DiffResults]] deps = ["StaticArrays"] @@ -279,9 +268,9 @@ version = "1.0.2" [[DiffRules]] deps = ["NaNMath", "Random", "SpecialFunctions"] -git-tree-sha1 = "10dca52cf6d4a62d82528262921daf63b99704a2" +git-tree-sha1 = "eb0c34204c8410888844ada5359ac8b96292cfd1" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "1.0.0" +version = "1.0.1" [[Distances]] deps = ["LinearAlgebra", "Statistics"] @@ -295,9 +284,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" [[Distributions]] deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"] -git-tree-sha1 = "e063d0b5d27180b98edacd2b1cb90ecfbc171385" +git-tree-sha1 = "55e1de79bd2c397e048ca47d251f8fa70e530550" uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" -version = "0.21.12" +version = "0.22.6" [[DocStringExtensions]] deps = ["LibGit2", "Markdown", "Pkg", "Test"] @@ -337,9 +326,9 @@ version = "1.2.0" [[FFTW_jll]] deps = ["Libdl", "Pkg"] -git-tree-sha1 = "05674f209a6e3387dd103a945b0113eeb64b1a58" +git-tree-sha1 = "ddb57f4cf125243b4aa4908c94d73a805f3cbf2c" uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a" -version = "3.3.9+3" +version = "3.3.9+4" [[FastGaussQuadrature]] deps = ["LinearAlgebra", "SpecialFunctions"] @@ -361,24 +350,24 @@ version = "0.2.13+0" [[FileIO]] deps = ["Pkg"] -git-tree-sha1 = "74585bf1f7ed7259e166011e89f49363d7fa89a6" +git-tree-sha1 = "250ac7dfd54b5ce47372505b392756633d4e9732" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.2.1" +version = "1.2.3" [[FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[FillArrays]] deps = ["LinearAlgebra", "Random", "SparseArrays"] -git-tree-sha1 = "fec413d4fc547992eb62a5c544cedb6d7853c1f5" +git-tree-sha1 = "85c6b57e2680fa28d5c8adc798967377646fbf66" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "0.8.4" +version = "0.8.5" [[FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"] -git-tree-sha1 = "109cca539ac87b1b95538f539ed8eb7e3f35eee5" +git-tree-sha1 = "f60e5d6944975f7140bde67278e10b6b01fb4f29" uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" -version = "2.1.0" +version = "2.3.0" [[FixedPointNumbers]] git-tree-sha1 = "d14a6fa5890ea3a7e5dcab6811114f132fec2b4b" @@ -387,9 +376,9 @@ version = "0.6.1" [[Flux]] deps = ["AbstractTrees", "Adapt", "CodecZlib", "Colors", "CuArrays", "DelimitedFiles", "Juno", "MacroTools", "NNlib", "Pkg", "Printf", "Random", "Reexport", "SHA", "Statistics", "StatsBase", "Test", "ZipFile", "Zygote"] -git-tree-sha1 = "8134adbb0f10b0d22b22f8b4299d0d20509edc5f" +git-tree-sha1 = "b5647a92b4d547f835b0eac904331a97c45d773d" uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" -version = "0.10.1" +version = "0.10.3" [[ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "NaNMath", "Random", "SpecialFunctions", "StaticArrays"] @@ -398,20 +387,9 @@ uuid = "f6369f11-7733-5829-9624-2563aa707210" version = "0.10.9" [[FunctionWrappers]] -deps = ["Compat"] -git-tree-sha1 = "49bf793ebd37db5adaa7ac1eae96c2c97ec86db5" +git-tree-sha1 = "e4813d187be8c7b993cb7f85cbf2b7bfbaadc694" uuid = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" -version = "1.0.0" - -[[Future]] -deps = ["Random"] -uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" - -[[GLM]] -deps = ["Distributions", "LinearAlgebra", "Printf", "Random", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "StatsModels"] -git-tree-sha1 = "9768bbf52d4fbb2e2bb3e4e304a787c4cb8aa980" -uuid = "38e38edf-8417-5370-95a0-9cbb8c7f171a" -version = "1.3.6" +version = "1.1.1" [[GMP_jll]] deps = ["Libdl", "Pkg"] @@ -439,9 +417,9 @@ version = "0.2.2" [[GeometryTypes]] deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "StaticArrays"] -git-tree-sha1 = "a96baa00f5ac755689c82c29bc3395e161337c69" +git-tree-sha1 = "78f0ce9d01993b637a8f28d84537d75dc0ce8eef" uuid = "4d00f742-c7ba-57c2-abde-4428a4b178cb" -version = "0.7.7" +version = "0.7.10" [[IRTools]] deps = ["InteractiveUtils", "MacroTools", "Test"] @@ -477,22 +455,16 @@ git-tree-sha1 = "4214b48a62eb8f2c292b2ee34a508c256c0cdbc9" uuid = "8197267c-284f-5f27-9208-e0e47529a953" version = "0.3.2" -[[InvertedIndices]] -deps = ["Test"] -git-tree-sha1 = "15732c475062348b0165684ffe28e85ea8396afc" -uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" -version = "1.0.0" - [[IterTools]] git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18" uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e" version = "1.3.0" [[IterativeSolvers]] -deps = ["LinearAlgebra", "Printf", "Random", "RecipesBase", "SparseArrays", "Test"] -git-tree-sha1 = "5687f68018b4f14c0da54d402bb23eecaec17f37" +deps = ["LinearAlgebra", "Printf", "Random", "RecipesBase", "SparseArrays"] +git-tree-sha1 = "f272a02b57a1a1d2150a1a6cc4a3441ee806ab96" uuid = "42fd0dbc-a981-5370-80f2-aaf504508153" -version = "0.8.1" +version = "0.8.3" [[IteratorInterfaceExtensions]] git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" @@ -501,9 +473,9 @@ version = "1.0.0" [[JLD2]] deps = ["CodecZlib", "DataStructures", "FileIO", "Mmap", "Pkg", "Printf", "UUIDs"] -git-tree-sha1 = "5deae9f0745ef505ed155a0029629cf08502ccab" +git-tree-sha1 = "d6cfa7c24e27d7eaa2290372739c8298257dae16" uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" -version = "0.1.11" +version = "0.1.12" [[JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -513,33 +485,39 @@ version = "0.21.0" [[JuliaInterpreter]] deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "a4f675340a109713f74c47a2b499df06f800c8d0" +git-tree-sha1 = "2eadbbde5534346cbb837c3a75b377cba477a06d" uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.7.8" +version = "0.7.13" [[Juno]] -deps = ["Base64", "Logging", "Media", "Profile", "Test"] -git-tree-sha1 = "30d94657a422d09cb97b6f86f04f750fa9c50df8" +deps = ["Base64", "Logging", "Media", "Profile"] +git-tree-sha1 = "e1ba2a612645b3e07c773c3a208f215745081fe6" uuid = "e5e0dc1b-0480-54bc-9374-aad01c23163d" -version = "0.7.2" +version = "0.8.1" [[LLVM]] deps = ["CEnum", "Libdl", "Printf", "Unicode"] -git-tree-sha1 = "1d08d7e4250f452f6cb20e4574daaebfdbee0ff7" +git-tree-sha1 = "b6b86801ae2f2682e0a4889315dc76b68db2de71" uuid = "929cbde3-209d-540e-8aea-75f648917ca0" -version = "1.3.3" +version = "1.3.4" [[LatinHypercubeSampling]] deps = ["Random", "StatsBase", "Test"] -git-tree-sha1 = "f049eba097c2a93a6ac6d5babb6bd711a8123444" +git-tree-sha1 = "b6d72344668dba064cc5791681bac7d55d272b6e" uuid = "a5e1c1ea-c99a-51d3-a14d-a9a37257b02d" -version = "1.4.0" +version = "1.6.3" [[LazyArrays]] deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra", "MacroTools", "StaticArrays"] -git-tree-sha1 = "6e818d550c2158def13c236c3b825fc14995160c" +git-tree-sha1 = "b799f90cd9a1d90a54038f8263e701023bce1af8" uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02" -version = "0.15.0" +version = "0.15.1" + +[[LeftChildRightSiblingTrees]] +deps = ["AbstractTrees"] +git-tree-sha1 = "71be1eb5ad19cb4f61fa8c73395c0338fd092ae0" +uuid = "1d6d02ad-be62-4b6b-8a6d-2f90e265016e" +version = "0.1.2" [[LibGit2]] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" @@ -549,9 +527,9 @@ uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[LightGraphs]] deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] -git-tree-sha1 = "a0d4bcea4b9c056da143a5ded3c2b7f7740c2d41" +git-tree-sha1 = "f40c4dbcd957cc3afc8cca0ff26c9f8304def00d" uuid = "093fc24a-ae57-5d10-9952-331d41423f4d" -version = "1.3.0" +version = "1.3.1" [[LineSearches]] deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf", "Test"] @@ -566,6 +544,11 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +[[LoggingExtras]] +git-tree-sha1 = "c867b50bfc564f0beded1c566f4fc66cfd8b5418" +uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" +version = "0.4.0" + [[LowRankApprox]] deps = ["FFTW", "FillArrays", "LinearAlgebra", "Nullables", "Random", "SparseArrays", "Test"] git-tree-sha1 = "1963361c4e8a837b9ca7cca3f45372f953e6b0ed" @@ -574,9 +557,9 @@ version = "0.4.0" [[LoweredCodeUtils]] deps = ["JuliaInterpreter"] -git-tree-sha1 = "b416a30717e9109fffd4d9869f2f962b5dca3162" +git-tree-sha1 = "1c41621653250b2824b6e664ac5bd805558aeff9" uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "0.4.2" +version = "0.4.3" [[MKL_jll]] deps = ["IntelOpenMP_jll", "Libdl", "Pkg"] @@ -592,9 +575,9 @@ version = "4.0.2+2" [[MacroTools]] deps = ["DataStructures", "Markdown", "Random"] -git-tree-sha1 = "e2fc7a55bb2224e203bbd8b59f72b91323233458" +git-tree-sha1 = "07ee65e03e28ca88bc9a338a3726ae0c3efaa94b" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.3" +version = "0.5.4" [[Markdown]] deps = ["Base64"] @@ -633,9 +616,9 @@ version = "0.2.2" [[NLSolversBase]] deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"] -git-tree-sha1 = "b13b1f97ce88a37dd55ce7ae7e75b81002bf2b9d" +git-tree-sha1 = "7c4e66c47848562003250f28b579c584e55becc0" uuid = "d41bc354-129a-5804-8e4c-c37616107c6c" -version = "7.6.0" +version = "7.6.1" [[NLsolve]] deps = ["Distances", "LineSearches", "LinearAlgebra", "NLSolversBase", "Printf", "Reexport"] @@ -645,9 +628,9 @@ version = "4.3.0" [[NNlib]] deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Requires", "Statistics"] -git-tree-sha1 = "755c0bab3912ff782167e1b4b774b833f8a0e550" +git-tree-sha1 = "d9f196d911f55aeaff11b11f681b135980783824" uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" -version = "0.6.4" +version = "0.6.6" [[NaNMath]] git-tree-sha1 = "928b8ca9b2791081dc71a51c55347c27c618760f" @@ -661,21 +644,21 @@ version = "1.0.0" [[OpenBLAS_jll]] deps = ["Libdl", "Pkg"] -git-tree-sha1 = "3a6e5767e8ae022871c19162cc3ecd80748bd3dc" +git-tree-sha1 = "139adbff69e8149e68824994b68f06a61a5a2797" uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.7+4" +version = "0.3.7+8" [[OpenSpecFun_jll]] -deps = ["Libdl", "Pkg"] -git-tree-sha1 = "65f672edebf3f4e613ddf37db9dcbd7a407e5e90" +deps = ["CompilerSupportLibraries_jll", "Libdl", "Pkg"] +git-tree-sha1 = "d51c416559217d974a1113522d5919235ae67a87" uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" -version = "0.5.3+1" +version = "0.5.3+3" [[Optim]] -deps = ["FillArrays", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "Random", "SparseArrays", "StatsBase"] -git-tree-sha1 = "b1e90642d0addb7d9651d409ad465ac5c764c11f" +deps = ["Compat", "FillArrays", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] +git-tree-sha1 = "1c44e1ac9c39892ff74de99ec9f7428f03660851" uuid = "429524aa-4258-5aef-a3af-852621145aeb" -version = "0.20.0" +version = "0.20.4" [[OrderedCollections]] deps = ["Random", "Serialization", "Test"] @@ -684,16 +667,16 @@ uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" version = "1.1.0" [[OrdinaryDiffEq]] -deps = ["ArrayInterface", "DataStructures", "DiffEqBase", "ExponentialUtilities", "FiniteDiff", "ForwardDiff", "GenericSVD", "LinearAlgebra", "Logging", "MacroTools", "MuladdMacro", "Parameters", "RecursiveArrayTools", "Reexport", "SparseArrays", "SparseDiffTools", "StaticArrays"] -git-tree-sha1 = "eee8bb40d5265b97b1e6c685d46afbdcc559f789" +deps = ["ArrayInterface", "DataStructures", "DiffEqBase", "ExponentialUtilities", "FiniteDiff", "ForwardDiff", "GenericSVD", "LinearAlgebra", "Logging", "MacroTools", "MuladdMacro", "NLsolve", "RecursiveArrayTools", "Reexport", "SparseArrays", "SparseDiffTools", "StaticArrays", "UnPack"] +git-tree-sha1 = "586c962ad54d355f195ef4e2e370d420362820d2" uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" -version = "5.28.1" +version = "5.31.0" [[PDMats]] deps = ["Arpack", "LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"] -git-tree-sha1 = "5f303510529486bb02ac4d70da8295da38302194" +git-tree-sha1 = "2fc6f50ddd959e462f0a2dbc802ddf2a539c6e35" uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" -version = "0.9.11" +version = "0.9.12" [[Parameters]] deps = ["OrderedCollections"] @@ -703,9 +686,9 @@ version = "0.12.0" [[Parsers]] deps = ["Dates", "Test"] -git-tree-sha1 = "0139ba59ce9bc680e2925aec5b7db79065d60556" +git-tree-sha1 = "0c16b3179190d3046c073440d94172cfc3bb0553" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "0.3.10" +version = "0.3.12" [[Pkg]] deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] @@ -719,9 +702,9 @@ version = "1.0.1" [[PlotUtils]] deps = ["Colors", "Dates", "Printf", "Random", "Reexport"] -git-tree-sha1 = "22bd7d0a1f4665d66317d6c89a57f6bba9f2560d" +git-tree-sha1 = "132e468bf7d67ee6c997c160b982a7ab2e7c3e37" uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043" -version = "0.6.2" +version = "0.6.4" [[Plots]] deps = ["Base64", "Contour", "Dates", "FFMPEG", "FixedPointNumbers", "GR", "GeometryTypes", "JSON", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "Reexport", "Requires", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs"] @@ -731,15 +714,9 @@ version = "0.28.4" [[Polynomials]] deps = ["LinearAlgebra", "RecipesBase"] -git-tree-sha1 = "ae71c2329790af97b7682b11241b3609e4d48626" +git-tree-sha1 = "1185511cac8ab9d0b658b663eae34fe9a95d4332" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" -version = "0.6.0" - -[[PooledArrays]] -deps = ["DataAPI"] -git-tree-sha1 = "b1333d4eced1826e15adbdf01a4ecaccca9d353c" -uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" -version = "0.5.3" +version = "0.6.1" [[PositiveFactorizations]] deps = ["LinearAlgebra", "Test"] @@ -755,6 +732,18 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" deps = ["Printf"] uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" +[[ProgressLogging]] +deps = ["Logging", "SHA", "UUIDs"] +git-tree-sha1 = "e47914361d124d8760f5e356403daeb7f3b81633" +uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c" +version = "0.1.2" + +[[ProgressMeter]] +deps = ["Distributed", "Printf"] +git-tree-sha1 = "ea1f4fa0ff5e8b771bf130d87af5b7ef400760bd" +uuid = "92933f4c-e287-5a05-a399-4b506db050ca" +version = "1.2.0" + [[QuadGK]] deps = ["DataStructures", "LinearAlgebra"] git-tree-sha1 = "dc84e810393cfc6294248c9032a9cdacc14a3db4" @@ -763,9 +752,9 @@ version = "2.3.1" [[QuasiMonteCarlo]] deps = ["Distributions", "LatinHypercubeSampling", "Sobol"] -git-tree-sha1 = "e01670ab0faee2fc060e080909cfbba774ab2ee2" +git-tree-sha1 = "283d3f2f74d38c5b7fc124bc1c476c9a3b8e2e89" uuid = "8a4e6c94-4038-4cdc-81c3-7e6ffdb2a71b" -version = "0.1.0" +version = "0.1.1" [[REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets"] @@ -782,9 +771,9 @@ version = "0.7.0" [[RecursiveArrayTools]] deps = ["ArrayInterface", "RecipesBase", "Requires", "StaticArrays", "Statistics", "ZygoteRules"] -git-tree-sha1 = "275cb9be63cbb8a1e9d5737dac45ecff5840ad48" +git-tree-sha1 = "bd13db2a3561fb3a3635220c5ee21e3356d7631e" uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" -version = "2.0.4" +version = "2.1.0" [[RecursiveFactorization]] deps = ["LinearAlgebra"] @@ -800,27 +789,39 @@ version = "0.2.0" [[Requires]] deps = ["UUIDs"] -git-tree-sha1 = "999513b7dea8ac17359ed50ae8ea089e4464e35e" +git-tree-sha1 = "d37400976e98018ee840e0ca4f9d20baa231dc6b" uuid = "ae029012-a4dd-5104-9daa-d747884805df" -version = "1.0.0" +version = "1.0.1" + +[[ReverseDiff]] +deps = ["DiffResults", "DiffRules", "ForwardDiff", "FunctionWrappers", "LinearAlgebra", "NaNMath", "Random", "SpecialFunctions", "StaticArrays", "Statistics"] +git-tree-sha1 = "5f7dafd314ff2ada3076797b1edfb71e52151cb9" +uuid = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +version = "1.1.0" [[Revise]] deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "UUIDs", "Unicode"] -git-tree-sha1 = "2ecbd19f31a934b035bfc38036d5f7ac575d0878" +git-tree-sha1 = "3c04c929f8720c2fabb12534cd102a2356a7705c" uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "2.5.0" +version = "2.5.4" [[Rmath]] -deps = ["BinaryProvider", "Libdl", "Random", "Statistics"] -git-tree-sha1 = "2bbddcb984a1d08612d0c4abb5b4774883f6fa98" +deps = ["Random", "Rmath_jll"] +git-tree-sha1 = "86c5647b565873641538d8f812c04e4c9dbeb370" uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" -version = "0.6.0" +version = "0.6.1" + +[[Rmath_jll]] +deps = ["Libdl", "Pkg"] +git-tree-sha1 = "1660f8fefbf5ab9c67560513131d4e933012fc4b" +uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f" +version = "0.2.2+0" [[Roots]] deps = ["Printf"] -git-tree-sha1 = "dcc013908465ca1019b34b4bf547b6a187d195f9" +git-tree-sha1 = "869a9990ec6347862d59040d00416ecd0683b965" uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" -version = "0.8.4" +version = "1.0.0" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" @@ -832,11 +833,6 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" deps = ["Distributed", "Mmap", "Random", "Serialization"] uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" -[[ShiftedArrays]] -git-tree-sha1 = "22395afdcf37d6709a5a0766cc4a5ca52cb85ea0" -uuid = "1277b4bf-5013-50f5-be3d-901d8477a67a" -version = "1.0.0" - [[Showoff]] deps = ["Dates"] git-tree-sha1 = "e032c9df551fb23c9f98ae1064de074111b7bc39" @@ -870,9 +866,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[SparseDiffTools]] deps = ["Adapt", "ArrayInterface", "Compat", "DataStructures", "FiniteDiff", "ForwardDiff", "InteractiveUtils", "LightGraphs", "LinearAlgebra", "Requires", "SparseArrays", "VertexSafeGraphs"] -git-tree-sha1 = "f65937edd6d1e9ba48da16315c14c12568867dd6" +git-tree-sha1 = "6429f706e7da24a8c1c5e0416c3f0ce9974ab991" uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804" -version = "1.3.3" +version = "1.4.0" [[SpatialIndexing]] deps = ["Printf", "Random", "Test"] @@ -882,9 +878,9 @@ version = "0.1.2" [[SpecialFunctions]] deps = ["OpenSpecFun_jll"] -git-tree-sha1 = "268052ee908b2c086cc0011f528694f02f3e2408" +git-tree-sha1 = "e19b98acb182567bcb7b75bb5d9eedf3a3b5ec6c" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "0.9.0" +version = "0.10.0" [[StaticArrays]] deps = ["LinearAlgebra", "Random", "Statistics"] @@ -898,21 +894,15 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [[StatsBase]] deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"] -git-tree-sha1 = "c53e809e63fe5cf5de13632090bc3520649c9950" +git-tree-sha1 = "19bfcb46245f69ff4013b3df3b977a289852c3a1" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.32.0" +version = "0.32.2" [[StatsFuns]] deps = ["Rmath", "SpecialFunctions"] -git-tree-sha1 = "79982835d2ff3970685cb704500909c94189bde9" +git-tree-sha1 = "f290ddd5fdedeadd10e961eb3f4d3340f09d030a" uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" -version = "0.9.3" - -[[StatsModels]] -deps = ["DataAPI", "DataStructures", "LinearAlgebra", "ShiftedArrays", "SparseArrays", "StatsBase", "Tables"] -git-tree-sha1 = "f4a967704cae9426654cf4649561f263a6dc8419" -uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d" -version = "0.6.7" +version = "0.9.4" [[SuiteSparse]] deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] @@ -924,11 +914,11 @@ git-tree-sha1 = "b1ad568ba658d8cbb3b892ed5380a6f3e781a81e" uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" version = "1.0.0" -[[Tables]] -deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"] -git-tree-sha1 = "aaed7b3b00248ff6a794375ad6adf30f30ca5591" -uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "0.2.11" +[[TerminalLoggers]] +deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"] +git-tree-sha1 = "8c05be75dfe73d90e5dfb6293e0c852013f7282d" +uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" +version = "0.1.1" [[Test]] deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] @@ -942,9 +932,9 @@ version = "0.5.3" [[ToeplitzMatrices]] deps = ["AbstractFFTs", "FFTW", "LinearAlgebra", "StatsBase"] -git-tree-sha1 = "5351f20c159d02fa1372076d0731a38066efd137" +git-tree-sha1 = "8bc327ddbce87cb5976e27ab4adb9ffce5345a05" uuid = "c751599d-da0a-543b-9d20-d0a503d91d24" -version = "0.6.0" +version = "0.6.1" [[Tracker]] deps = ["Adapt", "DiffRules", "ForwardDiff", "LinearAlgebra", "MacroTools", "NNlib", "NaNMath", "Printf", "Random", "Requires", "SpecialFunctions", "Statistics", "Test"] @@ -968,6 +958,11 @@ version = "0.3.0" deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +[[UnPack]] +git-tree-sha1 = "e0cb9715adda456f7657e45377fd3063bf87179a" +uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" +version = "0.1.0" + [[Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" @@ -985,15 +980,15 @@ version = "0.9.1" [[Zlib_jll]] deps = ["Libdl", "Pkg"] -git-tree-sha1 = "5618a43055eb09377edca21d19d0e99bce24a9c3" +git-tree-sha1 = "fd36a6739e256527287c5444960d0266712cd49e" uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.11+7" +version = "1.2.11+8" [[Zygote]] -deps = ["DiffRules", "FFTW", "FillArrays", "ForwardDiff", "IRTools", "InteractiveUtils", "LinearAlgebra", "MacroTools", "NNlib", "NaNMath", "Random", "Requires", "SpecialFunctions", "Statistics", "ZygoteRules"] -git-tree-sha1 = "ca4dfa4de0a0e2c1da6c8c67d3b9af99645b57fc" +deps = ["ArrayLayouts", "DiffRules", "FFTW", "FillArrays", "ForwardDiff", "IRTools", "InteractiveUtils", "LinearAlgebra", "MacroTools", "NNlib", "NaNMath", "Random", "Requires", "SpecialFunctions", "Statistics", "ZygoteRules"] +git-tree-sha1 = "4a3c8decdf1d498cd13fe29827350d727a3b3854" uuid = "e88e6eb3-aa80-5325-afca-941959d7151f" -version = "0.4.6" +version = "0.4.10" [[ZygoteRules]] deps = ["MacroTools"] diff --git a/Climate/NeuralPDE/Project.toml b/Climate/NeuralPDE/Project.toml index 37c6125..7623417 100644 --- a/Climate/NeuralPDE/Project.toml +++ b/Climate/NeuralPDE/Project.toml @@ -1,10 +1,10 @@ [deps] ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f" BlackBoxOptim = "a134a8b2-14d6-55f6-9291-3336d3ab0209" -CuArrays = "3a865a2d-5b23-5a0f-bc46-62713ec82fae" DiffEqFlux = "aae7a2af-3d4f-5e19-a356-7da93b79d9d0" DiffEqSensitivity = "41bf760c-e81c-5289-8e54-58b1f1f8abe2" Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" +IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Optim = "429524aa-4258-5aef-a3af-852621145aeb" diff --git a/Climate/NeuralPDE/data_copy.jl b/Climate/NeuralPDE/data_copy.jl new file mode 100644 index 0000000..73b5779 --- /dev/null +++ b/Climate/NeuralPDE/data_copy.jl @@ -0,0 +1,109 @@ +cd(@__DIR__) +using Pkg; Pkg.activate("."); Pkg.instantiate() + +using Revise +using Optim, Zygote +using OrdinaryDiffEq, Flux, DiffEqFlux, LinearAlgebra, Plots +using DiffEqSensitivity, JLD2 +const EIGEN_EST = Ref(0.0f0) +const USE_GPU = Ref(false) +USE_GPU[] = false # the network is small enough such that CPU works just great +#USE_GPU[] = true + +USE_GPU[] && (using CuArrays) + +_gpu(arg) = USE_GPU[] ? gpu(arg) : cpu(arg) +_cu(arg) = USE_GPU[] ? cu(arg) : identity(arg) + +function getops(grid, T=Float32) + N, dz = length(grid), step(grid) + d = ones(N-2) + dl = ones(N-3) # super/lower diagonal + zv = zeros(N-2) # zero diagonal used to extend D* for boundary conditions + + # D1 first order discretization of ∂_z + D1 = diagm(-1 => -dl, 0 => d) + D1[1, :] .= 0 + D1[end, :] .= 0 + + # D2 discretization of ∂_zz + D2 = diagm(-1 => dl, 0 => -2*d, 1 => dl) + κ = 0.05 + D2[1, 1] = D2[end, end] = -1 + D2 = (κ/(dz^2)).*D2 #add the constant κ as the equation requires and finish the discretization + display(D2), display(D1) + + EIGEN_EST[] = maximum(abs, eigvals(D2)) + D1 = _cu(D1) + D2 = _cu(D2) + return (D1=T.(D1), D2=T.(D2)) +end + +file = jldopen("../DataGeneration/rayleigh_taylor_instability_3d_horizontal_averages.jld2") + +Is = keys(file["timeseries/t"]) + +N = file["grid/Nz"] +Lz = file["grid/Lz"] +Nt = length(Is) + +t = Float32.(zeros(Nt)) +soldata = Float32.(zeros(Nt, N)) + +for (i, I) in enumerate(Is) + t[i] = file["timeseries/t/$I"] + soldata[i, :] .= file["timeseries/b/$I"] +end + +grid = range(0, 1, length = N) +tspan = (t[1], t[end]) +u0 = _cu(soldata[1,2:end-1]) +ops = getops(grid) + +ann = FastChain(FastDense(N-2,N-2,tanh), FastDense(N-2,N-2,tanh), FastDense(N-2,N-2,tanh), + FastDense(N-2,N-2,tanh), FastDense(N-2,N-2,tanh)) |> _gpu +pp = initial_params(ann) +lyrs = Flux.params(pp) + +function dudt_(u,p,t) + Φ = ann + return ops.D1*Φ(u, p) + ops.D2*u +end + +function predict_adjoint(fullp) + Array(concrete_solve(prob, + ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), + u0, fullp, saveat = saveat)) +end + +function loss_adjoint(fullp) + pre = predict_adjoint(fullp) + sum(abs2, training_data - pre) +end + +function cb(opt_state:: Optim.OptimizationState) + display(opt_state.value) + false +end + +cb(trace::Optim.OptimizationTrace) = cb(last(trace)) + +prob = ODEProblem{false}(dudt_,u0,tspan,pp) +nn = 1 +print("here") +saveat = t +soldata = soldata' +soldata = soldata[2:end-1, :] +training_data = _cu(soldata) +epochs = Iterators.repeated((), 20) +concrete_solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), u0, pp) +learning_rate = ADAM(0.01) +res = DiffEqFlux.sciml_train(loss_adjoint, pp, BFGS(initial_stepnorm=0.01), cb=cb) + +#Flux.train!(loss_adjoint, lyrs, epochs, learning_rate, cb=cb) +#= +learning_rate = ADAM(0.001) +epochs = Iterators.repeated((), 300) +Flux.train!(loss_adjoint, lyrs, epochs, learning_rate, cb=cb) +@time loss_adjoint() +=# diff --git a/Climate/NeuralPDE/example.jl b/Climate/NeuralPDE/example.jl new file mode 100644 index 0000000..c4d2305 --- /dev/null +++ b/Climate/NeuralPDE/example.jl @@ -0,0 +1,50 @@ +using DiffEqFlux, Flux, Optim, OrdinaryDiffEq, IterTools + +u0 = Float32(1.1) +tspan = (0.0f0,25.0f0) + +ann = FastChain(FastDense(2,16,tanh), FastDense(16,16,tanh), FastDense(16,1)) +p1 = initial_params(ann) +p2 = Float32[0.5,-0.5] +p3 = [p1;p2] +θ = Float32[u0;p3] + +function dudt_(du,u,p,t) + x, y = u + du[1] = ann(u,p[1:length(p1)])[1] + du[2] = p[end-1]*y + p[end]*x +end +prob = ODEProblem(dudt_,u0,tspan,p3) +concrete_solve(prob,Tsit5(),[0f0,u0],p3,abstol=1e-8,reltol=1e-6) + +function predict_adjoint(θ) + Array(concrete_solve(prob,Tsit5(),[0f0,θ[1]],θ[2:end],saveat=0.0:1:25.0)) +end +function loss_adjoint(θ, X, Y) + print("X", X) + print("Y", Y) + sum(abs2,predict_adjoint(θ)[2,:].-1) +end +#l = loss_adjoint(θ, "x0", "y0") + +cb = function (θ,l) + println(l) + #display(plot(solve(remake(prob,p=Flux.data(p3),u0=Flux.data(u0)),Tsit5(),saveat=0.1),ylim=(0,6))) + return false +end + +# Display the ODE with the current parameter values. +#cb(θ,l) + +function mini_batch(X, Y) + i = rand(1:size(X)[1]) + return (x[i,:], Y[i,:]) +end + + +x = [1 2; 3 4; 5 6; 7 8] +y = [1 ; 0 ; 1; 0] +data = [mini_batch(x,y) for i in 1:20] +#train_loader = Flux.Data.Data +#loss1 = loss_adjoint(θ) +res = DiffEqFlux.sciml_train(loss_adjoint, θ, BFGS(initial_stepnorm=0.01), data, cb = cb) diff --git a/Climate/NeuralPDE/julia-vim b/Climate/NeuralPDE/julia-vim new file mode 160000 index 0000000..1db5eed --- /dev/null +++ b/Climate/NeuralPDE/julia-vim @@ -0,0 +1 @@ +Subproject commit 1db5eed71d7f5fe4b95b0dadfb3f798983485554 diff --git a/Climate/NeuralPDE/npde.jl b/Climate/NeuralPDE/npde.jl index 1193b31..01e2bd8 100644 --- a/Climate/NeuralPDE/npde.jl +++ b/Climate/NeuralPDE/npde.jl @@ -4,16 +4,24 @@ using Revise using Zygote, Optim using OrdinaryDiffEq, Flux, DiffEqFlux, LinearAlgebra, Plots using DiffEqSensitivity +using IterTools +using Random +#using CuArrays +#Random.seed!(0) +print(rand(1:100)) + const EIGEN_EST = Ref(0.0f0) + const USE_GPU = Ref(false) -USE_GPU[] = false # the network is small enough such that CPU works just great +USE_GPU[] = false# the network is small enough such that CPU works just great USE_GPU[] && (using CuArrays) _gpu(arg) = USE_GPU[] ? gpu(arg) : cpu(arg) _cu(arg) = USE_GPU[] ? cu(arg) : identity(arg) + function getops(grid, T=Float32) N, dz = length(grid), step(grid) d = ones(N-2) @@ -45,6 +53,7 @@ function getops(grid, T=Float32) return (D1=T.(D1), D2=T.(D2)) end + function getu0(grid, T=Float32) z = grid[2:N-1] f0 = z -> T(exp(-200*(z-0.75)^2)) @@ -57,7 +66,7 @@ function ode_i(u, p, t) end function ground_truth(grid, tspan) - prob = ODEProblem(ode_i, u0, (tspan[1], tspan[2]+0.1), ops) + prob = ODEProblem(ode_i, u0, (tspan[1], tspan[2]), ops) sol = solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), abstol = 1e-9, reltol = 1e-9) return sol end @@ -65,68 +74,66 @@ end N = 32 grid = range(0, 1, length = N) tspan = (0.0f0, 1.5f0) -u0 = getu0(grid) +u0 = getu0(grid) ops = getops(grid) soldata = ground_truth(grid, tspan) -ann = Chain(Dense(30,8,tanh), Dense(8,30,tanh)) |> _gpu -pp, re = Flux.destructure(ann) + +ann = FastChain(FastDense(30,8,tanh), FastDense(8,30,tanh)) |> _gpu +pp = initial_params(ann) lyrs = Flux.params(pp) + + + function dudt_(u,p,t) - Φ = re(p) - return ops.D1*Φ(u) + ops.D2*u + return ops.D1*ann(u,p) + ops.D2*u end -function predict_adjoint(fullp) +function predict_adjoint(fullp, i) Array(concrete_solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), - u0, fullp, saveat = saveat)) + u0, fullp, saveat = saveat[i[1]:i[1]+i[2]])) end -function loss_adjoint(fullp) - pre = predict_adjoint(fullp) - sum(abs2, training_data - pre) +function loss_adjoint(fullp, x, y) + pre = predict_adjoint(fullp,(x,y)) + sum(abs2, training_data[:,x:x+y] - pre) end - -function cb(opt_state:: Optim.OptimizationState) - cur_pred = collect(predict_adjoint(opt_state.metadata["x"])) - n = size(training_data, 1) - pl = scatter(1:n,training_data[:,10],label="data", legend =:bottomright,title="Spatial Plot at t=$(saveat[10])") - scatter!(pl,1:n,cur_pred[:,10],label="prediction") - pl2 = scatter(saveat,training_data[N÷2,:],label="data", legend =:bottomright, title="Timeseries Plot at Middle X") - scatter!(pl2,saveat,cur_pred[N÷2,:],label="prediction") - display(plot(pl, pl2, size=(600, 300))) - display(opt_state.value) - false +function mini_batch(training_data, k) + return ((rand(1:size(training_data)[2] -k), k) for i in 1:10000) end -cb(trace::Optim.OptimizationTrace) = cb(last(trace)) + +cb = function(fullp, l) + display(l) + return false +end -saveat = range(tspan..., length = 30) #time range +saveat = range(tspan..., length = 40) prob = ODEProblem{false}(dudt_,u0,tspan,pp) training_data = _cu(soldata(saveat)) -concrete_solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), u0, pp) -loss_adjoint(pp) -function loss_adjoint_gradient!(G, fullp) - G .= Zygote.gradient(loss_adjoint, fullp)[1] -end - -result = optimize(loss_adjoint, loss_adjoint_gradient!, pp, BFGS(), Optim.Options(extended_trace=true,callback = cb)) - -prob2 = ODEProblem{false}(dudt_,u0,(0f0,10f0),pp) -@time full_sol = solve(prob2, - ROCK2(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), - saveat = saveat, abstol=1e-4, reltol=1e-2) - -cur_pred = collect((predict_adjoint(result.minimizer))) -n = size(training_data, 1) -pl = scatter(1:n,training_data[:,10],label="data", legend =:bottomright) -scatter!(pl,1:n,cur_pred[:,10],label="prediction",title="Spatial Plot at t=$(saveat[10])") -pl2 = scatter(saveat,training_data[N÷2,:],label="data", legend =:bottomright, title="Time Series Plot: Middle X") -scatter!(pl2,saveat,cur_pred[N÷2,:],label="prediction") -plot(pl, pl2, size=(600, 300)) -savefig("npde_fit.pdf") +concrete_solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), u0, pp) +#loss_adjoint(pp) + + +k = 15 +data = ((rand(1:size(training_data)[2] -k), k) for i in 1:10000) +res = DiffEqFlux.sciml_train(loss_adjoint, pp, BFGS(initial_stepnorm=0.01), data,cb = cb) + +#prob2 = ODEProblem{false}(dudt_,u0,(0f0,10f0),pp) +#@time full_sol = solve(prob2, +# ROCK2(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), +# saveat = saveat, abstol=1e-4, reltol=1e-2) +# +#cur_pred = collect((predict_adjoint(result.minimizer))) +#n = size(training_data, 1) +#pl = scatter(1:n,training_data[:,10],label="data", legend =:bottomright) +#scatter!(pl,1:n,cur_pred[:,10],label="prediction",title="Spatial Plot at t=$(saveat[10])") +#pl2 = scatter(saveat,training_data[N÷2,:],label="data", legend =:bottomright, title="Time Series Plot: Middle X") +#scatter!(pl2,saveat,cur_pred[N÷2,:],label="prediction") +#plot(pl, pl2, size=(600, 300)) +#savefig("npde_fit.pdf") diff --git a/Climate/NeuralPDE/npde_data.jl b/Climate/NeuralPDE/npde_data.jl index 9a6d6f2..16feaf4 100644 --- a/Climate/NeuralPDE/npde_data.jl +++ b/Climate/NeuralPDE/npde_data.jl @@ -4,10 +4,11 @@ using Pkg; Pkg.activate("."); Pkg.instantiate() using Revise using OrdinaryDiffEq, Flux, DiffEqFlux, LinearAlgebra, Plots using DiffEqSensitivity, JLD2 +using Zygote, Optim const EIGEN_EST = Ref(0.0f0) const USE_GPU = Ref(false) #USE_GPU[] = false # the network is small enough such that CPU works just great -USE_GPU[] = true +USE_GPU[] = false USE_GPU[] && (using CuArrays) @@ -39,77 +40,73 @@ function getops(grid, T=Float32) end file = jldopen("../DataGeneration/rayleigh_taylor_instability_3d_horizontal_averages.jld2") - Is = keys(file["timeseries/t"]) -N = file["grid/Nz"] +N = floor(Int, file["grid/Nz"]/2) Lz = file["grid/Lz"] -Nt = length(Is) +Nt = floor(Int, length(Is)) t = Float32.(zeros(Nt)) soldata = Float32.(zeros(Nt, N)) - for (i, I) in enumerate(Is) - t[i] = file["timeseries/t/$I"] - soldata[i, :] .= file["timeseries/b/$I"] + t[i] = file["timeseries/t/$I"] + soldata[i, :] .= file["timeseries/b/$I"][1:2:end] end - grid = range(0, 1, length = N) tspan = (t[1], t[end]) -u0 = _cu(soldata[1,2:end-1]) +u0 = _cu(soldata[1, 2:end-1]) ops = getops(grid) - -ann = Chain(Dense(N-2,N-2,tanh), Dense(N-2,N-2,tanh), Dense(N-2,N-2,tanh), - Dense(N-2,N-2,tanh), Dense(N-2,N-2,tanh)) |> _gpu -pp = param(Flux.data(DiffEqFlux.destructure(ann))) +ann = FastChain(FastDense(N-2,N-2,tanh), FastDense(N-2,N-2,tanh), FastDense(N-2,N-2,tanh), + FastDense(N-2,N-2,tanh), FastDense(N-2,N-2,tanh)) +pp = initial_params(ann) lyrs = Flux.params(pp) -function dudt(u::TrackedArray,p,t) - Φ = DiffEqFlux.restructure(ann, p) - return ops.D1*Φ(u) + ops.D2*u + + + +function dudt_(u,p,t) + Φ = ann + return ops.D1*Φ(u,p) + ops.D2*u end -function dudt(u::AbstractArray,p,t) - Φ = DiffEqFlux.restructure(ann, p) - return ops.D1*Tracker.data(Φ(u)) + ops.D2*u + +function predict_adjoint(fullp, i) + Array(concrete_solve(prob, + ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), + u0, fullp, saveat = saveat[i[1]:i[1]+i[2]])) end -predict_adjoint() = diffeq_adjoint(pp, - prob, - ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), - u0=u0, saveat = saveat, - reltol=1e-5, abstol=1e-6, - # no back solve - sensealg=SensitivityAlg(quad=false, backsolve=false)) - -function loss_adjoint() - pre = predict_adjoint() - sum(abs2, training_data - pre) +function loss_adjoint(fullp, x, y) + pre = predict_adjoint(fullp, (x,y)) + sum(abs2, training_data[:, x:x+y] - pre) end -cb = function () - arr = Array(training_data) - cur_pred = collect(Flux.data(predict_adjoint())) - n = size(arr, 1) - pl = scatter(1:n,arr[:,10],label="data", legend =:bottomright, title = "10th time over space") - scatter!(pl,1:n,cur_pred[:,10],label="prediction") - pl2 = scatter(saveat,arr[end÷2,:],label="data", legend =:bottomright, title = "middle point over time") - scatter!(pl2,saveat,cur_pred[end÷2,:],label="prediction") - #display(plot(pl, pl2, size=(600, 300))) - display(loss_adjoint()) +function cb(p, l) + display(l) + false end -prob = ODEProblem{false}(dudt,u0,tspan,pp) + +prob = ODEProblem{false}(dudt_,u0,tspan,pp) +#concrete_solve(prob, ROCK4(eigen_est = (integ)->integ.eigen_est = EIGEN_EST[]), u0, pp) + nn = 1 saveat = t soldata = soldata' soldata = soldata[2:end-1, :] training_data = _cu(soldata) -epochs = Iterators.repeated((), 20) -learning_rate = ADAM(0.01) -Flux.train!(loss_adjoint, lyrs, epochs, learning_rate, cb=cb) + +k = 15 +data = ((rand(1:size(training_data)[2] -k), k) for i in 1:10000) + +res = DiffEqFlux.sciml_train(loss_adjoint, pp, BFGS(initial_stepnorm=0.01), data, cb=cb) + + +#= #= learning_rate = ADAM(0.001) epochs = Iterators.repeated((), 300) Flux.train!(loss_adjoint, lyrs, epochs, learning_rate, cb=cb) @time loss_adjoint() =# +=# + diff --git a/Climate/NeuralPDE/npde_fit.pdf b/Climate/NeuralPDE/npde_fit.pdf index f69dcc2..3dd5502 100644 Binary files a/Climate/NeuralPDE/npde_fit.pdf and b/Climate/NeuralPDE/npde_fit.pdf differ diff --git a/Climate/NeuralPDE/temp.jl b/Climate/NeuralPDE/temp.jl new file mode 100644 index 0000000..106d5ce --- /dev/null +++ b/Climate/NeuralPDE/temp.jl @@ -0,0 +1,36 @@ +using DiffEqFlux, Flux, Optim, OrdinaryDiffEq + +u0 = Float32(1.1) +tspan = (0.0f0,25.0f0) + +ann = FastChain(FastDense(2,16,tanh), FastDense(16,16,tanh), FastDense(16,1)) +p1 = initial_params(ann) +p2 = Float32[0.5,-0.5] +p3 = [p1;p2] +θ = Float32[u0;p3] + +function dudt_(du,u,p,t) + x, y = u + du[1] = ann(u,p[1:length(p1)])[1] + du[2] = p[end-1]*y + p[end]*x +end +prob = ODEProblem(dudt_,u0,tspan,p3) +concrete_solve(prob,Tsit5(),[0f0,u0],p3,abstol=1e-8,reltol=1e-6) + +function predict_adjoint(θ) + Array(concrete_solve(prob,Tsit5(),[0f0,θ[1]],θ[2:end],saveat=0.0:1:25.0)) +end +loss_adjoint(θ) = sum(abs2,predict_adjoint(θ)[2,:].-1) +l = loss_adjoint(θ) + +cb = function (θ,l) + println(l) + #display(plot(solve(remake(prob,p=Flux.data(p3),u0=Flux.data(u0)),Tsit5(),saveat=0.1),ylim=(0,6))) + return false +end + +# Display the ODE with the current parameter values. +cb(θ,l) + +loss1 = loss_adjoint(θ) +res = DiffEqFlux.sciml_train(loss_adjoint, θ, BFGS(initial_stepnorm=0.01), cb = cb)