base.nodes module¶
-
class
base.nodes.
Node
(configuration, parent=None, circuit=None, is_root=False, state=None)¶ Bases:
object
This class represents a node in the search space tree, mainly consisting of a list holding a Variant for each Candidate in the circuit.
Parameters: - configuration (list of
Variant
) – A list containing the Variants of all Candidates in the original circuit. The order of the Variants must be equal to the order of the respective Candidates in the framework’s CandidateSet. - parent (
Node
, optional) – The Node’s parent Node in the search space, i.e. the Node that creates this new Node. Default value isNone
. - circuit (
Circuit
, optional) – The actual Circuit represented by this Node. Default value isNone
. - is_root (bool, optional) – Flag specifying whether this Node should
be treated as the search space tree’s root node. Default value
is
False
. - state – Custom attribute in which additional component-specific information about this Node can be stored, e.g. whether a Node has been visited during search stage.
-
configuration
¶
-
parent
¶
-
id
¶ A string that uniquely identifies this Node by its configuration.
Type: str
-
circuit
¶
-
is_root
¶
-
state
¶
-
stats
¶ A dictionary storing estimated or computed statistical information about this Node.
Type: Dictionary
-
valid
¶ This Node’s Circuit’s valid attribute. Cannot be read if this Node does not have a Circuit.
Type: bool
-
validated
¶ Has this Node’s Circuit been validated? Returns
False
if this Node does not have a Circuit.Type: bool
-
getVariantOfCandidate
(cand)¶ Returns the Variant of a given Candidate in the configuration of this Node.
Parameters: cand ( Candidate
) – The Candidate whose Variant to return.Returns: The Variant corresponding to cand if it can be found, otherwise None
.
-
generateChildren
()¶ Returns a list of all child Nodes. Each child differs from its parent in exactly one Variant. The differing Variants are created using the
generateChildren()
method of the Variant. The resulting Variants will generally have higher error values than the Variants of this Node.
-
generateNeighbors
()¶ Returns a list of all neighboring Nodes. Each neighbor differs from this Node in exactly one Variant. The differing Variants are created using the
generateNeighbors()
method of the Variant. The resulting Variants will have different, but not necessarily higher error values than the Variants of this Node.
-
generateParents
()¶ Returns a list of all Nodes that could yield this Node as child. Each parent differs from this Node in exactly one Variant. The differing Variants are created using the
generateParents()
method of the Variant. The resulting Variants will generally have lower error values than the Variants of this Node.
-
static
generateNodeFromConfiguration
(gen_info, config_dict)¶ Generates a Node instance where for each Candidate, a predetermined Variant configuration is used. If a configuration is not or only partially specified, the original Variant’s values will be used.
Parameters: - gen_info (
GeneralInformation
) – The framework’s GeneralInformation instance. - config_dict (
Dictionary
) – A dictionary containing the Candidates’ names as keys and specification strings for the corresponding Variants as values.
Returns: A Node instance where the Variants are configured as specified by the
config_dict
, if their Candidate’s name is included as key, or generated like the Candidate’s original Variants.- gen_info (
- configuration (list of