Interface NeatNodeLayout
- All Known Implementing Classes:
ContiguousNeatNodeLayout, ExplicitNeatNodeLayout
public interface NeatNodeLayout
Describes the stable external node identities and hidden-node namespace of a NEAT chromosome.
Input and output lists preserve declaration order. That order defines the mapping between external vectors and node IDs, while the IDs themselves are opaque and may be sparse. The hidden-node range is half-open: its lower bound is inclusive and its upper bound is exclusive.
Implementations must provide non-empty input and output lists containing unique, non-negative, disjoint IDs. No external ID may fall inside the hidden-node range. Implementations should also provide value semantics when they are used as chromosome layouts.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longExclusive upper bound of the non-negativeintnode-ID domain. -
Method Summary
Modifier and TypeMethodDescriptionstatic NeatNodeLayoutcontiguous(int numInputs, int numOutputs) Creates a traditional contiguous layout with the remainder of the non-negativeintdomain reserved for hidden nodes.static NeatNodeLayoutcontiguous(int numInputs, int numOutputs, long hiddenNodeIdStartInclusive, long hiddenNodeIdEndExclusive) Creates a contiguous external layout with an explicit hidden-node range.static NeatNodeLayoutexplicit(List<Integer> inputNodeIds, List<Integer> outputNodeIds, long hiddenNodeIdStartInclusive, long hiddenNodeIdEndExclusive) Creates a layout with explicitly ordered external IDs and a dedicated hidden-node range.longReturns the exclusive end of the hidden-node namespace.longReturns the first ID reserved for hidden nodes.Returns input node IDs in external vector order.default booleanisCompatibleWith(NeatNodeLayout other) Tests semantic compatibility with another layout.default booleanisExternal(int nodeId) Tests whether an ID identifies either an input or output node.default booleanisHidden(int nodeId) Tests whether an ID belongs to the reserved hidden-node range.default booleanisInput(int nodeId) Tests whether an ID identifies an input node.default booleanisOutput(int nodeId) Tests whether an ID identifies an output node.default intdefault intReturns output node IDs in external vector order.
-
Field Details
-
MAX_NODE_ID_EXCLUSIVE
static final long MAX_NODE_ID_EXCLUSIVEExclusive upper bound of the non-negativeintnode-ID domain.- See Also:
-
-
Method Details
-
inputNodeIds
-
outputNodeIds
-
numInputs
default int numInputs()- Returns:
- the number of declared input nodes
-
numOutputs
default int numOutputs()- Returns:
- the number of declared output nodes
-
isInput
default boolean isInput(int nodeId) Tests whether an ID identifies an input node.- Parameters:
nodeId- node ID to test- Returns:
truewhen the ID is a declared input
-
isOutput
default boolean isOutput(int nodeId) Tests whether an ID identifies an output node.- Parameters:
nodeId- node ID to test- Returns:
truewhen the ID is a declared output
-
isExternal
default boolean isExternal(int nodeId) Tests whether an ID identifies either an input or output node.- Parameters:
nodeId- node ID to test- Returns:
truewhen the ID is external
-
isHidden
default boolean isHidden(int nodeId) Tests whether an ID belongs to the reserved hidden-node range.- Parameters:
nodeId- node ID to test- Returns:
truewhen the ID is in the hidden-node namespace
-
isCompatibleWith
Tests semantic compatibility with another layout.Compatible layouts declare identical ordered input and output IDs and the same hidden-node range. Their concrete implementation classes do not need to match.
- Parameters:
other- layout to compare- Returns:
truewhen chromosomes using the layouts can safely be combined
-
contiguous
Creates a traditional contiguous layout with the remainder of the non-negativeintdomain reserved for hidden nodes.- Parameters:
numInputs- number of input nodes; must be positivenumOutputs- number of output nodes; must be positive- Returns:
- a validated contiguous layout
-
contiguous
static NeatNodeLayout contiguous(int numInputs, int numOutputs, long hiddenNodeIdStartInclusive, long hiddenNodeIdEndExclusive) Creates a contiguous external layout with an explicit hidden-node range.- Parameters:
numInputs- number of input nodes; must be positivenumOutputs- number of output nodes; must be positivehiddenNodeIdStartInclusive- inclusive hidden-node range starthiddenNodeIdEndExclusive- exclusive hidden-node range end- Returns:
- a validated contiguous layout
-
explicit
static NeatNodeLayout explicit(List<Integer> inputNodeIds, List<Integer> outputNodeIds, long hiddenNodeIdStartInclusive, long hiddenNodeIdEndExclusive) Creates a layout with explicitly ordered external IDs and a dedicated hidden-node range.- Parameters:
inputNodeIds- input IDs in vector orderoutputNodeIds- output IDs in vector orderhiddenNodeIdStartInclusive- inclusive hidden-node range starthiddenNodeIdEndExclusive- exclusive hidden-node range end- Returns:
- a validated explicit layout
-