booldog.boolean.modifications
Module containing functions to manipulate Boolean networks. It is not intended to be used directly, but rather as a mixin for other classes.
Attributes
Classes
Types of modifications to the Boolean network. |
|
Class to represent a modification to the Boolean network. |
|
Mixin class to modify a Boolean network. |
Module Contents
- booldog.boolean.modifications.logger
- class booldog.boolean.modifications.ModificationTypes
Bases:
booldog.utils.ExtendedEnumTypes of modifications to the Boolean network.
- ADD = 'add_node'
- REMOVE = 'remove_node'
- UPDATE = 'update'
- class booldog.boolean.modifications.Modification(modification_type, node_id, rule=None)
Class to represent a modification to the Boolean network.
- type
- node_id
- rule = None
- __repr__()
- class booldog.boolean.modifications.BooleanNetworkModificationMixin
Mixin class to modify a Boolean network. This class is not intended to be used directly, but rather as a mixin.
- _track_network_modifications(modification_type, node_id, rule=None)
Keep track of network modifications
- _update_model_object(uncache_primes=True)
Update the model attributes after a modification.
- modify_network(modifications)
Modify the network according to the given modifications.
- Parameters:
modifications (list) – List of Modification objects.
- Returns:
The network is modified in place.
- Return type:
None
Notes
Each Modification object must have the following attributes: - modification_type : str
Type of modification. One of “add_node”, “remove_node”, “update”.
- nodestr or list
Name of node(s) to modify.
- rulestr or None
Rule to define the update function of node, in bnet form. All nodes in rule need to be defined in Network.
The modifications are applied in the order they are given. A node cannot be removed if other nodes depend on it (i.e. it occurs in their update logic). To remove such a node, either also remove all of its dependants, or first update the logic rule of its dependants to remove dependency.
This is a wrapper for pyboolnet.prime_implicants.create_variables and pyboolnet.prime_implicants.remove_variables.
- remove_node(node_id)
Removes node from the network.
- Parameters:
node (str) – Names of node to remove
- Return type:
None
Notes
A node cannot be removed if other nodes depend on it (i.e. it occurs in their update logic). To remove such a node, either also remove all of its dependants, or first update the logic rule of its dependants to remove dependency.
This is a wrapper for pyboolnet.prime_implicants.remove_variables.
- _test_node_removabilty(node_ids)
Test if a node (set) can be removed from the network.
- remove_nodes(node_ids)
Removes all nodes in node_ids from the network.
- Parameters:
node_ids (list) – List of identifiers of nodes to remove
- Return type:
None
Notes
A node cannot be removed if other nodes depend on it (i.e. it occurs in their update logic). To remove such a node, either also remove all of its dependants, or first update the logic rule of its dependants to remove dependency.
This is a wrapper for pyboolnet.prime_implicants.remove_variables.
- add_node(node_id, rule, name=None)
Add a new node to Network.
- Parameters:
node (str) – Node name
rule (str) – Rule to define update of node, in bnet form. All nodes in rule need to be defined in Network.
- Returns:
None
This is a wrapper for pyboolnet.prime_implicants.create_variables.
- update_node(node_id, rule, modification_type=ModificationTypes.UPDATE)
Update (modify) or add the logic rule defining the update of node. If node does not yet exist, it will be added, if it does exist, its update logic will be overwritten.
- Parameters:
node_id (str) – Node identifier
rule (str) – New rule to define update of node, in bnet form. All nodes in rule need to be defined in Network.
- Returns:
None
This is a wrapper for pyboolnet.prime_implicants.create_variables.