Record Class TSPTWState

java.lang.Object
java.lang.Record
org.ddolib.examples.tsptw.TSPTWState
Record Components:
position - The current last position of the vehicle. Usually unique and represented by TSPNode. In merged states, the vehicle can be "at any position at the same time," represented by VirtualNodes.
time - The arrival time of the vehicle at the current position.
mustVisit - A BitSet representing all nodes that must still be visited.
possiblyVisit - A BitSet representing nodes that might have been visited or not in merged states.
depth - The depth of the layer containing this state in the dynamic programming model.

public record TSPTWState(org.ddolib.examples.tsptw.Position position, int time, BitSet mustVisit, BitSet possiblyVisit, int depth) extends Record
Represents a state in the dynamic programming model for the Traveling Salesman Problem with Time Windows (TSPTW).

Each state encapsulates the current information about the vehicle's position, the set of nodes yet to visit, and timing information. This record is used both for individual states and for relaxed/merged states.

  • Constructor Summary

    Constructors
    Constructor
    Description
    TSPTWState(org.ddolib.examples.tsptw.Position position, int time, BitSet mustVisit, BitSet possiblyVisit, int depth)
    Creates an instance of a TSPTWState record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the depth record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the mustVisit record component.
    org.ddolib.examples.tsptw.Position
    Returns the value of the position record component.
    Returns the value of the possiblyVisit record component.
    int
    Returns the value of the time record component.
    Returns a string representation of this TSPTW state, including position, time, must-visit and possibly-visit nodes, and depth.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TSPTWState

      public TSPTWState(org.ddolib.examples.tsptw.Position position, int time, BitSet mustVisit, BitSet possiblyVisit, int depth)
      Creates an instance of a TSPTWState record class.
      Parameters:
      position - the value for the position record component
      time - the value for the time record component
      mustVisit - the value for the mustVisit record component
      possiblyVisit - the value for the possiblyVisit record component
      depth - the value for the depth record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this TSPTW state, including position, time, must-visit and possibly-visit nodes, and depth.
      Specified by:
      toString in class Record
      Returns:
      a formatted string describing the state
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • position

      public org.ddolib.examples.tsptw.Position position()
      Returns the value of the position record component.
      Returns:
      the value of the position record component
    • time

      public int time()
      Returns the value of the time record component.
      Returns:
      the value of the time record component
    • mustVisit

      public BitSet mustVisit()
      Returns the value of the mustVisit record component.
      Returns:
      the value of the mustVisit record component
    • possiblyVisit

      public BitSet possiblyVisit()
      Returns the value of the possiblyVisit record component.
      Returns:
      the value of the possiblyVisit record component
    • depth

      public int depth()
      Returns the value of the depth record component.
      Returns:
      the value of the depth record component