Preferences dialog/Turning off Domain acts as self index

< Preferences dialog
Revision as of 16:34, 30 March 2018 by Lchrisman (Talk | contribs) (What gets changed)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Domain acts as self index preference setting is a legacy setting that exists to provide backward compatibility with models created in Analytica 4.2 or earlier. In the Analytica 4.3 release, the Domain attribute was redesigned so as to eliminate inconsistencies with the original design and to expand the generality and uses of the Domain attribute. There are several features in Analytica that require the preference to be off, and we strongly recommend that you turn this preference off in your own models.

For most models, the preference can be turned off without any impact on the computations. However, that is not true of all models. If your model relies on the domain being the same the self index, then turning it off will alter the computations within your model. To test whether your model falls in the latter category, you can always just turn the preference off and compare results to see if anything changes.

If your model is impacted, you will need to change some of your variable Definitions. To make this easier, Analytica 5.1 has added a helper that will scan your model's Definitions looking for expressions that would be affected by the change, and rewrites them. The helper is able to handle most common cases, but is not guaranteed to be perfect, so you should save a copy of your model before and compare computed results after to be sure.

Using the conversion tool

To launch the automated helper, open the Preferences dialog in Analytica 5.1 or later, uncheck the Domain acts as self index preference and press OK. The following dialog appears

TurnOffDomainAsSelfIndex.png

Press Yes to run the helper. To turn it off without altering your model (for example to just test whether your model relies on the domain being the self index), press No. If you select No and turn it back on, you be back where you started. Cancel will leave the preference back on, but doesn't undo any other preference settings you just made in the dialog.

What gets changed

This section describes the changes that the auto-updater (helper) makes to Definitions in your model.

Identifier in index context

Sub-expressions in the Analytica expression language occur either in a value context or an index context. For example, in the expression A [ J = X ], the identifiers A and X occur in a value context, whereas J occurs in an index context. Whenever a function declares a parameter as an index, an expression passed to that parameter is in an index context.

The auto-updater finds objects that have a discrete domain, i.e., a domain that can serve as an index, and replaces occurrences of that identifier, A, in index contexts with Domain of A. One exception is that table indexes for DetermTables and ProbTables don't require modification.

Self-Choices

When a variable is defined as Choice( Self, ...), and All is selected, the resulting dimensionality differs depending on whether the Domain acts as self index preference is on or not. When on, the result is both the self index and the domain index. When off, it becomes the self index value, but is a distinct index from the domain index. Because of this, a simple replacement of the identifier, A, in index contexts with Domain of A isn't enough. For example, suppose X is a function of the choice A, and hence has A as an index when A is set to All but does not have A as an index when a single item is selected. Then for the expression

Sum( X, A )

to be equivalent after the preference is turned off, it would need to sum over index A when A is set to All, but would need to sum over Domain of A when A has a singleton selected.

When the choice variable, A, has a Copy from index domain, say from index J, the auto-updater changes A to a Choice( J, ...) so that the result is indexed by J when All is selected. Occurrences of A in index contexts are then changed to J. This preserves the equivalent computations, but the index in the results changes from being the A index to being the J index.

When the domain of a self-choice is not a copy-from-index domain, the auto-updater does not automatically transform the model. This is a case you would need to adjust yourself, if your model operates over A in a manner that is impacted.

See Also

Comments


You are not allowed to post comments.