Class MKSState

java.lang.Object
org.ddolib.examples.mks.MKSState

public class MKSState extends Object
Represents the state of a multi-dimensional Knapsack problem (MKS) in terms of the remaining capacities of each knapsack dimension.

This class encapsulates the capacities as a double array and provides standard methods for cloning, equality checking, and string representation.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MKSState(double[] capacities)
    Constructs a new MKSState with the given capacities.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a deep copy of this state.
    boolean
    Compares this state to another object for equality.
    int
    Computes the hash code based on the capacities array.
    Returns a string representation of this state.

    Methods inherited from class java.lang.Object

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

    • MKSState

      public MKSState(double[] capacities)
      Constructs a new MKSState with the given capacities.
      Parameters:
      capacities - an array representing the remaining capacities of each knapsack dimension
  • Method Details

    • clone

      public MKSState clone()
      Creates a deep copy of this state.
      Overrides:
      clone in class Object
      Returns:
      a new MKSState with a cloned capacities array
    • toString

      public String toString()
      Returns a string representation of this state.
      Overrides:
      toString in class Object
      Returns:
      a string showing the capacities array
    • hashCode

      public int hashCode()
      Computes the hash code based on the capacities array.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this state
    • equals

      public boolean equals(Object o)
      Compares this state to another object for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if o is an MKSState and has identical capacities; false otherwise