Divide and Conquer (solve one endogenous state models faster)

VFI Toolkit can now use a ‘divide and conquer’ algorithm, specifically two-level monotonicity, to solve problems where aprime(a) is a monotone function (where next period endogenous state is weakly increasing in this period endogenous state).

This is faster and uses less memory than the default (pure discretization). It is now available in the baseline settings (finite horizon, possibly with decision variables d, exogenous markov states z, exogenous iid stats e).

You use it by setting
vfoptions.divideandconquer=1;
vfoptions.level1n=11;
The second of these controls how many points to use in the ‘first level’.

This brief pdf explains what two-level monotonicity does. It will allow you to solve value function problems faster and with less memory. It applies to all models where aprime(a) is a weakly increasing function (conditional on any d, z or e); which is borderline all models in economics. Currently only allows for one endogenous state.

This github repo has a few examples, which just differ by the combination of d, a, z in the model (they are largely copy-paste of some examples from the Intro to Life-Cycle Models). Each solves the value function twice: once with default (pure discretization) algorithm, and once with the divide-and-conquer algorithm. You can see that both give the same solution, but divide and conquer is faster.

In short, if you set
vfoptions.divideandconquer=1;
vfoptions.level1n=11;
then you can solve problems faster (and use bigger grids as memory is less of a bottleneck). You will only get the correct solution if your problem is montone, but almost all economics problems are (and you can always double-check by solving with default and comparing answers).

This divide-and-conquer algorithm, called ‘two-level monotonicity’ is basically just the ‘binary monotonicity’ idea of Gordon & Qiu (2018), but modified so that it performs on a GPU [theirs is very serial]. Thanks to Alessandro Di Nola for suggesting GQ2018 to me :smiling_face:


This will be properly documented later this year (2024). For now it is buyer-beware, I ran some tests and everything seems to work but it is not widely tested. It will be by late this year once it gets full documentation, but the speed ups and large grids it enables are very nice so wanted to make them available sooner rather than later.

1 Like

Wow, that’s great! Does it work also for models with semi-exogenous shocks?

Not yet, just the basics for now. Hopefully I can do semi-exogenous shocks in the later half of this year (conceptually I can’t see any issue, should work fine), but I am about to start teaching so won’t happen this side of July.

1 Like