Difference between revisions of "Error Messages/41035"

m
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
== Message Text ==
 
== Message Text ==
:<code>''Cyclic Dependency between variables.''</code>
+
 
::<code>''Va1 - Va2 - Va3 - Va4 - Va1''</code>
+
Syntax error:
 +
Cyclic Dependency between variables.<br>
 +
Va1 → <br>
 +
Va2 →  <br>
 +
Va3 <br>
 +
Va1
  
 
== Description ==
 
== Description ==
The definition of the first variable shown (<code>Va1</code> in the example) depends either directly or indirectly on itself.  This creates a cycle in the dependencies between variables, which would appear as a directed cycle in the influence diagram.
+
A cyclic dependency means there is a cycle or directed loop of dependencies. If there is only one variable mentioned in the list, it is because its definition refers to itself.  If there are more than one variables in the cycle, as in the example above, there is indirect dependency,
 
+
with the definition of the last variable depending on the first variable (<code>Va1</code> in the example) .  This creates a cycle in the dependencies between variables, which would appear as a directed cycle in the influence diagram.
A cycle between variables is not allowed, since the true definition of the variables in the cycle would then be ambiguous.
 
 
 
There are a few instances where directed cycles in a model may be legitimate.  Perhaps the most common case is where a variable's value at a given point in [[Time]] depends on its own values at earlier points in [[Time]].  This type of recurrence over time forms a cycle at the variable level, but not at the individual cell level, since the definition of each time slice of a variable depends only on earlier time slices, never on the same time slice.  You can model a recurrence of this type over the system index [[Time]] by using the function [[Dynamic]].
 
 
 
Another style of dependence can occur when your intention is for each variable to define its own "update" equation, with the intention that the variables in the cycle should be repeatedly evaluated until they converge to a fixed-point value.  You can accomplish this style of cyclic dependence using the [[Iterate]] function. 
 
 
 
Hard-core Excel users may find themselves encountering a third type of cyclic dependence, where the cells in a single table depend on other cells within the same table.  Because the cells exist in the same variable, this creates a cycle at the variable level.  You can create a table in which cells of the table depend on other cells in the same table in arbitrary ways (as long as they don't form a cell-level cycle).  To do this, you must change your [[Table]] definition into an [[IntraTable]] definition (by just editing the first word in the definition, changing "[[Table]]" to "[[IntraTable]]").  When it is at all possible, it is highly recommended that you avoid using this type of ''within-table'' cycle dependence.  It is usually avoidable, but stylistically it has many of the same downsides that plague spreadsheet models, and evaluation of that table is likely to be less efficient.
 
  
A fourth type of cyclic dependence can occur as a result of encoding constraints in a constraint satisfaction or optimization problem.  For example, in an economic equilibrium model, you might attempt to define supply as a function of price, and price as a function of supply. This type of cyclic dependency indicates that you are encoding the problem incorrectly for Analytica -- expressing it like you might in an algebraic modeling language, rather than in terms of constraints as expected by the Analytica optimizer. (to do: add additional elaboration on this elsewhere on the Wiki).
+
Analytica does not normally allow cycles, because they would lead to infinite loops. There are however some cases, where a directed cycle is valid:
  
A fifth type of cyclic dependency can occur when you want to create a recursive user-defined function.  However, this will generally result in a different error message, [[Error Messages/41036]].
+
# If the value of a variable at a given point in [[Time]] depends on its own values at a previous [[Time]] (or other Index). You can model this kind of recurrence using the function [[Dynamic]], which lets you define a variable <code>V</code> to depend on itself, <code>V</code>, or another variable that depends on <code>V</code> -- provided there is a time delay somewhere in the cycle, so that <code>V</code> depends on itself at an earlier [[Time]]. The dependency containing [[Dynamic]] and the time delay appears as a gray arrow in the influence diagram.  See  [[Dynamic]] for details.
 +
# Another style of cyclic dependence when you want to define a variable as a function of itself and iterate the computation until it converges  to a fixed value.  You can do this with the [[Iterate]] function. 
 +
# A recursive user-defined function may call itselfIf you do this, it usually gives you a different error message, [[Error Messages/41036]], which lets you say whether indeed you wanted to define the function as recursive.
 +
# Hard-core Excel users may want to define a table in which some cells depend on other cells in the same table.  Because these cells exist in the same variable, this creates a cycle at the variable level -- even if there are no dependency cycles among the cells. You can specify cells that depend on other cells within a Table by using  an [[IntraTable]] definition. You can change your  [[Table]] definition into [[IntraTable]] simply be editing the first word in the definition.  We recommend avoiding [[IntraTable]] when possible, because it has many of the same downsides that plague spreadsheet models, and it can slow calculations.  But occasionally it is the simplest approach.
 +
# In a constraint satisfaction or optimization problem -- for example, in an economic equilibrium model, you might attempt to define supply as a function of price, and price as a function of supply.  This type of cycle indicates that you are encoding the problem incorrectly for Analytica -- expressing it as you might in an algebraic modeling language, rather than in terms of constraints as expected by the Analytica optimizer.
  
 
== Dependencies through other attributes ==
 
== Dependencies through other attributes ==

Latest revision as of 17:58, 19 April 2017


Message Text

Syntax error: Cyclic Dependency between variables.
Va1 →
Va2 →
Va3 →
Va1

Description

A cyclic dependency means there is a cycle or directed loop of dependencies. If there is only one variable mentioned in the list, it is because its definition refers to itself. If there are more than one variables in the cycle, as in the example above, there is indirect dependency, with the definition of the last variable depending on the first variable (Va1 in the example) . This creates a cycle in the dependencies between variables, which would appear as a directed cycle in the influence diagram.

Analytica does not normally allow cycles, because they would lead to infinite loops. There are however some cases, where a directed cycle is valid:

  1. If the value of a variable at a given point in Time depends on its own values at a previous Time (or other Index). You can model this kind of recurrence using the function Dynamic, which lets you define a variable V to depend on itself, V, or another variable that depends on V -- provided there is a time delay somewhere in the cycle, so that V depends on itself at an earlier Time. The dependency containing Dynamic and the time delay appears as a gray arrow in the influence diagram. See Dynamic for details.
  2. Another style of cyclic dependence when you want to define a variable as a function of itself and iterate the computation until it converges to a fixed value. You can do this with the Iterate function.
  3. A recursive user-defined function may call itself. If you do this, it usually gives you a different error message, Error Messages/41036, which lets you say whether indeed you wanted to define the function as recursive.
  4. Hard-core Excel users may want to define a table in which some cells depend on other cells in the same table. Because these cells exist in the same variable, this creates a cycle at the variable level -- even if there are no dependency cycles among the cells. You can specify cells that depend on other cells within a Table by using an IntraTable definition. You can change your Table definition into IntraTable simply be editing the first word in the definition. We recommend avoiding IntraTable when possible, because it has many of the same downsides that plague spreadsheet models, and it can slow calculations. But occasionally it is the simplest approach.
  5. In a constraint satisfaction or optimization problem -- for example, in an economic equilibrium model, you might attempt to define supply as a function of price, and price as a function of supply. This type of cycle indicates that you are encoding the problem incorrectly for Analytica -- expressing it as you might in an algebraic modeling language, rather than in terms of constraints as expected by the Analytica optimizer.

Dependencies through other attributes

Dependencies can be formed through the attributes Definition, Check, and OptInitialGuess. If you don't see the dependency in the definition, and are wondering why it thinks a variable depends on a particular parent, take a look at Check, for example.

See Also

Comments


You are not allowed to post comments.