Class BoundedRealVector

java.lang.Object
org.cicirello.search.representations.RealVector
org.cicirello.search.representations.BoundedRealVector
All Implemented Interfaces:
RealValued, Copyable<RealVector>

public final class BoundedRealVector extends RealVector
A class for representing the input to a multivariate function, with real values (floating-point) that are bounded in some interval [min, max].
  • Constructor Summary

    Constructors
    Constructor
    Description
    BoundedRealVector(double[] x, double min, double max)
    Initializes the vector to the specified values, subject to the given bounds [min, max].
    Copies a BoundedRealVector.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates an identical copy of this object.
    boolean
    equals(Object other)
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value.
    final boolean
    Checks if the bounds of this BoundedRealVector are the same as those of another.
    final void
    set(double[] values)
    Sets from an array, subject to the lower and upper bounds for this vector.
    final void
    set(int i, double value)
    Sets a parameter to a specified value, subject to the lower and upper bounds for this function input.

    Methods inherited from class org.cicirello.search.representations.RealVector

    exchange, get, length, toArray

    Methods inherited from class java.lang.Object

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

    • BoundedRealVector

      public BoundedRealVector(double[] x, double min, double max)
      Initializes the vector to the specified values, subject to the given bounds [min, max].
      Parameters:
      x - The initial values for the vector. Any values that are less than min will instead be set to min. Any values that are greater than max will instead be set to max.
      min - The minimum allowed value for each integer.
      max - The maximum allowed value for each integer.
      Throws:
      IllegalArgumentException - if min > max
    • BoundedRealVector

      public BoundedRealVector(BoundedRealVector other)
      Copies a BoundedRealVector.
      Parameters:
      other - The other BoundedRealVector
  • Method Details

    • set

      public final void set(int i, double value)
      Sets a parameter to a specified value, subject to the lower and upper bounds for this function input. If the specified new value is less than the min, then the function input is set to the min. If the specified new value is greater than the max, then the function input is set to the max. Otherwise, the function input is set to the specified value.
      Specified by:
      set in interface RealValued
      Overrides:
      set in class RealVector
      Parameters:
      i - The input to set.
      value - The new value for the i-th function input.
      Throws:
      ArrayIndexOutOfBoundsException - if i < 0 or i ≥ length().
    • set

      public final void set(double[] values)
      Sets from an array, subject to the lower and upper bounds for this vector. If a specified new value is less than the min, then it is set to the min. If the specified new value is greater than the max, then the it is set to the max. Otherwise, it is set to the specified value.
      Specified by:
      set in interface RealValued
      Overrides:
      set in class RealVector
      Parameters:
      values - The values to set.
    • sameBounds

      public final boolean sameBounds(BoundedRealVector other)
      Checks if the bounds of this BoundedRealVector are the same as those of another.
      Parameters:
      other - The other vector.
      Returns:
      true if the vectors have the same bounds and false otherwise
    • copy

      public BoundedRealVector copy()
      Creates an identical copy of this object.
      Specified by:
      copy in interface Copyable<RealVector>
      Overrides:
      copy in class RealVector
      Returns:
      an identical copy of this object
    • equals

      public boolean equals(Object other)
      Indicates whether some other object is "equal to" this one. To be equal, the other object must be of the same runtime type and contain the same values and bounds.
      Overrides:
      equals in class RealVector
      Parameters:
      other - The other object to compare.
      Returns:
      true if other is not null, is of the same runtime type as this, and contains the same values and bounds.
    • hashCode

      public int hashCode()
      Returns a hash code value.
      Overrides:
      hashCode in class RealVector
      Returns:
      a hash code value