Class PSState

java.lang.Object
org.ddolib.examples.pigmentscheduling.PSState

public class PSState extends Object
Represents a state in the Production Scheduling Problem (PSP).

Each PSState captures the scheduling situation at a given time slot, including which item is scheduled next and the remaining demands for all item types. This class is immutable in practice, with the exception of cloning for safe transitions.

Fields:

  • t: the current time slot (counting down from the horizon).
  • next: the item type scheduled for production at time t+1. A value of -1 indicates that the next item is not yet assigned.
  • previousDemands: an array where previousDemands[i] stores the latest time before t when a demand for item i occurs. A value of -1 indicates that there are no remaining demands for that item.

This class overrides hashCode(), equals(Object), and toString() to allow proper usage in hash-based collections, state comparison, and debugging output.

PSState is used in combination with PSProblem, PSRelax, and PSFastLowerBound in Dynamic Decision Optimization (DDO) or A* search frameworks.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    PSState(int t, int next, int[] previousDemands)
    Constructs a new state for the PSP.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected PSState
    Creates a deep copy of this state.
    boolean
    Compares this state with another object for equality.
    int
    Computes a hash code for the state, based on time, next item, and previous demands.
    Returns a string representation of the state, including current time, next item, and previous demands for debugging purposes.

    Methods inherited from class java.lang.Object

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

    • PSState

      public PSState(int t, int next, int[] previousDemands)
      Constructs a new state for the PSP.
      Parameters:
      t - the current time slot
      next - the next item type scheduled for production, -1 if unknown
      previousDemands - an array indicating, for each item type, the last time a demand occurs before t
  • Method Details

    • clone

      protected PSState clone()
      Creates a deep copy of this state.
      Overrides:
      clone in class Object
      Returns:
      a cloned PSState instance
    • hashCode

      public int hashCode()
      Computes a hash code for the state, based on time, next item, and previous demands.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of the state
    • equals

      public boolean equals(Object obj)
      Compares this state with another object for equality. Two PSState instances are equal if they have the same time, next item, and previous demand array.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare
      Returns:
      true if the states are equal, false otherwise
    • toString

      public String toString()
      Returns a string representation of the state, including current time, next item, and previous demands for debugging purposes.
      Overrides:
      toString in class Object
      Returns:
      a string describing the state