What is the easiest way to implement Dynamical Block State Selection (DBSS) within ITensor's DMRG function call?

That is, I want to set the maximum number of states kept, M, based on a property of the density matrix at the middle of a 1D chain for each sweep. This requires setting M in real time rather than reading it in as a constant value.

This technique is, for instance, described in Schollwock's dmrg review article from 2005.

Also, I have the related question: How is the truncation value used when it is supplied to dmrg() in a sweeps object?

To review what I know: during a sweep and at a particular bond, the density matrix is formed from the previous MPS, and subsequently truncated (to dimension M) before a new site is added. The truncation error should be the difference between the sum of density matrix eigenvalues before and after the truncation. In my calculations, I have set limits on truncation error, M, and energy precision (sweep to sweep), and my (default) dmrgObserver is outputting the truncation error, the cutoff M, and the energy; Sometimes the output M is less than the value requested, meaning dmrg() selected a lower value than the input value, while other times M maxes out and truncation error also maxes out. I haven't studied my raw data files to check all of this, but it seems like dmrg() is picking whichever limit applies (if truncation is not reached, then M gets maxed out; if truncation is reached before M, then M does not max out). This implies it should be possible to alter the comparison function on the truncation error, but I don't know whether this would be in the dmrg() function or in the observer function.

Thanks!

Jon