Class TSPState

java.lang.Object
org.ddolib.examples.tsp.TSPState

public class TSPState extends Object
Represents a state in the Traveling Salesman Problem (TSP).

A TSPState captures the current situation of the tour:

  • current – the set of nodes currently being considered as the current location. In most cases, this is a singleton, but during state merging (relaxation), it may contain multiple nodes.
  • toVisit – the set of nodes that have not yet been visited.

This class provides methods to handle singleton nodes, and overrides equals, hashCode, and toString for proper use in collections and debugging.

See Also:
  • Constructor Details

    • TSPState

      public TSPState(BitSet current, BitSet toVisit)
      Constructs a new TSPState.
      Parameters:
      current - the current node(s)
      toVisit - the nodes that have not yet been visited
  • Method Details

    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • singleton

      public BitSet singleton(int singletonValue)
      Creates a BitSet containing only the specified singleton value.
      Parameters:
      singletonValue - the value to set
      Returns:
      a BitSet with a single bit set
    • toString

      public String toString()
      Overrides:
      toString in class Object