chenwilliam77 / RiskAdjustedLinearizations.jl

Linearize dynamic economic models around their stochastic steady state
https://chenwilliam77.github.io/RiskAdjustedLinearizations.jl/dev/
Other
10 stars 3 forks source link

Figure out how to robustly choose the chunk size #12

Open chenwilliam77 opened 3 years ago

chenwilliam77 commented 3 years ago

To use ForwardDiff during nlsolve for either the homotopy or relaxation algorithms, we need to choose the chunk size appropriately so that, when re-interpreting arrays to be able to use caches, we will not get a "cannot reinterpret" error b/c "the resulting array would have non-integral first dimension." The problem is that different caches have different sizes (sometimes it's a vector and sometimes a matrix) and the inputs have different lengths, depending on whether you want to use homotopy or relaxation. The input variables are z, y, and/or Psi, which have dimensions Nz, Ny, and Nz * Ny, respectively. For homotopy, all three are inputs, but for relaxation, only z and y will be inputs. My understanding of chunk sizes doesn't seem to be entirely correct, so I'm having difficulty.

One approach is, whenever using homotopy or relaxation, we add an option to recalculate the chunk size so we can specialize for homotopy and relaxation.

chenwilliam77 commented 3 years ago

ForwardDiff2, whenever it comes out, should hopefully address this problem.