Support for cyclical graphs
If A->B and B->A, one of these needs to be the start point when evaluating the graph. But what does the input port of the start node get when it has an edge from the output port of the not yet run node?
One option is to define a "default_value" on one of the input ports and the graph can be "snipped" there...
Work on this in progress here: https://github.com/ModECI/MDF/tree/cyclic_graphs
Potential extension for cyclical graphs: add parameter cycle_default_value - the default value only to use when it's in a cycle, not standalone.
@pgleeson in addition to this: snippet from src/modeci_mdf/execution_engine.py
def init(self, node: Node, verbose: Optional[bool] = False): self.verbose = verbose self.node = node self.evaluable_inputs = {} self.evaluable_parameters = OrderedDict() self.evaluable_functions = OrderedDict() self.evaluable_outputs = {}
Can using OrderedDict() be the reason for the existing constraint?
Not really. It's basically that one of the nodes in a cycle (e.g. A->B->C->A) needs to be flagged as "this is the one to start evaluating the nodes at". We will do this by stating that an input node has a default value, and that this can be used to start the evaluation, e.g. if A has a default value, you don't have the problem that you first need to evaluate the output of C, but before that the output of B, but before that A...