Oxford, January 2024
Arnau Quera-Bofarull
www.arnau.ai
Pros:
"cheap",
simple,
...
Cons:
only models "averages",
...
Pros:
individual agents,
individual interactions,
...
Cons:
computational cost,
calibration,
...
Typically hard because
Knoblauch et al (2019)
ABM
Prior
(Generalized) posterior
Optimization problem
Assume posterior approximated by variational family
Distance between ABM output and data
Divergence posterior - prior
Choose parametric family of distributions (e.g., Normal)
Need to compute the gradient
Score function estimator
Monte Carlo
gradient estimation
Mohamed et al (2020)
Path-wise estimator
Reparameterization
Score function estimator
Path-wise estimator
"Gradient assisted calibration of financial agent-based models" Dyer et al. (2023)
Inaccurate
def f(x1)
t1 = x1 * x1
t2 = t1 * t1
return t2 * t2
2
4
16
256
Idea:
Decompose program into basic operations that we can differentiate
Reverse mode AD
2
4
16
256
Forward mode AD
2
4
16
256
Reverse mode AD
2
4
16
256
Forward mode AD
2
4
16
256
Multiple outputs
def f(x1)
t1 = x1 * x1
t2 = t1 * t1
return [t2, t2, t2]
Reverse needs 3 full model evaluations!
Forward can amortize
Multiple inputs
def f(x1, x2, x3)
t1 = x1 * x2 * x3
t2 = t1 * t1
return t2 * t2
Forward needs 3 full model evaluations!
Reverse can amortize
Reverse mode preferred for deep learning
However
Quera-Bofarull et al. "Some challenges of calibrating differentiable agent-based models"
Reverse mode needs to store computational graph!
Can blow up in memory
Just assign a gradient of 1.
Works if program is linear
Bengio et al. (2013)
Jang et al. (2016)
Bias vs Variance tradeoff
StochaticAD.jl -- Arya et al. (2022)
Unbiased!
arnau.ai/blackbirds
Multiple examples of differentiable ABMs in PyTorch and Julia
JUNE epidemiological model
Reverse-mode gives us senstivity analysis for free
Generalized Variational Inference promising route to calibrate differentiable ABMs.
Differentiable ABMs can be built using Automatic Differentiation
Automatic Differentiation provides O(1) sensitivity analysis.
Slides and papers:
www.arnau.ai/talks
Diff ABM examples:
www.arnau.ai/blackbirds
function f(x1)
t1 = x1 * x1
t2 = t1 * t1
return t2 * t2
end
Hard-code calculus 101 derivatives
Recurrently go down the tree via chain rule
Inefficient representation
Exact result