From 5d60a232700a04f1b69e06eb30ae046fad7572d9 Mon Sep 17 00:00:00 2001 From: youainti Date: Tue, 9 Nov 2021 13:05:54 -0800 Subject: [PATCH] current work on making operator level maximization as opposed to just the planner level. --- julia_code/BellmanResidualMinimization.jl | 179 ++-- julia_code/BellmanResidual_Operators.jl | 1106 +++++++++++++++++++++ 2 files changed, 1221 insertions(+), 64 deletions(-) create mode 100644 julia_code/BellmanResidual_Operators.jl diff --git a/julia_code/BellmanResidualMinimization.jl b/julia_code/BellmanResidualMinimization.jl index 5b1bb1d..571d881 100644 --- a/julia_code/BellmanResidualMinimization.jl +++ b/julia_code/BellmanResidualMinimization.jl @@ -69,8 +69,8 @@ end # ╔═╡ 5b45b29e-f0f4-41e9-91e7-d444687feb4e #implement survival function function survival( - stocks::Array - ,debris::Array + stocks::Array{Float32} + ,debris::Array{Float32} ,physical_model::BasicModel ) return exp.( @@ -82,9 +82,9 @@ end # ╔═╡ 152f3a3c-a565-41bb-8e59-6ab0d2315ffb #debris evolution function H( - stocks::Array - ,debris::Array - ,launches::Array + stocks::Array{Float32} + ,debris::Array{Float32} + ,launches::Array{Float32} , physical_model::BasicModel ) #get changes in debris from natural dynamics @@ -103,9 +103,9 @@ end # ╔═╡ 25ac9438-2b1d-4f6b-9ff1-1695e1d52b51 #stock update rules function G( - stocks::Array - ,debris::Array - ,launches::Array + stocks::Array{Float32} + ,debris::Array{Float32} + ,launches::Array{Float32} , physical_model::BasicModel ) return LinearAlgebra.diagm(survival(stocks,debris,physical_model) .- physical_model.decay_rate)*stocks + launches @@ -117,42 +117,44 @@ md""" """ # ╔═╡ f7aabe43-9a2c-4fe0-8099-c29cdf66566c -function value_function_generator(number_params=10) +function value_function_generator(number_params=32) return Flux.Chain( Flux.Parallel(vcat #parallel joins together stocks and debris, after a little bit of preprocessing ,Flux.Chain( - Flux.Dense(N_constellations, N_states*2,Flux.relu) - ,Flux.Dense(N_states*2, N_states*2,Flux.σ) + Flux.Dense(N_constellations, number_params*2,Flux.relu) + ,Flux.Dense(number_params*2, number_params*2,Flux.σ) ) ,Flux.Chain( - Flux.Dense(N_debris, N_states,Flux.relu) - ,Flux.Dense(N_states, N_states,Flux.σ) + Flux.Dense(N_debris, number_params,Flux.relu) + ,Flux.Dense(number_params, number_params,Flux.σ) ) ) #Apply some transformations to the preprocessed data. - ,Flux.Dense(N_states*3,number_params,Flux.σ) + ,Flux.Dense(number_params*3,number_params,Flux.σ) + ,Flux.Dense(number_params,number_params,Flux.σ) ,Flux.Dense(number_params,1) ) end # ╔═╡ d816b252-bdca-44ba-ac5c-cb21163a1e9a -function policy_function_generator(number_params=10) +function planner_policy_function_generator(number_params=32) return Flux.Chain( Flux.Parallel(vcat #parallel joins together stocks and debris ,Flux.Chain( - Flux.Dense(N_constellations, N_states*2,Flux.relu) - ,Flux.Dense(N_states*2, N_states*2,Flux.σ) + Flux.Dense(N_constellations, number_params*2,Flux.relu) + ,Flux.Dense(number_params*2, number_params*2,Flux.σ) ) ,Flux.Chain( - Flux.Dense(N_debris, N_states,Flux.relu) - ,Flux.Dense(N_states, N_states) + Flux.Dense(N_debris, number_params,Flux.relu) + ,Flux.Dense(number_params, number_params) ) ) #Apply some transformations - ,Flux.Dense(N_states*3,number_params,Flux.σ) + ,Flux.Dense(number_params*3,number_params,Flux.σ) + ,Flux.Dense(number_params,number_params,Flux.σ) ,Flux.Dense(number_params,N_constellations,Flux.relu) ) @@ -176,6 +178,12 @@ begin Flux.@functor Split (m::Split)(x::AbstractArray) = tuple(map(f -> f(x), m.paths)) + struct Duplicate + n::Int + end + Flux.@functor Duplicate + (m::Duplicate)(x::Tuple) = [x for i=1:m.n] + ### TESTING ### @@ -187,21 +195,55 @@ begin end +# ╔═╡ 6a3b5f7a-a535-450f-8c5f-19bdcc280146 +function operators_policy_function_generator(number_params=32) + function f() + return Flux.Chain( + Flux.Parallel(vcat + #parallel joins together stocks and debris + ,Flux.Chain( + Flux.Dense(N_constellations, number_params,Flux.relu) + ,Flux.Dense(number_params, number_params,Flux.σ) + ) + ,Flux.Chain( + Flux.Dense(N_debris, number_params,Flux.relu) + ,Flux.Dense(number_params, number_params) + ) + ) + #Apply some transformations + ,Flux.Dense(number_params*3,number_params,Flux.σ) + ,Flux.Dense(number_params,number_params,Flux.σ) + ,Flux.Dense(number_params,1,Flux.relu) + ) + end + + a = [f() for i=1:N_constellations] + + Flux.Chain( + Duplicate(N_constellations) + + ) + +end + +# ╔═╡ 0ba48a75-36db-4003-95c0-2329d4fb29c5 +Duplicate(2)(([1.0f0 2],[3f0])) + # ╔═╡ 340da189-f443-4376-a82d-7699a21ab7a2 abstract type EconomicParameters end # ╔═╡ 206ac4cc-5102-4381-ad8a-777b02dc4d5a begin #basic linear model struct EconModel1 <: EconomicParameters - β::Real - payoff_array::Array{Real} - policy_costs::Array{Real} + β::Float32 + payoff_array::Array{Float32} + policy_costs::Array{Float32} end function payoff1( - s::Vector - ,d::Vector - ,a::Vector + s::Vector{Float32} + ,d::Vector{Float32} + ,a::Vector{Float32} ,em::EconModel1 ) return em.payoff_array*s - em.policy_costs*a @@ -212,16 +254,16 @@ end # ╔═╡ eebb8706-a431-4fd1-b7a5-40f07a63d5cb begin #basic CES model struct CESParams <: EconomicParameters - β::Real - r::Real #elasticity of subsititution - payoff_array::Array{Real} - policy_costs::Array{Real} - debris_costs::Array{Real} + β::Float32 + r::Float32 #elasticity of subsititution + payoff_array::Array{Float32} + policy_costs::Array{Float32} + debris_costs::Array{Float32} end function CES_with_debris( - s::Vector - ,d::Vector - ,a::Vector + s::Vector{Float32} + ,d::Vector{Float32} + ,a::Vector{Float32} ,em::CESParams ) return (em.payoff_array*(s.^em.r) - em.debris_costs*(d.^em.r)).^(1/em.r) - em.policy_costs*a @@ -250,21 +292,25 @@ md""" """ # ╔═╡ 65e0b1fa-d5e1-4ff6-8736-c9d6b5f40150 -em1 = EconModel1(0.95, [1 0 0 0], [5 0 0 0]) -#= -This is the most basic profit model - - -You earn 1 per operating satellite and it costs 5 per launch. -Only interaction is through debris. -=# +begin + em1_a = EconModel1(0.95, [1.0 0 0 0], [5 0 0 0]) + em1_b = EconModel1(0.95, [0 1.0 0 0], [0 5 0 0]) + em1_c = EconModel1(0.95, [0 0 1.0 0], [0 0 5 0]) + em1_d = EconModel1(0.95, [0 0 0 1.0], [0 0 0 5]) + #= + This is the most basic profit model + + You earn 1 per operating satellite and it costs 5 per launch. + Only interaction is through debris. + =# +end # ╔═╡ 19ccfc3a-6dbb-4c64-bf03-e2e219ef0efe begin - em2_a = EconModel1(0.95, [1 -0.02 -0.02 0], [5 0 0 0]) - em2_b = EconModel1(0.95, [-0.02 1 -0.02 0], [0 5 0 0]) - em2_c = EconModel1(0.95, [0 -0.02 1 -0.02], [0 0 5 0]) - em2_d = EconModel1(0.95, [0 -0.02 -0.02 1], [0 0 0 5]) + em2_a = EconModel1(0.95, [1 -0.02 -0.02 0], [5.0 0 0 0]) + em2_b = EconModel1(0.95, [-0.02 1 -0.02 0], [0.0 5 0 0]) + em2_c = EconModel1(0.95, [0 -0.02 1 -0.02], [0.0 0 5 0]) + em2_d = EconModel1(0.95, [0 -0.02 -0.02 1], [0.0 0 0 5]) #= This is a simple addition to the basic model, where you lose some benefit based the size of your competitor's satellites. @@ -287,13 +333,13 @@ md""" """ # ╔═╡ fb6aacff-c42d-4ec1-88cb-5ce1b2e8874f -policy = policy_function_generator(); +policy = planner_policy_function_generator(); # ╔═╡ 41271ab4-1ec7-431f-9efb-0f7c3da2d8b4 #Constellation level loss function function Ξ( - s::Vector - ,d::Vector + s::Vector{Float32} + ,d::Vector{Float32} , physical_model::PhysicalParameters ,co::ConstellationOperator ) @@ -322,14 +368,17 @@ end # ╔═╡ 43b99708-0052-4b78-886c-92ac2b532f29 begin #testing - s1 = ones(N_constellations) - d1 = ones(N_debris) + s1 = ones(Float32,N_constellations) + d1 = ones(Float32,N_debris) Ξ(s1,d1,bm,operators[1]) end # ╔═╡ dff642d9-ec5a-4fed-a059-6c07760a3a58 #planner's loss function -function planners_loss(s,d) +function planners_loss( + s::Vector{Float32} + ,d::Vector{Float32} +) l = 0.0 for co in operators l += Ξ(s,d,bm,co) @@ -340,13 +389,13 @@ end # ╔═╡ 5abebc1a-370c-4f5f-8826-dc0b143d5166 md""" -## Constructing data +## Constructing data and training """ # ╔═╡ a20959be-65e4-4b69-9521-503bc59f0854 begin N=200 #increase later - data = [(rand(1:500, N_constellations),rand(1:500, N_debris)) for n=1:N] + data = [(rand(1:500f0, N_constellations),rand(1:500f0, N_debris)) for n=1:N] end # ╔═╡ 6bf8d29a-7990-4e91-86e6-d9894ed3db27 @@ -355,7 +404,7 @@ ADAM = Flux.Optimise.ADAM(0.1) # ╔═╡ e7ee1a0f-ab9b-439e-a7be-4a6d3b8f160d begin - accum1 = 0.0 + local accum1 = 0.0 for d in data accum1 += planners_loss(d...) end @@ -364,8 +413,8 @@ end # ╔═╡ 74f5fde3-0593-46fc-a688-f1db7ab28c64 # Social planners problem -for epoch in 1:200 - data1 = [(rand(1:500, N_constellations),rand(1:500, N_debris)) for n=1:N] +for epoch in 1:20 + data1 = [(rand(1:500f0, N_constellations),rand(1:500f0, N_debris)) for n=1:N] #train the social planner's policy funciton Flux.Optimise.train!(planners_loss, params(policy), data1, ADAM) @@ -378,7 +427,7 @@ end # ╔═╡ 02f3fe78-e7a7-453f-9ddf-acddf08d8676 begin - accum = 0.0 + local accum = 0.0 for d in data accum += planners_loss(d...) @@ -391,7 +440,7 @@ policy(data[3]) # ╔═╡ 14e61097-f28f-4029-b6b4-5fb119620fc3 begin - n=1 + n=15 [operators[1].value(data[n]) ,operators[2].value(data[n]) @@ -982,12 +1031,14 @@ uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" # ╠═9fa41b7c-1923-4c1e-bfc6-20ce4a1a2ede # ╟─90446134-4e45-471c-857d-4e165e51937a # ╠═5b45b29e-f0f4-41e9-91e7-d444687feb4e -# ╟─152f3a3c-a565-41bb-8e59-6ab0d2315ffb -# ╟─25ac9438-2b1d-4f6b-9ff1-1695e1d52b51 +# ╠═152f3a3c-a565-41bb-8e59-6ab0d2315ffb +# ╠═25ac9438-2b1d-4f6b-9ff1-1695e1d52b51 # ╠═29ff1777-d276-4e8f-8582-4ca191f2e2ff -# ╟─f7aabe43-9a2c-4fe0-8099-c29cdf66566c -# ╟─d816b252-bdca-44ba-ac5c-cb21163a1e9a +# ╠═f7aabe43-9a2c-4fe0-8099-c29cdf66566c +# ╠═d816b252-bdca-44ba-ac5c-cb21163a1e9a +# ╠═6a3b5f7a-a535-450f-8c5f-19bdcc280146 # ╠═95bfc9d8-8427-41d6-9f0f-f155296eef91 +# ╠═0ba48a75-36db-4003-95c0-2329d4fb29c5 # ╠═340da189-f443-4376-a82d-7699a21ab7a2 # ╠═206ac4cc-5102-4381-ad8a-777b02dc4d5a # ╠═eebb8706-a431-4fd1-b7a5-40f07a63d5cb @@ -1003,7 +1054,7 @@ uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" # ╠═cd55e232-493d-4849-8bd7-b0ba85e21bab # ╠═fb6aacff-c42d-4ec1-88cb-5ce1b2e8874f # ╠═f30904a7-5caa-449a-a5bd-f2aa78777a9a -# ╟─5abebc1a-370c-4f5f-8826-dc0b143d5166 +# ╠═5abebc1a-370c-4f5f-8826-dc0b143d5166 # ╠═a20959be-65e4-4b69-9521-503bc59f0854 # ╠═6bf8d29a-7990-4e91-86e6-d9894ed3db27 # ╠═e7ee1a0f-ab9b-439e-a7be-4a6d3b8f160d diff --git a/julia_code/BellmanResidual_Operators.jl b/julia_code/BellmanResidual_Operators.jl new file mode 100644 index 0000000..81e22a0 --- /dev/null +++ b/julia_code/BellmanResidual_Operators.jl @@ -0,0 +1,1106 @@ +### A Pluto.jl notebook ### +# v0.17.0 + +using Markdown +using InteractiveUtils + +# ╔═╡ 0829eb90-1d74-46b6-80ec-482a2b71c6fe +using PlutoUI, Flux,LinearAlgebra + +# ╔═╡ 66f0e667-d722-4e1e-807b-84a39cbc41b1 +md""" +# Bellman Residual Minimization + + +""" + +# ╔═╡ 9fa41b7c-1923-4c1e-bfc6-20ce4a1a2ede +md""" +Number of Constellations: $(const N_constellations = 4) + +Number of Debris Trackers: $(const N_debris = 1) + +Number of Overall States: $(const N_states = N_constellations + N_debris) +""" + +# ╔═╡ 90446134-4e45-471c-857d-4e165e51937a +begin + abstract type PhysicalParameters end + + #setup physical model + struct BasicModel <: PhysicalParameters + #rate at which debris hits satellites + debris_collision_rate::Real + #rate at which satellites of different constellations collide + satellite_collision_rates::Matrix{Float64} + #rate at which debris exits orbits + decay_rate::Real + #rate at which satellites + autocatalysis_rate::Real + #ratio at which a collision between satellites produced debris + satellite_collision_debris_ratio::Real + #Ratio at which launches produce debris + launch_debris_ratio::Real + end + + #Getting loss parameters together. + loss_param = 2e-3; + loss_weights = loss_param*(ones(N_constellations,N_constellations) - LinearAlgebra.I); + + #orbital decay rate + decay_param = 0.01; + + #debris generation parameters + autocatalysis_param = 0.001; + satellite_loss_debris_rate = 5.0; + launch_debris_rate = 0.05; + + #Todo, wrap physical model as a struct with the parameters + bm = BasicModel( + loss_param + ,loss_weights + ,decay_param + ,autocatalysis_param + ,satellite_loss_debris_rate + ,launch_debris_rate + ) +end + +# ╔═╡ 5b45b29e-f0f4-41e9-91e7-d444687feb4e +#implement survival function +function survival( + stocks::Array{Float32} + ,debris::Array{Float32} + ,physical_model::BasicModel + ) + return exp.( + -(physical_model.satellite_collision_rates .- physical_model.decay_rate) * stocks + .- (physical_model.debris_collision_rate*debris) + ) +end + +# ╔═╡ 152f3a3c-a565-41bb-8e59-6ab0d2315ffb +#debris evolution +function H( + stocks::Array{Float32} + ,debris::Array{Float32} + ,launches::Array{Float32} + , physical_model::BasicModel + ) + #get changes in debris from natural dynamics + natural_debris_dynamics = (1-physical_model.decay_rate+physical_model.autocatalysis_rate) * debris + + #get changes in debris from satellite loss + satellite_loss_debris = physical_model.satellite_collision_debris_ratio * (1 .- survival(stocks,debris,physical_model))'*stocks + + #get changes in debris from launches + launch_debris = physical_model.launch_debris_ratio*sum(launches) + + #return total debris level + return natural_debris_dynamics .+ satellite_loss_debris .+ launch_debris +end + +# ╔═╡ 25ac9438-2b1d-4f6b-9ff1-1695e1d52b51 +#stock update rules +function G( + stocks::Array{Float32} + ,debris::Array{Float32} + ,launches::Array{Float32} + , physical_model::BasicModel +) + return LinearAlgebra.diagm(survival(stocks,debris,physical_model) .- physical_model.decay_rate)*stocks + launches +end + +# ╔═╡ 29ff1777-d276-4e8f-8582-4ca191f2e2ff +md""" +## Setup Neural Networks +""" + +# ╔═╡ f7aabe43-9a2c-4fe0-8099-c29cdf66566c +function value_function_generator(number_params=32) + return Flux.Chain( + Flux.Parallel(vcat + #parallel joins together stocks and debris, after a little bit of preprocessing + ,Flux.Chain( + Flux.Dense(N_constellations, number_params*2,Flux.relu) + ,Flux.Dense(number_params*2, number_params*2,Flux.σ) + ) + ,Flux.Chain( + Flux.Dense(N_debris, number_params,Flux.relu) + ,Flux.Dense(number_params, number_params,Flux.σ) + ) + ) + #Apply some transformations to the preprocessed data. + ,Flux.Dense(number_params*3,number_params,Flux.σ) + ,Flux.Dense(number_params,number_params,Flux.σ) + ,Flux.Dense(number_params,1) + ) + +end + +# ╔═╡ d816b252-bdca-44ba-ac5c-cb21163a1e9a +function planner_policy_function_generator(number_params=32) + return Flux.Chain( + Flux.Parallel(vcat + #parallel joins together stocks and debris + ,Flux.Chain( + Flux.Dense(N_constellations, number_params*2,Flux.relu) + ,Flux.Dense(number_params*2, number_params*2,Flux.σ) + ) + ,Flux.Chain( + Flux.Dense(N_debris, number_params,Flux.relu) + ,Flux.Dense(number_params, number_params) + ) + ) + #Apply some transformations + ,Flux.Dense(number_params*3,number_params,Flux.σ) + ,Flux.Dense(number_params,number_params,Flux.σ) + ,Flux.Dense(number_params,N_constellations,Flux.relu) + ) + +end + +# ╔═╡ f2523e2c-2c56-4883-a074-5de7a0aed25b +begin + a = Flux.Chain( + Flux.Parallel( + vcat + ,Dense(1,2) + ,Dense(1,2) + ) + ,Dense(2,1) + ) + + c = Flux.Chain( + Flux.Parallel( + vcat + ,Dense(1,2) + ,Dense(1,2) + ) + ,Dense(2,1) + ) + + + fancyNN = Flux.Parallel(vcat, + a,c) +end + +# ╔═╡ 7075d5fb-8273-498e-87bb-40e084c97601 +fancyNN(([1],[2]),([3],[4])) + +# ╔═╡ 95bfc9d8-8427-41d6-9f0f-f155296eef91 +#not needed yet +begin + #= CUSTOM LAYERS + + =# + #Custom passthrough layer + passthrough(x::Array{Float32}) = x + + + # custom split layer + struct Split{T} + paths::T + end + Split(paths...) = Split(paths) + Flux.@functor Split + (self::Split)(x::AbstractArray{Float32}) = tuple(map(f -> f(x), self.paths)) + + + ### TESTING ### + + + #multiple branches + Flux.Parallel(vcat, + passthrough, passthrough, passthrough + )(([1f0],[2f0,3],[4f0])) + + +end + +# ╔═╡ 6a3b5f7a-a535-450f-8c5f-19bdcc280146 +function operators_policy_function_generator(number_params=32) + function f() + return Flux.Chain( + Flux.Parallel(vcat + #parallel joins together stocks and debris + ,Flux.Chain( + Flux.Dense(N_constellations, number_params,Flux.relu) + #,Flux.Dense(number_params, number_params,Flux.σ) + ) + ,Flux.Chain( + Flux.Dense(N_debris, number_params,Flux.relu) + #,Flux.Dense(number_params, number_params) + ) + ) + #Apply some transformations + ,Flux.Dense(number_params*3,number_params,Flux.σ) + ,Flux.Dense(number_params,1,Flux.relu) + ) + end + + a = [f() for i=1:N_constellations] + b = [passthrough for i=1:N_constellations] + + return Flux.Chain( + Split(a) + #,Flux.Parallel(vcat, b) + ) + +end + +# ╔═╡ 3d9a2425-d549-48a4-badb-34c0c07aeecc +b = operators_policy_function_generator() + +# ╔═╡ b73396ce-f5ef-46bc-a92c-94a48d9b4551 +Split(() -> 1, () -> 2) + +# ╔═╡ bbca5143-f314-40ea-a20e-8a043272e362 +md""" +# Defining economic parameters and payoff functions +""" + +# ╔═╡ 340da189-f443-4376-a82d-7699a21ab7a2 +abstract type EconomicParameters end + +# ╔═╡ 206ac4cc-5102-4381-ad8a-777b02dc4d5a +begin #basic linear model + struct EconModel1 <: EconomicParameters + β::Float32 + payoff_array::Array{Float32} + policy_costs::Array{Float32} + end + + function payoff1( + s::Vector{Float32} + ,d::Vector{Float32} + ,a::Vector{Float32} + ,em::EconModel1 +) + return em.payoff_array*s - em.policy_costs*a +end + +end + +# ╔═╡ eebb8706-a431-4fd1-b7a5-40f07a63d5cb +begin #basic CES model + struct CESParams <: EconomicParameters + β::Float32 + r::Float32 #elasticity of subsititution + payoff_array::Array{Float32} + policy_costs::Array{Float32} + debris_costs::Array{Float32} + end + function CES_with_debris( + s::Vector{Float32} + ,d::Vector{Float32} + ,a::Vector{Float32} + ,em::CESParams + ) + return (em.payoff_array*(s.^em.r) - em.debris_costs*(d.^em.r)).^(1/em.r) - em.policy_costs*a + end +end + +# ╔═╡ f8d582cb-10cf-4c72-8127-787f662e0567 +#= +This struct organizes information about a given constellation operator +=# +struct ConstellationOperator + payoff_fn::Function + econ_params::EconomicParameters + value::Flux.Chain +end +#TODO: create a function that takes this struct and checks backprop + +# ╔═╡ 5946daa3-4608-43f3-8933-dd3eb3f4541c +md""" +# Loss function specification +""" + +# ╔═╡ b433a7ec-8264-48d6-8b95-53d2ec4bad05 +md""" +# examples of parameter models +""" + +# ╔═╡ 65e0b1fa-d5e1-4ff6-8736-c9d6b5f40150 +begin + em1_a = EconModel1(0.95, [1.0 0 0 0], [5 0 0 0]) + em1_b = EconModel1(0.95, [0 1.0 0 0], [0 5 0 0]) + em1_c = EconModel1(0.95, [0 0 1.0 0], [0 0 5 0]) + em1_d = EconModel1(0.95, [0 0 0 1.0], [0 0 0 5]) + #= + This is the most basic profit model + + You earn 1 per operating satellite and it costs 5 per launch. + Only interaction is through debris. + =# +end + +# ╔═╡ 19ccfc3a-6dbb-4c64-bf03-e2e219ef0efe +begin + em2_a = EconModel1(0.95, [1 -0.02 -0.02 0], [5.0 0 0 0]) + em2_b = EconModel1(0.95, [-0.02 1 -0.02 0], [0.0 5 0 0]) + em2_c = EconModel1(0.95, [0 -0.02 1 -0.02], [0.0 0 5 0]) + em2_d = EconModel1(0.95, [0 -0.02 -0.02 1], [0.0 0 0 5]) + #= + This is a simple addition to the basic model, where you lose some benefit based + the size of your competitor's satellites. + Constellations interact throuch debris and imposing costs on one another. + =# +end + +# ╔═╡ dc614254-c211-4552-b985-03020bfc5ab3 +em3 = CESParams(0.95,0.6,[1 0 0 0], [5 0 0 0], Vector([0.002])) +#= +This is a variation on a CES model. + +The model is CES the relationship between payoffs and debris. +In this particular specification, the only interaction is in debris +=# + +# ╔═╡ cd55e232-493d-4849-8bd7-b0ba85e21bab +md""" +# Start setting things up +""" + +# ╔═╡ fb6aacff-c42d-4ec1-88cb-5ce1b2e8874f +policy = planner_policy_function_generator(); + +# ╔═╡ 41271ab4-1ec7-431f-9efb-0f7c3da2d8b4 +#Constellation level loss function +function Ξ( + s::Vector{Float32} + ,d::Vector{Float32} + , physical_model::PhysicalParameters + ,co::ConstellationOperator +) + a = policy((s,d)) + s′ = G(s,d,a,physical_model) + d′ = H(s,d,a,physical_model) + + bellman_residuals = co.value((s,d)) - co.payoff_fn(s,d,a,co.econ_params) - co.econ_params.β*co.value((s′,d′)) + maximization_condition = - co.payoff_fn(s,d,a,co.econ_params) - co.econ_params.β*co.value((s′,d′)) + + return sum([bellman_residuals.^2 maximization_condition]) +end + +# ╔═╡ f30904a7-5caa-449a-a5bd-f2aa78777a9a +begin + #setup the operators + operators = [ ConstellationOperator(payoff1,em2_a,value_function_generator()) + ,ConstellationOperator(payoff1,em2_b,value_function_generator()) + ,ConstellationOperator(payoff1,em2_c,value_function_generator()) + ,ConstellationOperator(payoff1,em2_d,value_function_generator()) + ] + + #check whether or not we've matched the setup correctly. + @assert length(operators) == N_constellations "Mismatch in predetermined number of constellations and the number of operators initialized" +end + +# ╔═╡ 43b99708-0052-4b78-886c-92ac2b532f29 +begin #testing + s1 = ones(Float32,N_constellations) + d1 = ones(Float32,N_debris) + Ξ(s1,d1,bm,operators[1]) +end + +# ╔═╡ caaabe93-cc09-45c3-9c3f-be4aeb281099 +b((s1,d1)) + +# ╔═╡ dff642d9-ec5a-4fed-a059-6c07760a3a58 +#planner's loss function +function planners_loss( + s::Vector{Float32} + ,d::Vector{Float32} +) + l = 0.0 + for co in operators + l += Ξ(s,d,bm,co) + end + return l +end + + +# ╔═╡ 5abebc1a-370c-4f5f-8826-dc0b143d5166 +md""" +## Constructing data and training +""" + +# ╔═╡ a20959be-65e4-4b69-9521-503bc59f0854 +begin + N=200 #increase later + data = [(rand(1:500f0, N_constellations),rand(1:500f0, N_debris)) for n=1:N] +end + +# ╔═╡ 6bf8d29a-7990-4e91-86e6-d9894ed3db27 +#optimizer +ADAM = Flux.Optimise.ADAM(0.1) + +# ╔═╡ e7ee1a0f-ab9b-439e-a7be-4a6d3b8f160d +begin + local accum1 = 0.0 + for d in data + accum1 += planners_loss(d...) + end + accum1/N +end + +# ╔═╡ 74f5fde3-0593-46fc-a688-f1db7ab28c64 +# Social planners problem +for epoch in 1:20 + data1 = [(rand(1:500f0, N_constellations),rand(1:500f0, N_debris)) for n=1:N] + + #train the social planner's policy funciton + Flux.Optimise.train!(planners_loss, params(policy), data1, ADAM) + + #Sweep through training the value functions + for co in operators + Flux.Optimise.train!(planners_loss, params(co.value), data1, ADAM) + end +end + +# ╔═╡ 02f3fe78-e7a7-453f-9ddf-acddf08d8676 +begin + local accum = 0.0 + for d in data + accum += planners_loss(d...) + + end + accum/N +end + +# ╔═╡ 14e61097-f28f-4029-b6b4-5fb119620fc3 +begin + n=15 + + [operators[1].value(data[n]) + ,operators[2].value(data[n]) + ,operators[3].value(data[n]) + ,operators[4].value(data[n])] +end + +# ╔═╡ c50b1d39-fe87-441b-935c-c5fe971d09ef +policy(data[n]) + +# ╔═╡ bf0c6061-daf4-45ac-82bc-b26e093ac6a7 +with_terminal() do + for d in data + println(d) + println("\t",policy(d)) + end +end + +# ╔═╡ 00000000-0000-0000-0000-000000000001 +PLUTO_PROJECT_TOML_CONTENTS = """ +[deps] +Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" + +[compat] +Flux = "~0.12.8" +PlutoUI = "~0.7.18" +""" + +# ╔═╡ 00000000-0000-0000-0000-000000000002 +PLUTO_MANIFEST_TOML_CONTENTS = """ +# This file is machine-generated - editing it directly is not advised + +[[AbstractFFTs]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0" +uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" +version = "1.0.1" + +[[AbstractPlutoDingetjes]] +deps = ["Pkg"] +git-tree-sha1 = "0ec322186e078db08ea3e7da5b8b2885c099b393" +uuid = "6e696c72-6542-2067-7265-42206c756150" +version = "1.1.0" + +[[AbstractTrees]] +git-tree-sha1 = "03e0550477d86222521d254b741d470ba17ea0b5" +uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" +version = "0.3.4" + +[[Adapt]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "84918055d15b3114ede17ac6a7182f68870c16f7" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "3.3.1" + +[[ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" + +[[ArrayInterface]] +deps = ["Compat", "IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] +git-tree-sha1 = "e527b258413e0c6d4f66ade574744c94edef81f8" +uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +version = "3.1.40" + +[[Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + +[[BFloat16s]] +deps = ["LinearAlgebra", "Printf", "Random", "Test"] +git-tree-sha1 = "a598ecb0d717092b5539dbbe890c98bac842b072" +uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" +version = "0.2.0" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[CEnum]] +git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9" +uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" +version = "0.4.1" + +[[CUDA]] +deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CompilerSupportLibraries_jll", "ExprTools", "GPUArrays", "GPUCompiler", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions", "TimerOutputs"] +git-tree-sha1 = "2c8329f16addffd09e6ca84c556e2185a4933c64" +uuid = "052768ef-5323-5732-b1bb-66c8b64840ba" +version = "3.5.0" + +[[ChainRules]] +deps = ["ChainRulesCore", "Compat", "LinearAlgebra", "Random", "RealDot", "Statistics"] +git-tree-sha1 = "035ef8a5382a614b2d8e3091b6fdbb1c2b050e11" +uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2" +version = "1.12.1" + +[[ChainRulesCore]] +deps = ["Compat", "LinearAlgebra", "SparseArrays"] +git-tree-sha1 = "f885e7e7c124f8c92650d61b9477b9ac2ee607dd" +uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +version = "1.11.1" + +[[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" +uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" +version = "0.11.0" + +[[Colors]] +deps = ["ColorTypes", "FixedPointNumbers", "Reexport"] +git-tree-sha1 = "417b0ed7b8b838aa6ca0a87aadf1bb9eb111ce40" +uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" +version = "0.12.8" + +[[CommonSubexpressions]] +deps = ["MacroTools", "Test"] +git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7" +uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" +version = "0.3.0" + +[[Compat]] +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 = "dce3e3fea680869eaa0b774b2e8343e9ff442313" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "3.40.0" + +[[CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" + +[[DataAPI]] +git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8" +uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" +version = "1.9.0" + +[[DataStructures]] +deps = ["Compat", "InteractiveUtils", "OrderedCollections"] +git-tree-sha1 = "7d9d316f04214f7efdbb6398d545446e246eff02" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.18.10" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[DelimitedFiles]] +deps = ["Mmap"] +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" + +[[DiffResults]] +deps = ["StaticArrays"] +git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805" +uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" +version = "1.0.3" + +[[DiffRules]] +deps = ["LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] +git-tree-sha1 = "3287dacf67c3652d3fed09f4c12c187ae4dbb89a" +uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" +version = "1.4.0" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[DocStringExtensions]] +deps = ["LibGit2"] +git-tree-sha1 = "b19534d1895d702889b219c382a6e18010797f0b" +uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +version = "0.8.6" + +[[Downloads]] +deps = ["ArgTools", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" + +[[ExprTools]] +git-tree-sha1 = "b7e3d17636b348f005f11040025ae8c6f645fe92" +uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" +version = "0.1.6" + +[[FillArrays]] +deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"] +git-tree-sha1 = "8756f9935b7ccc9064c6eef0bff0ad643df733a3" +uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" +version = "0.12.7" + +[[FixedPointNumbers]] +deps = ["Statistics"] +git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" +uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" +version = "0.8.4" + +[[Flux]] +deps = ["AbstractTrees", "Adapt", "ArrayInterface", "CUDA", "CodecZlib", "Colors", "DelimitedFiles", "Functors", "Juno", "LinearAlgebra", "MacroTools", "NNlib", "NNlibCUDA", "Pkg", "Printf", "Random", "Reexport", "SHA", "SparseArrays", "Statistics", "StatsBase", "Test", "ZipFile", "Zygote"] +git-tree-sha1 = "e8b37bb43c01eed0418821d1f9d20eca5ba6ab21" +uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" +version = "0.12.8" + +[[ForwardDiff]] +deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"] +git-tree-sha1 = "ef3fec65f9db26fa2cf8f4133c697c5b7ce63c1d" +uuid = "f6369f11-7733-5829-9624-2563aa707210" +version = "0.10.22" + +[[Functors]] +git-tree-sha1 = "e4768c3b7f597d5a352afa09874d16e3c3f6ead2" +uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196" +version = "0.2.7" + +[[GPUArrays]] +deps = ["Adapt", "LinearAlgebra", "Printf", "Random", "Serialization", "Statistics"] +git-tree-sha1 = "7772508f17f1d482fe0df72cabc5b55bec06bbe0" +uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" +version = "8.1.2" + +[[GPUCompiler]] +deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "TimerOutputs", "UUIDs"] +git-tree-sha1 = "77d915a0af27d474f0aaf12fcd46c400a552e84c" +uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" +version = "0.13.7" + +[[Hyperscript]] +deps = ["Test"] +git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" +uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" +version = "0.0.4" + +[[HypertextLiteral]] +git-tree-sha1 = "5efcf53d798efede8fee5b2c8b09284be359bf24" +uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" +version = "0.9.2" + +[[IOCapture]] +deps = ["Logging", "Random"] +git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a" +uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" +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 = "debdd00ffef04665ccbb3e150747a77560e8fad1" +uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" +version = "0.1.1" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[InverseFunctions]] +deps = ["Test"] +git-tree-sha1 = "f0c6489b12d28fb4c2103073ec7452f3423bd308" +uuid = "3587e190-3f89-42d0-90ee-14403ec27112" +version = "0.1.1" + +[[IrrationalConstants]] +git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151" +uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" +version = "0.1.1" + +[[JLLWrappers]] +deps = ["Preferences"] +git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.3.0" + +[[JSON]] +deps = ["Dates", "Mmap", "Parsers", "Unicode"] +git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.21.2" + +[[Juno]] +deps = ["Base64", "Logging", "Media", "Profile"] +git-tree-sha1 = "07cb43290a840908a771552911a6274bc6c072c7" +uuid = "e5e0dc1b-0480-54bc-9374-aad01c23163d" +version = "0.8.4" + +[[LLVM]] +deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"] +git-tree-sha1 = "46092047ca4edc10720ecab437c42283cd7c44f3" +uuid = "929cbde3-209d-540e-8aea-75f648917ca0" +version = "4.6.0" + +[[LLVMExtra_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "6a2af408fe809c4f1a54d2b3f188fdd3698549d6" +uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" +version = "0.0.11+0" + +[[LazyArtifacts]] +deps = ["Artifacts", "Pkg"] +uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" + +[[LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" + +[[LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" + +[[LibGit2]] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[LogExpFunctions]] +deps = ["ChainRulesCore", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] +git-tree-sha1 = "6193c3815f13ba1b78a51ce391db8be016ae9214" +uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" +version = "0.3.4" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[MacroTools]] +deps = ["Markdown", "Random"] +git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf" +uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" +version = "0.5.9" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" + +[[Media]] +deps = ["MacroTools", "Test"] +git-tree-sha1 = "75a54abd10709c01f1b86b84ec225d26e840ed58" +uuid = "e89f7d12-3494-54d1-8411-f7d8b9ae1f27" +version = "0.5.0" + +[[Missings]] +deps = ["DataAPI"] +git-tree-sha1 = "bf210ce90b6c9eed32d25dbcae1ebc565df2687f" +uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" +version = "1.0.2" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" + +[[NNlib]] +deps = ["Adapt", "ChainRulesCore", "Compat", "LinearAlgebra", "Pkg", "Requires", "Statistics"] +git-tree-sha1 = "5203a4532ad28c44f82c76634ad621d7c90abcbd" +uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" +version = "0.7.29" + +[[NNlibCUDA]] +deps = ["CUDA", "LinearAlgebra", "NNlib", "Random", "Statistics"] +git-tree-sha1 = "04490d5e7570c038b1cb0f5c3627597181cc15a9" +uuid = "a00861dc-f156-4864-bf3c-e6376f28a68d" +version = "0.1.9" + +[[NaNMath]] +git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb" +uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" +version = "0.3.5" + +[[NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" + +[[OpenLibm_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "05823500-19ac-5b8b-9628-191a04bc5112" + +[[OpenSpecFun_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" +uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" +version = "0.5.5+0" + +[[OrderedCollections]] +git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.4.1" + +[[Parsers]] +deps = ["Dates"] +git-tree-sha1 = "ae4bbcadb2906ccc085cf52ac286dc1377dceccc" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "2.1.2" + +[[Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[PlutoUI]] +deps = ["AbstractPlutoDingetjes", "Base64", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"] +git-tree-sha1 = "57312c7ecad39566319ccf5aa717a20788eb8c1f" +uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" +version = "0.7.18" + +[[Preferences]] +deps = ["TOML"] +git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.2.2" + +[[Printf]] +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" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[Random123]] +deps = ["Libdl", "Random", "RandomNumbers"] +git-tree-sha1 = "0e8b146557ad1c6deb1367655e052276690e71a3" +uuid = "74087812-796a-5b5d-8853-05524746bad3" +version = "1.4.2" + +[[RandomNumbers]] +deps = ["Random", "Requires"] +git-tree-sha1 = "043da614cc7e95c703498a491e2c21f58a2b8111" +uuid = "e6cf234a-135c-5ec9-84dd-332b85af5143" +version = "1.5.3" + +[[RealDot]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "9f0a1b71baaf7650f4fa8a1d168c7fb6ee41f0c9" +uuid = "c1ae055f-0cd5-4b69-90a6-9a35b1a98df9" +version = "0.1.0" + +[[Reexport]] +git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" +uuid = "189a3867-3050-52da-a836-e630ba90ab69" +version = "1.2.2" + +[[Requires]] +deps = ["UUIDs"] +git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621" +uuid = "ae029012-a4dd-5104-9daa-d747884805df" +version = "1.1.3" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[SharedArrays]] +deps = ["Distributed", "Mmap", "Random", "Serialization"] +uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SortingAlgorithms]] +deps = ["DataStructures"] +git-tree-sha1 = "b3363d7460f7d098ca0912c69b082f75625d7508" +uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" +version = "1.0.1" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[SpecialFunctions]] +deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +git-tree-sha1 = "f0bccf98e16759818ffc5d97ac3ebf87eb950150" +uuid = "276daf66-3868-5448-9aa4-cd146d93841b" +version = "1.8.1" + +[[Static]] +deps = ["IfElse"] +git-tree-sha1 = "e7bc80dc93f50857a5d1e3c8121495852f407e6a" +uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" +version = "0.4.0" + +[[StaticArrays]] +deps = ["LinearAlgebra", "Random", "Statistics"] +git-tree-sha1 = "3c76dde64d03699e074ac02eb2e8ba8254d428da" +uuid = "90137ffa-7385-5640-81b9-e52037218182" +version = "1.2.13" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[StatsAPI]] +git-tree-sha1 = "1958272568dc176a1d881acb797beb909c785510" +uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0" +version = "1.0.0" + +[[StatsBase]] +deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] +git-tree-sha1 = "eb35dcc66558b2dda84079b9a1be17557d32091a" +uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" +version = "0.33.12" + +[[TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" + +[[Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" + +[[Test]] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[TimerOutputs]] +deps = ["ExprTools", "Printf"] +git-tree-sha1 = "7cb456f358e8f9d102a8b25e8dfedf58fa5689bc" +uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" +version = "0.5.13" + +[[TranscodingStreams]] +deps = ["Random", "Test"] +git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c" +uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" +version = "0.9.6" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[ZipFile]] +deps = ["Libdl", "Printf", "Zlib_jll"] +git-tree-sha1 = "3593e69e469d2111389a9bd06bac1f3d730ac6de" +uuid = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" +version = "0.9.4" + +[[Zlib_jll]] +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 = "0fc9959bcabc4668c403810b4e851f6b8962eac9" +uuid = "e88e6eb3-aa80-5325-afca-941959d7151f" +version = "0.6.29" + +[[ZygoteRules]] +deps = ["MacroTools"] +git-tree-sha1 = "8c1a8e4dfacb1fd631745552c8db35d0deb09ea0" +uuid = "700de1a5-db45-46bc-99cf-38207098b444" +version = "0.2.2" + +[[nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" + +[[p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +""" + +# ╔═╡ Cell order: +# ╠═0829eb90-1d74-46b6-80ec-482a2b71c6fe +# ╟─66f0e667-d722-4e1e-807b-84a39cbc41b1 +# ╠═9fa41b7c-1923-4c1e-bfc6-20ce4a1a2ede +# ╟─90446134-4e45-471c-857d-4e165e51937a +# ╠═5b45b29e-f0f4-41e9-91e7-d444687feb4e +# ╠═152f3a3c-a565-41bb-8e59-6ab0d2315ffb +# ╠═25ac9438-2b1d-4f6b-9ff1-1695e1d52b51 +# ╠═29ff1777-d276-4e8f-8582-4ca191f2e2ff +# ╠═f7aabe43-9a2c-4fe0-8099-c29cdf66566c +# ╠═d816b252-bdca-44ba-ac5c-cb21163a1e9a +# ╠═6a3b5f7a-a535-450f-8c5f-19bdcc280146 +# ╠═3d9a2425-d549-48a4-badb-34c0c07aeecc +# ╠═caaabe93-cc09-45c3-9c3f-be4aeb281099 +# ╠═b73396ce-f5ef-46bc-a92c-94a48d9b4551 +# ╠═f2523e2c-2c56-4883-a074-5de7a0aed25b +# ╠═7075d5fb-8273-498e-87bb-40e084c97601 +# ╠═95bfc9d8-8427-41d6-9f0f-f155296eef91 +# ╠═bbca5143-f314-40ea-a20e-8a043272e362 +# ╠═340da189-f443-4376-a82d-7699a21ab7a2 +# ╠═206ac4cc-5102-4381-ad8a-777b02dc4d5a +# ╠═eebb8706-a431-4fd1-b7a5-40f07a63d5cb +# ╠═f8d582cb-10cf-4c72-8127-787f662e0567 +# ╠═5946daa3-4608-43f3-8933-dd3eb3f4541c +# ╠═41271ab4-1ec7-431f-9efb-0f7c3da2d8b4 +# ╠═43b99708-0052-4b78-886c-92ac2b532f29 +# ╠═dff642d9-ec5a-4fed-a059-6c07760a3a58 +# ╠═b433a7ec-8264-48d6-8b95-53d2ec4bad05 +# ╠═65e0b1fa-d5e1-4ff6-8736-c9d6b5f40150 +# ╠═19ccfc3a-6dbb-4c64-bf03-e2e219ef0efe +# ╠═dc614254-c211-4552-b985-03020bfc5ab3 +# ╠═cd55e232-493d-4849-8bd7-b0ba85e21bab +# ╠═fb6aacff-c42d-4ec1-88cb-5ce1b2e8874f +# ╠═f30904a7-5caa-449a-a5bd-f2aa78777a9a +# ╠═5abebc1a-370c-4f5f-8826-dc0b143d5166 +# ╠═a20959be-65e4-4b69-9521-503bc59f0854 +# ╠═6bf8d29a-7990-4e91-86e6-d9894ed3db27 +# ╠═e7ee1a0f-ab9b-439e-a7be-4a6d3b8f160d +# ╠═74f5fde3-0593-46fc-a688-f1db7ab28c64 +# ╠═02f3fe78-e7a7-453f-9ddf-acddf08d8676 +# ╠═c50b1d39-fe87-441b-935c-c5fe971d09ef +# ╠═14e61097-f28f-4029-b6b4-5fb119620fc3 +# ╠═bf0c6061-daf4-45ac-82bc-b26e093ac6a7 +# ╟─00000000-0000-0000-0000-000000000001 +# ╟─00000000-0000-0000-0000-000000000002