- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This interface allows creating a vector object from a given array type
In the example above, the first dimension of the created vector is maximized,
the following two are minimized, and the last vector component is again
maximized.
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);
}
- Since:
- 5.2
- Version:
- 6.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCreate a newVec
object from the givenarray
.static VecFactory
<double[]> Create a new factory fordouble[]
vectors, where all dimensions are maximized.static VecFactory
<double[]> ofDoubleVec
(Optimize... optimizes) Create a new factory fordouble[]
vectors.static VecFactory
<double[]> ofDoubleVec
(List<Optimize> optimizes) Create a new factory fordouble[]
vectors.static VecFactory
<int[]> ofIntVec()
Create a new factory forint[]
vectors, where all dimensions are maximized.static VecFactory
<int[]> Create a new factory forint[]
vectors.static VecFactory
<int[]> Create a new factory forint[]
vectors.static VecFactory
<long[]> Create a new factory forlong[]
vectors, where all dimensions are maximized.static VecFactory
<long[]> Create a new factory forlong[]
vectors.static VecFactory
<long[]> Create a new factory forlong[]
vectors.static <T extends Comparable<? super T>>
VecFactory<T[]> Create a new factory forT[]
vectors with comparable element types.static <T extends Comparable<? super T>>
VecFactory<T[]> ofObjectVec
(ElementDistance<T[]> distance, Optimize... optimizes) Create a new factory forT[]
vectors with comparable element types.static <T extends Comparable<? super T>>
VecFactory<T[]> ofObjectVec
(ElementDistance<T[]> distance, List<Optimize> optimizes) Create a new factory forT[]
vectors with comparable element types.static <T extends Comparable<? super T>>
VecFactory<T[]> ofObjectVec
(Optimize... optimizes) Create a new factory forT[]
vectors with comparable element types.static <T> VecFactory
<T[]> ofObjectVec
(Comparator<? super T> comparator, ElementDistance<T[]> distance, Optimize... optimizes) Create a new factory forT[]
vectors.static <T> VecFactory
<T[]> ofObjectVec
(Comparator<? super T> comparator, ElementDistance<T[]> distance, List<Optimize> optimizes) Create a new factory forT[]
vectors.static <T extends Comparable<? super T>>
VecFactory<T[]> ofObjectVec
(List<Optimize> optimizes) Create a new factory forT[]
vectors with comparable element types.
-
Method Details
-
newVec
Create a newVec
object from the givenarray
.- Parameters:
array
- the array used in the created vector- Returns:
- a new
Vec
object from the givenarray
- Throws:
NullPointerException
- if the givenarray
isnull
IllegalArgumentException
- if thearray
length is zero or doesn't match the required length of the actual factory
-
ofIntVec
Create a new factory forint[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
int[]
vectors - Throws:
NullPointerException
- if the givenoptimizes
isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
- API Note:
- Only one factory instance should be used for a given multi-objective problem.
-
ofIntVec
Create a new factory forint[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
int[]
vectors - Throws:
NullPointerException
- if the givenoptimizes
isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
- API Note:
- Only one factory instance should be used for a given multi-objective problem.
-
ofIntVec
Create a new factory forint[]
vectors, where all dimensions are maximized.- Returns:
- a new factory for
int[]
vectors, where all dimensions are maximized - See Also:
-
ofLongVec
Create a new factory forlong[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
long[]
vectors - Throws:
NullPointerException
- if the givenoptimizes
isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
- API Note:
- Only one factory instance should be used for a given multi-objective problem.
-
ofLongVec
Create a new factory forlong[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
long[]
vectors - Throws:
NullPointerException
- if the givenoptimizes
isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
- API Note:
- Only one factory instance should be used for a given multi-objective problem.
-
ofLongVec
Create a new factory forlong[]
vectors, where all dimensions are maximized.- Returns:
- a new factory for
long[]
vectors, where all dimensions are maximized - See Also:
-
ofDoubleVec
Create a new factory fordouble[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
double[]
vectors - Throws:
NullPointerException
- if the givenoptimizes
isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
- API Note:
- Only one factory instance should be used for a given multi-objective problem.
-
ofDoubleVec
Create a new factory fordouble[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
double[]
vectors - Throws:
NullPointerException
- if the givenoptimizes
isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
- API Note:
- Only one factory instance should be used for a given multi-objective problem.
-
ofDoubleVec
Create a new factory fordouble[]
vectors, where all dimensions are maximized.- Returns:
- a new factory for
double[]
vectors, where all dimensions are maximized - See Also:
-
ofObjectVec
static <T> VecFactory<T[]> ofObjectVec(Comparator<? super T> comparator, ElementDistance<T[]> distance, List<Optimize> optimizes) Create a new factory forT[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Parameters:
comparator
- the array element comparatordistance
- the element distance functionoptimizes
- the optimization direction for each dimension- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
-
ofObjectVec
static <T> VecFactory<T[]> ofObjectVec(Comparator<? super T> comparator, ElementDistance<T[]> distance, Optimize... optimizes) Create a new factory forT[]
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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Parameters:
comparator
- the array element comparatordistance
- the element distance functionoptimizes
- the optimization direction for each dimension- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- See Also:
-
ofObjectVec
static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec(ElementDistance<T[]> distance, List<Optimize> optimizes) Create a new factory forT[]
vectors with comparable element types. 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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Parameters:
distance
- the element distance functionoptimizes
- the optimization direction for each dimension- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- Since:
- 6.0
- See Also:
-
ofObjectVec
static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec(ElementDistance<T[]> distance, Optimize... optimizes) Create a new factory forT[]
vectors with comparable element types. 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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Parameters:
distance
- the element distance functionoptimizes
- the optimization direction for each dimension- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- Since:
- 6.0
- See Also:
-
ofObjectVec
Create a new factory forT[]
vectors with comparable element types. 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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- Since:
- 6.0
- See Also:
-
ofObjectVec
Create a new factory forT[]
vectors with comparable element types. 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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Parameters:
optimizes
- the optimization direction for each dimension- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- Since:
- 6.0
- See Also:
-
ofObjectVec
Create a new factory forT[]
vectors with comparable element types. 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 givenoptimizes
. If the lengths don't match, anIllegalArgumentException
is thrown.- Type Parameters:
T
- the array element type- Returns:
- a new factory for
T[]
vectors - Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if theoptimizes
length is zero- Since:
- 6.0
- See Also:
-