@FunctionalInterface public interface VecFactory<T>
T. It is useful if you need some additional parametrization of the
created vectors.
As the following example shows, only one VecFactory instance should
be used for creating the vectors for a given multi-objective problem.
private static final VecFactory<double[]> FACTORY = VecFactory.ofDoubleVec(
Optimize.MAXIMUM,
Optimize.MINIMUM,
Optimize.MINIMUM,
Optimize.MAXIMUM
);
// The fitness function.
static Vec<double[]> fitness(final double[] x) {
final double[] result = new double[4];
// ...
return FACTORY.newVec(result);
}Vec| Modifier and Type | Method and Description |
|---|---|
Vec<T> |
newVec(T array)
Create a new
Vec object from the given array. |
static VecFactory<double[]> |
ofDoubleVec()
Create a new factory for
double[] vectors, where all dimensions
are maximized. |
static VecFactory<double[]> |
ofDoubleVec(List<Optimize> optimizes)
Create a new factory for
double[] vectors. |
static VecFactory<double[]> |
ofDoubleVec(Optimize... optimizes)
Create a new factory for
double[] vectors. |
static VecFactory<int[]> |
ofIntVec()
Create a new factory for
int[] vectors, where all dimensions are
maximized. |
static VecFactory<int[]> |
ofIntVec(List<Optimize> optimizes)
Create a new factory for
int[] vectors. |
static VecFactory<int[]> |
ofIntVec(Optimize... optimizes)
Create a new factory for
int[] vectors. |
static VecFactory<long[]> |
ofLongVec()
Create a new factory for
long[] vectors, where all dimensions are
maximized. |
static VecFactory<long[]> |
ofLongVec(List<Optimize> optimizes)
Create a new factory for
long[] vectors. |
static VecFactory<long[]> |
ofLongVec(Optimize... optimizes)
Create a new factory for
long[] vectors. |
static <T> VecFactory<T[]> |
ofObjectVec(Comparator<? super T> comparator,
ElementDistance<T[]> distance,
List<Optimize> optimizes)
Create a new factory for
T[] vectors. |
static <T> VecFactory<T[]> |
ofObjectVec(Comparator<? super T> comparator,
ElementDistance<T[]> distance,
Optimize... optimizes)
Create a new factory for
T[] vectors. |
Vec<T> newVec(T array)
Vec object from the given array.array - the array used in the created vectorVec object from the given arrayNullPointerException - if the given array is nullIllegalArgumentException - if the array length is zero or
doesn't match the required length of the actual factorystatic VecFactory<int[]> ofIntVec(List<Optimize> optimizes)
int[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.optimizes - the optimization direction for each dimensionint[] vectorsNullPointerException - if the given optimizes is
nullIllegalArgumentException - if the optimizes length is zeroofIntVec(Optimize...)static VecFactory<int[]> ofIntVec(Optimize... optimizes)
int[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.optimizes - the optimization direction for each dimensionint[] vectorsNullPointerException - if the given optimizes is
nullIllegalArgumentException - if the optimizes length is zeroofIntVec(List)static VecFactory<int[]> ofIntVec()
int[] vectors, where all dimensions are
maximized.int[] vectors, where all dimensions are
maximizedVec.of(int...)static VecFactory<long[]> ofLongVec(List<Optimize> optimizes)
long[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.optimizes - the optimization direction for each dimensionlong[] vectorsNullPointerException - if the given optimizes is
nullIllegalArgumentException - if the optimizes length is zeroofLongVec(Optimize...)static VecFactory<long[]> ofLongVec(Optimize... optimizes)
long[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.optimizes - the optimization direction for each dimensionlong[] vectorsNullPointerException - if the given optimizes is
nullIllegalArgumentException - if the optimizes length is zeroofLongVec(List)static VecFactory<long[]> ofLongVec()
long[] vectors, where all dimensions are
maximized.long[] vectors, where all dimensions are
maximizedVec.of(long...)static VecFactory<double[]> ofDoubleVec(List<Optimize> optimizes)
double[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.optimizes - the optimization direction for each dimensiondouble[] vectorsNullPointerException - if the given optimizes is
nullIllegalArgumentException - if the optimizes length is zeroofDoubleVec(Optimize...)static VecFactory<double[]> ofDoubleVec(Optimize... optimizes)
double[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.optimizes - the optimization direction for each dimensiondouble[] vectorsNullPointerException - if the given optimizes is
nullIllegalArgumentException - if the optimizes length is zeroofDoubleVec(List)static VecFactory<double[]> ofDoubleVec()
double[] vectors, where all dimensions
are maximized.double[] vectors, where all dimensions
are maximizedVec.of(double...)static <T> VecFactory<T[]> ofObjectVec(Comparator<? super T> comparator, ElementDistance<T[]> distance, List<Optimize> optimizes)
T[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.T - the array element typecomparator - the array element comparatordistance - the element distance functionoptimizes - the optimization direction for each dimensionT[] vectorsNullPointerException - if one of the arguments is nullIllegalArgumentException - if the optimizes length is zeroofObjectVec(Comparator, ElementDistance, Optimize...)static <T> VecFactory<T[]> ofObjectVec(Comparator<? super T> comparator, ElementDistance<T[]> distance, Optimize... optimizes)
T[] vectors. Additionally you can
specify the optimization direction (maximization or minimization) for
each dimension. The dimensionality of the created vectors must be exactly
the same as the given length of the given optimizes. If the
lengths doesn't match, an IllegalArgumentException is thrown.T - the array element typecomparator - the array element comparatordistance - the element distance functionoptimizes - the optimization direction for each dimensionT[] vectorsNullPointerException - if one of the arguments is nullIllegalArgumentException - if the optimizes length is zeroofObjectVec(Comparator, ElementDistance, List)© 2007-2020 Franz Wilhelmstötter (2020-02-18 20:08)