Class UnconditionedExactTest.Candidates

java.lang.Object
org.apache.commons.statistics.inference.UnconditionedExactTest.Candidates
Enclosing class:
UnconditionedExactTest

static class UnconditionedExactTest.Candidates extends Object
A container of (key,value) pairs to store candidate minima. Encapsulates the logic of storing multiple initial search points for optimization.

Stores all pairs within a relative tolerance of the lowest minima up to a set capacity. When at capacity the worst candidate is replaced by addition of a better candidate.

Special handling is provided to store only a single NaN value if no non-NaN values have been observed. This prevents storing a large number of NaN candidates.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double[][]
    Candidate (key,value) pairs.
    private final double
    Relative distance from lowest candidate.
    private final int
    The maximum size of array to allocate.
    private double
    Current minimum.
    private int
    Current size of the list.
    private double
    Current threshold for inclusion.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Candidates(int max, double eps)
    Create an instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    add(double k, double v)
    Adds the (key, value) pair.
    private void
    addPair(double k, double v)
    Add the (key, value) pair to the data.
    (package private) void
    forEach(Consumer<double[]> action)
    Perform the given action for each (key, value) pair.
    (package private) double[]
    Return the minimum (key,value) pair.
    private void
    replaceWorst(double k, double v)
    Replace the worst candidate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • max

      private final int max
      The maximum size of array to allocate.
    • eps

      private final double eps
      Relative distance from lowest candidate.
    • data

      private double[][] data
      Candidate (key,value) pairs.
    • size

      private int size
      Current size of the list.
    • min

      private double min
      Current minimum.
    • threshold

      private double threshold
      Current threshold for inclusion.
  • Constructor Details

    • Candidates

      Candidates(int max, double eps)
      Create an instance.
      Parameters:
      max - Maximum number of allowed candidates (limited to at least 1).
      eps - Relative distance of candidate minima from the lowest candidate (assumed to be positive and finite).
  • Method Details

    • add

      void add(double k, double v)
      Adds the (key, value) pair.
      Parameters:
      k - Key.
      v - Value.
    • addPair

      private void addPair(double k, double v)
      Add the (key, value) pair to the data. It is assumed the data satisfy the conditions for addition.
      Parameters:
      k - Key.
      v - Value.
    • replaceWorst

      private void replaceWorst(double k, double v)
      Replace the worst candidate.
      Parameters:
      k - Key.
      v - Value.
    • getMinimum

      double[] getMinimum()
      Return the minimum (key,value) pair.
      Returns:
      the minimum (or null)
    • forEach

      void forEach(Consumer<double[]> action)
      Perform the given action for each (key, value) pair.
      Parameters:
      action - Action.