Class Connection

java.lang.Object
com.github.raimannma.architecture.Connection

public class Connection
extends Object
The type Connection.
Author:
Manuel Raimann
  • Field Details

    • to

      public final Node to
      The output node of this connection.
    • from

      public final Node from
      The input node of this connection.
    • gateNode

      public Node gateNode
      The node which gates this connection.
    • weight

      public double weight
      The weight of this connection.
    • gain

      public double gain
      The connection gain.

      Used for gating, gets multiplied with weight

  • Method Details

    • getInnovationID

      public static int getInnovationID​(int a, int b)
      Get innovation ID. Encode two integers into a single integer.
      Parameters:
      a - the first integer
      b - the second integer
      Returns:
      An Integer that uniquely represents a pair of Integers
      See Also:
      (Cantor pairing function)|Pairing function (Cantor pairing function)}
    • fromJSON

      public static Connection fromJSON​(com.google.gson.JsonObject jsonObject, List<Node> nodes)
      Convert a JsonObject to a connection.
      Parameters:
      jsonObject - the json object which holds the information
      nodes - will be used to get the from, to and gate node from
      Returns:
      the connection created from the information of the json object
    • getConnectionData

      @NotNull protected @NotNull Double[] getConnectionData()
      Stores connection data in an array. Used for crossover.

      ConnectionData [0] weight value [1] node from index [2] node to index [3] gate node index

      Returns:
      array containing information about the connection
    • toJSON

      public com.google.gson.JsonObject toJSON()
      Converts the connection to a JsonObject that can later be converted back.
      Returns:
      the created JsonObject
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isSelfConnection

      public boolean isSelfConnection()
    • isGated

      public boolean isGated()