Closed grdw closed 6 years ago
How does https://github.com/quintel/refinery/commit/90cc27ef67e620d8d26e80097d8408a31fbce3fb this actually work? recursing
is never ever set to true is it?
recursing
is never ever set to true is it?
It is on line 100, when calling share
on the other slots:
098 | set(:share, 0.0)
099 | elsif ! recursing && node_demand.zero? &&
100 | others.all? { |o| o.share(true) }
### | ^^^^^^^^^^^^^
101 | # Opposite of the special case above.
102 | set(:share, 1.0 - others.sum(&:share))
103 | elsif ! node_demand.zero?
The stack would overflow when demands were zero because slot A would try to look at the share of slot B, which would look at slot A, which would look at slot B, ad infinitum... We break that loop (line 99) by setting recursing
to true.
Assume graph as:
Whent the demand of A,B,C = 0. The input slot ratio of D (input slot A-D, B-D, C-D) should be able to calculate and not throw a "SystemStackError: stack level too deep".
Suggestions for solving this:
amount of nodes
(in the example 3) as the default input shareRelated issue: https://github.com/quintel/etlocal/issues/73