Stage 2 · Understand
How DeltaRecon works
DeltaRecon starts from two recorded results and attributes the deviation between them to the single changes that lie between them. This page follows that path in four parts, explains how the search halves the history, and names the limits.
From two results to the attribution
Two results of the same model differ, and you want to know which changes to the model cause the deviation. DeltaRecon answers this from three things: the two results, each with its record; the history of the model between them, in which each change is one revision; and states of that history, which it computes and compares. The same input gives the same result each time.
The diagram shows the path in four parts. The list below it says what happens in each part.
-
Two recorded results
-
The changes in order
-
Search by halving
-
Attribution to single changes
search result
The path from two recorded results to the search result, in four parts. The line runs through them in this order; the list below the diagram describes each part.
-
Two recorded results
Every run leaves a record of what was computed with what: code, parameters and portfolio data. DeltaRecon takes the records of two runs, an older and a newer one, and reads from them on which revision of the model each result was computed. It then computes both states again and goes on only when each of them reproduces its recorded result.
-
The changes in order
DeltaRecon reads the history of the model between the two revisions and lists every change on its own, in the order in which it was made: the change manifest. The older result is state 0, and one further state follows after each change; the last state is the newer result. The example of the quick start has 32 changes and so 33 states.
-
Search by halving
DeltaRecon compares the first state with the last. Where they differ, it computes a state in the middle and compares each half on its own, and it goes on like this in every half that still differs. It does not compute a state it does not need: in the example it computes 17 of the 33 states.
-
Attribution to single changes
A half that still differs and holds a single change belongs to that change. For each such change the result names the signed sum of “state after the change minus state before it”. Understand the results reads the result of the example line by line.
How the search halves the history
The search judges a stretch of the history, an interval, by its two ends. It compares the state at the beginning of the interval with the state at its end, value by value: each quantity of each model point in each period on its own. The interval differs when at least one value differs by more than the tolerance. The tolerance profile sets the tolerance for each quantity; without one, every difference counts. Sums play no part in this judgement: an interval in which values differ counts as differing even where the differences add up to zero.
The first interval is the whole history, from state 0 to the last state. If its two ends agree, the search ends there. If they differ, the search computes the state in the middle and judges both halves, the earlier one first. A half whose ends agree is not divided further. A half that differs is halved again, and so on, until an interval holds a single change. That change gets the deviation of its interval.
You can narrow the search to a target: one or several quantities and a range of projection periods. The search then judges and sums only the values of the target. The demo of the quick start searches in the Bruttobeitrag, the gross premium, in the first five projection years.
The search has a counterpart that computes everything: the full walk, the command walk. It computes every state, one after the other, and compares each state with the state before it. Every change thus gets a comparison of its own, and the signed sums of all changes add up to the whole difference between the first and the last state. The price is the number of computations: one for each state, in the example 33, where the search computed 17. The full walk is the reference: a search finds the changes that deviate with fewer computations and does not replace it.
Limits
A search result says what the two results, the history and the chosen target establish, and nothing beyond that. Read it with these limits in mind.
-
Changes that cancel within one interval stay unseen
The search sees an interval only by its two ends. Two changes whose effects on the target cancel within one interval, such as a change and its revert, leave the ends of that interval equal, and the search does not divide it. Neither of the two then appears in the result. In the example this holds for changes 17 and 18 and for changes 19 and 20. Only the full walk sees such changes.
-
Small effects that exceed the tolerance only together
An interval can differ while neither of its halves does: each part stays below the tolerance, and only together they exceed it. The search then reports the interval as “not resolved” and attributes this part of the deviation to no change. It names the interval, not the cause inside it; in the example these are changes 25 to 28. The full walk judges every single change under the same tolerance, so a change that stays below it does not count as deviating there either. The search result holds a sum only for the changes it attributes, and none for an interval whose ends do not differ under the tolerance or that is not resolved; its sums therefore need not add up to the whole deviation. Understand the results shows the remainder of the example.
-
The order and the grain of the history decide
A deviation belongs to a change in the order of the history. Where two changes act together, their joint effect falls to the later one; another order could attribute differently, and DeltaRecon does not try another. The smallest unit is one revision of the main line of the history: a revision that alters several things at once is not split, and a side branch that was merged counts as one change, the merge. In the example that is change 6; the changes inside the branch are not told apart.
-
Only the target, and only what moves with the history
A search with a target says nothing about other quantities and other periods: a change that acts only outside the target does not appear. An input on which both results were computed stays fixed in every state. In the demo these are the portfolio data of release N, so the search does not show the effect of the change that alters the table of the model points. A difference that no revision of the history carries is not attributed: for example another version of the core of the engine, which is not part of the history. For the reference model these are the libraries modelx, pandas and numpy, and Python itself.
-
Ends that are not reproduced, states that do not run
Before it searches, DeltaRecon computes the first and the last state again. If one of them does not run or does not reproduce its recorded result, the search stops and attributes nothing. If a state in between does not run, the search divides the interval at the nearest state that does. The changes directly before and after a state that did not run cannot be separated: where they deviate, they get one deviation together.
Hint
The reference model and your own engine
The examples on this page come from the reference model. It demonstrates the mechanics and is not a valuation model; its portfolio is synthetic. With an engine of your own, DeltaRecon reaches the engine through its adapter. A fault of an engine or of its adapter can still end a command with a technical error text instead of a clear message; this is a known limit. What your engine must provide describes what an adapter has to provide.