Interesting 'Daisy Chain' problem.
Hi,
I have a series of tasks whose run sequence is dictated by a 'state' number. Runs can also occur in parallel. Each sequence is terminated with a 'next state' of zero.
e.g.
This would run these jobs in parallel:
The daisy-chaining from one state to another is easy enough, my question is, given just this dataset, what ECL returns a list of all the start states.
e.g., in this case, the result would be 1,4,55 (I've deliberately mixed the numbers up as the numbers given to states may well not be in sequence)
There is LOOP, but I wondered if there was something a bit clever?
Yours
Allan
I have a series of tasks whose run sequence is dictated by a 'state' number. Runs can also occur in parallel. Each sequence is terminated with a 'next state' of zero.
e.g.
- Code: Select all
state next-state Task
1 2 Job1
2 3 Job2
3 0 Job3
55 77 Job4
77 22 Job5
22 23 Job6
23 0 Job7
4 0 Job8
This would run these jobs in parallel:
- Code: Select all
Job1,Job2,Job3
Job4,Job5,Job6,Job7
Job8
The daisy-chaining from one state to another is easy enough, my question is, given just this dataset, what ECL returns a list of all the start states.
e.g., in this case, the result would be 1,4,55 (I've deliberately mixed the numbers up as the numbers given to states may well not be in sequence)
There is LOOP, but I wondered if there was something a bit clever?
Yours
Allan
- Allan
- Posts: 444
- Joined: Sat Oct 01, 2011 7:26 pm
Allan,
Here's how I would do it:
HTH,
Richard
Here's how I would do it:
- Code: Select all
rec := {UNSIGNED1 state, UNSIGNED1 next_state, STRING4 Task};
ds := DATASET([{ 1, 2, 'Job1'},
{ 2, 3, 'Job2'},
{ 3, 0, 'Job3'},
{ 55, 77, 'Job4'},
{ 77, 22, 'Job5'},
{ 22, 23, 'Job6'},
{ 23, 0, 'Job7'},
{ 4, 0, 'Job8'}],rec);
StartTbl := TABLE(ds,{ds,BOOLEAN start := FALSE});
Flagged := ITERATE(StartTbl,
TRANSFORM({StartTbl},
SELF.start := LEFT.next_state = 0,
SELF := RIGHT));
Starters := PROJECT(Flagged(start = TRUE),rec);
Starters;
HTH,
Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
You're essentially looking for all those not referenced in next_state, right?
JOIN logic could be used, especially if ds is large.
- Code: Select all
ds(state not in set(ds, next_state));
JOIN logic could be used, especially if ds is large.
- Tony Kirk
- Posts: 17
- Joined: Thu Jun 23, 2011 5:01 pm
Tony,
Nice!!
Richard
Nice!!

Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
Thanks, Both of you.
Tony, Whatever they're paying you it's not enough.
Allan
Tony, Whatever they're paying you it's not enough.
Allan
- Allan
- Posts: 444
- Joined: Sat Oct 01, 2011 7:26 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest