Package io.jenetics.ext.moea
Interface ElementDistance<V>
-
- Type Parameters:
V
- the vector type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ElementDistance<V>
Defines the distance of two elements of a given vector typeV
. The following example creates anElementDistance
function for adouble[] array
:final ElementDistance<double[]> dist = (u, v, i) -> u[i] - v[i];
- Since:
- 4.1
- Version:
- 4.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description double
distance(V u, V v, int index)
Calculates the distance of two vector elements at the givenindex
.default <T> ElementDistance<T>
map(Function<? super T,? extends V> mapper)
Return an element distance function for the mapped typeT
.default ToDoubleBiFunction<V,V>
ofIndex(int index)
Return a function which calculates the distance of two vector elements at a givenindex
.
-
-
-
Method Detail
-
distance
double distance(V u, V v, int index)
Calculates the distance of two vector elements at the givenindex
. E.g.final ElementDistance<double[]> dist = (u, v, i) -> u[i] - v[i];
- Parameters:
u
- the first vectorv
- the second vectorindex
- the vector index- Returns:
- the distance of the two element vectors
-
map
default <T> ElementDistance<T> map(Function<? super T,? extends V> mapper)
Return an element distance function for the mapped typeT
.- Type Parameters:
T
- the new distance type- Parameters:
mapper
- the mapper function- Returns:
- an element distance function for the mapped type
T
-
ofIndex
default ToDoubleBiFunction<V,V> ofIndex(int index)
Return a function which calculates the distance of two vector elements at a givenindex
.- Parameters:
index
- the vector index- Returns:
- a function which calculates the distance of two vector elements
-
-