Node¶
Boolean Node¶
Main class for Boolean node objects.
-
class
cana.boolean_node.
BooleanNode
(id=0, name='x', k=1, inputs=[1], state=False, outputs=[0, 1], constant=False, network=None, verbose=False, *args, **kwargs)[source]¶ -
bias
()[source]¶ The node bias. The sum of the boolean output transitions divided by the number of entries (\(2^k\)) in the LUT.
\[bias(x) = \frac{ \sum_{f_{\alpha}\in F} s_{\alpha} }{ |F| }\]- Returns
(float)
See also
-
c_sensitivity
(c, mode='default', max_k=0)[source]¶ Node c-sensitivity. c-sensitivity is defined as: the mean probability that changing exactly
c
variables in input variables would change output value. There is another mode “forceK”, which will be used to calculate Derrida value. In that mode, it would assume the number of input variables is specified as max_k this methods is equivalent to Derrida value in [KKL17], only move a normalization coefficient from expression of Derrida value to c-sensitivity to simplify it- Parameters
c (int) – the
c
in the definition of c-senstivity abovemode (string) – either “default” or “forceK”
max_k (int) – you must specify max_k when you set mode as ‘forceK’
- Returns
(float)
See also
derrida_curve()
-
canalizing_map
(output=None)[source]¶ Computes the node Canalizing Map (CM).
- Parameters
output (int) – The output CM to return. Default is
None
, retuning both [0,1].- Returns
a directed graph representation of the CM.
- Return type
CM (networkx.DiGraph)
See also
boolean_network.dynamics_canalization_map()
for the DCM anddrawing.draw_canalizing_map_graphviz()
for plotting.
-
dynamic_step
(input_state)[source]¶ Returns the output of the node based on a specific input
- Parameters
input (list) – an input to the node.
- Returns
the output value.
- Return type
output (bool)
-
edge_effectiveness
(bound='mean')[source]¶ The Edge Effectiveness is the mean number of an input’s states needed to determine the transition of the node.
\[e_i(x_i) = 1 - r_i(x_i)\]- Parameters
bound (string) – The bound for the \(k_r\) Input Redundancy
- Returns
The list of \(e_r\) values.
- Return type
(list)
See also
-
edge_redundancy
(bound='mean')[source]¶ The Edge Redundancy \(r_{i}\) is the mean number of unnecessary inputs (or
#
) in the Prime Implicants Look Up Table (LUT) for that input. Since there may be more than one redescription schema for each input entry, the input redundancy is bounded by an upper and lower limit.\[r_i(x_i) = \frac{ \sum_{f_{\alpha} \in F} \Phi_{\theta:f_{\alpha} \in \Theta_{\theta}} (X^{\#}_{\theta_i} ) }{ |F| }\]where \(\Phi\) is a function (\(min\) or \(max\)) and \(F\) is the node LUT.
- Parameters
bound (string) – The bound to which compute input redundancy. Mode “input” accepts: [“lower”, “mean”, “ave”, upper”, “tuple”]. Defaults to “mean”.
- Returns
The list of \(r_i\) for inputs.
- Return type
(list)
Note
The complete mathematical description can be found in :cite:Gates:2020`.
See also
-
edge_symmetry
(bound='upper')[source]¶ Edge Symmetry is a measure of permutation redundancy of a single input. Similar to the computation of Edge Effectiveness but using the Two-Symbol instead of the Prime Implicant schemata.
\[s_i = \frac{ \sum_{f_{\alpha} \in F} \Phi_{\theta:f_{\alpha} \in \Theta_{\theta}} (n^{\circ}_i)}{ |F| }\]where \(\Phi\) is the function \(min\) or \(max\) and \(F\) is the node LUT.
- Parameters
bound (string) – The bound to which compute input symmetry. Mode “node” accepts: [“lower”, “upper”]. Mode “input” accepts: [“lower”, “mean”, “upper”, “tuple”]. Defaults to “upper”.
- Returns
The \(k_s\) or a list of \(r_i\).
- Return type
(float/list)
See also
-
effective_connectivity
(operator=<function mean>, norm=True)[source]¶ The Effective Connectiviy is the mean number of input nodes needed to determine the transition of the node.
\[k_e(x) = k(x) - k_r(x)\]- Parameters
operator (function) – The operator to use while computing input redundancy for the node. Defaults to statistics.mean, but min or max can be also considered.
norm (bool) –
Normalized between [0,1]. Use this value when comparing nodes with different input sizes. (Defaults to “True”.)
\(k^{*}_e(x) = \frac{ k_e(x) }{ k(x) }\).
- Returns
The \(k_e\) value.
- Return type
(float)
See also
-
classmethod
from_output_list
(outputs=[], *args, **kwargs)[source]¶ Instanciate a Boolean Node from a output transition list.
- Parameters
outputs (list) – The transition outputs of the node.
- Returns
the instanciated object.
- Return type
Example
>>> BooleanNode.from_output_list(outputs=[0,0,0,1], name="AND")
-
input_mask
(binstate)[source]¶ Returns the mask applied to the binary state binstate
- Parameters
binstate (str) – the binary state
- Returns
the masked state
- Return type
output (str)
-
input_redundancy
(operator=<function mean>, norm=True)[source]¶ The Input Redundancy \(k_{r}\) is the mean number of unnecessary inputs (or
#
) in the Prime Implicants Look Up Table (LUT). Since there may be more than one redescription schema for each input entry, the input redundancy is bounded by an upper and lower limit.\[k_{r}(x) = \frac{ \sum_{f_{\alpha} \in F} \Phi_{\theta:f_{\alpha} \in \Theta_{\theta}} (n^{\#}_{\theta} ) }{ |F| }\]where \(\Phi\) is a function (\(min\) or \(max\)) and \(F\) is the node LUT.
- Parameters
operator (function) – The operator to use while computing input redundancy for the node. Defaults to statistics.mean, but min or max can be also considered.
norm (bool) –
Normalized between [0,1]. Use this value when comparing nodes with different input sizes. (Defaults to “True”.)
\(k^{*}_r(x) = \frac{ k_r(x) }{ k(x) }\).
- Returns
The \(k_r\) value.
- Return type
(float)
Note
The complete mathematical description can be found in [MPR13].
-
input_symmetry
(bound='upper', norm=True)[source]¶ The Input Symmetry is a measure of permutation redundancy. Similar to the computation of Input Redundancy but using the Two-Symbol instead of the Prime Implicant schemata.
\[k_s = \frac{ \sum_{f_{\alpha} \in F} \Phi_{\theta:f_{\alpha} \in \Theta_{\theta}} (n^{\circ}) }{ |F| }\]where \(\Phi\) is the function \(min\) or \(max\) and \(F\) is the node LUT.
- Parameters
bound (string) – The bound to which compute input symmetry. Mode “node” accepts: [“lower”, “upper”]. Mode “input” accepts: [“lower”, “mean”, “upper”, “tuple”]. Defaults to “upper”.
norm (bool) –
Normalized between [0,1]. Use this value when comparing nodes with different input sizes. (Defaults to “True”.)
\(k^{*}_s(x) = \frac{ k_s(x) }{ k(x) }\).
- Returns
The \(k_s\) or a list of \(r_i\).
- Return type
(float/list)
See also
-
look_up_table
()[source]¶ Returns the Look Up Table (LUT)
- Returns
the LUT
- Return type
(pandas.DataFrame)
Examples
>>> AND = BooleanNode.from_output_list([0,0,0,1]) >>> AND.look_up_table()
See also
-
pi_coverage
()[source]¶ Returns the \(F'\) (Prime Implicants) binary state coverage.
- Returns
(list)
See also
-
schemata_look_up_table
(type='pi', pi_symbol='#', ts_symbol_unicode='̊', ts_symbol_latex='\\circ', format='pandas')[source]¶ Returns the simplified schemata Look Up Table (LUT)
- Parameters
type (string) – The type of schemata to return, either Prime Implicants
pi
or Two-Symbolts
. Defaults to ‘pi’.pi_symbol (unicode) – The Prime Implicant don’t care symbol. Default is
#
.ts_symbol_unicode (unicode) – A unicode string for the Two Symbol permutable symbol. Default is
u"̊"
.ts_symbol_latex (unicode) – The latex string for Two Symbol permutable symbol. Default is
\circ
.format (string) – The format to return. Possible values are
pandas
(default) andlatex
.
- Returns
the schemata LUT
- Return type
(pandas.DataFrame or Latex)
Examples
>>> AND = BooleanNode.from_output_list([0,0,0,1]) >>> AND.schemata_look_up_table(type='pi')
Note
See the full list of combining characters to use other symbols as the permutation symbol.
See also
-