Difference between revisions of "Error Messages/41107"
Line 1: | Line 1: | ||
− | + | [[Category: Error messages]] | |
− | Encountered | + | == Error message variants == |
− | Encountered | + | |
+ | <pre style="background:white; border:white; margin-left: 1em; font-style:italic"> | ||
+ | Encountered Subscript(*, Time, *) referencing 'future' Time. | ||
+ | Encountered Slice(*, Time, *) referencing 'future' Time. | ||
| | ||
− | + | Consider using a conditional in the third parameter to ensure the third parameter is not greater than Time. | |
+ | </pre> | ||
− | = Cause | + | == Cause== |
− | In a [[Dynamic]] function, you may express the value at [[Time]]=t in terms of earlier values. If, however, you attempt to define the value at Time=t based on future value, the error results. A trivial case would be: | + | In a [[Dynamic]] function, you may express the value at [[Time]] = t in terms of earlier values. If, however, you attempt to define the value at ''Time = t'' based on future value, the error results. A trivial case would be: |
− | : | + | :<code>Dynamic(1, Self[Time = Time + 1])</code> |
− | When the error indicates that [[Subscript]] is to blame, this may be due to an explicit call to the [[Subscript]] function, or it may be resulting from a subscript expression of the form ''expr[Time=x]''. Similarly, if it reads [[Slice]], it may either be an explicit call to the [[Slice]] function, or a slice operator of the form ''expr[@Time=n]''. | + | When the error indicates that [[Subscript]] is to blame, this may be due to an explicit call to the [[Subscript]] function, or it may be resulting from a subscript expression of the form ''expr[Time = x]''. Similarly, if it reads [[Slice]], it may either be an explicit call to the [[Slice]] function, or a slice operator of the form ''expr[@Time = n]''. |
The error may occur in less obvious situations when position parameter is computed, or is an array. For example, suppose you have an index named ''T'' defined to be have the same index values as [[Time]]. If you attempted a re-indexing operation such as: | The error may occur in less obvious situations when position parameter is computed, or is an array. For example, suppose you have an index named ''T'' defined to be have the same index values as [[Time]]. If you attempted a re-indexing operation such as: | ||
− | :[[Dynamic]](1,A[Time=T]) | + | :<code>Dynamic(1, A[Time = T])</code> |
+ | |||
+ | you would encounter this error, since when [[Dynamic]] is evaluating at <code>Time = 2</code>, ''T'' contains the value 3, etc. Because a "hard error" occurs in this case, rather than just a warning, you can't simply ignore warnings as is possible in other subscript-out-of-range instances. Hence, you may need to include a conditional (or other expression) in the third parameter, as well as a conditional outside, as follows: | ||
+ | |||
+ | :<code>Dynamic(1, If T >= Time Then Null Else A[Time = (If T >= Time Then 1 Else T)])</code> | ||
− | + | The conditional inside the third parameter serves only to ensure that it never references a [[Time]] value beyond the computed range. The following variation is often more syntactically convenient: | |
− | : | + | :<code>Dynamic(1, If T >= Time Then Null Else A[Time = Min([T, Time - 1])])</code> |
− | + | ==Remedies== | |
+ | Reformulate the input to your function (as advised above) so that the function parameters do no reference a future time value. | ||
− | + | ==See Also== | |
+ | * [[Function calls and parameters]] | ||
+ | * [[Arrays and Indexes]] | ||
+ | * [[Dynamic]] | ||
+ | * [[Time]] | ||
+ | * [[Self]] | ||
+ | * [[Subscript]] | ||
+ | * [[Slice]] | ||
+ | * [[If-Then-Else]] |
Latest revision as of 19:20, 7 April 2016
Error message variants
Encountered Subscript(*, Time, *) referencing 'future' Time. Encountered Slice(*, Time, *) referencing 'future' Time. Consider using a conditional in the third parameter to ensure the third parameter is not greater than Time.
Cause
In a Dynamic function, you may express the value at Time = t in terms of earlier values. If, however, you attempt to define the value at Time = t based on future value, the error results. A trivial case would be:
Dynamic(1, Self[Time = Time + 1])
When the error indicates that Subscript is to blame, this may be due to an explicit call to the Subscript function, or it may be resulting from a subscript expression of the form expr[Time = x]. Similarly, if it reads Slice, it may either be an explicit call to the Slice function, or a slice operator of the form expr[@Time = n].
The error may occur in less obvious situations when position parameter is computed, or is an array. For example, suppose you have an index named T defined to be have the same index values as Time. If you attempted a re-indexing operation such as:
Dynamic(1, A[Time = T])
you would encounter this error, since when Dynamic is evaluating at Time = 2
, T contains the value 3, etc. Because a "hard error" occurs in this case, rather than just a warning, you can't simply ignore warnings as is possible in other subscript-out-of-range instances. Hence, you may need to include a conditional (or other expression) in the third parameter, as well as a conditional outside, as follows:
Dynamic(1, If T >= Time Then Null Else A[Time = (If T >= Time Then 1 Else T)])
The conditional inside the third parameter serves only to ensure that it never references a Time value beyond the computed range. The following variation is often more syntactically convenient:
Dynamic(1, If T >= Time Then Null Else A[Time = Min([T, Time - 1])])
Remedies
Reformulate the input to your function (as advised above) so that the function parameters do no reference a future time value.
Enable comment auto-refresher