CachingMethod
New to Analytica 4.2
This features requires Analytica Enterprise
Attribute CachingMethod
When the results for variables are computed, Analytica automatically saves these results in memory so they don't need to be recomputed again later when they get used or viewed again. Analytica carries out this caching and dependency maintanence automatically, and you seldom have to worry about it. This represents a core feature of Analytica, is it provides many benefits, see Controlling When Result Values Are Cached.
Caching of results, however, has the downside that it consumes memory in order to store those computed results. When you are running low on memory, this may limit the size of the computations that you are able to carry out with your model. The CachingMethod attribute allows you to exert some control over which variables consume memory.
Accessing the CachingMethod attribute
You can only access the CachingMethod attribute from Analytica Enterprise. In addition, to access it, you must turn it on from the Attributes dialog. Follow these steps:
- Select Edit→Attribute... on the menu to bring up the Attributes dialog.
- With Variable selected, scroll down to locate CachingMethod
- Double click on CachingMethod to make a check mark appear next to it.
- Press OK
With this checked, CachingMethod will appear on the attribute selection pulldown in the attribute pane at the bottom of diagrams. (It does not appear in object windows). To set the attribute for a particular variable, enter edit mode, click on the variable to select it, open the attribute pane at the bottom of the diagram, and select CachingMethod on the attribute selection pulldown.
Possible Settings
The CachingMethod attribute, if set, must be set to a single integer value. The following are the possible values: 0 = Analytica's default (this is Always cache) 1 = Always cache result 2 = Never cache result 3 = Release cached result after all children are fully computed These values apply to both cached mid-value and sample-value results.
You can also separately control how mid and sample values are cached. Basically, Analytica looks at bits 1-4 (the four least significant bits) of the integer value for the Mid-value setting, and at bits 5-8 for the prob-value setting. If bits 5-8 are all zero, then the prob-value uses the same configuration as the mid-value. If bits 5-8 contain a "2" (as is the case with the value 32 = 001000002), then the prob-value is set to never-cache. This scheme results in the following meaningful configurations:
18 = Always cache sample, Never cache mid 19 = Always cache sample, release mid 33 = Never cache sample, always cache mid 35 = Never cache sample, release mid 49 = Release sample, always cache mid 50 = Release sample, never cache mid
How it works
When a variable is set to CachingMethod=2, its value is never cached. This means that its definition must be reevaluated every time it is accessed.
When a variable is set to CachingMethod=3, then its value is cached until all children of that variable have been fully computed. Specifically, as soon as Analytica can prove that no child of the variable will need access to the cached value, Analytica releases the cached value, freeing up that memory. Simple numeric results are not released, since doing so does not reclaim any extra memory.
For more details, see Controlling When Result Values Are Cached.
Availability by Analytica Edition
To access the CachingMethod attribute, you must be using Analytica Enterprise, Analytica Optimizer, or ADE. It is only possible to change the value from these editions. The attribute's value can be changed in a button script (or a function called from a button script) in Analytica Power Player and AWP. The attribute cannot be viewed from the GUI from Analytica Professional or Analytica Player, although if you are running a model where the CachingMethod has been configured (i.e., by someone who built the model in Enterprise), the caching method will take effect when the model is evaluated in Analytica Professional, Analytica Player, or AWP.
Related Attributes
In order to track when child variables have been computed, and the dependencies of children across evaluation modes, the following two read-only attributes are used:
Att_EvalMode_Dep
This record dependency information for children of variable configured to release-cache (CachingMethod=3). The attribute only appears on variables whose parent has CachingMethod==3 (in either bits 1-4 or bits 5-8). The attribute is maintained by Analytica, and cannot be set by the user.
The attribute contains a tuple, where the odd-element contain parent variable identifiers, and the even elements contain integers encoding the nature of the dependency. The integers have the following possible values, or combinations of these values added together:
- 1 = Context
- 2 = Mid
- 4 = Sample
Suppose the Att_EvalMode_Dep value for Y is: [X,5]. This indicates that Y depends on both the context value of X and on the sample value of Y (5=4+1). From this we know that to compute Mid(Y), we need both Mid(X) and Sample(X). However, to compute Sample(Y), we only need Sample(X) -- not Mid(X). In this case, the cached value for Mid(X) is eligible to be released when Mid(Y) is fully computed.
Att_Computed_Relsd
This attribute is used to track values that have been computed but not cached, as can happen when CachingMethod=2 or CachingMethod=3. A variable with CachingMethod=3 needs to know when its children have been computed. If the child is configured with CachingMethod=2, then it can't tell that the value is computed by looking for a cached value. Instead, this attribute records that the result has been computed.
Possible values:
- 1 = Mid value has been computed and released
- 2 = Sample value has been computed and released
- 3 = Both Mid and Sample have been computed and released.
Enable comment auto-refresher