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

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Exclusive upper bound of the non-negative int node-ID domain.
  • Method Summary

    Modifier and Type
    Method
    Description
    contiguous(int numInputs, int numOutputs)
    Creates a traditional contiguous layout with the remainder of the non-negative int domain reserved for hidden nodes.
    contiguous(int numInputs, int numOutputs, long hiddenNodeIdStartInclusive, long hiddenNodeIdEndExclusive)
    Creates a contiguous external layout with an explicit hidden-node range.
    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.
    long
    Returns the exclusive end of the hidden-node namespace.
    long
    Returns the first ID reserved for hidden nodes.
    Returns input node IDs in external vector order.
    default boolean
    Tests semantic compatibility with another layout.
    default boolean
    isExternal(int nodeId)
    Tests whether an ID identifies either an input or output node.
    default boolean
    isHidden(int nodeId)
    Tests whether an ID belongs to the reserved hidden-node range.
    default boolean
    isInput(int nodeId)
    Tests whether an ID identifies an input node.
    default boolean
    isOutput(int nodeId)
    Tests whether an ID identifies an output node.
    default int
     
    default int
     
    Returns output node IDs in external vector order.
  • Field Details

    • MAX_NODE_ID_EXCLUSIVE

      static final long MAX_NODE_ID_EXCLUSIVE
      Exclusive upper bound of the non-negative int node-ID domain.
      See Also:
  • Method Details

    • inputNodeIds

      List<Integer> inputNodeIds()
      Returns input node IDs in external vector order.
      Returns:
      an ordered, non-empty list of input node IDs
    • outputNodeIds

      List<Integer> outputNodeIds()
      Returns output node IDs in external vector order.
      Returns:
      an ordered, non-empty list of output node IDs
    • hiddenNodeIdStartInclusive

      long hiddenNodeIdStartInclusive()
      Returns the first ID reserved for hidden nodes.
      Returns:
      the inclusive hidden-node range start
    • hiddenNodeIdEndExclusive

      long hiddenNodeIdEndExclusive()
      Returns the exclusive end of the hidden-node namespace.
      Returns:
      the exclusive hidden-node range end
    • 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:
      true when 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:
      true when 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:
      true when 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:
      true when the ID is in the hidden-node namespace
    • isCompatibleWith

      default boolean isCompatibleWith(NeatNodeLayout other)
      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:
      true when chromosomes using the layouts can safely be combined
    • contiguous

      static NeatNodeLayout contiguous(int numInputs, int numOutputs)
      Creates a traditional contiguous layout with the remainder of the non-negative int domain reserved for hidden nodes.
      Parameters:
      numInputs - number of input nodes; must be positive
      numOutputs - 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 positive
      numOutputs - number of output nodes; must be positive
      hiddenNodeIdStartInclusive - inclusive hidden-node range start
      hiddenNodeIdEndExclusive - 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 order
      outputNodeIds - output IDs in vector order
      hiddenNodeIdStartInclusive - inclusive hidden-node range start
      hiddenNodeIdEndExclusive - exclusive hidden-node range end
      Returns:
      a validated explicit layout