Difference between revisions of "Error Messages/41108"

 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Error Message Examples =
+
[[Category:Error messages]]
  
Cycle encountered during evaluation of [[Slice]](*,[[Time]],*).
+
== Error message examples ==
 
+
:<code>''Cycle encountered during evaluation of Slice(*, Time, *).''</code>
= Cause =
 
  
 +
== Cause ==
 
The use of the [[Slice]] function inside the [[Dynamic]] loop has caused a cycle. Not specifying the offset in the call to [[Slice]] is a possible cause of this error.
 
The use of the [[Slice]] function inside the [[Dynamic]] loop has caused a cycle. Not specifying the offset in the call to [[Slice]] is a possible cause of this error.
  
 
The following dynamic call below would trigger this error:
 
The following dynamic call below would trigger this error:
<code>
+
:<code>Dynamic(100, Slice(DynamicVar, Time, @Time - 0)*1.1)</code>
[[Dynamic]](100, [[Slice]](DynamicVar, Time, @Time-0) * 1.1)
 
</code>
 
  
 
You might also get this error if the offsets in your [[Dynamic]] loop jump around in time, eventually returning to the same time value and thus causing a cycle.  For example:
 
You might also get this error if the offsets in your [[Dynamic]] loop jump around in time, eventually returning to the same time value and thus causing a cycle.  For example:
  
<code>
+
:<code>A := Dynamic(a0, f(B[@Time = @Time - 1]))</code>
A := [[Dynamic]]( a0, f(B[@Time=@Time-1]) )
+
:<code>B := Dynamic(b0, g(A[@Time = @Time + 1]))</code>
B := [[Dynamic]]( b0, g(A[@Time=@Time+1]) )
 
</code>
 
  
I've noticed that even though the error message says "Slice(..)" is used, this error message sometimes occurs when [[Subscript]] is being used -- e.g.:
+
We've noticed that even though the error message says [[Slice]] is used, this error message sometimes occurs when [[Subscript]] is being used -- e.g.:
  
<code>
+
:<code>Dynamic(x0, y[Time = t2])</code>
[[Dynamic]](x0, y[Time=t2] )
 
</code>
 
 
 
= Remedies =
 
  
 +
== Remedies ==
 
Remove the cycle by passing an offset to the [[Slice]] operation.
 
Remove the cycle by passing an offset to the [[Slice]] operation.
  
In a large dynamic loop, it can be difficult to debug the loop and find the offending variable, which for example might be a variable that requests a value at a future time point, ultimately causing the loop.  The error message is reported for the variable at which Analytica discovers a loop -- i.e., the first variable where a value x[Time=t] is requested when a computation of x[Time=t] is already in progress.  But where Analytica first detects the cycle is not necessarily the same place where your actual model bug is.  There are a few secret tricks that can be helpful in debugging these cycles, which I'll reveal here.
+
In a large dynamic loop, it can be difficult to debug the loop and find the offending variable, which for example might be a variable that requests a value at a future time point, ultimately causing the loop.  The error message is reported for the variable at which Analytica discovers a loop -- i.e., the first variable where a value <code>x[Time = t]</code> is requested when a computation of <code>x[Time = t]</code> is already in progress.  But where Analytica first detects the cycle is not necessarily the same place where your actual model bug is.  There are a few secret tricks that can be helpful in debugging these cycles, which we'll reveal here.
  
 
One of the most helpful things is to get an evaluation trace, which you can do as follows:   
 
One of the most helpful things is to get an evaluation trace, which you can do as follows:   
#. Press F12 to open the [[Typescript]] Window.
+
# Press ''F12'' to open the [[Typescript]] Window.
#. In the typescript window, type:  [[Verbosity]]:6
+
# In the typescript window, type:  <code>Verbosity: 6</code>
#. Re-evaluate the offending variable until the error message appears again.
+
# Re-evaluate the offending variable until the error message appears again.
#. View the trace in the typescript window.
+
# View the trace in the typescript window.
#. Turn tracing back off by typing: [[Verbosity]]:2
+
# Turn tracing back off by typing: <code>Verbosity: 2</code>
  
 
If your trace is too long to view in the typescript window, then use these steps:
 
If your trace is too long to view in the typescript window, then use these steps:
#. In the typescript window, type:  
+
# In the typescript window, type:  
* [[Photo]] "C:\Trace.log"
+
#* <code>Photo "C:\Trace.log"</code>
* [[Verbosity]]:6
+
#* <code>Verbosity: 6</code>
#. Re-evaluate the variable until the error message appears again
+
# Re-evaluate the variable until the error message appears again
#. In typescript, type:
+
# In Typescript, type:
* [[EndPhoto]]
+
#* <code>EndPhoto</code>
* [[Verbosity]]:2
+
#* <code>Verbosity: 2</code>
#. Open "C:\trace.log" in a text editor (Notepad, Textpad, etc).
+
# Open "C:\trace.log" in a text editor (Notepad, Textpad, etc).
  
 
When you view the trace, keep in mind that a line is printed each time the evaluation cycle requests a variable's value at a particular time point.  In many cases the request will come from the definition of the line immediately following, but in other cases it will originate from an earlier line in the trace.  The call-graph order is not revealed by the trace, just the sequence of calls, but in many cases, this is sufficient.
 
When you view the trace, keep in mind that a line is printed each time the evaluation cycle requests a variable's value at a particular time point.  In many cases the request will come from the definition of the line immediately following, but in other cases it will originate from an earlier line in the trace.  The call-graph order is not revealed by the trace, just the sequence of calls, but in many cases, this is sufficient.
  
Once the error occurs, there will be some [[Dynamic]] variables that are partially computed in memory.  For example, the variable ''X'' may have completed the computation of ''X[Time=2010]'' and ''X[Time=2011]'', but values ''X[Time=2012]'' and beyond are not computed because the error occurred before computation of these was complete.  In some cases, viewing these partially computed results can be helpful when debugging these problems, but you cannot view the partial result by showing the result window for ''X'', because doing so will cause ''X'' to attempt to finish the remaining evaluation which won't be possible because it will encounter your cycle error.  But there is a trick for viewing these partial results.  Create a new variable node (which you'll have around only temporarily for debugging purposes) and define it as <code>Value of X</code>.  Then show its result.  If you see a Calculate button appear, and re-appear each time you press it, this means that the variable ''X'' is entirely uncomputed -- it hasn't computed any time steps.  If any time steps is computed, you'll see an array result indexed by [[Time]], where all the uncomputed slots are empty cells.
+
Once the error occurs, there will be some [[Dynamic]] variables that are partially computed in memory.  For example, the variable <code>X</code> may have completed the computation of <code>X[Time = 2010]</code> and <code>X[Time = 2011]</code>, but values <code>X[Time = 2012]</code> and beyond are not computed because the error occurred before computation of these was complete.  In some cases, viewing these partially computed results can be helpful when debugging these problems, but you cannot view the partial result by showing the result window for <code>X</code>, because doing so will cause <code>X</code> to attempt to finish the remaining evaluation which won't be possible because it will encounter your cycle error.  But there is a trick for viewing these partial results.  Create a new variable node (which you'll have around only temporarily for debugging purposes) and define it as <code>Value of X</code>.  Then show its result.  If you see a '''Calculate''' button appear, and re-appear each time you press it, this means that the variable <code>X</code> is entirely uncomputed -- it hasn't computed any time steps.  If any time steps is computed, you'll see an array result indexed by [[Time]], where all the uncomputed slots are empty cells.
  
 
+
==See Also==
 
+
* [[Slice]]
<br><comments />
+
* [[Dynamic]]
 +
* [[Time]]
 +
* [[Photo]]
 +
* [[EndPhoto]]
 +
* [[Typescript]]
 +
* [[Verbosity]]

Latest revision as of 23:37, 4 February 2016


Error message examples

Cycle encountered during evaluation of Slice(*, Time, *).

Cause

The use of the Slice function inside the Dynamic loop has caused a cycle. Not specifying the offset in the call to Slice is a possible cause of this error.

The following dynamic call below would trigger this error:

Dynamic(100, Slice(DynamicVar, Time, @Time - 0)*1.1)

You might also get this error if the offsets in your Dynamic loop jump around in time, eventually returning to the same time value and thus causing a cycle. For example:

A := Dynamic(a0, f(B[@Time = @Time - 1]))
B := Dynamic(b0, g(A[@Time = @Time + 1]))

We've noticed that even though the error message says Slice is used, this error message sometimes occurs when Subscript is being used -- e.g.:

Dynamic(x0, y[Time = t2])

Remedies

Remove the cycle by passing an offset to the Slice operation.

In a large dynamic loop, it can be difficult to debug the loop and find the offending variable, which for example might be a variable that requests a value at a future time point, ultimately causing the loop. The error message is reported for the variable at which Analytica discovers a loop -- i.e., the first variable where a value x[Time = t] is requested when a computation of x[Time = t] is already in progress. But where Analytica first detects the cycle is not necessarily the same place where your actual model bug is. There are a few secret tricks that can be helpful in debugging these cycles, which we'll reveal here.

One of the most helpful things is to get an evaluation trace, which you can do as follows:

  1. Press F12 to open the Typescript Window.
  2. In the typescript window, type: Verbosity: 6
  3. Re-evaluate the offending variable until the error message appears again.
  4. View the trace in the typescript window.
  5. Turn tracing back off by typing: Verbosity: 2

If your trace is too long to view in the typescript window, then use these steps:

  1. In the typescript window, type:
    • Photo "C:\Trace.log"
    • Verbosity: 6
  2. Re-evaluate the variable until the error message appears again
  3. In Typescript, type:
    • EndPhoto
    • Verbosity: 2
  4. Open "C:\trace.log" in a text editor (Notepad, Textpad, etc).

When you view the trace, keep in mind that a line is printed each time the evaluation cycle requests a variable's value at a particular time point. In many cases the request will come from the definition of the line immediately following, but in other cases it will originate from an earlier line in the trace. The call-graph order is not revealed by the trace, just the sequence of calls, but in many cases, this is sufficient.

Once the error occurs, there will be some Dynamic variables that are partially computed in memory. For example, the variable X may have completed the computation of X[Time = 2010] and X[Time = 2011], but values X[Time = 2012] and beyond are not computed because the error occurred before computation of these was complete. In some cases, viewing these partially computed results can be helpful when debugging these problems, but you cannot view the partial result by showing the result window for X, because doing so will cause X to attempt to finish the remaining evaluation which won't be possible because it will encounter your cycle error. But there is a trick for viewing these partial results. Create a new variable node (which you'll have around only temporarily for debugging purposes) and define it as Value of X. Then show its result. If you see a Calculate button appear, and re-appear each time you press it, this means that the variable X is entirely uncomputed -- it hasn't computed any time steps. If any time steps is computed, you'll see an array result indexed by Time, where all the uncomputed slots are empty cells.

See Also

Comments


You are not allowed to post comments.