Adding, Removing and Editing Nodes in the Logic Tree Element

A logic tree consists of two types of nodes: gate nodes and variable nodes.

Gate nodes are used to construct the logical framework of the tree. Gate nodes require child nodes that are either other gate nodes or variable nodes.

There are three types of gate nodes:

AND-Gate. An AND-Gate is true when all of its child nodes are true.  The child nodes can be variable nodes, or other gate nodes.

OR-Gate. An OR-Gate is true when at least one of its child nodes is true. The child nodes can be variable nodes, or other gate nodes.

N-Vote Gate. An N-Vote Gate is true when N (which is user-specified) or more of its inputs are true. The child nodes can be variable nodes, or other gate nodes.

There are two types of variable nodes, each of which requires an input:

Condition. A Condition node is true when the specified condition evaluates to true. The input must be a Condition output or a conditional expression

Not. A Not node is true when the specified condition evaluates to false. The input must be a Condition output or a conditional expression. 

When a Logic Tree element is initially created, the logic tree will consist of a single AND-Gate:

Graphical user interface, text, application, Word

Description automatically generated

Clicking the Add button displays a menu which allows you to select the desired node type to the tree:

Graphical user interface, text, application, Word

Description automatically generated

Where the new node will appear is determined by the type of node that is selected prior to pressing the Add button:

   If a gate node is selected prior to pressing the Add button, the new node will appear as child node to the selected gate node:

Graphical user interface, text, application

Description automatically generated

In this example, the OR-Gate was selected when an AND-Gate was added.  The AND-Gate is therefore added as a child node to the OR-Gate..

   If a variable node is selected prior to pressing the Add button, the new node will appear as child node to the selected node’s parent (i.e., as a siblimng of the selected node):

Graphical user interface, text, application

Description automatically generated

In this example, a Condition node (“Water_Rising”) was selected when another Condition node (“Pump_Failed”) was added.  The second Condition node is therefore added as a sibling of the first Condition node.

Adding and using AND-Gates and OR-Gates is straightforward. 

An N-Vote Gate is true when N or more of its inputs are true.  The inputs can be conditions, or other gates. With an N-Vote gate, you need to specify the number of inputs that must be true in order for the gate to be true.  The following dialog appears when the N-Vote gate option is selected:

The number of required votes can be edited by typing directly into the text box, or by using the arrows to the right of the text box to increment the number of votes up or down.  The number of votes must be an integer, so non-integer numbers are automatically truncated.  Once the node has been placed, it will display the number of votes required, as shown below:

   Note: The top node of a Logic Tree is always an AND-Gate. If you want the top node to be an OR-Gate or or an N-Vote Gate simply add that single gate to the top of the tree under the top-level AND-Gate.

   Note: A gate node with no children always evaluates to False.  Hence, a Logic Tree element (which by default contains a single empty AND-Gate) defaults to False.

When a Condition or Not node is added, a small dialog appears:

This dialog allows you to enter a conditional expression (an expression which evaluates to true or false), or create a link to a condition-type output of another GoldSim element. A Condition node is true when the specified condition evaluates to true.  A Not node is true when the specified condition evaluates to false.

After adding a variable node, you can edit it by selecting the variable node in the logic tree and pressing the Edit button (if a gate node is selected it will be ignored).

Pressing the Remove button removes the node (and if it is a gate node, all of its children).

Related Topics…