T - the underlying array type, like int[] or double[]public interface Vec<T> extends Comparable<Vec<T>>
Vec interface represents the fitness result of a multi-objective
fitness function. It also defines a set of static factory methods which
allows you to create Vec instance from a given int[],
long[] or double[] array.
final Vec<double[]> point2D = Vec.of(0.1, 5.4);
final Vec<int[]> point3D = Vec.of(1, 2, 3);Vec once it is created,
Not copying the underlying array is done for performance reason. Changing
the Vec data is, of course, never a good idea.Vec interface extends the Comparable interface,
it violates its general contract. It only
implements the pareto dominance relation, which defines a partial
order. So, trying to sort a list of Vec objects, might lead
to an exception (thrown by the sorting method) at runtime.| Modifier and Type | Method and Description |
|---|---|
ElementComparator<T> |
comparator()
Return the comparator for comparing the elements of this MO vector.
|
default int |
compare(Vec<T> other,
int index)
Compares the
this vector with the other at the given
component index. |
default int |
compareTo(Vec<T> other)
The default implementation uses the
dominance(Vec) function
for defining a partial order of two vectors. |
T |
data()
Return the underlying data structure.
|
ElementDistance<T> |
distance()
Return a function which calculates the element distance of a vector at a
given element index.
|
default double |
distance(Vec<T> other,
int index)
Calculates the distance between two vector elements at the given
index. |
Comparator<T> |
dominance()
Return the comparator which defines the (Pareto) dominance measure.
|
static <C extends Comparable<? super C>> |
dominance(C[] u,
C[] v)
Calculates the
Pareto Dominance of the two vectors u and v.
|
static int |
dominance(double[] u,
double[] v)
Calculates the
Pareto Dominance of the two vectors u and v.
|
static int |
dominance(int[] u,
int[] v)
Calculates the
Pareto Dominance of the two vectors u and v.
|
static int |
dominance(long[] u,
long[] v)
Calculates the
Pareto Dominance of the two vectors u and v.
|
static <T> int |
dominance(T[] u,
T[] v,
Comparator<? super T> comparator)
Calculates the
Pareto Dominance of the two vectors u and v.
|
default int |
dominance(Vec<T> other)
|
int |
length()
Return the number of vector elements.
|
static <C extends Comparable<? super C>> |
of(C[] array)
Wraps the given array into a
Vec object. |
static <C extends Comparable<? super C>> |
of(C[] array,
ElementDistance<C[]> distance)
Wraps the given array into a
Vec object. |
static Vec<double[]> |
of(double... array)
Wraps the given array into a
Vec object. |
static Vec<int[]> |
of(int... array)
Wraps the given array into a
Vec object. |
static Vec<long[]> |
of(long... array)
Wraps the given array into a
Vec object. |
static <T> Vec<T[]> |
of(T[] array,
Comparator<? super T> comparator,
ElementDistance<T[]> distance)
Wraps the given array into a
Vec object. |
int length()
ElementComparator<T> comparator()
ElementDistance<T> distance()
Comparator<T> dominance()
default int compare(Vec<T> other, int index)
this vector with the other at the given
component index.other - the other vectorindex - the component indexthis[index] is less than, equal to, or greater than
other[index]NullPointerException - if the other object is nullIllegalArgumentException - if the index is out of the valid
range [0, length())default double distance(Vec<T> other, int index)
index.other - the second vectorindex - the vector element indexNullPointerException - if the other vector is nullIllegalArgumentException - if the index is out of the valid
range [0, length())default int dominance(Vec<T> other)
other - the other vector1 if value() ≻ other, -1 if
other ≻ value() and 0 otherwiseNullPointerException - if the other vector is nulldefault int compareTo(Vec<T> other)
dominance(Vec) function
for defining a partial order of two vectors.compareTo in interface Comparable<Vec<T>>other - the other vector1 if value() ≻ other, -1 if
other ≻ value() and 0 otherwiseNullPointerException - if the other vector is nullstatic <C extends Comparable<? super C>> int dominance(C[] u, C[] v)
C - the element type of vector u and vu - the first vectorv - the second vector1 if u ≻ v, -1 if v ≻
u and 0 otherwiseNullPointerException - if one of the arguments is nullIllegalArgumentException - if u.length != v.lengthPareto.dominance(Comparable[], Comparable[])static <T> int dominance(T[] u, T[] v, Comparator<? super T> comparator)
T - the element type of vector u and vu - the first vectorv - the second vectorcomparator - the element comparator which is used for calculating
the dominance1 if u ≻ v, -1 if v ≻
u and 0 otherwiseNullPointerException - if one of the arguments is nullIllegalArgumentException - if u.length != v.lengthPareto.dominance(Object[], Object[], Comparator)static int dominance(int[] u, int[] v)
u - the first vectorv - the second vector1 if u ≻ v, -1 if v ≻
u and 0 otherwiseNullPointerException - if one of the arguments is nullIllegalArgumentException - if u.length != v.lengthPareto.dominance(int[], int[])static int dominance(long[] u, long[] v)
u - the first vectorv - the second vector1 if u ≻ v, -1 if v ≻
u and 0 otherwiseNullPointerException - if one of the arguments is nullIllegalArgumentException - if u.length != v.lengthPareto.dominance(long[], long[])static int dominance(double[] u, double[] v)
u - the first vectorv - the second vector1 if u ≻ v, -1 if v ≻
u and 0 otherwiseNullPointerException - if one of the arguments is nullIllegalArgumentException - if u.length != v.lengthPareto.dominance(double[], double[])static <C extends Comparable<? super C>> Vec<C[]> of(C[] array)
Vec object.C - the array element typearray - the wrapped arrayVec object.NullPointerException - if one of the arguments is nullIllegalArgumentException - if the array length is zerostatic <C extends Comparable<? super C>> Vec<C[]> of(C[] array, ElementDistance<C[]> distance)
Vec object.C - the array element typearray - the wrapped arraydistance - the array element distance measureVec object.NullPointerException - if one of the arguments is nullIllegalArgumentException - if the array length is zerostatic <T> Vec<T[]> of(T[] array, Comparator<? super T> comparator, ElementDistance<T[]> distance)
Vec object.T - the array element typearray - the wrapped arraycomparator - the (natural order) comparator of the array elementsdistance - the distance function between two vector elementsVec object.NullPointerException - if one of the arguments is nullIllegalArgumentException - if the array length is zerostatic Vec<int[]> of(int... array)
Vec object.array - the wrapped arrayVec object.NullPointerException - if the given array is nullIllegalArgumentException - if the array length is zerostatic Vec<long[]> of(long... array)
Vec object.array - the wrapped arrayVec object.NullPointerException - if the given array is nullIllegalArgumentException - if the array length is zerostatic Vec<double[]> of(double... array)
Vec object.array - the wrapped arrayVec object.NullPointerException - if the given array is nullIllegalArgumentException - if the array length is zero© 2007-2018 Franz Wilhelmstötter (2018-10-28 17:23)