Expected Value Fn

Info for those interested in toolkit internals.

Previously, the toolkit always computed the expected next period value fn as EV=V.*pi_z.

I have changed this to use EV=V*pi_z.

The impact is that small models will be 1% slower for the value fn iteration, but large models are substantially faster and much larger models can be run due to avoiding out-of-memory errors.

Currently the change only impacts the markov z in models with standard endogenous states.

You can see a bunch of runtime tests that underlie the decision at:

Most users will notice no appreciable difference, except if you try solving a model with prod(n_z)>1000 in which case it will be much better.

PS. Obviously I am glossing over a bunch of details in how exactly the two are implemented, especially with relation to the way they handle -Inf in the value fn. But these details all just follow from trying to implement the two different .* vs *.

1 Like