Raul,

> On Nov 28, 2017, at 5:32 PM, Raul Miller <[email protected]> wrote:
> 
> Something based on transitive closure does sound like the way to go.
> 
> And this might be the essay Henry Rich was thinking of:
> http://code.jsoftware.com/wiki/User:Roger_Hui/t
> 
> But I am having trouble following along here.
> 
> The text says "task C can only start after tasks A and B finish" and
>   graph =: 4 4 $ 0 0 0 0  1 0 0 0  1 0 0 0  0 1 1 0  NB. col 0 =
> depends-on A, col 1 = depends-on B, etc.
> 

I actually didn't intend any relationship between that example sentence and the 
matrix I supplied! I'm very sorry, I see now that was a horrifyingly confusing 
thing to do!

> So, I am expecting
>   nodes=: 'ABCD'
> 
> And when I look at which nodes C depends on in that graph, I do not
> see a dependency on B:
>   ((nodes i.'C'){graph)#nodes
> A
> 
> So I am already lost.
> 
> But, wait, maybe I should be looking at the transitive closure of the graph?
> 
>   ((nodes i.'C'){(+. +./ .*~)^:_ graph)#nodes
> A
> 
> D depends on A and B and C, but B and C only depend on A.

Yes, I really intended the code part I supplied to be coherent on its own, so 
this is right. The point I was trying to make was that it looks correct for the 
supplied 4-node graph, but for the 5-node graph, the way E depends on C and D 
exposes something sequential about the calculation.

> There might be another subtlety to this problem, but need to get the
> problem statement correct before addressing any such thing.
> 
> That said, I think there's going to be another issue, though, with
> transitive closure. You don't strictly want the transitive closure
> here. It's not just that D depends on A, B and C - the A and B
> dependencies are in parallel, while the C dependency is in series.
> Parallel is handled by >. and series is handled by + - I suspect you
> need a third operation to determine relevance at any given step.

Well, it's really (this node's duration) + (maximum early finish of my 
dependencies), right? I just don't know how to phrase that "all at once" 
without some kind of loop or recursion, item-by-item.

I think Henry is right, the topological sort gives me the order in which to do 
the calculation, if I have to do it in order, and it seems like I do.

-- 
Daniel Lyons




----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to