This class represents a NOT node in a Rete network, which implements the logical negation. It tracks partial matches from the left (Beta side) and facts from the right (Alpha side) to determine when the NOT condition is satisfied. When a new left token is asserted, it checks against all right facts to see if any block it. If none block it, the token is propagated downstream. When a new right fact is asserted, it checks if it blocks any existing left tokens and updates their state accordingly. The node also supportsretractions and refreshes to maintain correct state as facts and tokens change over time. <Remark> As a side note, in a rete network, the NotNode and the ExistsNode are very similar in structure and logic, with the main difference being that the ExistsNode propagates tokens when at least one match exists, while the NotNode propagates tokens only when no matches exist. This means that the ExistsNode will assert tokens when the count of blocking facts is greater than zero, whereas the NotNode will assert tokens when the count is zero. Both nodes must carefully manage their internal state to ensure correct propagation of tokens based on changes in the right memory.</Remark>.
More...
|
| | NotNode (string name, Func< Token, object, bool > constraint) |
| | The constructor for the NotNode takes a name for identification and a join constraint function that defines how to determine if a right fact blocks a left token.
|
| void | AddSuccessor (IReteNode node) |
| | Adds a successor node to this NOT node. When a new successor is added, it is immediately refreshed with the current valid state of left tokens that are not blocked by any right facts, ensuring that the new node is up-to-date with the current state of matches in this NOT node. This allows for dynamic construction of the Rete network while maintaining correct propagation of matches to successor nodes.
|
| void | Assert (object factOrToken) |
| | The Assert method is the main entry point for incoming facts or tokens. It determines whether the input is a left token or a right fact and delegates to the appropriate method (AssertLeft or AssertRight) to handle the logic specific to that side of the NOT node. This design allows for a clean separation of concerns and ensures that the correct processing logic is applied based on the type of input received.
|
| void | AssertLeft (Token token) |
| | Handles incoming partial matches from the Left (Beta side). It checks the new token against all facts in the right memory using the join constraint.
|
| void | AssertRight (object fact) |
| | Handles incoming single facts from the Right (Alpha side). It checks the new fact against all existing left tokens to see if it blocks any of them.
|
| void | Retract (object factOrToken) |
| | The Retract method is the main entry point for retractions of facts or tokens. Similar to Assert, it determines whether the input is a left token or a right fact and delegates to the appropriate method (Retract or RetractRight) to handle the logic specific to that side of the NOT node. This allows for proper handling of retractions and ensures that the state of the NOT node is correctly updated when facts or tokens are removed from the network.
|
| void | RetractLeft (Token token) |
| | Handles retractions of left tokens. It removes the token from the left matches and, if it was not blocked by any right facts, it propagates a retract downstream to indicate that the NOT condition is now satisfied again. This ensures that any successor nodes that were previously blocked by this token will now receive an assertion for it, allowing the Rete network to correctly reflect the change in state caused by the retraction of the token.
|
| void | RetractRight (object fact) |
| | Handles retractions of right facts. It removes the fact from the right memory and checks if this retraction "resurrects" any left tokens that were previously blocked by this fact. If a left token's block count transitions from 1 to 0, it means the NOT condition is now satisfied for that token, and it propagates an assertion downstream to indicate that the token is now valid again. This ensures that the Rete network correctly reflects the change in state caused by the retraction of the right fact and allows any successor nodes to update their state accordingly based on the new valid tokens.
|
| void | Refresh (object factOrToken, string propertyName) |
| | Forces a downstream node to sync with this node's current valid tokens. This is used when a new successor node is added to ensure it receives the correct state of matches from this NOT node. It checks if the input is a left token or a right fact and delegates to the appropriate refresh method to update the state of matches and propagate any necessary assertions or retractions downstream. This allows for dynamic updates to the Rete network while maintaining correct propagation of matches to successor nodes.
|
| void | RefreshLeft (Token token) |
| | Handles refreshes of left tokens. It checks if the token is currently blocked by any right facts and, if not, it propagates an assertion downstream to ensure that successor nodes are updated with the current valid state of this token. This is important for maintaining correct state in the Rete network, especially when new successor nodes are added or when existing nodes need to be refreshed due to changes in the network. By checking the block count for the token and only propagating if it is currently valid (not blocked), we ensure that the NOT condition is correctly maintained and that successor nodes receive accurate information about the state of matches in this NOT node.
|
| void | RefreshRight (object fact, string propertyName) |
| | Handles refreshes of right facts. It checks if the fact blocks any existing left tokens and updates their block counts accordingly. If a token transitions from blocked to unblocked or vice versa, it propagates the necessary assertions or retractions downstream to ensure that successor nodes are updated with the current valid state of matches in this NOT node. This is important for maintaining correct state in the Rete network, especially when new successor nodes are added or when existing nodes need to be refreshed due to changes in the network. By checking the join constraint for each token against the refreshed fact and updating their block counts, we ensure that the NOT condition is correctly maintained and that successor nodes receive accurate information about the state of matches in this NOT node.
|
| void | DebugPrint (object fact, int level=0) |
| | A debug method to print the current state of the NOT node, including the number of left tokens, right facts, and the block counts for each left token. This can be useful for understanding how the NOT node is processing matches and how it is affected by incoming facts and tokens. The method takes an optional level parameter to control indentation for better readability when printing nested nodes in the Rete network. By providing insight into the internal state of the NOT node, this debug method can help developers diagnose issues and understand the behavior of the Rete network during development and testing.
|
This class represents a NOT node in a Rete network, which implements the logical negation. It tracks partial matches from the left (Beta side) and facts from the right (Alpha side) to determine when the NOT condition is satisfied. When a new left token is asserted, it checks against all right facts to see if any block it. If none block it, the token is propagated downstream. When a new right fact is asserted, it checks if it blocks any existing left tokens and updates their state accordingly. The node also supportsretractions and refreshes to maintain correct state as facts and tokens change over time. <Remark> As a side note, in a rete network, the NotNode and the ExistsNode are very similar in structure and logic, with the main difference being that the ExistsNode propagates tokens when at least one match exists, while the NotNode propagates tokens only when no matches exist. This means that the ExistsNode will assert tokens when the count of blocking facts is greater than zero, whereas the NotNode will assert tokens when the count is zero. Both nodes must carefully manage their internal state to ensure correct propagation of tokens based on changes in the right memory.</Remark>.
◆ NotNode()
| ReteCore.NotNode.NotNode |
( |
string | name, |
|
|
Func< Token, object, bool > | constraint ) |
The constructor for the NotNode takes a name for identification and a join constraint function that defines how to determine if a right fact blocks a left token.
- Parameters
-
| name | The name of this node as identification. |
| constraint | The condition to be used as the 'NOT' blocking constraint. |
◆ AddSuccessor()
| void ReteCore.NotNode.AddSuccessor |
( |
IReteNode | node | ) |
|
Adds a successor node to this NOT node. When a new successor is added, it is immediately refreshed with the current valid state of left tokens that are not blocked by any right facts, ensuring that the new node is up-to-date with the current state of matches in this NOT node. This allows for dynamic construction of the Rete network while maintaining correct propagation of matches to successor nodes.
- Parameters
-
| node | The node to add this node to as a successor. |
◆ Assert()
| void ReteCore.NotNode.Assert |
( |
object | factOrToken | ) |
|
The Assert method is the main entry point for incoming facts or tokens. It determines whether the input is a left token or a right fact and delegates to the appropriate method (AssertLeft or AssertRight) to handle the logic specific to that side of the NOT node. This design allows for a clean separation of concerns and ensures that the correct processing logic is applied based on the type of input received.
- Parameters
-
| factOrToken | The fact or token this operation is acting upon. |
Implements ReteCore.IReteNode.
◆ AssertLeft()
| void ReteCore.NotNode.AssertLeft |
( |
Token | token | ) |
|
Handles incoming partial matches from the Left (Beta side). It checks the new token against all facts in the right memory using the join constraint.
- Parameters
-
| token | The token this operation is acting upon. |
◆ AssertRight()
| void ReteCore.NotNode.AssertRight |
( |
object | fact | ) |
|
Handles incoming single facts from the Right (Alpha side). It checks the new fact against all existing left tokens to see if it blocks any of them.
- Parameters
-
| fact | The fact this operation is acting upon. |
◆ DebugPrint()
| void ReteCore.NotNode.DebugPrint |
( |
object | fact, |
|
|
int | level = 0 ) |
A debug method to print the current state of the NOT node, including the number of left tokens, right facts, and the block counts for each left token. This can be useful for understanding how the NOT node is processing matches and how it is affected by incoming facts and tokens. The method takes an optional level parameter to control indentation for better readability when printing nested nodes in the Rete network. By providing insight into the internal state of the NOT node, this debug method can help developers diagnose issues and understand the behavior of the Rete network during development and testing.
- Parameters
-
| fact | The fact whose information is to be output. |
| level | A level of indentation. |
Implements ReteCore.IReteNode.
◆ Refresh()
| void ReteCore.NotNode.Refresh |
( |
object | factOrToken, |
|
|
string | propertyName ) |
Forces a downstream node to sync with this node's current valid tokens. This is used when a new successor node is added to ensure it receives the correct state of matches from this NOT node. It checks if the input is a left token or a right fact and delegates to the appropriate refresh method to update the state of matches and propagate any necessary assertions or retractions downstream. This allows for dynamic updates to the Rete network while maintaining correct propagation of matches to successor nodes.
- Parameters
-
| factOrToken | The fact or token this operation is acting upon. |
| propertyName | The name of the property in the fact cell that is being updated. |
Implements ReteCore.IReteNode.
◆ RefreshLeft()
| void ReteCore.NotNode.RefreshLeft |
( |
Token | token | ) |
|
Handles refreshes of left tokens. It checks if the token is currently blocked by any right facts and, if not, it propagates an assertion downstream to ensure that successor nodes are updated with the current valid state of this token. This is important for maintaining correct state in the Rete network, especially when new successor nodes are added or when existing nodes need to be refreshed due to changes in the network. By checking the block count for the token and only propagating if it is currently valid (not blocked), we ensure that the NOT condition is correctly maintained and that successor nodes receive accurate information about the state of matches in this NOT node.
- Parameters
-
| token | The token this operation is acting upon. |
◆ RefreshRight()
| void ReteCore.NotNode.RefreshRight |
( |
object | fact, |
|
|
string | propertyName ) |
Handles refreshes of right facts. It checks if the fact blocks any existing left tokens and updates their block counts accordingly. If a token transitions from blocked to unblocked or vice versa, it propagates the necessary assertions or retractions downstream to ensure that successor nodes are updated with the current valid state of matches in this NOT node. This is important for maintaining correct state in the Rete network, especially when new successor nodes are added or when existing nodes need to be refreshed due to changes in the network. By checking the join constraint for each token against the refreshed fact and updating their block counts, we ensure that the NOT condition is correctly maintained and that successor nodes receive accurate information about the state of matches in this NOT node.
- Parameters
-
| fact | The fact this operation is acting upon. |
| propertyName | The name of the property in the fact cell that is being updated. |
◆ Retract()
| void ReteCore.NotNode.Retract |
( |
object | factOrToken | ) |
|
The Retract method is the main entry point for retractions of facts or tokens. Similar to Assert, it determines whether the input is a left token or a right fact and delegates to the appropriate method (Retract or RetractRight) to handle the logic specific to that side of the NOT node. This allows for proper handling of retractions and ensures that the state of the NOT node is correctly updated when facts or tokens are removed from the network.
- Parameters
-
| factOrToken | The fact or token this operation is acting upon. |
Implements ReteCore.IReteNode.
◆ RetractLeft()
| void ReteCore.NotNode.RetractLeft |
( |
Token | token | ) |
|
Handles retractions of left tokens. It removes the token from the left matches and, if it was not blocked by any right facts, it propagates a retract downstream to indicate that the NOT condition is now satisfied again. This ensures that any successor nodes that were previously blocked by this token will now receive an assertion for it, allowing the Rete network to correctly reflect the change in state caused by the retraction of the token.
- Parameters
-
| token | The token this operation is acting upon. |
◆ RetractRight()
| void ReteCore.NotNode.RetractRight |
( |
object | fact | ) |
|
Handles retractions of right facts. It removes the fact from the right memory and checks if this retraction "resurrects" any left tokens that were previously blocked by this fact. If a left token's block count transitions from 1 to 0, it means the NOT condition is now satisfied for that token, and it propagates an assertion downstream to indicate that the token is now valid again. This ensures that the Rete network correctly reflects the change in state caused by the retraction of the right fact and allows any successor nodes to update their state accordingly based on the new valid tokens.
- Parameters
-
| fact | The fact this operation is acting upon. |
The documentation for this class was generated from the following file: