Nodal reduction

From Organic Design wiki
Revision as of 00:32, 26 May 2016 by Nad (talk | contribs) (Consumption)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.

Control flow

Control flow refers to the order in which the individual statements in a program are executed. Within a programming language, a control flow statement is an instruction that when executed can cause a change in the subsequent control flow to differ from the natural sequential order in which the instructions are listed. Discussion of control flow is almost always restricted to a single thread of execution, as it depends upon a definite sequence in which instructions are executed one at a time.

The kinds of control flow statements available differ by language, but can be roughly categorized by their effect:

  • continuation at a different statement (jump),
  • executing a set of statements only if some condition is met (choice),
  • executing a set of statements repeatedly (loop; equivalent to jumping to an earlier point in the code),
  • executing a set of distant statements, after which the flow of control returns (subroutine),
  • stopping the program, preventing any further execution (halt).

In the nodal model, the subroutine and loop aspects of control flow are defined in the nodal structure of the node space which is a tree of loops. Conditions and jumps are handled within the nodal functions by manipulation of the nodes which compose the loops in the noda space.


The reduction algorithm divides available execution up into quanta which are like "atoms" of change, in that they are essentially indivisible, so most of the control flow aspect of a program is handled by nodal reduction. They have no definite rules about the amount of time they can take to execute, but should be generally infinitesimal (linearisable) compared to the macro scale. Any looping or iteration-based functionality should be implemented in terms of reducable structure (process). Top-level nodal reduction is implemented as an infinite execute-quantum loop within the context of the root node of the local Nodal Space. The currently running nodal reduction algorithm is defined in nodeSpace.c and sits upon a list space defined in listSpace.c. The afore mentioned infinite execute-quanta loop is in peerd.c. Some logic or algorithmics has to be O(1) and so is required within a function rather than as reducible structure.

Communications example.png


Each node has both associative content and a possible local state (which in nodeSpace.c is accessible via a list of pointers using the node-index in the nodes data association as an index into an array of pointers). The associations are in the form of nodeRef:nodeRef pairs similar in concept to the key:value pairs of associative arrays, and the non-nodal data is in a form specific to the local runtime environment (if there is no state, it will be returned as the local environments representation of null).

Node names and references

All node referencing at runtime is done using list space indexes not names as in a normal object-model or associative array. For storage and distribution of nodal information, GUIDs are used. List-space references and GUIDs are used internally, but nodes can have context-specific names for external use. The names we use to refer to nodes here in the wiki are taken from the names of the constants to represent them in the peerd.c scripts.

Tree of loops

Using an association called Right, allows the formation of loops of nodes (singly-linked-circular lists) within the local Nodal Space (loops also use a Left association too so that nodes can easily be inserted or removed without needing to query other nodes). Combining this with another association called Down allows the formation of a loop-tree starting at the root node (node with index zero). Following the Down association from root takes us down into another node, which is also part of a loop. Every traversal of a Down takes us from an item in one loop to an item in another loop. The loop may contain zero items, but the idea here is that Down's always connect items in loops, even though other associations may lead to other nodal structure which may or may not be a loop.

Loop rotation

Systems are formed from ongoing, reoccurring patterns which can be described in terms of rotation of the loops in the tree described above. Every time the nodal reduction process follows a Down association it also rotates that loop, so that next time the same Down association is traversed it will lead to the next node. This process is active (change occurs to the structure) but reversable, ie it's cyclic and non-entropic change.

Whiteboard diagram showing rotation in nodal reduction

NOTE: the diagram is rotating the wrong way - it should rotate clockwise so that next's are right and prev's left.



The actual consumption of a quanta of execution occurs by calling the reduce function which takes no parameters, but maintains its own persistent state defining the current focal node - just like a current working directory. The reduction function applies its quantum by first rotating the current focal node's loop and following its loop association as described above, then checks if there's any non-nodal data, and if there is and it's a function reference it executes it and exits. If a function was executed, then that quantum is considered consumed and the next quantum is executed starting back at root again. But if the data was not executable, then the reduce function is called again, but remember that current focal node is now down one level because loop was traversed, so the result is that the quanta of execution has been passed within. If there is no loop association, the quantum is passed back up to root unspent, but in practice this condition should not occur.

// Moves "this" to node's focus if exists then rotates loop and executes/reduces the focus item
void nodeReduce() {
    if(this = nodeLoopRotate(parent = this)) {        // Move "this" to the focus in the node's loop and rotate
        nodeSetValue(this, nodePARENT, parent);       // Update the parent association
        if(code = *nodeState(this, nodeCODE)) code(); // nodeCODE value is a pointer-index, execute as function-reference if non-zero


As the nodal reduction process rotate the loops in the tree, all of the nodes in loops will periodically get execution focus. The period is longer depending on the depth of the loop, since each node is effectively dividing its share of quanta between its currently active child processes. This method of division is called multiplexing, see also Wikipedia's article.


Nodal network

Storage and distribution is a nodal organisation which extends reduction out to form a single harmonic global reduction space called the nodal network. Large organisations involving the process and resources of many individual nodal peers are also formed from and loops, but they rotate on larger cycles which are the globally known harmonics of spectrum.