[kepler-dev] Workflow for recursive algorithm?
Christopher Brooks
cxh at eecs.berkeley.edu
Fri Jan 20 13:35:16 PST 2006
In Ptolemy II, you would use the Dynamic Dataflow (DDF) domain
for this.
I'm not sure if the DDFDirector is present in Kepler or not.
See
http://ptolemy.eecs.berkeley.edu/papers/04/DynamicDataflow/
_Christopher
--------
Hi,
Does anybody have the experience of modeling recursive process using
Kepler workflow? Any comments/suggestions/ideas are appreciated.
Currently I am trying to model an algorithm which is similar to a tree
traversing process. Many algorithms involving tree data structrue use
recursion. Although theoretically any recursive function can be
transformed into an iterative function by using a stack, it is often
difficult to transform tree traversing algorithm because the tree may have
unknown length. So I prefer to explore Kepler's ability of describing
recursions.
Here comes the pseudo code of the recursive algorithm:
FUNCTION recursiveDCM(tree)
IF tree is small enough THEN
evaluateTree(tree)
ELSE
subtrees[] = divideTree(tree)
FOR EACH subtree IN subtrees[]
recursiveDCM(subtree) // Recursive call
finaltree = mergeTree(subtrees[])
END IF
return(finaltree)
END FUNCTION
The functions evaluateTree, divideTree, and mergeTree have been
implemented as actors. I would like to build the function recursiveDCM as
a workflow. I know it's pretty easy to wrap all the code into one actor
to implement the recursion since Java itself supports recursion. But I
would like see if Kepler can handle it.
The first method popped up in my mind is to use CompositeActors. I tested
my idea with a simple String Concatenate workflow. I firstly built up a
workflow which includes a StringConstant actor, a StringConcatenate actor,
and a TextDisplay actor. They are linked as the following:
StringConstant-->InputPort1 of StringConcatenate-->TextDisplay
Then I wrapped the StringConstant and StringConcatenate actors as a
CompositeActor. So the workflow now looks like:
CompositeActor-->TextDisplay
Then I copied the CompositeActor, open the CompositeActor (look inside),
and pasted the CompositeActor into the CompositeActor editing interface.
Then within the CompositeActor editing interface, I connected the output
of CompositeActor to another input port of the StringConcatenate actor.
Now the inner structure of the CompositeActor looks like:
StringConstant-->InputPort1 of
StringConcatenate -->Outgoing port
InputPort2 of
/
/
CompositeActor
I hope including a CompositeActor into itself could let me model the
recursive process. But it does not work as I expected. I checked the
workflow XML file, this method only adds one more layer of CompositeActor
into workflow definition.
Does anybody have better solutions to this problem?
Thanks in advance!
Zhijie
_______________________________________________
Kepler-dev mailing list
Kepler-dev at ecoinformatics.org
http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
--------
More information about the Kepler-dev
mailing list