Object Tracking with Particle Filters

Introduction

So far, we've seen two general classes of inference algorithm, importance sampling and MCMC. Very informally, and focusing only on one aspect of the algorithms, we might describe them as follows:

  • Importance Sampling: guesses solutions "all at once" using a proposal distribution. That proposal may be "smart" (e.g., a neural network), but still guesses an entire solution in one go. We make many guesses, and weight them according to the importance weighting formula.

  • MCMC: beginning with an initial guess, iteratively refine the guess to explore the space of possible solutions. At every iteration, the current state is an entire proposed solution to the problem.

In this notebook, we will explore a third paradigm: Sequential Monte Carlo. SMC methods, such as particle filtering, iteratively solve a sequence of inference problems using techniques based on importance sampling and in some cases MCMC [1][2]. The solution to each problem in the sequence is represented as a collection of samples or particles. The particles for each problem are based on extending or adjusting the particles for the previous problem in the sequence.

The sequence of inference problems that are solved often arise naturally from observations that arrive incrementally, as in particle filtering. Particle filtering algorithms are a subclass of SMC algorithms, often applied to state-space models in which we observe an evolving process over time. We begin by only considering the first time step, inferring the latent variables at that time step given that time step's observations. We then consider a slightly more difficult inference problem: joint inference of the first two time steps' latent variables, given both time steps' observations. And so on, until the observations stop.

But SMC is a more general algorithm than the particle filter might suggest. Sometimes, the sequence of problems does not arise from data arriving incrementally, but is rather constructed instrumentally to facilitate inference, as in annealed importance sampling [3].

However, this notebook focuses on particle filtering for a typical tracking problem. We show how Gen's support for SMC integrates with its support for MCMC, enabling "rejuvenation" MCMC moves. Specifically, we will address the "bearings only tracking" problem described in [4].

This notebook will also introduce you to the Unfold combinator, which can be used to improve performance of SMC. Unfold is just one example of the levers that Gen provides for improving performance; once you understand it, you can check Gen's documentation to see how similar principles apply to the Map combinator and to the static DSL. (These features are also covered in the previous tutorial, Scaling with the Static Modeling Language)

Prerequisites for this tutorial

Implementing the Generative Model

We will implement a generative model for the movement of a point in the x-y plane and bearing measurements of the location of this point relative to the origin over time. We imagine, for example, that we are located at the origin, and can measure the location of a far-away ship (the object we are tracking) only by measuring its bearing relative to us, i.e., the angle formed with the x axis by the ray connecting us to the ship. We would like to infer its (x, y) position over time.

We assume that we know the approximate initial position and velocity of the ship. We assume the point's x- and y- velocity are subject to random perturbations drawn from some normal distribution with a known variance. Each bearing measurement consists of the angle of the point being tracked relative to the positive x-axis.

We write the generative model as a generative function below. The function first samples the initial state of the ship from a prior distribution, and then generates T successive states in a for loop. The argument to the model (T) is the number of time steps not including the initial state.

using Gen, Plots
bearing(x, y) = atan(y, x)

@gen function model(T::Int)

    measurement_noise = 0.005
    velocity_var = 1e-6

    xs = Vector{Float64}(undef, T+1)
    ys = Vector{Float64}(undef, T+1)

    # prior on initial x-coordinate
    x = {:x0} ~ normal(0.01, 0.01)

    # prior on initial y-coordinate
    y = {:y0} ~ normal(0.95, 0.01)

    # prior on x-component of initial velocity
    vx = {:vx0} ~ normal(0.002, 0.01)

    # prior on y-component of initial velocity
    vy = {:vy0} ~ normal(-0.013, 0.01)

    # initial bearing measurement
    z0 ~ normal(bearing(x, y), measurement_noise)

    # record position
    xs[1] = x
    ys[1] = y

    # generate successive states and measurements
    for t=1:T

        # update the state of the point
        vx = {(:vx, t)} ~ normal(vx, sqrt(velocity_var))
        vy = {(:vy, t)} ~ normal(vy, sqrt(velocity_var))
        x += vx
        y += vy

        # bearing measurement
        {(:z, t)} ~ normal(bearing(x, y), measurement_noise)

        # record position
        xs[t+1] = x
        ys[t+1] = y
    end

    # return the sequence of positions
    return (xs, ys)
end;
DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false)

Note that the model function itself uses mutation to evolve the variables x, y, vx, and vy over time. The {addr} ~ distribution() syntax keeps the names of traced random variables (for which each address may only be used once) separate from the names of program variables, like x, which may be reassigned multiple times during the function's execution.

We generate a data set of positions, and observed bearings, by sampling from this model, with T=50:

import Random
Random.seed!(3)

# generate trace with specific initial conditions
T = 50
constraints = Gen.choicemap((:x0, 0.01), (:y0, 0.95), (:vx0, 0.002), (:vy0, -0.013))
(trace, _) = Gen.generate(model, (T,), constraints)
nothing

Let's extract the observed data zs from the trace

choices = Gen.get_choices(trace)
zs = Vector{Float64}(undef, T+1)
zs[1] = choices[:z0]
for t=1:T
    zs[t+1] = choices[(:z, t)]
end
zs
51-element Vector{Float64}:
 1.5662281786303143
 1.5558350925240616
 1.5617399748368006
 1.5660184709840879
 1.559863392211382
 1.5523686349728332
 1.5530074965250469
 1.5568099906364763
 1.5561153261358702
 1.5529641739074254
 ⋮
 1.4858819222241892
 1.4782173917689414
 1.464410441372264
 1.4468437983949325
 1.421531127903808
 1.4312792622565906
 1.4213779592266755
 1.4225661261798335
 1.4082019589591854

We next write a visualization for full traces of this model. It shows the ship's positions (as dots) as well as the observed bearings (as fixed length line segments from the origin):

function render(trace; show_data=true, max_T=get_args(trace)[1], overlay=false)
    (T,) = Gen.get_args(trace)
    (xs, ys) = Gen.get_retval(trace)

    zs = Vector{Float64}(undef, T+1)
    zs[1] = trace[:z0]
    for t=1:T
        zs[t+1] = trace[(:z, t)]
    end

    f = overlay ? scatter! : scatter
    fig = f(xs[1:max_T+1], ys[1:max_T+1], msize=3, msw=1, label=nothing)

    if show_data
        for z in zs[1:max_T+1]
            dx = cos(z) * 0.5
            dy = sin(z) * 0.5
            plot!([0., dx], [0., dy], color="red", alpha=0.3, label=nothing)
        end
    end

    return fig
end
render (generic function with 1 method)

We visualize the synthetic trace below:

render(trace)
title!("Observed bearings (lines) and positions (dots)")
Example block output

Note that these are the observed bearings, but we are not plotting the "ground truth" locations of the ship. There are many trajectories consistent with these bearings; for each of the red rays in the above plot, the ship could be anywhere along the ray (or even slightly off it, given that our measurements are noisy). However, our assumptions about the dynamics of the situation — that is, the conditional distributions $P(x_{t+1}, y_{t+1} \mid x_t, y_t)$ — will ensure that physics-defying trajectories (e.g., where the ship moves from a very high Y coordinate to a very low one in a short time) are ruled out.

Implementing a Basic Particle Filter

In Gen, a particle is represented as a trace and the particle filter state contains a weighted collection of traces. Below we define an inference program that runs a particle filter on an observed data set of bearings (zs). We use num_particles particles internally, and then we return a sample of num_samples traces from the weighted collection that the particle filter produces.

Gen provides methods for initializing and updating the state of a particle filter, documented in Particle Filtering.

  • Gen.initialize_particle_filter

  • Gen.particle_filter_step!

Both of these methods can used either with the default proposal or a custom proposal. In this problem, we will use the default proposal. There is also a method that resamples particles based on their weights, which serves to redistribute the particles to more promising parts of the latent space.

  • Gen.maybe_resample!

Gen also provides a method for sampling a collection of unweighted traces from the current weighted collection in the particle filter state:

  • Gen.sample_unweighted_traces
function particle_filter(num_particles::Int, zs::Vector{Float64}, num_samples::Int)

    # construct initial observations
    init_obs = Gen.choicemap((:z0, zs[1]))
    state = Gen.initialize_particle_filter(model, (0,), init_obs, num_particles)

    # steps
    for t=1:length(zs)-1
        Gen.maybe_resample!(state, ess_threshold=num_particles/2)
        obs = Gen.choicemap(((:z, t), zs[t+1]))
        Gen.particle_filter_step!(state, (t,), (UnknownChange(),), obs)
    end

    # return a sample of unweighted traces from the weighted collection
    return Gen.sample_unweighted_traces(state, num_samples)
end
particle_filter (generic function with 1 method)

The initial state is obtained by providing the following to initialize_particle_filter:

  • The generative function for the generative model (model)

  • The initial arguments to the generative function.

  • The initial observations, expressed as a map from choice address to values (init_obs).

  • The number of particles.

At each step, we resample from the collection of traces (maybe_resample!) and then we introduce one additional bearing measurement by calling particle_filter_step! on the state. We pass the following arguments to particle_filter_step!:

  • The state (it will be mutated)

  • The new arguments to the generative function for this step. In our case, this is the number of measurements beyond the first measurement.

  • The argdiff value, which provides detailed information about the change to the arguments between the previous step and this step. We will revisit this value later. For now, we indicate that we do not know how the T::Int argument will change with each step.

  • The new observations associated with the new step. In our case, this just contains the latest measurement.

We run this particle filter with 5000 particles, and return a sample of 200 particles. This will take 30-60 seconds. We will see one way of speeding up the particle filter in a later section.

@time pf_traces = particle_filter(5000, zs, 200);
200-element Vector{Gen.DynamicDSLTrace}:
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.378196060247766, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.019088691896952507, 5.91851099384585, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.304010445867526, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002171020812880315, 4.453295135682281, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011322250004090302, 5.982196906657568, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.142171613292042, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.299217024190132, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.011437313804826212, 5.909653344821026, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.363303392163109, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.013202035237870627, 5.8419504680432945, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 777.9602144221575, 0.0, (50,), ([0.003141307383066949, 0.006089989025537246, 0.007718354298609053, 0.008316892853075984, 0.009186811863335625, 0.01117624665702462, 0.01220134346499343, 0.01274085548244932, 0.013015487131590694, 0.013229066041993646  …  0.02465473933693734, 0.02874780270734603, 0.03212839075183027, 0.03475494204993676, 0.038755838299152294, 0.04219870314121769, 0.04314390469216308, 0.0440682479723099, 0.04446121588498906, 0.04577095149398764], [0.9444417718701219, 0.9231387399081132, 0.9010184370509562, 0.880220425177557, 0.859371059114957, 0.8382263484834268, 0.8175189027805646, 0.7968154093260015, 0.7781960137041404, 0.7594823038119071  …  0.3436115156100141, 0.3352249965161887, 0.32692515675493405, 0.3186441460179397, 0.31182648606019336, 0.30439998520462563, 0.297085083925025, 0.2913422516002843, 0.28640300849222383, 0.28308742686328414]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.376218488276378, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.012400381513552177, 5.673120678931177, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.753172605862946, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0014777085633541883, 5.742548563179797, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.007650296093245677, 5.640533135078466, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.046245796791604, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.2719439332038736, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.00848490212090064, 5.547190412406198, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.015960462512153, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00881647237880015, 5.980360291416959, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 763.42034068372, 0.0, (50,), ([0.008836200844559848, 0.00926539061857293, 0.009544790246064588, 0.009565342660527653, 0.010275769904633067, 0.011512898937003338, 0.01302179002286212, 0.014260324316240911, 0.015124678634781586, 0.016985189094288637  …  0.04157930119886653, 0.049145131951514646, 0.056705107172207794, 0.06304836502517218, 0.06822045175974072, 0.07309802903211571, 0.07619971774977981, 0.07892411044164378, 0.082035830138721, 0.08603758365180646], [0.9479367838074559, 0.9356711869650056, 0.9254354088894284, 0.9161792339366491, 0.9068776261232968, 0.8968679204422335, 0.8860030569712442, 0.874572306933807, 0.8644033040874424, 0.8527975244450764  …  0.5693772879306629, 0.564750807131468, 0.5611414662501206, 0.557835098302531, 0.5546077686889149, 0.5504933838897356, 0.5475415217413658, 0.5431464076370421, 0.5374573707042093, 0.5322231433273313]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.199410730700697, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.0020298294818714684, 5.936639135446035, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.137720029188837, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0016263187909299579, 4.996659388852916, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011024808605560496, 3.930375100926117, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 2.8932863941893334, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.290780783583031, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.008995798184270676, 5.945724484260288, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.3143539588002255, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.005828653271093647, 5.980423337472328, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 760.4095586815748, 0.0, (50,), ([0.010476675535320727, 0.011307549878103071, 0.010954496300208883, 0.011202490924204426, 0.013037062753969292, 0.01329713113153653, 0.014814668200722253, 0.014934948834565675, 0.014698504987327766, 0.014887201109071319  …  0.050581870086674856, 0.057871459036449524, 0.06502321504415795, 0.07193473596641724, 0.07793890970578082, 0.08430762109873877, 0.08919677822748594, 0.09254560329085508, 0.09608902760902677, 0.0995106802908462], [0.9495160700137101, 0.9445876863713134, 0.9420040338865577, 0.939699824103356, 0.9356584431567347, 0.9323726602692457, 0.9293254127852699, 0.9280713008763402, 0.9264066821886826, 0.9240538121200997  …  0.6731798403484066, 0.6644692853148939, 0.6552886637628415, 0.6458816378554744, 0.6371534395308349, 0.6279518448432222, 0.6206869946155267, 0.6117261025225205, 0.604250412543802, 0.5959694347317768]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.376218488276378, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.012400381513552177, 5.673120678931177, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.753172605862946, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0014777085633541883, 5.742548563179797, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.007650296093245677, 5.640533135078466, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.046245796791604, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.2719439332038736, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.00848490212090064, 5.547190412406198, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.015960462512153, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00881647237880015, 5.980360291416959, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 760.3091336396317, 0.0, (50,), ([0.008836200844559848, 0.00926539061857293, 0.009544790246064588, 0.009565342660527653, 0.010275769904633067, 0.011512898937003338, 0.01302179002286212, 0.014260324316240911, 0.015124678634781586, 0.016985189094288637  …  0.04157930119886653, 0.049145131951514646, 0.056705107172207794, 0.06304836502517218, 0.06822045175974072, 0.07309802903211571, 0.07619971774977981, 0.07947883555751176, 0.08338161039507024, 0.08574982170288273], [0.9479367838074559, 0.9356711869650056, 0.9254354088894284, 0.9161792339366491, 0.9068776261232968, 0.8968679204422335, 0.8860030569712442, 0.874572306933807, 0.8644033040874424, 0.8527975244450764  …  0.5693772879306629, 0.564750807131468, 0.5611414662501206, 0.557835098302531, 0.5546077686889149, 0.5504933838897356, 0.5475415217413658, 0.542335940214602, 0.5383700786895167, 0.5332299682286135]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.376218488276378, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.012400381513552177, 5.673120678931177, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.753172605862946, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0014777085633541883, 5.742548563179797, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.007650296093245677, 5.640533135078466, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.046245796791604, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.2719439332038736, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.00848490212090064, 5.547190412406198, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.015960462512153, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00881647237880015, 5.980360291416959, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 759.6857479192149, 0.0, (50,), ([0.008836200844559848, 0.00926539061857293, 0.009544790246064588, 0.009565342660527653, 0.010275769904633067, 0.011512898937003338, 0.01302179002286212, 0.014260324316240911, 0.015124678634781586, 0.016985189094288637  …  0.04157930119886653, 0.049145131951514646, 0.056705107172207794, 0.06304836502517218, 0.06822045175974072, 0.07309802903211571, 0.07619971774977981, 0.0807836842804387, 0.08490554717474065, 0.08886557637986225], [0.9479367838074559, 0.9356711869650056, 0.9254354088894284, 0.9161792339366491, 0.9068776261232968, 0.8968679204422335, 0.8860030569712442, 0.874572306933807, 0.8644033040874424, 0.8527975244450764  …  0.5693772879306629, 0.564750807131468, 0.5611414662501206, 0.557835098302531, 0.5546077686889149, 0.5504933838897356, 0.5475415217413658, 0.5436900854616554, 0.5428178630277041, 0.5420566817957626]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.100892576486806, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.014322623400253275, 5.953853723650573, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.320239216676962, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002475764223299581, 5.5588454156135985, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011452989318907467, 5.399878906196065, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.352671483173199, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.320824071005301, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.012538289129633885, 5.986514040361751, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.37844505300051, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.011154185570578455, 5.967872977584661, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 761.7567048453747, 0.0, (50,), ([0.008507756422126084, 0.008515378016626865, 0.010340735831838112, 0.012490021968126281, 0.013259236097576996, 0.013964600429230102, 0.013654123891958869, 0.013565045062365262, 0.013714194193281112, 0.013633082458545566  …  0.033632993265544565, 0.038298602189582906, 0.04271190271880423, 0.04710108485688064, 0.05109521040469906, 0.055384416357303866, 0.05714203023786563, 0.05759404905154243, 0.057619451671317656, 0.05840632460703277], [0.9568895338156379, 0.9449957379419819, 0.9319458581489866, 0.9179836007737407, 0.9041097925654539, 0.8916393488557194, 0.877966310387499, 0.8640877601109721, 0.8498746530856893, 0.8352875943544876  …  0.4495344058137061, 0.43941742255792365, 0.42862262735706125, 0.4190517288315601, 0.41046747172382375, 0.40188051518627466, 0.39379643096592337, 0.38596783382490985, 0.38041591220690163, 0.3773604522428866]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.376218488276378, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.012400381513552177, 5.673120678931177, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.753172605862946, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0014777085633541883, 5.742548563179797, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.007650296093245677, 5.640533135078466, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.046245796791604, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.2719439332038736, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.00848490212090064, 5.547190412406198, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.015960462512153, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00881647237880015, 5.980360291416959, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 764.7406662609579, 0.0, (50,), ([0.008836200844559848, 0.00926539061857293, 0.009544790246064588, 0.009565342660527653, 0.010275769904633067, 0.011512898937003338, 0.01302179002286212, 0.014260324316240911, 0.015124678634781586, 0.016985189094288637  …  0.04157930119886653, 0.049145131951514646, 0.056705107172207794, 0.06304836502517218, 0.06822045175974072, 0.07309802903211571, 0.07619971774977981, 0.08049827361320107, 0.08393742726445666, 0.08730487134186336], [0.9479367838074559, 0.9356711869650056, 0.9254354088894284, 0.9161792339366491, 0.9068776261232968, 0.8968679204422335, 0.8860030569712442, 0.874572306933807, 0.8644033040874424, 0.8527975244450764  …  0.5693772879306629, 0.564750807131468, 0.5611414662501206, 0.557835098302531, 0.5546077686889149, 0.5504933838897356, 0.5475415217413658, 0.5445559425902762, 0.5411928270715689, 0.5374863451917546]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.355474511261612, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013033597123441043, 5.978501142665864, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.162330457057097, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002664214516509999, 5.879842676309497, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.014463359391011739, 5.791967177646321, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.280400226344396, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.368181466580135, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.015090813880407014, 5.922018475188154, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 3.8779936660060543, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.017458316381598032, 5.561990665420222, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 763.9749770971282, 0.0, (50,), ([0.009043370070018803, 0.008726415029118095, 0.007947870665716339, 0.00905847757445659, 0.010662385002643035, 0.01140051924114552, 0.011418449089018873, 0.012403026992008615, 0.013620453375285954, 0.0151200084350832  …  0.024081938471400742, 0.026236860928191736, 0.029280010092896425, 0.03283278930571355, 0.03514563316738469, 0.03638179740352625, 0.03565197419381094, 0.03352214207813263, 0.03125259357030989, 0.03036217858038804], [0.9492145427917357, 0.934027655684896, 0.9177588417190959, 0.9028236292294892, 0.8865540490835833, 0.870992643733629, 0.8556431845787014, 0.8417022858328744, 0.8291943364887617, 0.8163043750371547  …  0.34079421570998664, 0.3245445625043388, 0.30846375816879784, 0.29077052796279174, 0.2730217473267354, 0.2545478812278587, 0.23790696671313852, 0.22255489078697657, 0.20699623821801694, 0.1913082580343056]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.100892576486806, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.014322623400253275, 5.953853723650573, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.320239216676962, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002475764223299581, 5.5588454156135985, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011452989318907467, 5.399878906196065, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.352671483173199, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.320824071005301, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.012538289129633885, 5.986514040361751, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.37844505300051, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.011154185570578455, 5.967872977584661, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 763.6253075732371, 0.0, (50,), ([0.008507756422126084, 0.008515378016626865, 0.010340735831838112, 0.012490021968126281, 0.013259236097576996, 0.013964600429230102, 0.013654123891958869, 0.013565045062365262, 0.013714194193281112, 0.013633082458545566  …  0.033632993265544565, 0.038298602189582906, 0.04271190271880423, 0.04710108485688064, 0.05109521040469906, 0.055384416357303866, 0.05714203023786563, 0.059535203765362206, 0.0596790514685283, 0.0607840702837508], [0.9568895338156379, 0.9449957379419819, 0.9319458581489866, 0.9179836007737407, 0.9041097925654539, 0.8916393488557194, 0.877966310387499, 0.8640877601109721, 0.8498746530856893, 0.8352875943544876  …  0.4495344058137061, 0.43941742255792365, 0.42862262735706125, 0.4190517288315601, 0.41046747172382375, 0.40188051518627466, 0.39379643096592337, 0.38777508522912674, 0.3813421609507994, 0.37420005141671553]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.376218488276378, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.012400381513552177, 5.673120678931177, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.753172605862946, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0014777085633541883, 5.742548563179797, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.007650296093245677, 5.640533135078466, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.046245796791604, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.2719439332038736, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.00848490212090064, 5.547190412406198, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.015960462512153, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00881647237880015, 5.980360291416959, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 762.8352793328363, 0.0, (50,), ([0.008836200844559848, 0.00926539061857293, 0.009544790246064588, 0.009565342660527653, 0.010275769904633067, 0.011512898937003338, 0.01302179002286212, 0.014260324316240911, 0.015124678634781586, 0.016985189094288637  …  0.04157930119886653, 0.049145131951514646, 0.056705107172207794, 0.06304836502517218, 0.06822045175974072, 0.07309802903211571, 0.07619971774977981, 0.07964564160887333, 0.08420735087171768, 0.08719889423054666], [0.9479367838074559, 0.9356711869650056, 0.9254354088894284, 0.9161792339366491, 0.9068776261232968, 0.8968679204422335, 0.8860030569712442, 0.874572306933807, 0.8644033040874424, 0.8527975244450764  …  0.5693772879306629, 0.564750807131468, 0.5611414662501206, 0.557835098302531, 0.5546077686889149, 0.5504933838897356, 0.5475415217413658, 0.5443056876815618, 0.5417668671910906, 0.5402936944449825]))
 ⋮
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 3.912603050574317, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.010509966676240406, 5.895002752274784, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.317724760098002, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0038962766361537765, 5.929829638469565, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.013105548579320522, 4.6826702605696795, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.331415140669205, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 3.8143751312447267, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.014721807522193096, 5.757095188239482, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.265528056538082, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016102672728897406, 4.0334406226871, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 768.3762842147058, 0.0, (50,), ([0.005984595936559078, 0.009458028917916906, 0.012239582655613706, 0.013777292843036627, 0.014006398136378965, 0.014547401336417739, 0.0153076887159441, 0.016484964871463493, 0.01599597913870833, 0.01658872320350035  …  0.029246792885923214, 0.03238628958362043, 0.03601359636856476, 0.04054114558440863, 0.04494318533621683, 0.04825877345002416, 0.04936357395603624, 0.05006110744913794, 0.049859662780610804, 0.04895698358910142], [0.943706302362945, 0.9292446715068213, 0.9147252426595514, 0.9007838727474281, 0.8884340935076428, 0.8769561039866675, 0.8649746579600812, 0.8539740681171798, 0.8445015822471416, 0.833558455107556  …  0.40471525035665473, 0.3936970561514562, 0.3831560768859593, 0.37250264763184193, 0.3616930379195492, 0.3487576501376564, 0.33676523230408656, 0.32471512860233687, 0.3128779502909983, 0.30282301423518837]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.100892576486806, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.014322623400253275, 5.953853723650573, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.320239216676962, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002475764223299581, 5.5588454156135985, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011452989318907467, 5.399878906196065, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.352671483173199, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.320824071005301, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.012538289129633885, 5.986514040361751, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.37844505300051, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.011154185570578455, 5.967872977584661, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 767.9967408909087, 0.0, (50,), ([0.008507756422126084, 0.008515378016626865, 0.010340735831838112, 0.012490021968126281, 0.013259236097576996, 0.013964600429230102, 0.013654123891958869, 0.013565045062365262, 0.013714194193281112, 0.013633082458545566  …  0.033632993265544565, 0.038298602189582906, 0.04271190271880423, 0.04710108485688064, 0.05109521040469906, 0.055384416357303866, 0.05714203023786563, 0.05882189907522454, 0.059348890449805666, 0.05944493867511223], [0.9568895338156379, 0.9449957379419819, 0.9319458581489866, 0.9179836007737407, 0.9041097925654539, 0.8916393488557194, 0.877966310387499, 0.8640877601109721, 0.8498746530856893, 0.8352875943544876  …  0.4495344058137061, 0.43941742255792365, 0.42862262735706125, 0.4190517288315601, 0.41046747172382375, 0.40188051518627466, 0.39379643096592337, 0.38522861580576406, 0.3770259855887753, 0.3684571307937833]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.3727418274263705, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013308419793844891, 5.900614662838176, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.9767212039105067, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0022702126979923824, 5.738488442734511, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011227978701717718, 3.887429283150237, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.303529735679173, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.321892425295604, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.009177911647874246, 5.209330404655396, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.187950520579689, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00886471083266191, 5.484061078291908, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 758.0018690010129, 0.0, (50,), ([0.005477660209349238, 0.007102819384543879, 0.0080033372781015, 0.009160832537386577, 0.01032093075736967, 0.010603869837450288, 0.011556530236322362, 0.013436833306420677, 0.01567223890306559, 0.016510230647283967  …  0.04008049224042908, 0.044927077630905726, 0.049117510393990045, 0.05368322036935383, 0.05773592984316276, 0.06158559809755074, 0.06536972646813058, 0.06720788173562219, 0.06794922348449313, 0.06873882538818019], [0.9526989396663296, 0.9390984554364405, 0.9250924641585725, 0.911016091909719, 0.89673089681012, 0.8838259895950576, 0.871336946797358, 0.8567767662567293, 0.8420929926485695, 0.8283645678953746  …  0.501409156097102, 0.4928895089715324, 0.48457947719104705, 0.47573042111267183, 0.4666941675517824, 0.45703388714365156, 0.44897072868703786, 0.44163419131635634, 0.4336958765977855, 0.4269366410763468]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.199410730700697, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.0020298294818714684, 5.936639135446035, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.137720029188837, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0016263187909299579, 4.996659388852916, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011024808605560496, 3.930375100926117, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 2.8932863941893334, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.290780783583031, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.008995798184270676, 5.945724484260288, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.3143539588002255, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.005828653271093647, 5.980423337472328, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 762.8327572134879, 0.0, (50,), ([0.010476675535320727, 0.011307549878103071, 0.010954496300208883, 0.011202490924204426, 0.013037062753969292, 0.01329713113153653, 0.014814668200722253, 0.014934948834565675, 0.014698504987327766, 0.014887201109071319  …  0.050581870086674856, 0.057871459036449524, 0.06502321504415795, 0.07193473596641724, 0.07793890970578082, 0.08430762109873877, 0.08919677822748594, 0.0931858727451545, 0.09725734607977336, 0.10167933249155704], [0.9495160700137101, 0.9445876863713134, 0.9420040338865577, 0.939699824103356, 0.9356584431567347, 0.9323726602692457, 0.9293254127852699, 0.9280713008763402, 0.9264066821886826, 0.9240538121200997  …  0.6731798403484066, 0.6644692853148939, 0.6552886637628415, 0.6458816378554744, 0.6371534395308349, 0.6279518448432222, 0.6206869946155267, 0.6134598243111109, 0.6068995317395992, 0.5999951773521545]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.3727418274263705, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013308419793844891, 5.900614662838176, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.9767212039105067, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0022702126979923824, 5.738488442734511, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.010156383826342614, 5.510112843759147, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.303529735679173, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.321892425295604, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.009177911647874246, 5.209330404655396, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.187950520579689, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00886471083266191, 5.484061078291908, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 762.0906568110664, 0.0, (50,), ([0.005477660209349238, 0.007102819384543879, 0.0080033372781015, 0.009160832537386577, 0.01032093075736967, 0.010603869837450288, 0.011556530236322362, 0.013436833306420677, 0.01567223890306559, 0.016510230647283967  …  0.03707903608854933, 0.04158790067148459, 0.04716895935495713, 0.05063567023067067, 0.05555645067578999, 0.05947171343563301, 0.06282890948504694, 0.06555056224185701, 0.06640932066299782, 0.06598346578172035], [0.9526989396663296, 0.9390984554364405, 0.9250924641585725, 0.911016091909719, 0.89673089681012, 0.8838259895950576, 0.871336946797358, 0.8567767662567293, 0.8420929926485695, 0.8283645678953746  …  0.4934415380196728, 0.483344825425001, 0.47441216889050813, 0.46362398598099275, 0.4530111528139309, 0.44341158713486983, 0.43459317284123733, 0.4255583310538581, 0.4168109411558022, 0.4080922910662017]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.199410730700697, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.0020298294818714684, 5.936639135446035, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.137720029188837, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0016263187909299579, 4.996659388852916, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011024808605560496, 3.930375100926117, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 2.8932863941893334, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.290780783583031, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.008995798184270676, 5.945724484260288, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.3143539588002255, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.005828653271093647, 5.980423337472328, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 763.443522873443, 0.0, (50,), ([0.010476675535320727, 0.011307549878103071, 0.010954496300208883, 0.011202490924204426, 0.013037062753969292, 0.01329713113153653, 0.014814668200722253, 0.014934948834565675, 0.014698504987327766, 0.014887201109071319  …  0.050581870086674856, 0.057871459036449524, 0.06502321504415795, 0.07193473596641724, 0.07793890970578082, 0.08430762109873877, 0.08919677822748594, 0.09244311353498368, 0.09528106554479476, 0.09848059414246696], [0.9495160700137101, 0.9445876863713134, 0.9420040338865577, 0.939699824103356, 0.9356584431567347, 0.9323726602692457, 0.9293254127852699, 0.9280713008763402, 0.9264066821886826, 0.9240538121200997  …  0.6731798403484066, 0.6644692853148939, 0.6552886637628415, 0.6458816378554744, 0.6371534395308349, 0.6279518448432222, 0.6206869946155267, 0.6137992408646433, 0.6064249617456035, 0.5996221832856814]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.3727418274263705, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013308419793844891, 5.900614662838176, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.9767212039105067, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0022702126979923824, 5.738488442734511, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.010156383826342614, 5.510112843759147, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.303529735679173, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.321892425295604, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.009177911647874246, 5.209330404655396, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.187950520579689, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00886471083266191, 5.484061078291908, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 762.5366479694289, 0.0, (50,), ([0.005477660209349238, 0.007102819384543879, 0.0080033372781015, 0.009160832537386577, 0.01032093075736967, 0.010603869837450288, 0.011556530236322362, 0.013436833306420677, 0.01567223890306559, 0.016510230647283967  …  0.03707903608854933, 0.04158790067148459, 0.04716895935495713, 0.05063567023067067, 0.05555645067578999, 0.05947171343563301, 0.06282890948504694, 0.06503528056535005, 0.06567608160160127, 0.06666394076639412], [0.9526989396663296, 0.9390984554364405, 0.9250924641585725, 0.911016091909719, 0.89673089681012, 0.8838259895950576, 0.871336946797358, 0.8567767662567293, 0.8420929926485695, 0.8283645678953746  …  0.4934415380196728, 0.483344825425001, 0.47441216889050813, 0.46362398598099275, 0.4530111528139309, 0.44341158713486983, 0.43459317284123733, 0.42699349640069395, 0.418776316078967, 0.41158943832895645]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.199410730700697, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.0020298294818714684, 5.936639135446035, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.137720029188837, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0016263187909299579, 4.996659388852916, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011024808605560496, 3.930375100926117, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 2.8932863941893334, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.290780783583031, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.008995798184270676, 5.945724484260288, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.3143539588002255, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.005828653271093647, 5.980423337472328, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 760.2688250874189, 0.0, (50,), ([0.010476675535320727, 0.011307549878103071, 0.010954496300208883, 0.011202490924204426, 0.013037062753969292, 0.01329713113153653, 0.014814668200722253, 0.014934948834565675, 0.014698504987327766, 0.014887201109071319  …  0.050581870086674856, 0.057871459036449524, 0.06502321504415795, 0.07193473596641724, 0.07793890970578082, 0.08430762109873877, 0.08919677822748594, 0.09254560329085508, 0.09525418491959627, 0.09960660978617795], [0.9495160700137101, 0.9445876863713134, 0.9420040338865577, 0.939699824103356, 0.9356584431567347, 0.9323726602692457, 0.9293254127852699, 0.9280713008763402, 0.9264066821886826, 0.9240538121200997  …  0.6731798403484066, 0.6644692853148939, 0.6552886637628415, 0.6458816378554744, 0.6371534395308349, 0.6279518448432222, 0.6206869946155267, 0.6117261025225205, 0.6021743077261935, 0.592491748843834]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.376218488276378, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.012400381513552177, 5.673120678931177, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.753172605862946, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0014777085633541883, 5.742548563179797, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.007650296093245677, 5.640533135078466, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.046245796791604, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.2719439332038736, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.00848490212090064, 5.547190412406198, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.015960462512153, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.00881647237880015, 5.980360291416959, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 761.2598473083236, 0.0, (50,), ([0.008836200844559848, 0.00926539061857293, 0.009544790246064588, 0.009565342660527653, 0.010275769904633067, 0.011512898937003338, 0.01302179002286212, 0.014260324316240911, 0.015124678634781586, 0.016985189094288637  …  0.04157930119886653, 0.049145131951514646, 0.056705107172207794, 0.06304836502517218, 0.06822045175974072, 0.07309802903211571, 0.07619971774977981, 0.08089939463602674, 0.0844598775066293, 0.08736354673797517], [0.9479367838074559, 0.9356711869650056, 0.9254354088894284, 0.9161792339366491, 0.9068776261232968, 0.8968679204422335, 0.8860030569712442, 0.874572306933807, 0.8644033040874424, 0.8527975244450764  …  0.5693772879306629, 0.564750807131468, 0.5611414662501206, 0.557835098302531, 0.5546077686889149, 0.5504933838897356, 0.5475415217413658, 0.544904241883922, 0.5403154400490304, 0.5366063851793677]))

To render these traces, we first define a function that overlays many renderings:

function overlay(renderer, traces; same_data=true, args...)
    fig = plot(xlabel="X", ylabel="Y",
        title="Observed bearings (red) and \npositions of individual traces (one color per trace)")

    renderer(traces[1], show_data=true, overlay=true, args...)
    for i=2:length(traces)
        renderer(traces[i], show_data=!same_data, overlay=true, args...)
    end
    fig
end
overlay (generic function with 1 method)

We then render the traces from the particle filter:

overlay(render, pf_traces)
Example block output

We see a broad posterior; many trajectories (i.e. x- and y-positions) explain the observed bearings.

Notice that as during the period of denser bearing measurements, the trajectories tend to turn so that the heading is more parallel to the bearing vector. An alternative explanation is that the point maintained a constant heading, but just slowed down significantly. It is interesting to see that the inferences favor the "turning explanation" over the "slowing down explanation".

Note

Run the particle filter with fewer particles and visualize the results.

Run the particle filter without the maybe_resample! step, and visualize the results. What do you observe? Why do you think this is? Answer in the free response section below.

The code for particle_filter (from above) is copied in the body of the function below. Modify it so that it does NOT perform resampling after each time step.

function particle_filter_no_resampling(num_particles::Int, zs::Vector{Float64}, num_samples::Int)

    # construct initial observations
    init_obs = Gen.choicemap((:z0, zs[1]))
    state = Gen.initialize_particle_filter(model, (0,), init_obs, num_particles)

    # steps
    for t=1:length(zs)-1
        Gen.maybe_resample!(state, ess_threshold=num_particles/2)
        obs = Gen.choicemap(((:z, t), zs[t+1]))
        Gen.particle_filter_step!(state, (t,), (UnknownChange(),), obs)
    end

    # return a sample of unweighted traces from the weighted collection
    return Gen.sample_unweighted_traces(state, num_samples)
end

@time pf_traces_no_resampling = particle_filter_no_resampling(5000, zs, 200);
overlay(render, pf_traces_no_resampling)
Example block output
Note

Describe how the inference differs with and without resampling (based on the two plots above). Why do you think that is? Is it desirable?

function particle_filter_no_resampling(num_particles::Int, zs::Vector{Float64}, num_samples::Int)

    # construct initial observations
    init_obs = Gen.choicemap((:z0, zs[1]))
    state = Gen.initialize_particle_filter(model, (0,), init_obs, num_particles)

    # steps
    for t=1:length(zs)-1
        obs = Gen.choicemap(((:z, t), zs[t+1]))
        Gen.particle_filter_step!(state, (t,), (UnknownChange(),), obs)
    end

    # return a sample of unweighted traces from the weighted collection
    return Gen.sample_unweighted_traces(state, num_samples)
end
particle_filter_no_resampling (generic function with 1 method)

Without resampling, we get particle collapse, because the model converges on one best guess. This is not desirable; we have lost diversity in our samples.

END ANSWER KEY

Adding Rejuvenation Moves

The particle filter we developed above works as follows:

  • At the start, guess many possible initial positions and velocities for the ship.
  • Score these proposals based on the initial observation, z0.
  • Use maybe_resample! to clone the guesses that explain z0 well, and cull the guesses that explain it poorly.
  • For each data point:
    1. For each guess (particle) from the previous time step, guess many possible extensions of the particle to include values of vx and vy for the next time step.
    2. Score these extended proposed particles based on the latest bearing.
    3. Use maybe_resample! to clone the guesses that explain the z's so far, and cull the guesses that don't.

A problem with this procedure is that after the initial guesses for a quantity have been made, they are never revised. This is despite the fact that learning about later bearings may tell us a lot about earlier positions. This can be especially problematic in the presence of resampling: notice how, in the above results, the starting locations of all the particles are likely nearly identical, even though the paths become more diverse as time goes on. This is because "good" particles at the first step were likely cloned and propagated through the particle filter, never changing the x0 and y0 values.

Therefore, it is sometimes useful to add MCMC moves to particles in a particle filter between steps. These MCMC moves are often called "rejuvenation moves" [4]. Each rejuvenation move targets the current posterior distribution at the given step. For example, when applying the rejuvenation move after incorporating 3 observations, our rejuvenation moves have as their stationary distribution the conditional distribution on the latent variables, given the first three observations.

Rejuvenation moves can target any portion of the latent space. It is common for rejuvenation moves to target "global" variables that affect every time step (e.g., the initial position of the ship), or a sliding window of recent variables, e.g., the velocities from the previous five time steps.

In this section, we write two new versions of the particle filter, each of which uses Metropolis-Hastings rejuvenation moves to adjust each particle at every time step. The first version uses so-called "resimulation MH" to adjust the initial choices (x0, y0, and the initial velocities). This means that the proposal distribution for MH is equal to the prior of the generative model. The proposed next state under this rejuvenation move is independent of the current state. By contrast, the second version we write will use Gaussian drift proposals, and therefore we refer to it as "random walk MH." The Gaussian drift rejuvenation moves will target a sliding window of recent velocities, perturbing them to see if — in light of new data — we can find better values for them.

First, the resimulation MH rejuvenation move (this function is the same as the previous, but with the addition of a rejuvenation move targeting the initial choices of each particle):

function particle_filter_rejuv_resim(num_particles::Int, zs::Vector{Float64}, num_samples::Int)
    init_obs = Gen.choicemap((:z0, zs[1]))
    state = Gen.initialize_particle_filter(model, (0,), init_obs, num_particles)
    for t=1:length(zs)-1

        # apply a rejuvenation move to each particle
        for i=1:num_particles
            initial_choices = select(:x0, :y0, :vx0, :vy0)
            state.traces[i], _  = mh(state.traces[i], initial_choices)
        end

        Gen.maybe_resample!(state, ess_threshold=num_particles/2)
        obs = Gen.choicemap(((:z, t), zs[t+1]))
        Gen.particle_filter_step!(state, (t,), (UnknownChange(),), obs)
    end

    # return a sample of unweighted traces from the weighted collection
    return Gen.sample_unweighted_traces(state, num_samples)
end

@time pf_rejuv_resim_traces = particle_filter_rejuv_resim(5000, zs, 200);
overlay(render, pf_rejuv_resim_traces)
title!("Rejuvenation with resimulation MH on the starting points")
Example block output

You may notice slightly more variety in the initial state, compared to our first round of particle filtering.

Note

Write a random walk MH rejuvenation move that perturbs the velocity vectors for a block of time steps between a and b inclusive. In this move, draw the perturbation from a normal distribution with standard deviation 1e-3. When sampling a new vx and vy for time step t (where a <= t <= b), make sure you use the right address –- you want to use the same address in your proposal as was used in the model.

We have provided starter code.

@gen function perturbation_proposal(prev_trace, a::Int, b::Int)
    (T,) = get_args(prev_trace)
    speed = Array{Float64}(undef, 2, 1)
    for t=a:b
        speed[1] = 0. # <Remove zero and put your code to perturb vx here>
        speed[2] = 0. # <Remove zero and put your code to perturb vy here>
    end
    return speed # Return an array of the most recent [vx, vy] for testing
end

function perturbation_move(trace, a::Int, b::Int)
    Gen.metropolis_hastings(trace, perturbation_proposal, (a, b))
end;
perturbation_move (generic function with 1 method)

We add this into our particle filtering inference program below. We apply the rejuvenation move to adjust the velocities for the previous 5 time steps.

function particle_filter_rejuv(num_particles::Int, zs::Vector{Float64}, num_samples::Int)
    init_obs = Gen.choicemap((:z0, zs[1]))
    state = Gen.initialize_particle_filter(model, (0,), init_obs, num_particles)
    for t=1:length(zs)-1

        # apply a rejuvenation move to each particle
        for i=1:num_particles
            state.traces[i], _ = perturbation_move(state.traces[i], max(1, t-5), t-1)
        end

        Gen.maybe_resample!(state, ess_threshold=num_particles/2)
        obs = Gen.choicemap(((:z, t), zs[t+1]))
        Gen.particle_filter_step!(state, (t,), (UnknownChange(),), obs)
    end

    # return a sample of unweighted traces from the weighted collection
    return Gen.sample_unweighted_traces(state, num_samples)
end
particle_filter_rejuv (generic function with 1 method)

We run the particle filter with rejuvenation below. This will take a minute or two. We will see one way of speeding up the particle filter in a later section.

@time pf_rejuv_traces = particle_filter_rejuv(5000, zs, 200);
200-element Vector{Gen.DynamicDSLTrace}:
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.295579489531342, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013959158310033434, 3.201697284341314, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.9680448326865148, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.003670381180378411, 5.8726440371509785, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.0031855301738570926, 5.42791280861486, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.6243797187149234, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.378998249808009, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.0021263758535027787, 5.696892755594144, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.158345364812688, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.009900346425192157, 5.88978953515732, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 770.3016733054135, 0.0, (50,), ([0.008135898898737476, 0.009564879458516671, 0.011140322560019273, 0.011233064545191854, 0.011750913069839422, 0.011918302002570911, 0.011551422940568849, 0.012298635419528374, 0.013234703771293134, 0.01478688573736426  …  0.04553862615173264, 0.052605084357724555, 0.059873791192685544, 0.06745464998977943, 0.07445967161346546, 0.07990706191329973, 0.08501030772196805, 0.08831648186392346, 0.0912188599838367, 0.09360491422965703], [0.9530029244099963, 0.9412507370623887, 0.9289834836726805, 0.9169977913940456, 0.9052670132045227, 0.8943615365728974, 0.8826353778659437, 0.870686183185412, 0.8593330096858441, 0.8477348339938899  …  0.6173876135065135, 0.6126216689133644, 0.6077949823395763, 0.6016151303194696, 0.595850113915989, 0.5917359752870887, 0.5869870510160544, 0.5824601735432793, 0.5773979692692681, 0.5741335803869092]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 765.8054478844709, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.02673256201912918, 0.024705800348828136, 0.022944662757018834], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.18053547452426902, 0.16696654987763235, 0.15133073059929864]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 761.8894550923188, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.027322987303471588, 0.027669162866376464, 0.029281493592677926], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.1833376820010324, 0.17471611181806135, 0.16676525979259674]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 771.9148133296372, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.027072973109084783, 0.025393240974072213, 0.024637908025146756], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.1815737242377784, 0.16718317536439595, 0.15250545000538807]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.315910912492375, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.01321527539704484, 5.929925804283048, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.178007561778246, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002055334088681571, 5.9854434419950255, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.010576215249564041, 5.75180246828971, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.6539338779602675, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.202764149197742, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.0098877179329567, 5.731388995291626, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.321025490438124, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.009275187214722525, 5.633834318410182, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 754.4812937917358, 0.0, (50,), ([0.009471390500860582, 0.010301096362104084, 0.010021796172312032, 0.00903546307380029, 0.008280031384006912, 0.009374798553259144, 0.008890592360825157, 0.009587600160369535, 0.010712920284446849, 0.012868332983497256  …  0.040907921060119305, 0.0441680051421101, 0.04941206004730382, 0.05486173276141522, 0.0609079873395559, 0.06583446351921383, 0.06923278388187526, 0.07300122544161841, 0.07470543856104667, 0.07540069769229661], [0.9531988070709899, 0.9408530198856087, 0.9291154467525315, 0.9171545698144828, 0.904744741462728, 0.8932237805036222, 0.8821197248205548, 0.8704030919355874, 0.85778890878477, 0.8449168270400395  …  0.5320604198140365, 0.5236484723776907, 0.5152332010447394, 0.5065735548293604, 0.49896425799954663, 0.4920959017607964, 0.48551083969099124, 0.4805170228670787, 0.47503592048690596, 0.4694492157037852]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 769.6418413189031, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.02625026730176542, 0.02570842870609435, 0.02458062118484226], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.1815908023842, 0.16822558019024478, 0.15310581128180156]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.017886790604528295, 3.1807094492551333, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.020256645999493283, 5.312665431312208, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 757.2620167103214, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.01737078519594209, 0.018823963731136546, 0.019102601835818477, 0.02064869626124909, 0.021153384069184555, 0.0206898022959792, 0.018565416222577055, 0.01608397343320001, 0.014029028648331153, 0.011140433458427338], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.24464024765354994, 0.223617952864616, 0.20354997837400537, 0.18177565507446397, 0.16129722232783328, 0.14110308847843847, 0.12299178530706092, 0.10509977465871714, 0.08707623929901047, 0.06901653654231892]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.315910912492375, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.01321527539704484, 5.929925804283048, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.178007561778246, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002055334088681571, 5.9854434419950255, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.010576215249564041, 5.75180246828971, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.6539338779602675, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.202764149197742, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.0098877179329567, 5.731388995291626, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.321025490438124, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.009275187214722525, 5.633834318410182, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 756.4023156204445, 0.0, (50,), ([0.009471390500860582, 0.010301096362104084, 0.010021796172312032, 0.00903546307380029, 0.008280031384006912, 0.009374798553259144, 0.008890592360825157, 0.009587600160369535, 0.010712920284446849, 0.012868332983497256  …  0.040907921060119305, 0.0441680051421101, 0.04941206004730382, 0.05486173276141522, 0.0609079873395559, 0.06583446351921383, 0.06923278388187526, 0.07132125909592818, 0.07252492645654451, 0.07437794963705287], [0.9531988070709899, 0.9408530198856087, 0.9291154467525315, 0.9171545698144828, 0.904744741462728, 0.8932237805036222, 0.8821197248205548, 0.8704030919355874, 0.85778890878477, 0.8449168270400395  …  0.5320604198140365, 0.5236484723776907, 0.5152332010447394, 0.5065735548293604, 0.49896425799954663, 0.4920959017607964, 0.48551083969099124, 0.4794414715967138, 0.4731025551582491, 0.4682690388608471]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 770.2099722884567, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.026388473610556865, 0.026378018345369677, 0.026173210593143523], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.18284122817618823, 0.17004041480753637, 0.15802673004266649]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 771.8212960302093, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.026975777254081262, 0.02622627239944952, 0.025837234744007544], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.18232949213090005, 0.16858676921780857, 0.15421458218597772]))
 ⋮
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.315910912492375, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.01321527539704484, 5.929925804283048, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.178007561778246, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002055334088681571, 5.9854434419950255, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.010576215249564041, 5.75180246828971, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.6539338779602675, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.202764149197742, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.0098877179329567, 5.731388995291626, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.321025490438124, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.009275187214722525, 5.633834318410182, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 756.4137039061909, 0.0, (50,), ([0.009471390500860582, 0.010301096362104084, 0.010021796172312032, 0.00903546307380029, 0.008280031384006912, 0.009374798553259144, 0.008890592360825157, 0.009587600160369535, 0.010712920284446849, 0.012868332983497256  …  0.040907921060119305, 0.0441680051421101, 0.04941206004730382, 0.05486173276141522, 0.0609079873395559, 0.06583446351921383, 0.06923278388187526, 0.07084562322005447, 0.07238570923447599, 0.07420073795558868], [0.9531988070709899, 0.9408530198856087, 0.9291154467525315, 0.9171545698144828, 0.904744741462728, 0.8932237805036222, 0.8821197248205548, 0.8704030919355874, 0.85778890878477, 0.8449168270400395  …  0.5320604198140365, 0.5236484723776907, 0.5152332010447394, 0.5065735548293604, 0.49896425799954663, 0.4920959017607964, 0.48551083969099124, 0.47934681743884944, 0.47372022643157885, 0.46929136669618987]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.379004695511222, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.016353607566584567, 4.498975893907469, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.643761595222026, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027854269676010597, 5.474959666670038, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018799961015994925, 5.86906967184306, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.337992081227702, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.348897999621789, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.01831057962293956, 5.682130583823012, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.226298928259002, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.016704871342468, 5.988636918475419, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 771.6648074835804, 0.0, (50,), ([0.0040224943338492735, 0.005112210898571744, 0.006448026415816911, 0.007868159181392555, 0.00982924742383088, 0.010513459040139166, 0.010834200574807969, 0.012782585734075307, 0.015242811198692429, 0.01601998776082449  …  0.020282870324530095, 0.021659602294751168, 0.024682797721419705, 0.025879469149701743, 0.027061671839625493, 0.028101645386374788, 0.027695160986826114, 0.027504503046791834, 0.02667854071843499, 0.025887440759014852], [0.9417693786812488, 0.9282875332526842, 0.9150876177016654, 0.9025539994180349, 0.8879047378581626, 0.8734658702239445, 0.8575127481975594, 0.8397423741241844, 0.821785689091864, 0.8037059060696146  …  0.2813227142166447, 0.26658369927521713, 0.2512038535209856, 0.23679534252865359, 0.2223053891532071, 0.2084895819768693, 0.19526710063457658, 0.18331178811983873, 0.17110037248867013, 0.15903016267933148]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.315910912492375, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.01321527539704484, 5.929925804283048, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.178007561778246, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002055334088681571, 5.9854434419950255, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.010576215249564041, 5.75180246828971, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.6539338779602675, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.202764149197742, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.0098877179329567, 5.731388995291626, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.321025490438124, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.009275187214722525, 5.633834318410182, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 755.8214511751147, 0.0, (50,), ([0.009471390500860582, 0.010301096362104084, 0.010021796172312032, 0.00903546307380029, 0.008280031384006912, 0.009374798553259144, 0.008890592360825157, 0.009587600160369535, 0.010712920284446849, 0.012868332983497256  …  0.040907921060119305, 0.0441680051421101, 0.04941206004730382, 0.05486173276141522, 0.0609079873395559, 0.06583446351921383, 0.06923278388187526, 0.07250151215967345, 0.073929312975278, 0.07436714745793933], [0.9531988070709899, 0.9408530198856087, 0.9291154467525315, 0.9171545698144828, 0.904744741462728, 0.8932237805036222, 0.8821197248205548, 0.8704030919355874, 0.85778890878477, 0.8449168270400395  …  0.5320604198140365, 0.5236484723776907, 0.5152332010447394, 0.5065735548293604, 0.49896425799954663, 0.4920959017607964, 0.48551083969099124, 0.4779616339152334, 0.47025105563317343, 0.46197769153315016]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.295579489531342, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013959158310033434, 3.201697284341314, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.9680448326865148, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.003670381180378411, 5.8726440371509785, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.0031855301738570926, 5.42791280861486, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.6243797187149234, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.378998249808009, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.0021263758535027787, 5.696892755594144, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.158345364812688, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.009900346425192157, 5.88978953515732, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 769.8075760477379, 0.0, (50,), ([0.008135898898737476, 0.009564879458516671, 0.011140322560019273, 0.011233064545191854, 0.011750913069839422, 0.011918302002570911, 0.011551422940568849, 0.012298635419528374, 0.013234703771293134, 0.01478688573736426  …  0.04553862615173264, 0.052605084357724555, 0.059873791192685544, 0.06745464998977943, 0.07445967161346546, 0.07990706191329973, 0.08501030772196805, 0.087650884228216, 0.08986946484805537, 0.09288794875158289], [0.9530029244099963, 0.9412507370623887, 0.9289834836726805, 0.9169977913940456, 0.9052670132045227, 0.8943615365728974, 0.8826353778659437, 0.870686183185412, 0.8593330096858441, 0.8477348339938899  …  0.6173876135065135, 0.6126216689133644, 0.6077949823395763, 0.6016151303194696, 0.595850113915989, 0.5917359752870887, 0.5869870510160544, 0.5828946226857092, 0.5776483614326289, 0.5714346295710131]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.2159944722851685, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.007553818707294857, 5.486602766576365, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 3.7521162073493235, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.002187185105572294, 5.6591976169846845, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.014629382988583253, 5.986648733854975, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.7435429671496125, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.098242253910592, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.014563534496990976, 3.392565399054614, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 3.768868487623201, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.008674769337387664, 5.638939289978644, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 759.4656928302174, 0.0, (50,), ([0.008301110437495908, 0.00974838602765443, 0.010717182697942326, 0.011450581766285781, 0.012668869041905902, 0.013199829751225104, 0.015181853668299883, 0.015942502048049947, 0.017281545186820863, 0.01813926153531577  …  0.041629476446746506, 0.04800955079565783, 0.05267007530218704, 0.05818962668467203, 0.062491296865157156, 0.06566989699029209, 0.06812518677508618, 0.06956027401343244, 0.06933875357523664, 0.06927627941059315], [0.9555582760564373, 0.9462678076180202, 0.9376103170442955, 0.9278089107713144, 0.9185669316381287, 0.9108730658127158, 0.9044297368115409, 0.8988051412363474, 0.8925759721104949, 0.8860243649369604  …  0.54302598840288, 0.5276082271740938, 0.5121213699580324, 0.4974394911391269, 0.4832497563183713, 0.4689212634838824, 0.45741921940704383, 0.4474481573520014, 0.4383976653118189, 0.4291071783242405]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.206059489566105, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013222760750379082, 5.421549769113944, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.376527988690471, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.003025983622300538, 5.9856309927116556, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.011749130412997333, 5.9858696759669145, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.664071580252239, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.36304278852371, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.011672357112813614, 5.004523409332757, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.378251311363106, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.01504525487121885, 5.592278296888024, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 752.8163563129402, 0.0, (50,), ([0.006224364876384997, 0.008692722963189663, 0.010298334182095973, 0.011897442646674604, 0.012427256725123573, 0.012179440552433526, 0.011961602033784553, 0.012639770937544998, 0.01507776878484774, 0.01669460871390882  …  0.027796605746811448, 0.032956782510917604, 0.03742757256073143, 0.041715392897302625, 0.04533657944578127, 0.04731677408469418, 0.04975889416414493, 0.050345075918487935, 0.049630709948961946, 0.04993838330607888], [0.954159744752834, 0.9387921722494047, 0.924818610450493, 0.9114173307788666, 0.8954886057289163, 0.8788338869157813, 0.86338431010389, 0.8488076373252966, 0.8337539355027382, 0.819466029713725  …  0.4130054534222807, 0.4034872985267609, 0.39241685468802767, 0.38071007983017574, 0.3691237747549804, 0.3562238892400438, 0.342008494606597, 0.32864557337612993, 0.31605204558911826, 0.30423710670379583]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.356201775707459, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.02112160049580274, 5.827680325520092, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.047204628666792, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.001893762257688182, 5.805617234023655, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.018482602123108104, 5.941590607348988, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 4.359733747659633, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.316221958616199, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.018789933014586577, 3.390615425795132, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.293465655182428, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.017226499035905934, 5.978859501554055, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 773.5314290220472, 0.0, (50,), ([0.007379522439335427, 0.008149031920435337, 0.009418502027987514, 0.009813893872302571, 0.010555677853812374, 0.011719706656030865, 0.01242019104740584, 0.012872657831275135, 0.013972384232430498, 0.014789270136747691  …  0.014343305458069399, 0.014649673989146605, 0.014522789584386953, 0.014618481211273768, 0.015248373631026513, 0.01469511808981161, 0.012566692260184737, 0.00994878870356703, 0.007502860960049913, 0.0060002407111381766], [0.96273327606403, 0.9410081030571642, 0.9198110387922136, 0.8998085810440777, 0.8789065003881013, 0.857694198395394, 0.8370854416747251, 0.8165508308401404, 0.794882844249628, 0.7731935529572513  …  0.18468525325408325, 0.1663825692639509, 0.14867309872750165, 0.13175036531880477, 0.11530565693879322, 0.09936693639479606, 0.08359783714619096, 0.06755060737952416, 0.051347969385364886, 0.03570556394136643]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.206059489566105, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.013222760750379082, 5.421549769113944, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.374478306648723, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0027964741721891325, 5.986838199489011, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.006438208439839163, 5.97211790881512, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.4305913682192624, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.36304278852371, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.006255458134983911, 5.9883760090891, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 4.348509408717581, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.014376374932641739, 5.687842664802077, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 765.5408321037085, 0.0, (50,), ([0.006224364876384997, 0.008692722963189663, 0.010298334182095973, 0.011897442646674604, 0.012427256725123573, 0.012179440552433526, 0.011961602033784553, 0.012639770937544998, 0.01507776878484774, 0.01669460871390882  …  0.03513451568520625, 0.03944262389563918, 0.04357412244846687, 0.047760624062481556, 0.05253406135022735, 0.05628261821069041, 0.05940541191358666, 0.061641646809099414, 0.061494301791075914, 0.06224164946852955], [0.954159744752834, 0.9387921722494047, 0.924818610450493, 0.9114173307788666, 0.8954886057289163, 0.8788338869157813, 0.86338431010389, 0.8488076373252966, 0.8337539355027382, 0.819466029713725  …  0.47486181559920904, 0.4631144991397099, 0.4509658612468553, 0.43866017114988304, 0.42840578153907893, 0.4187305606024606, 0.4102224776755154, 0.4013011422822563, 0.393091433364097, 0.38647424016873083]))
 Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}(DynamicDSLFunction{Any}(Dict{Symbol, Any}(), Dict{Symbol, Any}(), Type[Int64], false, Union{Nothing, Some{Any}}[nothing], Main.var"##model#396", Bool[0], false), Trie{Any, Gen.ChoiceOrCallRecord}(Dict{Any, Gen.ChoiceOrCallRecord}((:z, 4) => Gen.ChoiceOrCallRecord{Float64}(1.559863392211382, 4.327878819516771, NaN, true), (:vy, 10) => Gen.ChoiceOrCallRecord{Float64}(-0.01653183295841775, 5.958628107750171, NaN, true), (:z, 26) => Gen.ChoiceOrCallRecord{Float64}(1.5616539074102593, 4.124557138051114, NaN, true), (:vx, 27) => Gen.ChoiceOrCallRecord{Float64}(-0.0009548618555461511, 5.063994272611979, NaN, true), (:vy, 32) => Gen.ChoiceOrCallRecord{Float64}(-0.017103844882937203, 5.949901331587278, NaN, true), (:z, 30) => Gen.ChoiceOrCallRecord{Float64}(1.5782692403807541, 3.520281829332453, NaN, true), (:z, 7) => Gen.ChoiceOrCallRecord{Float64}(1.5568099906364763, 4.351450344357003, NaN, true), (:vy, 31) => Gen.ChoiceOrCallRecord{Float64}(-0.016824863112241746, 4.167645739287022, NaN, true), (:z, 17) => Gen.ChoiceOrCallRecord{Float64}(1.542795237740617, 3.6693718350234326, NaN, true), (:vy, 21) => Gen.ChoiceOrCallRecord{Float64}(-0.015157399481294177, 5.909469862542606, NaN, true)…), Dict{Any, Trie{Any, Gen.ChoiceOrCallRecord}}()), false, 753.5046115503926, 0.0, (50,), ([0.011337568227404803, 0.012722148690404037, 0.01262673493591519, 0.011626947906443365, 0.011131130821731358, 0.011584469129457013, 0.012077684408286958, 0.012566872039384561, 0.013871473862773102, 0.015321148685820157  …  0.018618229556265315, 0.020867999103866004, 0.022890285681846225, 0.025303366309263307, 0.02650073132345644, 0.026273575957098016, 0.024992972243989338, 0.02316589741813232, 0.021478846866721732, 0.019454453437646124], [0.963199359771068, 0.9442982579800068, 0.9261272634541826, 0.9082355788381649, 0.8877722894710091, 0.8674413359954736, 0.8481294947066808, 0.8284463981649389, 0.810650146109453, 0.7943640310300236  …  0.28622334777145914, 0.26614140593503377, 0.24507759368416662, 0.22406338944164958, 0.20557016488513813, 0.18682669539722657, 0.16948312625623696, 0.15054629233150396, 0.1331799352762456, 0.11629364816633282]))

We render the traces:

overlay(render, pf_rejuv_traces)
title!("Rejuvenation with resimulation MH on the starting points")
Example block output

<!– @gen function perturbationproposal(prevtrace, a::Int, b::Int) choices = getchoices(prevtrace) (T,) = getargs(prevtrace) speed = Array{Float64}(undef, 2, 1) for t=a:b speed[1] = {(:vx, t)} ~ normal(choices[(:vx, t)], 1e-3) speed[2] = {(:vy, t)} ~ normal(choices[(:vy, t)], 1e-3) end return speed end

function perturbationmove(trace, a::Int, b::Int) Gen.metropolishastings(trace, perturbation_proposal, (a, b)) end; –>

Speeding Up Inference Using the Unfold Combinator

For the particle filtering algorithms above, within an update step it is only necessary to revisit the most recent state (or the most recent 5 states if the rejuvenation moves are used) because the initial states are never updated, and the contribution of these states to the weight computation cancel.

However, each update step of the particle filter inference programs above scales linearly in the size of the trace because it visits every state when computing the weight update. This is because the built-in modeling DSL by default always performs an end-to-end execution of the generative function body whenever performing a trace update. This allows the built-in modeling DSL to be very flexible and to have a simple implementation, at the cost of performance. There are several ways of improving performance after one has a prototype written in the built-in modeling DSL. One of these is Generative Function Combinators, which make the flow of information through the generative process more explicit to Gen, and enable asymptotically more efficient inference programs.

To exploit the opportunity for incremental computation, and improve the scaling behavior of our particle filter inference programs, we will write a new model using a generative function combinator to replaces the following Julia for loop in our model.

    # generate successive states and measurements
    for t=1:T

        # update the state of the point
        vx = {(:vx, t)} ~ normal(vx, sqrt(velocity_var))
        vy = {(:vy, t)} ~ normal(vy, sqrt(velocity_var))
        x += vx
        y += vy

        # bearing measurement
        {(:z, t)} ~ normal(bearing(x, y), measurement_noise)

        # record position
        xs[t+1] = x
        ys[t+1] = y
    end

This for loop has a very specific pattern of information flow&mdash;there is a sequence of states (represented by x, y, vx, and vy), and each state is generated from the previous state. This is exactly the pattern that the Unfold generative function combinator is designed to handle.

Below, we re-express the Julia for loop over the state sequence using the Unfold combinator. Specifically, we define a generative function (kernel) that takes the prevous state as its second argument, and returns the new state. The Unfold combinator takes the kernel and returns a new generative function (chain) that applies kernel repeatedly. Read the Unfold combinator documentation for details on the behavior of the resulting generative function (chain).

struct State
    x::Float64
    y::Float64
    vx::Float64
    vy::Float64
end

@gen (static) function kernel(t::Int, prev_state::State,
                              velocity_var::Float64, measurement_noise::Float64)
    vx ~ normal(prev_state.vx, sqrt(velocity_var))
    vy ~ normal(prev_state.vy, sqrt(velocity_var))
    x = prev_state.x + vx
    y = prev_state.y + vy
    z ~ normal(bearing(x, y), measurement_noise)
    next_state = State(x, y, vx, vy)
    return next_state
end

chain = Gen.Unfold(kernel)

Gen.@load_generated_functions # To allow use of the generative function written in the static modeling language above.
┌ Warning: `Gen.@load_generated_functions` is no longer necessary and will be removed in a future release.
└ @ Gen ~/work/Gen.jl/Gen.jl/src/Gen.jl:33

We can understand the behavior of chain by getting a trace of it and printing the random choices:

trace = Gen.simulate(chain, (4, State(0., 0., 0., 0.), 0.01, 0.01)) Gen.get_choices(trace)

We now write a new version of the generative model that invokes chain instead of using the Julia for loop:

@gen (static) function unfold_model(T::Int)

    # parameters
    measurement_noise = 0.005
    velocity_var = 1e-6

    # initial conditions
    x0  ~ normal(0.01, 0.01)
    y0  ~ normal(0.95, 0.01)
    vx0 ~ normal(0.002, 0.01)
    vy0 ~ normal(-0.013, 0.01)

    # initial measurement
    z0 ~ normal(bearing(x0, y0), measurement_noise)

    # record initial state
    init_state = State(x0, y0, vx0, vy0)

    # run `chain` function under address namespace `:chain`, producing a vector of states
    chain ~ chain(T, init_state, velocity_var, measurement_noise)

    result = (init_state, chain)
    return result
end

Gen.@load_generated_functions

Let's generate a trace of this new model program to understand its structure:

(trace, _) = Gen.generate(unfold_model, (4,))
Gen.get_choices(trace)

We can now run a particle filter on the Unfold model and see a speedup:

function unfold_particle_filter(num_particles::Int, zs::Vector{Float64}, num_samples::Int)
    init_obs = Gen.choicemap((:z0, zs[1]))
    state = Gen.initialize_particle_filter(unfold_model, (0,), init_obs, num_particles)
    
    for t=1:length(zs)-1
        maybe_resample!(state, ess_threshold=num_particles/2)
        obs = Gen.choicemap((:chain => t => :z, zs[t+1]))
        Gen.particle_filter_step!(state, (t,), (UnknownChange(),), obs)
    end

    # return a sample of traces from the weighted collection:
    return Gen.sample_unweighted_traces(state, num_samples)
end

@time unfold_pf_traces = unfold_particle_filter(5000, zs, 200);

function unfold_render(trace; show_data=true, max_T=get_args(trace)[1], overlay=false)
    (T,) = Gen.get_args(trace)
    choices = Gen.get_choices(trace)
    (init_state, states) = Gen.get_retval(trace)
    xs = Vector{Float64}(undef, T+1)
    ys = Vector{Float64}(undef, T+1)
    zs = Vector{Float64}(undef, T+1)
    xs[1] = init_state.x
    ys[1] = init_state.y
    zs[1] = choices[:z0]
    for t=1:T
        xs[t+1] = states[t].x
        ys[t+1] = states[t].y
        zs[t+1] = choices[:chain => t => :z]
    end
    f = overlay ? scatter! : scatter
    fig = f(xs[1:max_T+1], ys[1:max_T+1], msize=3, msw=1, label=nothing)
    if show_data
        for z in zs[1:max_T+1]
            dx = cos(z) * 0.5
            dy = sin(z) * 0.5
            plot!([0., dx], [0., dy], color="red", alpha=0.3, label=nothing)
        end
    end
end

Let's check that the results are reasonable:

overlay(unfold_render, unfold_pf_traces, same_data=true)

We now empirically investigate the scaling behavior of

  1. the inference program that uses the Julia for loop (particle_filter),

and

  1. the equivalent inference program that uses Unfold

(unfold_particle_filter).

We will use a synthetic long vector of z data, and we will investigate how the running time depends on the number of observations.

fake_zs = rand(1000);

function timing_experiment(num_observations_list::Vector{Int}, num_particles::Int, num_samples::Int)
    times = Vector{Float64}()
    times_unfold = Vector{Float64}()
    for num_observations in num_observations_list
        println("evaluating inference programs for num_observations: $num_observations")
        tstart = time_ns()
        traces = particle_filter(num_particles, fake_zs[1:num_observations], num_samples)
        push!(times, (time_ns() - tstart) / 1e9)
        
        tstart = time_ns()
        traces = unfold_particle_filter(num_particles, fake_zs[1:num_observations], num_samples)
        push!(times_unfold, (time_ns() - tstart) / 1e9)
        
    end
    (times, times_unfold)
end;

num_observations_list = [1, 3, 10, 30, 50, 100, 150, 200, 500]
(times, times_unfold) = timing_experiment(num_observations_list, 100, 20);

Notice that the running time of the inference program without unfold appears to be quadratic in the number of observations, whereas the inference program that uses unfold appears to scale linearly:

plot(num_observations_list, times, color="blue", 
    xlabel="# observations", ylabel="running time (sec.)", label="for loop")
plot!(num_observations_list, times_unfold, color="red", label="unfold")
  • 1Doucet, Arnaud, Nando De Freitas, and Neil Gordon. "An introduction to sequential Monte Carlo methods." Sequential Monte Carlo methods in practice. Springer, New York, NY, 2001. 3-14.
  • 2Del Moral, Pierre, Arnaud Doucet, and Ajay Jasra. "Sequential Monte Carlo samplers." Journal of the Royal Statistical Society: Series B (Statistical Methodology) 68.3 (2006): 411-436.
  • 3Neal, Radford M. "Annealed importance sampling." Statistics and computing 11.2 (2001): 125-139.
  • 4Gilks, Walter R., and Carlo Berzuini. "Following a moving target—Monte Carlo inference for dynamic Bayesian models." Journal of the Royal Statistical Society: Series B (Statistical Methodology) 63.1 (2001): 127-146. PDF