Skip to content

Commit

Permalink
Adding tests for agent state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank Swaminathan committed Nov 14, 2024
1 parent 46f75d2 commit 38f7dbf
Show file tree
Hide file tree
Showing 4 changed files with 472 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/lineargaussianscalarfields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ struct LGSFModelParameters <: SCRIBEModelParameters
Q::Union{Nothing, Matrix{Float64}})
let ψ_p=[Dict([(, m),(, s),(, t)]) for m in collect(eachrow(μ)) for s in σ for t in τ], nᵩ=size(ψ_p,1)
p=Dict(=>μ, =>σ, =>τ)
if ϕ₀===nothing; ϕ₀=zeros(nᵩ); end
if ϕ₀===nothing
ϕ₀=zeros(nᵩ)
else
@assert size(ϕ₀,1)==nᵩ
end
if A===nothing; A=I(nᵩ); end
if Q===nothing; Q=I(nᵩ); end
w=Dict(:Q=>Q, :w_dist=>Gaussian(zeros(nᵩ), Q))
Expand Down Expand Up @@ -111,13 +115,15 @@ In the LGSF model, the only dynamic object is ϕ.
We use the simple linear stochastic update.
This is computed via an internal method (not exported) named `LGSF_ϕ_dynamics`.
"""
update_SCRIBEModel(smodel::LGSFModel) = LGSFModel(smodel.k+1, smodel.params, smodel.ψ, LGSF_ϕ_dynamics(smodel))
update_SCRIBEModel(smodel::LGSFModel) = LGSFModel(smodel.k+1, smodel.params, smodel.ψ,
LGSF_ϕ_dynamics(smodel), rand(smodel.params.w[:w_dist]))

"""Progresses the discrete-time model through one time step.
This is for model estimates. This requires explicit ϕ declarations.
"""
update_SCRIBEModel(smodel::LGSFModel, ϕₖ) = LGSFModel(smodel.k+1, smodel.params, smodel.ψ, ϕₖ)
update_SCRIBEModel(smodel::LGSFModel, ϕₖ) = LGSFModel(smodel.k+1, smodel.params, smodel.ψ,
ϕₖ, rand(smodel.params.w[:w_dist]))

function predict_SCRIBEModel(smodel::LGSFModel, x::Union{Vector{Float64}, Float64}, k::Integer)
@assert k==smodel.k "Timestep of prediction does not match the model timestep"
Expand Down
Loading

0 comments on commit 38f7dbf

Please sign in to comment.