Class UnconditionedExactTest.Candidates
- java.lang.Object
-
- org.apache.commons.statistics.inference.UnconditionedExactTest.Candidates
-
- Enclosing class:
- UnconditionedExactTest
static class UnconditionedExactTest.Candidates extends java.lang.ObjectA 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[][]dataCandidate (key,value) pairs.private doubleepsRelative distance from lowest candidate.private intmaxThe maximum size of array to allocate.private doubleminCurrent minimum.private intsizeCurrent size of the list.private doublethresholdCurrent threshold for inclusion.
-
Constructor Summary
Constructors Constructor Description Candidates(int max, double eps)Create an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(double k, double v)Adds the (key, value) pair.private voidaddPair(double k, double v)Add the (key, value) pair to the data.(package private) voidforEach(java.util.function.Consumer<double[]> action)Perform the given action for each (key, value) pair.(package private) double[]getMinimum()Return the minimum (key,value) pair.private voidreplaceWorst(double k, double v)Replace the worst candidate.
-
-
-
Field Detail
-
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.
-
-
Method Detail
-
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(java.util.function.Consumer<double[]> action)
Perform the given action for each (key, value) pair.- Parameters:
action- Action.
-
-