Class UnconditionedExactTest.Candidates
java.lang.Object
org.apache.commons.statistics.inference.UnconditionedExactTest.Candidates
- Enclosing class:
UnconditionedExactTest
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
FieldsModifier and TypeFieldDescriptionprivate 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 -
Method Summary
Modifier and TypeMethodDescription(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
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.
-
Field Details
-
max
private final int maxThe maximum size of array to allocate. -
eps
private final double epsRelative distance from lowest candidate. -
data
private double[][] dataCandidate (key,value) pairs. -
size
private int sizeCurrent size of the list. -
min
private double minCurrent minimum. -
threshold
private double thresholdCurrent 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
Perform the given action for each (key, value) pair.- Parameters:
action
- Action.
-