Benchmark Models¶
How do you know a numerical solver returned the right answer? One way is to run
it on a problem whose answer you already know. The
skagent.models.benchmarks registry collects such problems: benchmark
dynamic programming models, most of them with an optimal policy known in closed
form. Each entry pairs a working DBlock with that
policy. A few models, such as the buffer-stock problem, carry no closed form and
serve instead for numerical validation against known limiting behavior. The
registry has three uses for anyone building or testing solvers with
scikit-agent.
Validation. To check a solver, compare its output against the closed-form
policy on a set of test states.
validate_analytical_solution() does exactly
this: it evaluates the analytical policy on a standard grid, checks feasibility
together with any model-specific identities, and returns a "PASSED" or
"FAILED" status with diagnostics on the consumption range.
Regression testing. The same comparison runs in the test suite, so a regression that breaks an analytical identity surfaces early.
Pedagogy. The closed forms retrace the development of dynamic optimization theory in roughly the order it was discovered. The runnable Benchmark Consumption Models walks through the economics model by model, with equations and plots; this page stays focused on what the registry contains and how to call it.
Roster¶
The models below split into two groups. Seven ship in the BENCHMARK_MODELS
registry, each reachable through
list_benchmark_models() by the short
registry key shown in the table. Those keys, such as D-1 or U-2, are
internal identifiers rather than names anyone uses at the whiteboard, so the
table leads with each model’s descriptive name. The remaining four models ship
as standalone modules.
Registry models (fetch with
get_benchmark_model() and the registry key):
Model |
Key |
Utility |
Income |
Closed form |
|---|---|---|---|---|
Finite-horizon log utility |
|
Log |
Wealth only |
Remaining-horizon MPC |
Infinite-horizon perfect foresight |
|
CRRA |
Constant \(y\) |
Linear in total wealth |
Blanchard mortality |
|
CRRA |
Constant \(y\) |
Same with \(s\beta\) |
Hall random walk |
|
Quadratic |
Stochastic[1] |
PIH annuity rule |
Log utility with permanent shocks (normalized) |
|
Log |
Geometric random walk |
\(c = (1-\beta)(m + h)\) |
Buffer stock |
|
CRRA |
Geometric random walk |
None (numerical only) |
Constrained perfect foresight |
|
CRRA |
Constant \(y\), binding constraint |
None (VFI reference policy) |
Standalone modules (not in BENCHMARK_MODELS):
Module |
Problem |
Closed form |
|---|---|---|
Fisher two-period |
CRRA Euler + budget |
|
PF with mortality and growth |
Linear in total wealth |
|
Same, normalized variables |
Linear in normalized wealth |
|
Reed (1979) renewable resource |
Constant escapement |
Using the Registry¶
Look up each entry by its registry key. The typical workflow is to fetch a model, evaluate its analytical policy, and validate a candidate solver against it:
from skagent.models.benchmarks import (
list_benchmark_models,
get_benchmark_model,
get_benchmark_calibration,
get_analytical_policy,
has_analytical_policy,
validate_analytical_solution,
)
list_benchmark_models()
# {'D-1': '...', 'D-2': '...', 'D-3': '...',
# 'U-1': '...', 'U-2': '...', 'U-3': '...', 'D-4': '...'}
block = get_benchmark_model("D-2")
calibration = get_benchmark_calibration("D-2")
# Closed-form entries expose an analytical policy; query before fetching.
if has_analytical_policy("D-2"):
policy = get_analytical_policy("D-2")
result = validate_analytical_solution("D-2", tolerance=1e-8)
result["validation"] # 'PASSED'
Models without a closed form report False from
has_analytical_policy(), and requesting
their analytical policy raises ValueError. The constrained D-4 model
instead provides a value-function-iteration reference policy through
get_reference_policy(). For the rest, solve
numerically with EulerEquationLoss and
maliar_training_loop(); see Algorithms Guide.
See Also¶
Benchmark Consumption Models is the runnable companion: a model-by-model tour that loads each closed-form policy, shows its equations, validates it on the standard grid, and plots the lesson each model teaches.
Models for the full API reference, including every registry helper and the standalone model modules.
Algorithms Guide for the numerical solvers used on models that have no closed form.