Package org.nlpub.watset.util
Class Maximizer
java.lang.Object
org.nlpub.watset.util.Maximizer
Utilities for searching arguments of the maxima of the function.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Predicate<T>A predicate that is always false.static <T> Predicate<T>A predicate that is always true.static <V,S extends Comparable<S>>
Optional<V>Find the first argument of the maximum (argmax) of the function.static <V,S extends Comparable<S>>
Optional<V>Find the first argument of the maximum (argmax) of the function.static <V,S extends Comparable<S>>
Optional<V>argrandmax(Iterable<V> iterable, Function<V, S> scorer, Random random) Find the arguments of the maxima (argmax) of the function and randomly choose any of them.
-
Method Details
-
alwaysTrue
A predicate that is always true.- Type Parameters:
T- the type- Returns:
- the absolute truth
-
alwaysFalse
A predicate that is always false.- Type Parameters:
T- the type- Returns:
- the absolute non-truth
-
argmax
public static <V,S extends Comparable<S>> Optional<V> argmax(Iterable<V> iterable, Predicate<V> checker, Function<V, S> scorer) Find the first argument of the maximum (argmax) of the function.- Type Parameters:
V- the argument typeS- the score type- Parameters:
iterable- the finite iteratorchecker- the predicate that evaluates the suitability of the argumentscorer- the scoring function- Returns:
- a non-empty optional that contains the first found argmax, otherwise the empty one
-
argmax
public static <V,S extends Comparable<S>> Optional<V> argmax(Iterable<V> iterable, Function<V, S> scorer) Find the first argument of the maximum (argmax) of the function.- Type Parameters:
V- the argument typeS- the score type- Parameters:
iterable- the finite iteratorscorer- the scoring function- Returns:
- a non-empty optional that contains the first found argmax, otherwise the empty one
- See Also:
-
argrandmax
public static <V,S extends Comparable<S>> Optional<V> argrandmax(Iterable<V> iterable, Function<V, S> scorer, Random random) Find the arguments of the maxima (argmax) of the function and randomly choose any of them.- Type Parameters:
V- the argument typeS- the score type- Parameters:
iterable- the finite iteratorscorer- the scoring functionrandom- the random number generator- Returns:
- a non-empty optional that contains the randomly chosen argmax, otherwise the empty one
-